aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-01-21 16:16:27 -0800
committerJunio C Hamano <gitster@pobox.com>2026-01-21 16:16:27 -0800
commit070fa416755497ce78e09713ef5cd37e2c7205f2 (patch)
tree9501aa627d5239ab3bd11c38a042aa7c354ffd26 /t
parent83a69f19359e6d9bc980563caca38b2b5729808c (diff)
parentdcc9c7ef47d8755f1448116cdf0a421129999cd4 (diff)
downloadgit-070fa416755497ce78e09713ef5cd37e2c7205f2.tar.xz
Merge branch 'ps/geometric-repacking-with-promisor-remotes'
"git repack --geometric" did not work with promisor packs, which has been corrected. * ps/geometric-repacking-with-promisor-remotes: builtin/repack: handle promisor packs with geometric repacking repack-promisor: extract function to remove redundant packs repack-promisor: extract function to finalize repacking repack-geometry: extract function to compute repacking split builtin/pack-objects: exclude promisor objects with "--stdin-packs"
Diffstat (limited to 't')
-rwxr-xr-xt/t5331-pack-objects-stdin.sh39
-rwxr-xr-xt/t7703-repack-geometric.sh61
2 files changed, 100 insertions, 0 deletions
diff --git a/t/t5331-pack-objects-stdin.sh b/t/t5331-pack-objects-stdin.sh
index 4a8df5a389..cd949025b9 100755
--- a/t/t5331-pack-objects-stdin.sh
+++ b/t/t5331-pack-objects-stdin.sh
@@ -319,6 +319,45 @@ test_expect_success '--stdin-packs=follow walks into unknown packs' '
)
'
+test_expect_success '--stdin-packs with promisors' '
+ test_when_finished "rm -fr repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ git config set maintenance.auto false &&
+ git remote add promisor garbage &&
+ git config set remote.promisor.promisor true &&
+
+ for c in A B C D
+ do
+ echo "$c" >file &&
+ git add file &&
+ git commit --message "$c" &&
+ git tag "$c" || return 1
+ done &&
+
+ A="$(echo A | git pack-objects --revs $packdir/pack)" &&
+ B="$(echo A..B | git pack-objects --revs $packdir/pack --filter=blob:none)" &&
+ C="$(echo B..C | git pack-objects --revs $packdir/pack)" &&
+ D="$(echo C..D | git pack-objects --revs $packdir/pack)" &&
+ touch $packdir/pack-$B.promisor &&
+
+ test_must_fail git pack-objects --stdin-packs --exclude-promisor-objects pack- 2>err <<-EOF &&
+ pack-$B.pack
+ EOF
+ test_grep "is a promisor but --exclude-promisor-objects was given" err &&
+
+ PACK=$(git pack-objects --stdin-packs=follow --exclude-promisor-objects $packdir/pack <<-EOF
+ pack-$D.pack
+ EOF
+ ) &&
+ objects_in_packs $C $D >expect &&
+ objects_in_packs $PACK >actual &&
+ test_cmp expect actual &&
+ rm -f $packdir/pack-$PACK.*
+ )
+'
+
stdin_packs__follow_with_only () {
rm -fr stdin_packs__follow_with_only &&
git init stdin_packs__follow_with_only &&
diff --git a/t/t7703-repack-geometric.sh b/t/t7703-repack-geometric.sh
index 98806cdb6f..04d5d8fc33 100755
--- a/t/t7703-repack-geometric.sh
+++ b/t/t7703-repack-geometric.sh
@@ -480,4 +480,65 @@ test_expect_success '--geometric -l disables writing bitmaps with non-local pack
test_path_is_file member/.git/objects/pack/multi-pack-index-*.bitmap
'
+write_packfile () {
+ NR="$1"
+ PREFIX="$2"
+
+ printf "blob\ndata <<EOB\n$PREFIX %s\nEOB\n" $(test_seq $NR) |
+ git fast-import &&
+ git pack-objects --pack-loose-unreachable .git/objects/pack/pack &&
+ git prune-packed
+}
+
+write_promisor_packfile () {
+ PACKFILE=$(write_packfile "$@") &&
+ touch .git/objects/pack/pack-$PACKFILE.promisor &&
+ echo "$PACKFILE"
+}
+
+test_expect_success 'geometric repack works with promisor packs' '
+ test_when_finished "rm -fr repo" &&
+ git init repo &&
+ (
+ cd repo &&
+ git config set maintenance.auto false &&
+ git remote add promisor garbage &&
+ git config set remote.promisor.promisor true &&
+
+ # Packs A and B need to be merged.
+ NORMAL_A=$(write_packfile 2 normal-a) &&
+ NORMAL_B=$(write_packfile 2 normal-b) &&
+ NORMAL_C=$(write_packfile 14 normal-c) &&
+
+ # Packs A, B and C need to be merged.
+ PROMISOR_A=$(write_promisor_packfile 1 promisor-a) &&
+ PROMISOR_B=$(write_promisor_packfile 3 promisor-b) &&
+ PROMISOR_C=$(write_promisor_packfile 3 promisor-c) &&
+ PROMISOR_D=$(write_promisor_packfile 20 promisor-d) &&
+ PROMISOR_E=$(write_promisor_packfile 40 promisor-e) &&
+
+ git cat-file --batch-all-objects --batch-check="%(objectname)" >objects-expect &&
+
+ ls .git/objects/pack/*.pack >packs-before &&
+ test_line_count = 8 packs-before &&
+ git repack --geometric=2 -d &&
+ ls .git/objects/pack/*.pack >packs-after &&
+ test_line_count = 5 packs-after &&
+ test_grep ! "$NORMAL_A" packs-after &&
+ test_grep ! "$NORMAL_B" packs-after &&
+ test_grep "$NORMAL_C" packs-after &&
+ test_grep ! "$PROMISOR_A" packs-after &&
+ test_grep ! "$PROMISOR_B" packs-after &&
+ test_grep ! "$PROMISOR_C" packs-after &&
+ test_grep "$PROMISOR_D" packs-after &&
+ test_grep "$PROMISOR_E" packs-after &&
+
+ ls .git/objects/pack/*.promisor >promisors &&
+ test_line_count = 3 promisors &&
+
+ git cat-file --batch-all-objects --batch-check="%(objectname)" >objects-actual &&
+ test_cmp objects-expect objects-actual
+ )
+'
+
test_done