]> git.ipfire.org Git - thirdparty/git.git/commitdiff
advice: update message to suggest '--sparse'
authorDerrick Stolee <dstolee@microsoft.com>
Fri, 24 Sep 2021 15:39:14 +0000 (15:39 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Sep 2021 17:31:02 +0000 (10:31 -0700)
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>
advice.c
t/t3602-rm-sparse-checkout.sh
t/t3705-add-sparse-checkout.sh
t/t7002-mv-sparse-checkout.sh

index 0b9c89c48ab996da0e7938ac0667a3ecad925efc..713fff49ee31f1dfa8f20f0e228200859981218f 100644 (file)
--- a/advice.c
+++ b/advice.c
@@ -293,15 +293,16 @@ void advise_on_updating_sparse_paths(struct string_list *pathspec_list)
        if (!pathspec_list->nr)
                return;
 
-       fprintf(stderr, _("The following pathspecs didn't match any"
-                         " eligible path, but they do match index\n"
-                         "entries outside the current sparse checkout:\n"));
+       fprintf(stderr, _("The following paths and/or pathspecs matched paths that exist\n"
+                         "outside of your sparse-checkout definition, so will not be\n"
+                         "updated in the index:\n"));
        for_each_string_list_item(item, pathspec_list)
                fprintf(stderr, "%s\n", item->string);
 
        advise_if_enabled(ADVICE_UPDATE_SPARSE_PATH,
-                         _("Disable or modify the sparsity rules if you intend"
-                           " to update such entries."));
+                         _("If you intend to update such entries, try one of the following:\n"
+                           "* Use the --sparse option.\n"
+                           "* Disable or modify the sparsity rules."));
 }
 
 void detach_advice(const char *new_name)
index 5f92b60a56a9aa4a591772d854c18c42b19b0726..ecce497a9ca177594ea6d444371c415c3a7f2b21 100755 (executable)
@@ -11,12 +11,15 @@ test_expect_success 'setup' "
        git commit -m files &&
 
        cat >sparse_error_header <<-EOF &&
-       The following pathspecs didn't match any eligible path, but they do match index
-       entries outside the current sparse checkout:
+       The following paths and/or pathspecs matched paths that exist
+       outside of your sparse-checkout definition, so will not be
+       updated in the index:
        EOF
 
        cat >sparse_hint <<-EOF &&
-       hint: Disable or modify the sparsity rules if you intend to update such entries.
+       hint: If you intend to update such entries, try one of the following:
+       hint: * Use the --sparse option.
+       hint: * Disable or modify the sparsity rules.
        hint: Disable this message with \"git config advice.updateSparsePath false\"
        EOF
 
index 339ec0ed2d695f5299aa51832ec9f1e429a95855..5b904988d499e50d91554d6a67c6ad6a5584f961 100755 (executable)
@@ -44,12 +44,15 @@ test_sparse_entry_unstaged () {
 
 test_expect_success 'setup' "
        cat >sparse_error_header <<-EOF &&
-       The following pathspecs didn't match any eligible path, but they do match index
-       entries outside the current sparse checkout:
+       The following paths and/or pathspecs matched paths that exist
+       outside of your sparse-checkout definition, so will not be
+       updated in the index:
        EOF
 
        cat >sparse_hint <<-EOF &&
-       hint: Disable or modify the sparsity rules if you intend to update such entries.
+       hint: If you intend to update such entries, try one of the following:
+       hint: * Use the --sparse option.
+       hint: * Disable or modify the sparsity rules.
        hint: Disable this message with \"git config advice.updateSparsePath false\"
        EOF
 
index 07dbfeb6d1708fe281db758c498b2481bb9f1d3d..545748949aa4e21203e2d2f978413c95351787da 100755 (executable)
@@ -11,12 +11,15 @@ test_expect_success 'setup' "
        git commit -m files &&
 
        cat >sparse_error_header <<-EOF &&
-       The following pathspecs didn't match any eligible path, but they do match index
-       entries outside the current sparse checkout:
+       The following paths and/or pathspecs matched paths that exist
+       outside of your sparse-checkout definition, so will not be
+       updated in the index:
        EOF
 
        cat >sparse_hint <<-EOF
-       hint: Disable or modify the sparsity rules if you intend to update such entries.
+       hint: If you intend to update such entries, try one of the following:
+       hint: * Use the --sparse option.
+       hint: * Disable or modify the sparsity rules.
        hint: Disable this message with \"git config advice.updateSparsePath false\"
        EOF
 "