]> granicus.if.org Git - git/commitdiff
pack-objects: double-check options before discarding objects
authorJeff King <peff@peff.net>
Fri, 17 Oct 2014 00:44:54 +0000 (20:44 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sun, 19 Oct 2014 22:07:07 +0000 (15:07 -0700)
When we are given an expiration time like
--unpack-unreachable=2.weeks.ago, we avoid writing out old,
unreachable loose objects entirely, under the assumption
that running "prune" would simply delete them immediately
anyway. However, this is only valid if we computed the same
set of reachable objects as prune would.

In practice, this is the case, because only git-repack uses
the --unpack-unreachable option with an expiration, and it
always feeds as many objects into the pack as possible. But
we can double-check at runtime just to be sure.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c

index 0cf95c9901aa1ce342bc209e437477eb3f8e938a..64123d4222187afcf3bede5def93157bdff2748d 100644 (file)
@@ -2757,6 +2757,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 
        if (keep_unreachable && unpack_unreachable)
                die("--keep-unreachable and --unpack-unreachable are incompatible.");
+       if (!rev_list_all || !rev_list_reflog || !rev_list_index)
+               unpack_unreachable_expiration = 0;
 
        if (!use_internal_rev_list || !pack_to_stdout || is_repository_shallow())
                use_bitmap_index = 0;