aboutsummaryrefslogtreecommitdiff
path: root/t/t7701-repack-unpack-unreachable.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-10-16 20:44:49 -0400
committerJunio C Hamano <gitster@pobox.com>2014-10-19 15:07:07 -0700
commitc90f9e13abae630551ada3e895633bdc2cf4e080 (patch)
tree5f67d239fa22862022aff569f0699c9b79629ba1 /t/t7701-repack-unpack-unreachable.sh
parentedfbb2aa538148b38ee0ba6d62c95b7edda5d817 (diff)
downloadgit-c90f9e13abae630551ada3e895633bdc2cf4e080.tar.gz
git-c90f9e13abae630551ada3e895633bdc2cf4e080.tar.xz
repack: pack objects mentioned by the index
When we pack all objects, we use only the objects reachable from references and reflogs. This misses any objects which are reachable from the index, but not yet referenced. By itself this isn't a big deal; the objects can remain loose until they are actually used in a commit. However, it does create a problem when we drop packed but unreachable objects. We try to optimize out the writing of objects that we will immediately prune, which means we must follow the same rules as prune in determining what is reachable. And prune uses the index for this purpose. This is rather uncommon in practice, as objects in the index would not usually have been packed in the first place. But it could happen in a sequence like: 1. You make a commit on a branch that references blob X. 2. You repack, moving X into the pack. 3. You delete the branch (and its reflog), so that X is unreferenced. 4. You "git add" blob X so that it is now referenced only by the index. 5. You repack again with git-gc. The pack-objects we invoke will see that X is neither referenced nor recent and not bother loosening it. 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-xt/t7701-repack-unpack-unreachable.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh
index b8d4cdea8..aad8a9c64 100755
--- a/t/t7701-repack-unpack-unreachable.sh
+++ b/t/t7701-repack-unpack-unreachable.sh
@@ -109,4 +109,17 @@ test_expect_success 'do not bother loosening old objects' '
test_must_fail git cat-file -p $obj2
'
+test_expect_success 'keep packed objects found only in index' '
+ echo my-unique-content >file &&
+ git add file &&
+ git commit -m "make it reachable" &&
+ git gc &&
+ git reset HEAD^ &&
+ git reflog expire --expire=now --all &&
+ git add file &&
+ test-chmtime =-86400 .git/objects/pack/* &&
+ git gc --prune=1.hour.ago &&
+ git cat-file blob :file
+'
+
test_done