dir.c: fix EXC_FLAG_MUSTBEDIR match in sparse checkout
Commit c84de70 (excluded_1(): support exclude files in index - 2009-08-20) tries to work around the fact that there is no directory/file information in index entries, therefore EXC_FLAG_MUSTBEDIR match would fail. Unfortunately the workaround is flawed. This fixes it. Reported-by: Thomas Rinderknecht <thomasr@sailguy.org> 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
Nov 8, 2010 at 01:04 UTC
ae3cdfe1123d153f720bbe4a4abc97ed3e9f65a4
2 files changed
+9
-4
dir.c
+2
-1
@@ -360,7 +360,8 @@ int excluded_from_list(const char *pathname,
360
361
if (x->flags & EXC_FLAG_MUSTBEDIR) {
362
if (!dtype) {
363
- if (!prefixcmp(pathname, exclude))
363
+ if (!prefixcmp(pathname, exclude) &&
364
+ pathname[x->patternlen] == '/')
365
return to_exclude;
366
else
367
continue;
t/t1011-read-tree-sparse-checkout.sh
+7
-3
@@ -17,17 +17,19 @@ test_expect_success 'setup' '
17
cat >expected <<-\EOF &&
18
100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
19
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
20
+ 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 subsub/added
21
EOF
22
cat >expected.swt <<-\EOF &&
23
H init.t
24
H sub/added
25
+ H subsub/added
26
EOF
27
28
test_commit init &&
29
echo modified >>init.t &&
28
- mkdir sub &&
29
- touch sub/added &&
30
- git add init.t sub/added &&
30
+ mkdir sub subsub &&
31
+ touch sub/added subsub/added &&
32
+ git add init.t sub/added subsub/added &&
33
git commit -m "modified and added" &&
34
git tag top &&
35
git rm sub/added &&
@@ -81,6 +83,7 @@ test_expect_success 'match directories with trailing slash' '
83
cat >expected.swt-noinit <<-\EOF &&
84
S init.t
85
H sub/added
86
+ S subsub/added
87
EOF
88
89
echo sub/ > .git/info/sparse-checkout &&
@@ -105,6 +108,7 @@ test_expect_success 'checkout area changes' '
108
cat >expected.swt-nosub <<-\EOF &&
109
H init.t
110
S sub/added
111
+ S subsub/added
112
EOF
113
114
echo init.t >.git/info/sparse-checkout &&