diff options
author | Jeff King <peff@peff.net> | 2016-06-13 00:38:04 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-06-14 13:57:45 -0700 |
commit | e26a8c4721ceaf4c59e33bbd4e60f777b7ea9b62 (patch) | |
tree | 621b15b1697fda207311a48baf647cce59c53c9e /t/t7701-repack-unpack-unreachable.sh | |
parent | 905f27b86ac1f50c6870a064c3b5b9d82c97a145 (diff) | |
download | git-e26a8c4721ceaf4c59e33bbd4e60f777b7ea9b62.tar.gz git-e26a8c4721ceaf4c59e33bbd4e60f777b7ea9b62.tar.xz |
repack: extend --keep-unreachable to loose objects
If you use "repack -adk" currently, we will pack all objects
that are already packed into the new pack, and then drop the
old packs. However, loose unreachable objects will be left
as-is. In theory these are meant to expire eventually with
"git prune". But if you are using "repack -k", you probably
want to keep things forever and therefore do not run "git
prune" at all. Meaning those loose objects may build up over
time and end up fooling any object-count heuristics (such as
the one done by "gc --auto", though since git-gc does not
support "repack -k", this really applies to whatever custom
scripts people might have driving "repack -k").
With this patch, we instead stuff any loose unreachable
objects into the pack along with the already-packed
unreachable objects. This may seem wasteful, but it is
really no more so than using "repack -k" in the first place.
We are at a slight disadvantage, in that we have no useful
ordering for the result, or names to hand to the delta code.
However, this is again no worse than what "repack -k" is
already doing for the packed objects. The packing of these
objects doesn't matter much because they should not be
accessed frequently (unless they actually _do_ become
referenced, but then they would get moved to a different
part of the packfile during the next repack).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7701-repack-unpack-unreachable.sh')
-rwxr-xr-x | t/t7701-repack-unpack-unreachable.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh index f13df4329..987573c41 100755 --- a/t/t7701-repack-unpack-unreachable.sh +++ b/t/t7701-repack-unpack-unreachable.sh @@ -137,4 +137,17 @@ test_expect_success 'repack -k keeps unreachable packed objects' ' test_must_fail git cat-file -p $sha1 ' +test_expect_success 'repack -k packs unreachable loose objects' ' + # create loose unreachable object + sha1=$(echo would-be-deleted-loose | git hash-object -w --stdin) && + objpath=.git/objects/$(echo $sha1 | sed "s,..,&/,") && + test_path_is_file $objpath && + + # and confirm that the loose object goes away, but we can + # still access it (ergo, it is packed) + git repack -adk && + test_path_is_missing $objpath && + git cat-file -p $sha1 +' + test_done |