summaryrefslogtreecommitdiff
path: root/tree-walk.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-12-15 15:02:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-02-03 22:08:30 (GMT)
commit86e4ca69e358836599d4eb0c0e217caa9c9e455b (patch)
tree1b9f49279e2f071bb12b1777481826de1d139908 /tree-walk.c
parentbc96cc87dbb229cbdabfd93391e24ef168713a74 (diff)
downloadgit-86e4ca69e358836599d4eb0c0e217caa9c9e455b.zip
git-86e4ca69e358836599d4eb0c0e217caa9c9e455b.tar.gz
git-86e4ca69e358836599d4eb0c0e217caa9c9e455b.tar.bz2
tree_entry_interesting(): fix depth limit with overlapping pathspecs
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>
Diffstat (limited to 'tree-walk.c')
-rw-r--r--tree-walk.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tree-walk.c b/tree-walk.c
index 33feafa..be8182c 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -570,7 +570,7 @@ int tree_entry_interesting(const struct name_entry *entry,
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;