t1450: refactor ".", "..", and ".git" fsck tests

We check that fsck notices and complains about confusing
paths in trees. However, there are a few shortcomings:

  1. We check only for these paths as file entries, not as
     intermediate paths (so ".git" and not ".git/foo").

  2. We check "." and ".." together, so it is possible that
     we notice only one and not the other.

  3. We repeat a lot of boilerplate.

Let's use some loops to be more thorough in our testing, and
still end up with shorter code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2014-11-24 13:40:11 -05:00 committed by Junio C Hamano
parent cc2fc7c2f0
commit 450870cba7

View File

@ -237,35 +237,32 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
) )
' '
test_expect_success 'fsck notices "." and ".." in trees' ' while read name path; do
while read mode type; do
test_expect_success "fsck notices $path as $type" '
( (
git init dots && git init $name-$type &&
cd dots && cd $name-$type &&
blob=$(echo foo | git hash-object -w --stdin) && echo content >file &&
tab=$(printf "\\t") && git add file &&
git mktree <<-EOF && git commit -m base &&
100644 blob $blob$tab. blob=$(git rev-parse :file) &&
100644 blob $blob$tab.. tree=$(git rev-parse HEAD^{tree}) &&
EOF value=$(eval "echo \$$type") &&
printf "$mode $type %s\t%s" "$value" "$path" >bad &&
git mktree <bad &&
git fsck 2>out && git fsck 2>out &&
cat out && cat out &&
grep "warning.*\\." out grep "warning.*\\." out
) )'
' done <<-\EOF
100644 blob
test_expect_success 'fsck notices ".git" in trees' ' 040000 tree
(
git init dotgit &&
cd dotgit &&
blob=$(echo foo | git hash-object -w --stdin) &&
tab=$(printf "\\t") &&
git mktree <<-EOF &&
100644 blob $blob$tab.git
EOF EOF
git fsck 2>out && done <<-\EOF
cat out && dot .
grep "warning.*\\.git" out dotdot ..
) dotgit .git
' EOF
test_done test_done