summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-02-15 09:03:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-15 23:32:32 (GMT)
commita60ea8fb66945a886ea53fd3f41e61cc5fb3201e (patch)
tree7bed5e272e0a8a7fbcfada169c43738e839a45bc /dir.c
parent0e35fcb412965f855e5ac6f469343e2f8e28d5ae (diff)
downloadgit-a60ea8fb66945a886ea53fd3f41e61cc5fb3201e.zip
git-a60ea8fb66945a886ea53fd3f41e61cc5fb3201e.tar.gz
git-a60ea8fb66945a886ea53fd3f41e61cc5fb3201e.tar.bz2
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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index f0b6d0a..bcaafac 100644
--- a/dir.c
+++ b/dir.c
@@ -878,7 +878,7 @@ int match_pathname(const char *pathname, int pathlen,
* then our prefix match is all we need; we
* do not need to call fnmatch at all.
*/
- if (!patternlen && !namelen)
+ if (!patternlen && (!namelen || *name == '/'))
return 1;
}