Skip to content

Commit a60ea8f

Browse files
pcloudsgitster
authored andcommitted
dir.c: fix match_pathname()
Given the pattern "1/2/3/4" and the path "1/2/3/4/f", the pattern prefix is "1/2/3/4". We will compare and remove the prefix from both pattern and path and come to this code /* * If the whole pattern did not have a wildcard, * then our prefix match is all we need; we * do not need to call fnmatch at all. */ if (!patternlen && !namelen) return 1; where patternlen is zero (full pattern consumed) and the remaining path in "name" is "/f". We fail to realize it's matched in this case and fall back to fnmatch(), which also fails to catch it. Fix it. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0e35fcb commit a60ea8f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ int match_pathname(const char *pathname, int pathlen,
878878
* then our prefix match is all we need; we
879879
* do not need to call fnmatch at all.
880880
*/
881-
if (!patternlen && !namelen)
881+
if (!patternlen && (!namelen || *name == '/'))
882882
return 1;
883883
}
884884

0 commit comments

Comments
 (0)