Skip to content

Commit b1e757f

Browse files
peffgitster
authored andcommitted
pack-objects: double-check options before discarding objects
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c90f9e1 commit b1e757f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

builtin/pack-objects.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2757,6 +2757,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
27572757

27582758
if (keep_unreachable && unpack_unreachable)
27592759
die("--keep-unreachable and --unpack-unreachable are incompatible.");
2760+
if (!rev_list_all || !rev_list_reflog || !rev_list_index)
2761+
unpack_unreachable_expiration = 0;
27602762

27612763
if (!use_internal_rev_list || !pack_to_stdout || is_repository_shallow())
27622764
use_bitmap_index = 0;

0 commit comments

Comments
 (0)