From 7e52f5660e542cf801e8fc6902a30cc572c13736 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sat, 7 Apr 2012 06:30:09 -0400 Subject: 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 Acked-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- git-repack.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'git-repack.sh') diff --git a/git-repack.sh b/git-repack.sh index 624feec26f..757933174e 100755 --- a/git-repack.sh +++ b/git-repack.sh @@ -15,6 +15,7 @@ F pass --no-reuse-object to git-pack-objects n do not run git-update-server-info q,quiet be quiet l pass --local to git-pack-objects +unpack-unreachable= with -A, do not loosen objects older than this Packing constraints window= size of the window used for delta compression window-memory= same as the above, but limit memory size instead of entries count @@ -33,6 +34,8 @@ do -a) all_into_one=t ;; -A) all_into_one=t unpack_unreachable=--unpack-unreachable ;; + --unpack-unreachable) + unpack_unreachable="--unpack-unreachable=$2"; shift ;; -d) remove_redundant=t ;; -q) GIT_QUIET=t ;; -f) no_reuse=--no-reuse-delta ;; @@ -76,7 +79,12 @@ case ",$all_into_one," in if test -n "$existing" -a -n "$unpack_unreachable" -a \ -n "$remove_redundant" then - args="$args $unpack_unreachable" + # This may have arbitrary user arguments, so we + # have to protect it against whitespace splitting + # when it gets run as "pack-objects $args" later. + # Fortunately, we know it's an approxidate, so we + # can just use dots instead. + args="$args $(echo "$unpack_unreachable" | tr ' ' .)" fi fi ;; -- cgit v1.2.3