summaryrefslogtreecommitdiff
path: root/t/t7700-repack.sh
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-04-15 15:36:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-16 04:52:29 (GMT)
commited7e5fc3a2562e3d4fb4fe25e8dca0e9daa0ed13 (patch)
treef9dc45a7c7e520859d47a8fc0052cb50432e6050 /t/t7700-repack.sh
parente9e33ab0fba44c2680f5461cdc774c88b3bf4ac1 (diff)
downloadgit-ed7e5fc3a2562e3d4fb4fe25e8dca0e9daa0ed13.zip
git-ed7e5fc3a2562e3d4fb4fe25e8dca0e9daa0ed13.tar.gz
git-ed7e5fc3a2562e3d4fb4fe25e8dca0e9daa0ed13.tar.bz2
repack: add --keep-pack option
We allow to keep existing packs by having companion .keep files. This is helpful when a pack is permanently kept. In the next patch, git-gc just wants to keep a pack temporarily, for one pack-objects run. git-gc can use --keep-pack for this use case. A note about why the pack_keep field cannot be reused and pack_keep_in_core has to be added. This is about the case when --keep-pack is specified together with either --keep-unreachable or --unpack-unreachable, but --honor-pack-keep is NOT specified. In this case, we want to exclude objects from the packs specified on command line, not from ones with .keep files. If only one bit flag is used, we have to clear pack_keep on pack files with the .keep file. But we can't make any assumption about unreachable objects in .keep packs. If "pack_keep" field is false for .keep packs, we could potentially pull lots of unreachable objects into the new pack, or unpack them loose. The safer approach is ignore all packs with either .keep file or --keep-pack. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7700-repack.sh')
-rwxr-xr-xt/t7700-repack.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index 38247af..6162e2a 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -4,6 +4,12 @@ test_description='git repack works correctly'
. ./test-lib.sh
+commit_and_pack() {
+ test_commit "$@" >/dev/null &&
+ SHA1=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack </dev/null) &&
+ echo pack-${SHA1}.pack
+}
+
test_expect_success 'objects in packs marked .keep are not repacked' '
echo content1 > file1 &&
echo content2 > file2 &&
@@ -196,5 +202,24 @@ test_expect_success 'objects made unreachable by grafts only are kept' '
git cat-file -t $H1
'
+test_expect_success 'repack --keep-pack' '
+ test_create_repo keep-pack &&
+ (
+ cd keep-pack &&
+ P1=$(commit_and_pack 1) &&
+ P2=$(commit_and_pack 2) &&
+ P3=$(commit_and_pack 3) &&
+ P4=$(commit_and_pack 4) &&
+ ls .git/objects/pack/*.pack >old-counts &&
+ test_line_count = 4 old-counts &&
+ git repack -a -d --keep-pack $P1 --keep-pack $P4 &&
+ ls .git/objects/pack/*.pack >new-counts &&
+ grep -q $P1 new-counts &&
+ grep -q $P4 new-counts &&
+ test_line_count = 3 new-counts &&
+ git fsck
+ )
+'
+
test_done