Skip to content

Commit bce4fc6

Browse files
committed
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
2 parents 5fb9263 + aa984db commit bce4fc6

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

t/t1060-object-corruption.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ test_expect_failure 'clone --local detects misnamed objects' '
117117
'
118118

119119
test_expect_success 'fetch into corrupted repo with index-pack' '
120+
cp -R bit-error bit-error-cp &&
121+
test_when_finished "rm -rf bit-error-cp" &&
120122
(
121-
cd bit-error &&
123+
cd bit-error-cp &&
122124
test_must_fail git -c transfer.unpackLimit=1 \
123125
fetch ../no-bit-error 2>stderr &&
124126
test_i18ngrep ! -i collision stderr

t/t5300-pack-object.sh

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -468,29 +468,32 @@ test_expect_success 'pack-objects in too-many-packs mode' '
468468
git fsck
469469
'
470470

471-
#
472-
# WARNING!
473-
#
474-
# The following test is destructive. Please keep the next
475-
# two tests at the end of this file.
476-
#
477-
478-
test_expect_success \
479-
'fake a SHA1 hash collision' \
480-
'long_a=$(git hash-object a | sed -e "s!^..!&/!") &&
481-
long_b=$(git hash-object b | sed -e "s!^..!&/!") &&
482-
test -f .git/objects/$long_b &&
483-
cp -f .git/objects/$long_a \
484-
.git/objects/$long_b'
471+
test_expect_success 'setup: fake a SHA1 hash collision' '
472+
git init corrupt &&
473+
(
474+
cd corrupt &&
475+
long_a=$(git hash-object -w ../a | sed -e "s!^..!&/!") &&
476+
long_b=$(git hash-object -w ../b | sed -e "s!^..!&/!") &&
477+
test -f .git/objects/$long_b &&
478+
cp -f .git/objects/$long_a \
479+
.git/objects/$long_b
480+
)
481+
'
485482

486-
test_expect_success \
487-
'make sure index-pack detects the SHA1 collision' \
488-
'test_must_fail git index-pack -o bad.idx test-3.pack 2>msg &&
489-
test_i18ngrep "SHA1 COLLISION FOUND" msg'
483+
test_expect_success 'make sure index-pack detects the SHA1 collision' '
484+
(
485+
cd corrupt &&
486+
test_must_fail git index-pack -o ../bad.idx ../test-3.pack 2>msg &&
487+
test_i18ngrep "SHA1 COLLISION FOUND" msg
488+
)
489+
'
490490

491-
test_expect_success \
492-
'make sure index-pack detects the SHA1 collision (large blobs)' \
493-
'test_must_fail git -c core.bigfilethreshold=1 index-pack -o bad.idx test-3.pack 2>msg &&
494-
test_i18ngrep "SHA1 COLLISION FOUND" msg'
491+
test_expect_success 'make sure index-pack detects the SHA1 collision (large blobs)' '
492+
(
493+
cd corrupt &&
494+
test_must_fail git -c core.bigfilethreshold=1 index-pack -o ../bad.idx ../test-3.pack 2>msg &&
495+
test_i18ngrep "SHA1 COLLISION FOUND" msg
496+
)
497+
'
495498

496499
test_done

0 commit comments

Comments
 (0)