Merge branch 'ds/add-rm-with-sparse-index'
Regression fix.
* ds/add-rm-with-sparse-index:
dir: fix directory-matching bug
diff --git a/dir.c b/dir.c
index c6d7a86..9448929 100644
--- a/dir.c
+++ b/dir.c
@@ -1294,7 +1294,7 @@
* then our prefix match is all we need; we
* do not need to call fnmatch at all.
*/
- if (!patternlen && (!namelen || (flags & PATTERN_FLAG_MUSTBEDIR)))
+ if (!patternlen && !namelen)
return 1;
}
diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh
index 532637d..1889cfc 100755
--- a/t/t0008-ignores.sh
+++ b/t/t0008-ignores.sh
@@ -803,6 +803,32 @@
grep top-level-dir actual
'
+test_expect_success 'exact prefix matching (with root)' '
+ test_when_finished rm -r a &&
+ mkdir -p a/git a/git-foo &&
+ touch a/git/foo a/git-foo/bar &&
+ echo /git/ >a/.gitignore &&
+ git check-ignore a/git a/git/foo a/git-foo a/git-foo/bar >actual &&
+ cat >expect <<-\EOF &&
+ a/git
+ a/git/foo
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'exact prefix matching (without root)' '
+ test_when_finished rm -r a &&
+ mkdir -p a/git a/git-foo &&
+ touch a/git/foo a/git-foo/bar &&
+ echo git/ >a/.gitignore &&
+ git check-ignore a/git a/git/foo a/git-foo a/git-foo/bar >actual &&
+ cat >expect <<-\EOF &&
+ a/git
+ a/git/foo
+ EOF
+ test_cmp expect actual
+'
+
############################################################################
#
# test whitespace handling