summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-01-24 20:40:32 +0700
committerJunio C Hamano <gitster@pobox.com>2014-02-24 14:37:19 -0800
commit68690fdd0b78762eb6387d7a437b588d15b6cf47 (patch)
tree892afc2e10d1e91caa2f8a78a3cb544209400154 /dir.c
parent42b0874a7ef66f9bd561c66df6e989f58d0393b9 (diff)
downloadgit-68690fdd0b78762eb6387d7a437b588d15b6cf47.tar.gz
match_pathspec: match pathspec "foo/" against directory "foo"
Currently we do support matching pathspec "foo/" against directory "foo". That is because match_pathspec() has no way to tell "foo" is a directory and matching "foo/" against _file_ "foo" is wrong. The callers can now tell match_pathspec if "foo" is a directory, we could make an exception for this case. Code is not executed though because no callers pass the flag yet. 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.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index 124b434109..5359d75e8b 100644
--- a/dir.c
+++ b/dir.c
@@ -196,6 +196,7 @@ int within_depth(const char *name, int namelen,
}
#define DO_MATCH_EXCLUDE 1
+#define DO_MATCH_DIRECTORY 2
/*
* Does 'match' match the given name?
@@ -259,7 +260,11 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
if (match[matchlen-1] == '/' || name[matchlen] == '/')
return MATCHED_RECURSIVELY;
- }
+ } else if ((flags & DO_MATCH_DIRECTORY) &&
+ match[matchlen - 1] == '/' &&
+ namelen == matchlen - 1 &&
+ !ps_strncmp(item, match, name, namelen))
+ return MATCHED_EXACTLY;
if (item->nowildcard_len < item->len &&
!git_fnmatch(item, match, name,