From 8054a9ec602701973ca4010b5d37d6ec1889ec86 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Mon, 17 Nov 2008 09:25:19 +0100 Subject: [PATCH] t5303: Do not overwrite an existing pack This test corrupts a pack file, then repacks the objects. The consequence is that the repacked pack file has the same name as the original file (that has been corrupted). During its operation, git-pack-objects opens the corrupted file and keeps it open at all times. On Windows, this is a problem because a file that is open in any process cannot be delete or replaced, but that is what we do in some of the test cases, and so they fail. The work-around is to write the repacked objects to a file of a different name, and replace the original after git-pack-objects has terminated. Signed-off-by: Johannes Sixt --- t/t5303-pack-corruption-resilience.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/t/t5303-pack-corruption-resilience.sh b/t/t5303-pack-corruption-resilience.sh index 5132d41309..41c83e3477 100755 --- a/t/t5303-pack-corruption-resilience.sh +++ b/t/t5303-pack-corruption-resilience.sh @@ -43,8 +43,11 @@ create_new_pack() { do_repack() { pack=`printf "$blob_1\n$blob_2\n$blob_3\n" | - git pack-objects $@ .git/objects/pack/pack` && - pack=".git/objects/pack/pack-${pack}" + git pack-objects $@ .git/objects/pack/packtmp` && + packtmp=".git/objects/pack/packtmp-${pack}" && + pack=".git/objects/pack/pack-${pack}" && + mv "${packtmp}.pack" "${pack}.pack" && + mv "${packtmp}.idx" "${pack}.idx" } do_corrupt_object() { -- 2.11.4.GIT