Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sparse-checkout: disable advice in 'disable' #1800

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions builtin/sparse-checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,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));
Expand Down
5 changes: 3 additions & 2 deletions sparse-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
* advice for advice.sparseIndexExpanded when expanding a sparse index to a full
* one. However, this is sometimes done on purpose, such as in the sparse-checkout
* builtin, even when index.sparse=false. This may be disabled in
* convert_to_sparse().
* convert_to_sparse() or by commands that know they will lead to a full
* expansion, but this message is not actionable.
*/
static int give_advice_on_expansion = 1;
int give_advice_on_expansion = 1;
#define ADVICE_MSG \
"The sparse index is expanding to a full index, a slow operation.\n" \
"Your working directory likely has contents that are outside of\n" \
Expand Down
7 changes: 7 additions & 0 deletions sparse-index.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#ifndef SPARSE_INDEX_H__
#define SPARSE_INDEX_H__

/*
* If performing an operation where the index is supposed to expand to a
* full index, then disable the advice message by setting this global to
* zero.
*/
extern int give_advice_on_expansion;

struct index_state;
#define SPARSE_INDEX_MEMORY_ONLY (1 << 0)
int is_sparse_index_allowed(struct index_state *istate, int flags);
Expand Down
5 changes: 4 additions & 1 deletion t/t1092-sparse-checkout-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2355,7 +2355,10 @@ test_expect_success 'advice.sparseIndexExpanded' '
mkdir -p sparse-index/deep/deeper2/deepest &&
touch sparse-index/deep/deeper2/deepest/bogus &&
git -C sparse-index status 2>err &&
grep "The sparse index is expanding to a full index" err
grep "The sparse index is expanding to a full index" err &&

git -C sparse-index sparse-checkout disable 2>err &&
test_line_count = 0 err
'

test_expect_success 'cat-file -p' '
Expand Down
Loading