tree-walk.c: ignore trailing slash on submodule in tree_entry_interesting()
We do ignore trailing slash on a directory, so pathspec "abc/" matches directory "abc". A submodule is also a directory. Apply the same logic to it. This makes "git log submodule-path" and "git log submodule-path/" produce the same output. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Jan 23, 2014 at 20:22 UTC
74b4f7f27736f3e196a4eb3db41c68e37a6e2160
2 files changed
+18
-1
t/t4010-diff-pathspec.sh
+17
@@ -110,4 +110,21 @@ test_expect_success 'diff-tree -r with wildcard' '
110
test_cmp expected result
111
'
112
113
+test_expect_success 'setup submodules' '
114
+ test_tick &&
115
+ git init submod &&
116
+ ( cd submod && test_commit first; ) &&
117
+ git add submod &&
118
+ git commit -m first &&
119
+ ( cd submod && test_commit second; ) &&
120
+ git add submod &&
121
+ git commit -m second
122
+'
123
+
124
+test_expect_success 'diff-tree ignores trailing slash on submodule path' '
125
+ git diff --name-only HEAD^ HEAD submod >expect &&
126
+ git diff --name-only HEAD^ HEAD submod/ >actual &&
127
+ test_cmp expect actual
128
+'
129
+
130
test_done
tree-walk.c
+1
-1
@@ -543,7 +543,7 @@ static int match_entry(const struct pathspec_item *item,
543
if (matchlen > pathlen) {
544
if (match[pathlen] != '/')
545
return 0;
546
- if (!S_ISDIR(entry->mode))
546
+ if (!S_ISDIR(entry->mode) && !S_ISGITLINK(entry->mode))
547
return 0;
548
}
549