Skip to content

Commit 9293a93

Browse files
committed
Merge branch 'ds/sparse-checkout-expansion-advice'
When "git sparse-checkout disable" turns a sparse checkout into a regular checkout, the index is fully expanded. This totally expected behaviour however had an "oops, we are expanding the index" advice message, which has been corrected. * ds/sparse-checkout-expansion-advice: sparse-checkout: disable advice in 'disable'
2 parents e9356ba + 537e516 commit 9293a93

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

builtin/sparse-checkout.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,11 @@ static int sparse_checkout_disable(int argc, const char **argv,
924924
builtin_sparse_checkout_disable_options,
925925
builtin_sparse_checkout_disable_usage, 0);
926926

927+
/*
928+
* Disable the advice message for expanding a sparse index, as we
929+
* are expecting to do that when disabling sparse-checkout.
930+
*/
931+
give_advice_on_expansion = 0;
927932
repo_read_index(the_repository);
928933

929934
memset(&pl, 0, sizeof(pl));

sparse-index.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
* advice for advice.sparseIndexExpanded when expanding a sparse index to a full
2222
* one. However, this is sometimes done on purpose, such as in the sparse-checkout
2323
* builtin, even when index.sparse=false. This may be disabled in
24-
* convert_to_sparse().
24+
* convert_to_sparse() or by commands that know they will lead to a full
25+
* expansion, but this message is not actionable.
2526
*/
26-
static int give_advice_on_expansion = 1;
27+
int give_advice_on_expansion = 1;
2728
#define ADVICE_MSG \
2829
"The sparse index is expanding to a full index, a slow operation.\n" \
2930
"Your working directory likely has contents that are outside of\n" \

sparse-index.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#ifndef SPARSE_INDEX_H__
22
#define SPARSE_INDEX_H__
33

4+
/*
5+
* If performing an operation where the index is supposed to expand to a
6+
* full index, then disable the advice message by setting this global to
7+
* zero.
8+
*/
9+
extern int give_advice_on_expansion;
10+
411
struct index_state;
512
#define SPARSE_INDEX_MEMORY_ONLY (1 << 0)
613
int is_sparse_index_allowed(struct index_state *istate, int flags);

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,10 @@ test_expect_success 'advice.sparseIndexExpanded' '
23552355
mkdir -p sparse-index/deep/deeper2/deepest &&
23562356
touch sparse-index/deep/deeper2/deepest/bogus &&
23572357
git -C sparse-index status 2>err &&
2358-
grep "The sparse index is expanding to a full index" err
2358+
grep "The sparse index is expanding to a full index" err &&
2359+
2360+
git -C sparse-index sparse-checkout disable 2>err &&
2361+
test_line_count = 0 err
23592362
'
23602363

23612364
test_expect_success 'cat-file -p' '

0 commit comments

Comments
 (0)