sparse-checkout: disable advice in 'disable'

When running 'git sparse-checkout disable' with the sparse index
enabled, Git is expected to expand the index into a full index. However,
it currently outputs the advice message saying that that is unexpected
and likely due to an issue with the working directory.

Disable this advice message when in this code path. Establish a pattern
for doing a similar removal in the future.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Derrick Stolee
2024-09-23 19:31:22 +00:00
committed by Junio C Hamano
parent 4f71522dfb
commit 537e516a39
4 changed files with 19 additions and 3 deletions

View File

@ -925,6 +925,11 @@ static int sparse_checkout_disable(int argc, const char **argv,
builtin_sparse_checkout_disable_options,
builtin_sparse_checkout_disable_usage, 0);
/*
* Disable the advice message for expanding a sparse index, as we
* are expecting to do that when disabling sparse-checkout.
*/
give_advice_on_expansion = 0;
repo_read_index(the_repository);
memset(&pl, 0, sizeof(pl));