Skip to content

Commit 4e95698

Browse files
matheustavaresgitster
authored andcommitted
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>
1 parent a5828ae commit 4e95698

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

builtin/add.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static void refresh(int verbose, const struct pathspec *pathspec)
187187
for (i = 0; i < pathspec->nr; i++) {
188188
if (!seen[i])
189189
die(_("pathspec '%s' did not match any files"),
190-
pathspec->items[i].match);
190+
pathspec->items[i].original);
191191
}
192192
free(seen);
193193
}

t/t3700-add.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ test_expect_success 'git add --refresh with pathspec' '
196196
grep baz actual
197197
'
198198

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+
199205
test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unreadable file' '
200206
git reset --hard &&
201207
date >foo1 &&

0 commit comments

Comments
 (0)