Merge branch 'bc/maint-keep-pack'
authorJunio C Hamano <gitster@pobox.com>
Sun, 16 Nov 2008 08:49:02 +0000 (00:49 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 16 Nov 2008 08:49:02 +0000 (00:49 -0800)
* bc/maint-keep-pack:
repack: only unpack-unreachable if we are deleting redundant packs

Documentation/git-repack.txt
git-repack.sh
t/t7701-repack-unpack-unreachable.sh
index bbe1485a97979830f883377c2dd55c6a90eb8a09..aaa88526291a26db55c7ebb0833faefda9c7e5a4 100644 (file)
@@ -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
index 4d313d136e64678b99179b2e1dce7a1beaa36d04..458a497af810c7bb188a5aafb80c32aa0bc05264 100755 (executable)
@@ -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
index b48046e2614fa3926b49a7c5cb379d7f6359e881..63a8225ae5c7ffc265e28c9bf17bbec87ab339d8 100755 (executable)
@@ -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