gc: do not explode objects which will be immediately pruned
commit7e52f5660e542cf801e8fc6902a30cc572c13736
authorJeff King <peff@peff.net>
Sat, 7 Apr 2012 10:30:09 +0000 (7 06:30 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Apr 2012 18:09:49 +0000 (11 11:09 -0700)
tree203e0339a37a81deb5ff7c65e933ae197e91a0d1
parente8dde3e5f9ddb7cf95a6ff3cea6cf07c3a2db80d
gc: do not explode objects which will be immediately pruned

When we pack everything into one big pack with "git repack
-Ad", any unreferenced objects in to-be-deleted packs are
exploded into loose objects, with the intent that they will
be examined and possibly cleaned up by the next run of "git
prune".

Since the exploded objects will receive the mtime of the
pack from which they come, if the source pack is old, those
loose objects will end up pruned immediately. In that case,
it is much more efficient to skip the exploding step
entirely for these objects.

This patch teaches pack-objects to receive the expiration
information and avoid writing these objects out. It also
teaches "git gc" to pass the value of gc.pruneexpire to
repack (which in turn learns to pass it along to
pack-objects) so that this optimization happens
automatically during "git gc" and "git gc --auto".

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/gc.c
builtin/pack-objects.c
git-repack.sh
t/t7701-repack-unpack-unreachable.sh