threads / patch / 16315

patchrepack: only unpack-unreachable if we are deleting redundant packs

Subject: [PATCH] repack: only unpack-unreachable if we are deleting redundant packs

## tl;dr

One message between Nov 13, 2008 and Nov 13, 2008. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Brandon Casey· Nov 13, 2008, 20:11 UTC · lore

The -A option calls pack-objects with the --unpack-unreachable option so that the unreachable objects in local packs are left in the local object store loose. But if the -d option to repack was _not_ used, then these unpacked loose objects are redundant and unnecessary.

Update tests in t7701.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---

Here is another patch for bc/maint-keep-pack that seems to make sense. I can't think of a reason why porcelain repack should unpack the unreferenced objects if it's not going to delete the packs they were in.

-brandon
 Documentation/git-repack.txt         |   11 +++++------
 git-repack.sh                        |    3 ++-
 t/t7701-repack-unpack-unreachable.sh |   18 +++++++++++++++---
 3 files changed, 22 insertions(+), 10 deletions(-)
Show changes to 3 files +22 −10

Documentation/git-repack.txt, git-repack.sh, t/t7701-repack-unpack-unreachable.sh

diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index bbe1485..aaa8852 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -38,12 +38,11 @@ OPTIONS
 	dangling.
 
 -A::
-	Same as `-a`, but any unreachable objects in a previous
-	pack become loose, unpacked objects, instead of being
-	left in the old pack.  Unreachable objects are never
-	intentionally added to a pack, even when repacking.
-	When used with '-d', this option
-	prevents unreachable objects from being immediately
+	Same as `-a`, unless '-d' is used.  Then any unreachable
+	objects in a previous pack become loose, unpacked objects,
+	instead of being left in the old pack.  Unreachable objects
+	are never intentionally added to a pack, even when repacking.
+	This option prevents unreachable objects from being immediately
 	deleted by way of being left in the old pack and then
 	removed.  Instead, the loose unreachable objects
 	will be pruned according to normal expiry rules
diff --git a/git-repack.sh b/git-repack.sh
index 4d313d1..458a497 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -71,7 +71,8 @@ case ",$all_into_one," in
 				existing="$existing $e"
 			fi
 		done
-		if test -n "$args" -a -n "$unpack_unreachable"
+		if test -n "$args" -a -n "$unpack_unreachable" -a \
+			-n "$remove_redundant"
 		then
 			args="$args $unpack_unreachable"
 		fi
diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh
index b48046e..63a8225 100755
--- a/t/t7701-repack-unpack-unreachable.sh
+++ b/t/t7701-repack-unpack-unreachable.sh
@@ -8,7 +8,7 @@ fsha1=
 csha1=
 tsha1=
 
-test_expect_success '-A option leaves unreachable objects unpacked' '
+test_expect_success '-A with -d option leaves unreachable objects unpacked' '
 	echo content > file1 &&
 	git add . &&
 	git commit -m initial_commit &&
@@ -58,7 +58,7 @@ compare_mtimes ()
 		' -- "$@"
 }
 
-test_expect_success 'unpacked objects receive timestamp of pack file' '
+test_expect_success '-A without -d option leaves unreachable objects packed' '
 	fsha1path=$(echo "$fsha1" | sed -e "s|\(..\)|\1/|") &&
 	fsha1path=".git/objects/$fsha1path" &&
 	csha1path=$(echo "$csha1" | sed -e "s|\(..\)|\1/|") &&
@@ -75,7 +75,19 @@ test_expect_success 'unpacked objects receive timestamp of pack file' '
 	git branch -D transient_branch &&
 	sleep 1 &&
 	git repack -A -l &&
-	compare_mtimes "$packfile" "$fsha1path" "$csha1path" "$tsha1path"
+	test ! -f "$fsha1path" &&
+	test ! -f "$csha1path" &&
+	test ! -f "$tsha1path" &&
+	git show $fsha1 &&
+	git show $csha1 &&
+	git show $tsha1
+'
+
+test_expect_success 'unpacked objects receive timestamp of pack file' '
+	tmppack=".git/objects/pack/tmp_pack" &&
+	ln "$packfile" "$tmppack" &&
+	git repack -A -l -d &&
+	compare_mtimes "$tmppack" "$fsha1path" "$csha1path" "$tsha1path"
 '
 
 test_done
-- 
1.6.0.3.552.g12334

← back to recent threads