Skip to content

Commit e4ddb05

Browse files
Andy753421gitster
authored andcommitted
tree_entry_interesting: match against all pathspecs
The current basedir compare aborts early in order to avoid futile recursive searches. However, a match may still be found by another pathspec. This can cause an error while checking out files from a branch when using multiple pathspecs: $ git checkout master -- 'a/*.txt' 'b/*.txt' error: pathspec 'a/*.txt' did not match any file(s) known to git. Signed-off-by: Andy Spencer <[email protected]> Acked-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2f93541 commit e4ddb05

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

t/t4010-diff-pathspec.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,17 @@ test_expect_success 'diff-tree -r with wildcard' '
110110
test_cmp expected result
111111
'
112112

113+
test_expect_success 'diff multiple wildcard pathspecs' '
114+
mkdir path2 &&
115+
echo rezrov >path2/file1 &&
116+
git update-index --add path2/file1 &&
117+
tree3=`git write-tree` &&
118+
git diff --name-only $tree $tree3 -- "path2*1" "path1*1" >actual &&
119+
cat <<-\EOF >expect &&
120+
path1/file1
121+
path2/file1
122+
EOF
123+
test_cmp expect actual
124+
'
125+
113126
test_done

tree-walk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
696696

697697
if (item->nowildcard_len &&
698698
!match_wildcard_base(item, base_str, baselen, &matched))
699-
return entry_not_interesting;
699+
continue;
700700

701701
/*
702702
* Concatenate base and entry->path into one and do

0 commit comments

Comments
 (0)