1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-31 22:37:54 +01:00

Merge branch 'ab/pack-tests-cleanup'

A couple of tests used to leave the repository in a state that is
deliberately corrupt, which have been corrected.

* ab/pack-tests-cleanup:
  index-pack tests: don't leave test repo dirty at end
  pack-objects tests: don't leave test .git corrupt at end
  pack-objects test: modernize style
This commit is contained in:
Junio C Hamano 2018-11-13 22:37:20 +09:00
commit bce4fc60ca
2 changed files with 28 additions and 23 deletions

View file

@ -117,8 +117,10 @@ test_expect_failure 'clone --local detects misnamed objects' '
'
test_expect_success 'fetch into corrupted repo with index-pack' '
cp -R bit-error bit-error-cp &&
test_when_finished "rm -rf bit-error-cp" &&
(
cd bit-error &&
cd bit-error-cp &&
test_must_fail git -c transfer.unpackLimit=1 \
fetch ../no-bit-error 2>stderr &&
test_i18ngrep ! -i collision stderr

View file

@ -468,29 +468,32 @@ test_expect_success 'pack-objects in too-many-packs mode' '
git fsck
'
#
# WARNING!
#
# The following test is destructive. Please keep the next
# two tests at the end of this file.
#
test_expect_success 'setup: fake a SHA1 hash collision' '
git init corrupt &&
(
cd corrupt &&
long_a=$(git hash-object -w ../a | sed -e "s!^..!&/!") &&
long_b=$(git hash-object -w ../b | sed -e "s!^..!&/!") &&
test -f .git/objects/$long_b &&
cp -f .git/objects/$long_a \
.git/objects/$long_b
)
'
test_expect_success \
'fake a SHA1 hash collision' \
'long_a=$(git hash-object a | sed -e "s!^..!&/!") &&
long_b=$(git hash-object b | sed -e "s!^..!&/!") &&
test -f .git/objects/$long_b &&
cp -f .git/objects/$long_a \
.git/objects/$long_b'
test_expect_success 'make sure index-pack detects the SHA1 collision' '
(
cd corrupt &&
test_must_fail git index-pack -o ../bad.idx ../test-3.pack 2>msg &&
test_i18ngrep "SHA1 COLLISION FOUND" msg
)
'
test_expect_success \
'make sure index-pack detects the SHA1 collision' \
'test_must_fail git index-pack -o bad.idx test-3.pack 2>msg &&
test_i18ngrep "SHA1 COLLISION FOUND" msg'
test_expect_success \
'make sure index-pack detects the SHA1 collision (large blobs)' \
'test_must_fail git -c core.bigfilethreshold=1 index-pack -o bad.idx test-3.pack 2>msg &&
test_i18ngrep "SHA1 COLLISION FOUND" msg'
test_expect_success 'make sure index-pack detects the SHA1 collision (large blobs)' '
(
cd corrupt &&
test_must_fail git -c core.bigfilethreshold=1 index-pack -o ../bad.idx ../test-3.pack 2>msg &&
test_i18ngrep "SHA1 COLLISION FOUND" msg
)
'
test_done