summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c4dc9d4)
raw | patch | inline | side by side (parent: c4dc9d4)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Wed, 15 Dec 2010 15:02:45 +0000 (22:02 +0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 16 Dec 2010 21:20:22 +0000 (13:20 -0800) |
Suppose we have two pathspecs 'a' and 'a/b' (both are dirs) and depth
limit 1. In current code, pathspecs are checked in input order. When
'a/b' is checked against pathspec 'a', it fails depth limit and
therefore is excluded, although it should match 'a/b' pathspec.
This patch reorders all pathspecs alphabetically, then teaches
tree_entry_interesting() to check against the deepest pathspec first,
so depth limit of a shallower pathspec won't affect a deeper one.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
limit 1. In current code, pathspecs are checked in input order. When
'a/b' is checked against pathspec 'a', it fails depth limit and
therefore is excluded, although it should match 'a/b' pathspec.
This patch reorders all pathspecs alphabetically, then teaches
tree_entry_interesting() to check against the deepest pathspec first,
so depth limit of a shallower pathspec won't affect a deeper one.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c | patch | blob | history | |
tree-walk.c | patch | blob | history |
index 79e88f6b9f669d6056241c16f2817e5ec361f1d6..aa0522dc49a07a2925a1b29a2dfaa59f76afff75 100644 (file)
--- a/dir.c
+++ b/dir.c
return 0;
}
+static int pathspec_item_cmp(const void *a_, const void *b_)
+{
+ struct pathspec_item *a, *b;
+
+ a = (struct pathspec_item *)a_;
+ b = (struct pathspec_item *)b_;
+ return strcmp(a->match, b->match);
+}
+
int init_pathspec(struct pathspec *pathspec, const char **paths)
{
const char **p = paths;
item->match = path;
item->len = strlen(path);
}
+
+ qsort(pathspec->items, pathspec->nr,
+ sizeof(struct pathspec_item), pathspec_item_cmp);
+
return 0;
}
diff --git a/tree-walk.c b/tree-walk.c
index 91d7b36567a9cf3cf1669f504d0929ac4fe58790..93b05a744282d2311191975eb45ffbb9c2f7fdc5 100644 (file)
--- a/tree-walk.c
+++ b/tree-walk.c
pathlen = tree_entry_len(entry->path, entry->sha1);
- for (i = 0; i < ps->nr; i++) {
+ for (i = ps->nr-1; i >= 0; i--) {
const struct pathspec_item *item = ps->items+i;
const char *match = item->match;
int matchlen = item->len;