aboutsummaryrefslogtreecommitdiff
path: root/t/t5331-pack-objects-stdin.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-04-06 15:42:49 -0700
committerJunio C Hamano <gitster@pobox.com>2026-04-06 15:42:49 -0700
commit03311dca7f91f69e9e0c532fce1c1e3c0a9fa34d (patch)
tree99942cb6e498bd5ff78b17ea65618125372e3876 /t/t5331-pack-objects-stdin.sh
parentd75badf83bc3fc8e47413970874bac681eeb5bbe (diff)
parent9ad29df36d7c762677b5a4ecc6a6dc229c818b2a (diff)
downloadgit-03311dca7f91f69e9e0c532fce1c1e3c0a9fa34d.tar.xz
Merge branch 'tb/stdin-packs-excluded-but-open'
pack-objects's --stdin-packs=follow mode learns to handle excluded-but-open packs. * tb/stdin-packs-excluded-but-open: repack: mark non-MIDX packs above the split as excluded-open pack-objects: support excluded-open packs with --stdin-packs t7704: demonstrate failure with once-cruft objects above the geometric split pack-objects: refactor `read_packs_list_from_stdin()` to use `strmap` pack-objects: plug leak in `read_stdin_packs()`
Diffstat (limited to 't/t5331-pack-objects-stdin.sh')
-rwxr-xr-xt/t5331-pack-objects-stdin.sh105
1 files changed, 105 insertions, 0 deletions
diff --git a/t/t5331-pack-objects-stdin.sh b/t/t5331-pack-objects-stdin.sh
index 7eb79bc2cd..c74b5861af 100755
--- a/t/t5331-pack-objects-stdin.sh
+++ b/t/t5331-pack-objects-stdin.sh
@@ -415,4 +415,109 @@ test_expect_success '--stdin-packs=follow tolerates missing commits' '
stdin_packs__follow_with_only HEAD HEAD^{tree}
'
+test_expect_success '--stdin-packs=follow with open-excluded packs' '
+ test_when_finished "rm -fr repo" &&
+
+ git init repo &&
+ (
+ cd repo &&
+ git config set maintenance.auto false &&
+
+ git branch -M main &&
+
+ # Create the following commit structure:
+ #
+ # A <-- B <-- D (main)
+ # ^
+ # \
+ # C (other)
+ test_commit A &&
+ test_commit B &&
+ git checkout -B other &&
+ test_commit C &&
+ git checkout main &&
+ test_commit D &&
+
+ A="$(echo A | git pack-objects --revs $packdir/pack)" &&
+ B="$(echo A..B | git pack-objects --revs $packdir/pack)" &&
+ C="$(echo B..C | git pack-objects --revs $packdir/pack)" &&
+ D="$(echo B..D | git pack-objects --revs $packdir/pack)" &&
+
+ C_ONLY="$(git rev-parse other | git pack-objects $packdir/pack)" &&
+
+ git prune-packed &&
+
+ # Create a pack using --stdin-packs=follow where:
+ #
+ # - pack D is included,
+ # - pack C_ONLY is excluded, but open,
+ # - pack B is excluded, but closed, and
+ # - packs A and C are unknown
+ #
+ # The resulting pack should therefore contain:
+ #
+ # - objects from the included pack D,
+ # - A.t (rescued via D^{tree}), and
+ # - C^{tree} and C.t (rescued via pack C_ONLY)
+ #
+ # , but should omit:
+ #
+ # - C (excluded via C_ONLY),
+ # - objects from pack B (trivially excluded-closed)
+ # - A and A^{tree} (ancestors of B)
+ P=$(git pack-objects --stdin-packs=follow $packdir/pack <<-EOF
+ pack-$D.pack
+ !pack-$C_ONLY.pack
+ ^pack-$B.pack
+ EOF
+ ) &&
+
+ {
+ objects_in_packs $D &&
+ git rev-parse A:A.t "C^{tree}" C:C.t
+ } >expect.raw &&
+ sort expect.raw >expect &&
+
+ objects_in_packs $P >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success '--stdin-packs with !-delimited pack without follow' '
+ test_when_finished "rm -fr repo" &&
+
+ git init repo &&
+ (
+ test_commit A &&
+ test_commit B &&
+ test_commit C &&
+
+ A="$(echo A | git pack-objects --revs $packdir/pack)" &&
+ B="$(echo A..B | git pack-objects --revs $packdir/pack)" &&
+ C="$(echo B..C | git pack-objects --revs $packdir/pack)" &&
+
+ cat >in <<-EOF &&
+ !pack-$A.pack
+ pack-$B.pack
+ pack-$C.pack
+ EOF
+
+ # Without --stdin-packs=follow, we treat the first
+ # line of input as a literal packfile name, and thus
+ # expect pack-objects to complain of a missing pack
+ test_must_fail git pack-objects --stdin-packs --stdout \
+ >/dev/null <in 2>err &&
+ test_grep "could not find pack .!pack-$A.pack." err &&
+
+ # With --stdin-packs=follow, we treat the second line
+ # of input as indicating pack-$A.pack is an excluded
+ # open pack, and thus expect pack-objects to succeed
+ P=$(git pack-objects --stdin-packs=follow $packdir/pack <in) &&
+
+ objects_in_packs $B $C >expect &&
+ objects_in_packs $P >actual &&
+ test_cmp expect actual
+ )
+'
+
test_done