{"thread":{"id":"31450","subject":"git-repack.sh not server/multiuse safe?","startedAt":"2012-09-05T21:18:31Z","lastAt":"2012-09-05T21:18:31Z","messageCount":1,"participants":["Martin Fick"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"198404","messageId":"201209051518.34009.mfick@codeaurora.org","threadId":"31450","inReplyTo":null,"subject":"git-repack.sh not server/multiuse safe?","fromName":"Martin Fick","fromEmail":"mfick@codeaurora.org","sentAt":"2012-09-05T21:18:31Z","receivedAt":"2012-09-05T21:18:31Z","isPatch":false,"sender":{"key":"mfick@codeaurora.org","avatar":null},"body":"I have been reading the git-repack.sh script and I have \nfound a piece that I am concerned with.  It looks like after \nrepacking there is a place when packfiles could be \ntemporarily unaccessible making the objects within \ntemporarily unaccessible.  If my evaluation is true, it \nwould seem like git repacking is not \"server\" safe?\n\nIn particular, I am talking about this loop:\n\n # Ok we have prepared all new packfiles.\n\n # First see if there are packs of the same name and if so\n # if we can move them out of the way (this can happen if we\n # repacked immediately after packing fully.\n rollback=\n failed=\n for name in $names\n do\n        for sfx in pack idx\n        do\n                file=pack-$name.$sfx\n                test -f \"$PACKDIR/$file\" || continue\n                rm -f \"$PACKDIR/old-$file\" &&\n                mv \"$PACKDIR/$file\" \"$PACKDIR/old-$file\" ||  \n{\n                        failed=t\n                        break\n                }\n                rollback=\"$rollback $file\"\n        done\n        test -z \"$failed\" || break\n done\n\n\n\nIt would seem that one way to avoid this (at least on \nsystems supporting hardlinks), would be to instead link the \noriginal packfile to old-file first, then move the new \npackfile in place without ever deleting the original one \n(from its original name), only delete the old-file link.  \nDoes that make sense at all?\n\nThanks,\n\n-Martin\n\n\n-- \nEmployee of Qualcomm Innovation Center, Inc. which is a \nmember of Code Aurora Forum\n"}]}