summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a74ba54)
raw | patch | inline | side by side (parent: a74ba54)
author | Linus Torvalds <torvalds@g5.osdl.org> | |
Thu, 14 Jul 2005 23:43:01 +0000 (16:43 -0700) | ||
committer | Linus Torvalds <torvalds@g5.osdl.org> | |
Thu, 14 Jul 2005 23:43:01 +0000 (16:43 -0700) |
This brings all the same pathspec optimizations that git-diff-tree does
to git-diff-cache.
to git-diff-cache.
diff-cache.c | patch | blob | history |
diff --git a/diff-cache.c b/diff-cache.c
index be9222288fb6a6ecfdd4c91f6e386e9baf1c8f60..37c6eb5804ec7a454b0df83809e0208bcbd1b766 100644 (file)
--- a/diff-cache.c
+++ b/diff-cache.c
return 0;
}
-static int diff_cache(struct cache_entry **ac, int entries)
+static 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 (name[matchlen] == '/' || !name[matchlen])
+ return 1;
+ }
+ return 0;
+}
+
+static int diff_cache(struct cache_entry **ac, int entries, const char **pathspec)
{
while (entries) {
struct cache_entry *ce = *ac;
int same = (entries > 1) && ce_same_name(ce, ac[1]);
+ if (!ce_path_match(ce, pathspec))
+ goto skip_entry;
+
switch (ce_stage(ce)) {
case 0:
/* No stage 1 entry? That means it's a new file */
die("impossible cache entry stage");
}
+skip_entry:
/*
* Ignore all the different stages for this file,
* we've handled the relevant cases now.
if (read_tree(tree, size, 1, pathspec))
die("unable to read tree object %s", tree_name);
- ret = diff_cache(active_cache, active_nr);
+ ret = diff_cache(active_cache, active_nr, pathspec);
diffcore_std(pathspec,
detect_rename, diff_score_opt,