Skip to content

Commit ec727e1

Browse files
jayatheerthkulkarnigitster
authored andcommitted
dir.c: literal match with wildcard in pathspec should still glob
When a path with wildcard characters, e.g. 'f*o', exists in the working tree, "git add -- 'f*o'" stops after happily finding that there is 'f*o' and adding it to the index, without realizing there may be other paths, e.g. 'foooo', that may match the given pathspec. This is because dir.c:do_match_pathspec() disables further matches with pathspec when it finds an exact match. Reported-by: piotrsiupa <[email protected]> Helped-by: Jeff King <[email protected]> Signed-off-by: K Jayatheerth <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d50a5e8 commit ec727e1

File tree

3 files changed

+432
-1
lines changed

3 files changed

+432
-1
lines changed

dir.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,8 @@ static int do_match_pathspec(struct index_state *istate,
519519
( exclude && !(ps->items[i].magic & PATHSPEC_EXCLUDE)))
520520
continue;
521521

522-
if (seen && seen[i] == MATCHED_EXACTLY)
522+
if (seen && seen[i] == MATCHED_EXACTLY &&
523+
ps->items[i].nowildcard_len == ps->items[i].len)
523524
continue;
524525
/*
525526
* Make exclude patterns optional and never report

t/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ integration_tests = [
787787
't6134-pathspec-in-submodule.sh',
788788
't6135-pathspec-with-attrs.sh',
789789
't6136-pathspec-in-bare.sh',
790+
't6137-pathspec-wildcards-literal.sh',
790791
't6200-fmt-merge-msg.sh',
791792
't6300-for-each-ref.sh',
792793
't6301-for-each-ref-errors.sh',

0 commit comments

Comments
 (0)