Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-15 03:55:06 +0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-15 03:55:06 +0400
commitc0fd1f517efeb67df32b8d4ffa209afab14be436 (patch)
tree007728a4e0c2572196e5b118761bf69fdea5bfd8 /read-cache.c
parentfdee7d07ba6c79b3e5125e96adbe1d9c3e75ce1d (diff)
Make "ce_match_path()" a generic helper function
... and make git-diff-files use it too. This all _should_ make the diffcore-pathspec.c phase unnecessary, since the diff'ers now all do the path matching early interally.
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c
index 5a61bf752b..f448ab17e2 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -171,6 +171,30 @@ int ce_same_name(struct cache_entry *a, struct cache_entry *b)
return ce_namelen(b) == len && !memcmp(a->name, b->name, len);
}
+int ce_path_match(const struct cache_entry *ce, const char **pathspec)
+{
+ const char *match, *name;
+ int len;
+
+ if (!pathspec)
+ return 1;
+
+ len = ce_namelen(ce);
+ name = ce->name;
+ while ((match = *pathspec++) != NULL) {
+ int matchlen = strlen(match);
+ if (matchlen > len)
+ continue;
+ if (memcmp(name, match, matchlen))
+ continue;
+ if (matchlen && name[matchlen-1] == '/')
+ return 1;
+ if (name[matchlen] == '/' || !name[matchlen])
+ return 1;
+ }
+ return 0;
+}
+
/*
* Do we have another file that has the beginning components being a
* proper superset of the name we're trying to add?