Skip to content

Commit 6579e78

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 93d2c16 commit 6579e78

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

advice.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,16 @@ void advise_on_updating_sparse_paths(struct string_list *pathspec_list)
293293
if (!pathspec_list->nr)
294294
return;
295295

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"));
299299
for_each_string_list_item(item, pathspec_list)
300300
fprintf(stderr, "%s\n", item->string);
301301

302302
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."));
305306
}
306307

307308
void detach_advice(const char *new_name)

t/t3602-rm-sparse-checkout.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ test_expect_success 'setup' "
1111
git commit -m files &&
1212
1313
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:
1617
EOF
1718
1819
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.
2023
hint: Disable this message with \"git config advice.updateSparsePath false\"
2124
EOF
2225

t/t3705-add-sparse-checkout.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ test_sparse_entry_unstaged () {
4444

4545
test_expect_success 'setup' "
4646
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:
4950
EOF
5051
5152
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.
5356
hint: Disable this message with \"git config advice.updateSparsePath false\"
5457
EOF
5558

t/t7002-mv-sparse-checkout.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ test_expect_success 'setup' "
1111
git commit -m files &&
1212
1313
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:
1617
EOF
1718
1819
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.
2023
hint: Disable this message with \"git config advice.updateSparsePath false\"
2124
EOF
2225
"

0 commit comments

Comments
 (0)