]> git.ipfire.org Git - thirdparty/git.git/commitdiff
add: include magic part of pathspec on --refresh error
authorMatheus Tavares <matheus.bernardino@usp.br>
Thu, 8 Apr 2021 20:41:22 +0000 (17:41 -0300)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Apr 2021 21:18:03 +0000 (14:18 -0700)
When `git add --refresh <pathspec>` doesn't find any matches for the
given pathspec, it prints an error message using the `match` field of
the `struct pathspec_item`. However, this field doesn't contain the
magic part of the pathspec. Instead, let's use the `original` field.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/add.c
t/t3700-add.sh

index ea762a41e3a2d2c41718de2e97c6a0e6031ce91c..24ed7e25f319dbe5bd3f3b12fbd4d8e3076e790e 100644 (file)
@@ -187,7 +187,7 @@ static void refresh(int verbose, const struct pathspec *pathspec)
        for (i = 0; i < pathspec->nr; i++) {
                if (!seen[i])
                        die(_("pathspec '%s' did not match any files"),
-                           pathspec->items[i].match);
+                           pathspec->items[i].original);
        }
        free(seen);
 }
index b3b122ff977c20895df9e3d84b9511e603a435d3..dd3011430d59f6c3f048bc5ed49a09b9fb10a0ef 100755 (executable)
@@ -196,6 +196,12 @@ test_expect_success 'git add --refresh with pathspec' '
        grep baz actual
 '
 
+test_expect_success 'git add --refresh correctly reports no match error' "
+       echo \"fatal: pathspec ':(icase)nonexistent' did not match any files\" >expect &&
+       test_must_fail git add --refresh ':(icase)nonexistent' 2>actual &&
+       test_cmp expect actual
+"
+
 test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unreadable file' '
        git reset --hard &&
        date >foo1 &&