]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7703: test for promisor file content after geometric repack
authorLorenzoPegorari <lorenzo.pegorari2002@gmail.com>
Sat, 18 Apr 2026 14:17:23 +0000 (16:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 18 Apr 2026 19:38:17 +0000 (12:38 -0700)
Add test that checks if the content of ".promisor" files are correctly
copied inside the ".promisor" files created by a geometric `repack`.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7703-repack-geometric.sh

index 04d5d8fc33e9e50e120ccc1d2fa4b13e738c7727..316247a3b9c59dbd48a1fcc15bd6d52d9739a8c3 100755 (executable)
@@ -541,4 +541,37 @@ test_expect_success 'geometric repack works with promisor packs' '
        )
 '
 
+test_expect_success 'check .promisor file content after geometric repack' '
+       test_when_finished rm -rf prom_test &&
+       git init prom_test &&
+       path=prom_test/.git/objects/pack &&
+
+       (
+               # Create 2 packs with 3 objs each, and manually create .promisor files
+               test_commit_bulk -C prom_test --start=1 1 &&  # 3 objects
+               prom1=$(find $path -name "*.pack" | sed "s/.pack$/.promisor/") &&
+               oid1=$(git -C prom_test rev-parse HEAD) &&
+               echo "$oid1 ref1" >"$prom1" &&
+               test_commit_bulk -C prom_test --start=2 1 &&  # 3 objects
+               prom2=$(find $path -name "*.pack" | sed "s/.pack$/.promisor/; \|$prom1|d") &&
+               oid2=$(git -C prom_test rev-parse HEAD) &&
+               echo "$oid2 ref2" >"$prom2" &&
+
+               # Create 1 pack with 12 objs, and manually create .promisor file
+               test_commit_bulk -C prom_test --start=3 4 &&  # 12 objects
+               prom3=$(find $path -name "*.pack" | sed "s/.pack$/.promisor/; \|$prom1|d; \|$prom2|d") &&
+               oid3=$(git -C prom_test rev-parse HEAD) &&
+               echo "$oid3 ref3" >"$prom3" &&
+
+               # Geometric repack, and check if correct
+               git -C prom_test repack --geometric 2 -d &&
+               prom=$(find $path -name "*.pack" | sed "s/.pack$/.promisor/; \|$prom3|d") &&
+               # $prom should have repacked only the first 2 small packs, so it should only
+               # contain the following: "$oid1 ref1 <time>" & "$oid2 ref2 <time>"
+               test_grep "$oid1 ref1 " "$prom" &&
+               test_grep "$oid2 ref2 " "$prom" &&
+               test_grep ! "$oid3 ref3" "$prom"
+       )
+'
+
 test_done