add: include magic part of pathspec on --refresh error

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>

Matheus Tavares committed Apr 8, 2021 at 17:41 UTC 4e9569834936a8c0df8c9afdc0334f1b96b20914
2 files changed +7 -1
builtin/add.c
+1 -1
@@ -187,7 +187,7 @@ static void refresh(int verbose, const struct pathspec *pathspec)
187 for (i = 0; i < pathspec->nr; i++) {
188 if (!seen[i])
189 die(_("pathspec '%s' did not match any files"),
190 - pathspec->items[i].match);
190 + pathspec->items[i].original);
191 }
192 free(seen);
193 }
t/t3700-add.sh
+6
@@ -196,6 +196,12 @@ test_expect_success 'git add --refresh with pathspec' '
196 grep baz actual
197 '
198
199 +test_expect_success 'git add --refresh correctly reports no match error' "
200 + echo \"fatal: pathspec ':(icase)nonexistent' did not match any files\" >expect &&
201 + test_must_fail git add --refresh ':(icase)nonexistent' 2>actual &&
202 + test_cmp expect actual
203 +"
204 +
205 test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unreadable file' '
206 git reset --hard &&
207 date >foo1 &&