Skip to content

Commit ae3cdfe

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af77aee commit ae3cdfe

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

dir.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ int excluded_from_list(const char *pathname,
360360

361361
if (x->flags & EXC_FLAG_MUSTBEDIR) {
362362
if (!dtype) {
363-
if (!prefixcmp(pathname, exclude))
363+
if (!prefixcmp(pathname, exclude) &&
364+
pathname[x->patternlen] == '/')
364365
return to_exclude;
365366
else
366367
continue;

t/t1011-read-tree-sparse-checkout.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ test_expect_success 'setup' '
1717
cat >expected <<-\EOF &&
1818
100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
1919
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
20+
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 subsub/added
2021
EOF
2122
cat >expected.swt <<-\EOF &&
2223
H init.t
2324
H sub/added
25+
H subsub/added
2426
EOF
2527
2628
test_commit init &&
2729
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 &&
3133
git commit -m "modified and added" &&
3234
git tag top &&
3335
git rm sub/added &&
@@ -81,6 +83,7 @@ test_expect_success 'match directories with trailing slash' '
8183
cat >expected.swt-noinit <<-\EOF &&
8284
S init.t
8385
H sub/added
86+
S subsub/added
8487
EOF
8588
8689
echo sub/ > .git/info/sparse-checkout &&
@@ -105,6 +108,7 @@ test_expect_success 'checkout area changes' '
105108
cat >expected.swt-nosub <<-\EOF &&
106109
H init.t
107110
S sub/added
111+
S subsub/added
108112
EOF
109113
110114
echo init.t >.git/info/sparse-checkout &&

0 commit comments

Comments
 (0)