Skip to content

Commit 36f0a2e

Browse files
committed
Merge branch 'ds/add-rm-with-sparse-index'
Regression fix. * ds/add-rm-with-sparse-index: dir: fix directory-matching bug
2 parents e2a33ef + 5ceb663 commit 36f0a2e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ int match_pathname(const char *pathname, int pathlen,
12941294
* then our prefix match is all we need; we
12951295
* do not need to call fnmatch at all.
12961296
*/
1297-
if (!patternlen && (!namelen || (flags & PATTERN_FLAG_MUSTBEDIR)))
1297+
if (!patternlen && !namelen)
12981298
return 1;
12991299
}
13001300

t/t0008-ignores.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,32 @@ test_expect_success 'existing directory and file' '
803803
grep top-level-dir actual
804804
'
805805

806+
test_expect_success 'exact prefix matching (with root)' '
807+
test_when_finished rm -r a &&
808+
mkdir -p a/git a/git-foo &&
809+
touch a/git/foo a/git-foo/bar &&
810+
echo /git/ >a/.gitignore &&
811+
git check-ignore a/git a/git/foo a/git-foo a/git-foo/bar >actual &&
812+
cat >expect <<-\EOF &&
813+
a/git
814+
a/git/foo
815+
EOF
816+
test_cmp expect actual
817+
'
818+
819+
test_expect_success 'exact prefix matching (without root)' '
820+
test_when_finished rm -r a &&
821+
mkdir -p a/git a/git-foo &&
822+
touch a/git/foo a/git-foo/bar &&
823+
echo git/ >a/.gitignore &&
824+
git check-ignore a/git a/git/foo a/git-foo a/git-foo/bar >actual &&
825+
cat >expect <<-\EOF &&
826+
a/git
827+
a/git/foo
828+
EOF
829+
test_cmp expect actual
830+
'
831+
806832
############################################################################
807833
#
808834
# test whitespace handling

0 commit comments

Comments
 (0)