advice: update message to suggest '--sparse'

The previous changes modified the behavior of 'git add', 'git rm', and 'git mv' to not adjust paths outside the sparse-checkout cone, even if they exist in the working tree and their cache entries lack the SKIP_WORKTREE bit. The intention is to warn users that they are doing something potentially dangerous. The '--sparse' option was added to each command to allow careful users the same ability they had before. To improve the discoverability of this new functionality, add a message to advice.updateSparsePath that mentions the existence of the option. The previous set of changes also modified the purpose of this message to include possibly a list of paths instead of only a list of pathspecs. Make the warning message more clear about this new behavior. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Sep 24, 2021 at 15:39 UTC 6579e788c0a4b9468c5e2954a0868f9db0496e43
4 files changed +24 -14
advice.c
+6 -5
@@ -293,15 +293,16 @@ void advise_on_updating_sparse_paths(struct string_list *pathspec_list)
293 if (!pathspec_list->nr)
294 return;
295
296 - fprintf(stderr, _("The following pathspecs didn't match any"
297 - " eligible path, but they do match index\n"
298 - "entries outside the current sparse checkout:\n"));
296 + fprintf(stderr, _("The following paths and/or pathspecs matched paths that exist\n"
297 + "outside of your sparse-checkout definition, so will not be\n"
298 + "updated in the index:\n"));
299 for_each_string_list_item(item, pathspec_list)
300 fprintf(stderr, "%s\n", item->string);
301
302 advise_if_enabled(ADVICE_UPDATE_SPARSE_PATH,
303 - _("Disable or modify the sparsity rules if you intend"
304 - " to update such entries."));
303 + _("If you intend to update such entries, try one of the following:\n"
304 + "* Use the --sparse option.\n"
305 + "* Disable or modify the sparsity rules."));
306 }
307
308 void detach_advice(const char *new_name)
t/t3602-rm-sparse-checkout.sh
+6 -3
@@ -11,12 +11,15 @@ test_expect_success 'setup' "
11 git commit -m files &&
12
13 cat >sparse_error_header <<-EOF &&
14 - The following pathspecs didn't match any eligible path, but they do match index
15 - entries outside the current sparse checkout:
14 + The following paths and/or pathspecs matched paths that exist
15 + outside of your sparse-checkout definition, so will not be
16 + updated in the index:
17 EOF
18
19 cat >sparse_hint <<-EOF &&
19 - hint: Disable or modify the sparsity rules if you intend to update such entries.
20 + hint: If you intend to update such entries, try one of the following:
21 + hint: * Use the --sparse option.
22 + hint: * Disable or modify the sparsity rules.
23 hint: Disable this message with \"git config advice.updateSparsePath false\"
24 EOF
25
t/t3705-add-sparse-checkout.sh
+6 -3
@@ -44,12 +44,15 @@ test_sparse_entry_unstaged () {
44
45 test_expect_success 'setup' "
46 cat >sparse_error_header <<-EOF &&
47 - The following pathspecs didn't match any eligible path, but they do match index
48 - entries outside the current sparse checkout:
47 + The following paths and/or pathspecs matched paths that exist
48 + outside of your sparse-checkout definition, so will not be
49 + updated in the index:
50 EOF
51
52 cat >sparse_hint <<-EOF &&
52 - hint: Disable or modify the sparsity rules if you intend to update such entries.
53 + hint: If you intend to update such entries, try one of the following:
54 + hint: * Use the --sparse option.
55 + hint: * Disable or modify the sparsity rules.
56 hint: Disable this message with \"git config advice.updateSparsePath false\"
57 EOF
58
t/t7002-mv-sparse-checkout.sh
+6 -3
@@ -11,12 +11,15 @@ test_expect_success 'setup' "
11 git commit -m files &&
12
13 cat >sparse_error_header <<-EOF &&
14 - The following pathspecs didn't match any eligible path, but they do match index
15 - entries outside the current sparse checkout:
14 + The following paths and/or pathspecs matched paths that exist
15 + outside of your sparse-checkout definition, so will not be
16 + updated in the index:
17 EOF
18
19 cat >sparse_hint <<-EOF
19 - hint: Disable or modify the sparsity rules if you intend to update such entries.
20 + hint: If you intend to update such entries, try one of the following:
21 + hint: * Use the --sparse option.
22 + hint: * Disable or modify the sparsity rules.
23 hint: Disable this message with \"git config advice.updateSparsePath false\"
24 EOF
25 "