{"thread":{"id":"16315","subject":"[PATCH] repack: only unpack-unreachable if we are deleting redundant packs","startedAt":"2008-11-13T20:11:46Z","lastAt":"2008-11-13T20:11:46Z","messageCount":1,"participants":["Brandon Casey"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"95719","messageId":"ZpRBYSzxOgXYGvqPdRjOj6xEw2pJOdnr_qPneol8bh34gB4qYV-2ioB6a-uYxoUk0qdZSQJ9Y5E@cipher.nrlssc.navy.mil","threadId":"16315","inReplyTo":null,"subject":"[PATCH] repack: only unpack-unreachable if we are deleting redundant packs","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-11-13T20:11:46Z","receivedAt":"2008-11-13T20:11:46Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"The -A option calls pack-objects with the --unpack-unreachable option so\nthat the unreachable objects in local packs are left in the local object\nstore loose. But if the -d option to repack was _not_ used, then these\nunpacked loose objects are redundant and unnecessary.\n\nUpdate tests in t7701.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n\n\nHere is another patch for bc/maint-keep-pack that seems to make sense.\nI can't think of a reason why porcelain repack should unpack the\nunreferenced objects if it's not going to delete the packs they were in.\n\n-brandon\n\n\n Documentation/git-repack.txt         |   11 +++++------\n git-repack.sh                        |    3 ++-\n t/t7701-repack-unpack-unreachable.sh |   18 +++++++++++++++---\n 3 files changed, 22 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt\nindex bbe1485..aaa8852 100644\n--- a/Documentation/git-repack.txt\n+++ b/Documentation/git-repack.txt\n@@ -38,12 +38,11 @@ OPTIONS\n \tdangling.\n \n -A::\n-\tSame as `-a`, but any unreachable objects in a previous\n-\tpack become loose, unpacked objects, instead of being\n-\tleft in the old pack.  Unreachable objects are never\n-\tintentionally added to a pack, even when repacking.\n-\tWhen used with '-d', this option\n-\tprevents unreachable objects from being immediately\n+\tSame as `-a`, unless '-d' is used.  Then any unreachable\n+\tobjects in a previous pack become loose, unpacked objects,\n+\tinstead of being left in the old pack.  Unreachable objects\n+\tare never intentionally added to a pack, even when repacking.\n+\tThis option prevents unreachable objects from being immediately\n \tdeleted by way of being left in the old pack and then\n \tremoved.  Instead, the loose unreachable objects\n \twill be pruned according to normal expiry rules\ndiff --git a/git-repack.sh b/git-repack.sh\nindex 4d313d1..458a497 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -71,7 +71,8 @@ case \",$all_into_one,\" in\n \t\t\t\texisting=\"$existing $e\"\n \t\t\tfi\n \t\tdone\n-\t\tif test -n \"$args\" -a -n \"$unpack_unreachable\"\n+\t\tif test -n \"$args\" -a -n \"$unpack_unreachable\" -a \\\n+\t\t\t-n \"$remove_redundant\"\n \t\tthen\n \t\t\targs=\"$args $unpack_unreachable\"\n \t\tfi\ndiff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh\nindex b48046e..63a8225 100755\n--- a/t/t7701-repack-unpack-unreachable.sh\n+++ b/t/t7701-repack-unpack-unreachable.sh\n@@ -8,7 +8,7 @@ fsha1=\n csha1=\n tsha1=\n \n-test_expect_success '-A option leaves unreachable objects unpacked' '\n+test_expect_success '-A with -d option leaves unreachable objects unpacked' '\n \techo content > file1 &&\n \tgit add . &&\n \tgit commit -m initial_commit &&\n@@ -58,7 +58,7 @@ compare_mtimes ()\n \t\t' -- \"$@\"\n }\n \n-test_expect_success 'unpacked objects receive timestamp of pack file' '\n+test_expect_success '-A without -d option leaves unreachable objects packed' '\n \tfsha1path=$(echo \"$fsha1\" | sed -e \"s|\\(..\\)|\\1/|\") &&\n \tfsha1path=\".git/objects/$fsha1path\" &&\n \tcsha1path=$(echo \"$csha1\" | sed -e \"s|\\(..\\)|\\1/|\") &&\n@@ -75,7 +75,19 @@ test_expect_success 'unpacked objects receive timestamp of pack file' '\n \tgit branch -D transient_branch &&\n \tsleep 1 &&\n \tgit repack -A -l &&\n-\tcompare_mtimes \"$packfile\" \"$fsha1path\" \"$csha1path\" \"$tsha1path\"\n+\ttest ! -f \"$fsha1path\" &&\n+\ttest ! -f \"$csha1path\" &&\n+\ttest ! -f \"$tsha1path\" &&\n+\tgit show $fsha1 &&\n+\tgit show $csha1 &&\n+\tgit show $tsha1\n+'\n+\n+test_expect_success 'unpacked objects receive timestamp of pack file' '\n+\ttmppack=\".git/objects/pack/tmp_pack\" &&\n+\tln \"$packfile\" \"$tmppack\" &&\n+\tgit repack -A -l -d &&\n+\tcompare_mtimes \"$tmppack\" \"$fsha1path\" \"$csha1path\" \"$tsha1path\"\n '\n \n test_done\n-- \n1.6.0.3.552.g12334\n"}]}