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 коммит произвёл Junio C Hamano
Родитель cc2fc7c2f0
Коммит 450870cba7
1 изменённых файлов: 27 добавлений и 30 удалений

Просмотреть файл

@ -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
git init dots && test_expect_success "fsck notices $path as $type" '
cd dots && (
blob=$(echo foo | git hash-object -w --stdin) && git init $name-$type &&
tab=$(printf "\\t") && cd $name-$type &&
git mktree <<-EOF && echo content >file &&
100644 blob $blob$tab. git add file &&
100644 blob $blob$tab.. git commit -m base &&
EOF blob=$(git rev-parse :file) &&
git fsck 2>out && tree=$(git rev-parse HEAD^{tree}) &&
cat out && value=$(eval "echo \$$type") &&
grep "warning.*\\." out printf "$mode $type %s\t%s" "$value" "$path" >bad &&
) git mktree <bad &&
' git fsck 2>out &&
cat out &&
test_expect_success 'fsck notices ".git" in trees' ' grep "warning.*\\." out
( )'
git init dotgit && done <<-\EOF
cd dotgit && 100644 blob
blob=$(echo foo | git hash-object -w --stdin) && 040000 tree
tab=$(printf "\\t") && EOF
git mktree <<-EOF && done <<-\EOF
100644 blob $blob$tab.git dot .
EOF dotdot ..
git fsck 2>out && dotgit .git
cat out && EOF
grep "warning.*\\.git" out
)
'
test_done test_done