Skip to content

Commit 74b4f7f

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1649612 commit 74b4f7f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

t/t4010-diff-pathspec.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,21 @@ test_expect_success 'diff-tree -r with wildcard' '
110110
test_cmp expected result
111111
'
112112

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+
113130
test_done

tree-walk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ static int match_entry(const struct pathspec_item *item,
543543
if (matchlen > pathlen) {
544544
if (match[pathlen] != '/')
545545
return 0;
546-
if (!S_ISDIR(entry->mode))
546+
if (!S_ISDIR(entry->mode) && !S_ISGITLINK(entry->mode))
547547
return 0;
548548
}
549549

0 commit comments

Comments
 (0)