git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fix archive-destroying "git repack -a -d" bug
@ 2005-09-18  1:46 Linus Torvalds
  2005-09-18  3:18 ` Dave Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Torvalds @ 2005-09-18  1:46 UTC (permalink / raw)
  To: Git Mailing List, Junio C Hamano


Using "git repack -a -d" can destroy your git archive if you use it twice 
in succession.

Why? Because the new pack will be called the same as the old pack. And we 
delete the old packs _after_ we've moved the new pack to the .git/objects/ 
directory, which means that we'll delete the new pack too!

This is a totally untested patch that may or may not fix this.

Signed-off-by: Linus "testing is for suckers" Torvalds <torvalds@osdl.org>
---
diff --git a/git-repack.sh b/git-repack.sh
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -31,10 +31,6 @@ case ",$all_into_one," in
 	rev_list=
 	rev_parse='--all'
 	pack_objects=
-	# This part is a stop-gap until we have proper pack redundancy
-	# checker.
-	existing=`cd "$PACKDIR" && \
-	    find . -type f \( -name '*.pack' -o -name '*.idx' \) -print`
 	;;
 esac
 name=$(git-rev-list --objects $rev_list $(git-rev-parse $rev_parse) |
@@ -54,8 +50,13 @@ exit
 
 if test "$remove_redandant" = t
 then
+	# This part is a stop-gap until we have proper pack redundancy
+	# checker.
 	# We know $existing are all redandant only when
 	# all-into-one is used.
+	existing=`cd "$PACKDIR" && \
+	    find . -type f \( -name '*.pack' -o -name '*.idx' \) -print |
+	    grep -v $name`
 	if test "$all_into_one" != '' && test "$existing" != ''
 	then
 		( cd "$PACKDIR" && rm -f $existing )

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-09-18 17:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-18  1:46 Fix archive-destroying "git repack -a -d" bug Linus Torvalds
2005-09-18  3:18 ` Dave Jones
2005-09-18 17:00   ` Linus Torvalds
2005-09-18 17:26   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).