threads / patch / 17069

patcht7700: demonstrate misbehavior of 'repack -a' when local packs exist

Subject: [PATCH] t7700: demonstrate misbehavior of 'repack -a' when local packs exist

## tl;dr

One message between Jan 9, 2009 and Jan 9, 2009. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Brandon Casey· Jan 9, 2009, 22:14 UTC · lore

The ability to "...fatten [the] local repository by packing everything that is needed by the local ref into a single new pack, including things that are borrowed from alternates"[1] is supposed to be provided by the '-a' or '-A' options to repack when '-l' is not used, but there is a flaw. For each pack in the local repository without a .keep file, repack supplies a --unpacked=<pack> argument to pack-objects.

The --unpacked option to pack-objects, with or without an argument, causes pack-objects to ignore any object which is packed in a pack not mentioned in an argument to --unpacked=. So, if there are local packs, and 'repack -a' is called, then any objects which reside in packs accessible through alternates will _not_ be packed. If there are no local packs, then no --unpacked argument will be supplied, and repack will behave as expected.

[1] http://mid.gmane.org/7v8wrwidi3.fsf@gitster.siamese.dyndns.org
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
FYI: I won't be looking in to a fix for this immediately. So if someone else
     has time and the inclination, please be my guest. Also, you can thank a
     transformer blow, and lots of disk loss for the discovery of this bug.
-brandon
 t/t7700-repack.sh |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
Show changes to t/t7700-repack.sh +19 −0
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index 3f602ea..f5682d6 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -69,5 +69,24 @@ test_expect_success 'packed obs in alt ODB are repacked even when local repo is
 	done
 '
 
+test_expect_failure 'packed obs in alt ODB are repacked when local repo has packs' '
+	rm -f .git/objects/pack/* &&
+	echo new_content >> file1 &&
+	git add file1 &&
+	git commit -m more_content &&
+	git repack &&
+	git repack -a -d &&
+	myidx=$(ls -1 .git/objects/pack/*.idx) &&
+	test -f "$myidx" &&
+	for p in alt_objects/pack/*.idx; do
+		git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p"
+	done | while read sha1 rest; do
+		if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then
+			echo "Missing object in local pack: $sha1"
+			return 1
+		fi
+	done
+'
+
 test_done
 
-- 
1.6.1.76.gc123b

← back to recent threads