Skip to content

Commit

Permalink
dir.c: fix EXC_FLAG_MUSTBEDIR match in sparse checkout
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Nov 8, 2010
1 parent af77aee commit ae3cdfe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ int excluded_from_list(const char *pathname,

if (x->flags & EXC_FLAG_MUSTBEDIR) {
if (!dtype) {
if (!prefixcmp(pathname, exclude))
if (!prefixcmp(pathname, exclude) &&
pathname[x->patternlen] == '/')
return to_exclude;
else
continue;
Expand Down
10 changes: 7 additions & 3 deletions t/t1011-read-tree-sparse-checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ test_expect_success 'setup' '
cat >expected <<-\EOF &&
100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 subsub/added
EOF
cat >expected.swt <<-\EOF &&
H init.t
H sub/added
H subsub/added
EOF
test_commit init &&
echo modified >>init.t &&
mkdir sub &&
touch sub/added &&
git add init.t sub/added &&
mkdir sub subsub &&
touch sub/added subsub/added &&
git add init.t sub/added subsub/added &&
git commit -m "modified and added" &&
git tag top &&
git rm sub/added &&
Expand Down Expand Up @@ -81,6 +83,7 @@ test_expect_success 'match directories with trailing slash' '
cat >expected.swt-noinit <<-\EOF &&
S init.t
H sub/added
S subsub/added
EOF
echo sub/ > .git/info/sparse-checkout &&
Expand All @@ -105,6 +108,7 @@ test_expect_success 'checkout area changes' '
cat >expected.swt-nosub <<-\EOF &&
H init.t
S sub/added
S subsub/added
EOF
echo init.t >.git/info/sparse-checkout &&
Expand Down

0 comments on commit ae3cdfe

Please sign in to comment.