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

The `-f` flag is used when repacking to ensure that all the packs
(created with `test_commit_bulk`) are repacked into a single new pack.

Helped-by: Tian Yuchen <cat@malon.dev>
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/t7700-repack.sh

index 63ef63fc509a1db6db7bec96113a6943963177e8..1decd7520a84d4bbb3cc41d8b6526c57c94b8433 100755 (executable)
@@ -904,4 +904,65 @@ test_expect_success 'pending objects are repacked appropriately' '
        )
 '
 
+test_expect_success 'check one .promisor file content after repack' '
+       test_when_finished rm -rf prom_test prom_before_repack &&
+       git init prom_test &&
+       path=prom_test/.git/objects/pack &&
+
+       (
+               # Create 1 pack
+               test_commit_bulk -C prom_test 1 &&
+
+               # Simulate .promisor file by creating it manually
+               prom=$(find $path -name "*.pack" | sed "s/.pack$/.promisor/") &&
+               oid=$(git -C prom_test rev-parse HEAD) &&
+               echo "$oid ref" >"$prom" &&
+
+               # Repack, and check if correct
+               git -C prom_test repack -a -d -f &&
+               prom=$(find $path -name "*.promisor") &&
+               # $prom should contain "$oid ref <time>"
+               test_grep "$oid ref " "$prom" &&
+
+               # Save the current .promisor content, repack, and check if correct
+               cp "$prom" prom_before_repack &&
+               git -C prom_test repack -a -d -f &&
+               prom=$(find $path -name "*.promisor") &&
+               # $prom should be exactly the same as prom_before_repack
+               test_cmp prom_before_repack "$prom"
+       )
+'
+
+test_expect_success 'check multiple .promisor file content after repack' '
+       test_when_finished rm -rf prom_test prom_before_repack &&
+       git init prom_test &&
+       path=prom_test/.git/objects/pack &&
+
+       (
+               # Create 2 packs and simulate .promisor files by creating them manually
+               test_commit_bulk -C prom_test 1 &&
+               prom=$(find $path -name "*.pack" | sed "s/.pack$/.promisor/") &&
+               oid1=$(git -C prom_test rev-parse HEAD) &&
+               echo "$oid1 ref1" >"$prom" &&
+               test_commit_bulk -C prom_test 1 &&
+               prom=$(find $path -name "*.pack" | sed "s/.pack$/.promisor/; \|$prom|d") &&
+               oid2=$(git -C prom_test rev-parse HEAD) &&
+               echo "$oid2 ref2" >"$prom" &&
+
+               # Repack, and check if correct
+               git -C prom_test repack -a -d -f &&
+               prom=$(find $path -name "*.promisor") &&
+               # $prom should contain "$oid1 ref1 <time>" & "$oid2 ref2 <time>"
+               test_grep "$oid1 ref1 " "$prom" &&
+               test_grep "$oid2 ref2 " "$prom" &&
+
+               # Save the current .promisor content, repack, and check if correct
+               cp "$prom" prom_before_repack &&
+               git -C prom_test repack -a -d -f &&
+               prom=$(find $path -name "*.promisor") &&
+               # $prom should be exactly the same as prom_before_repack
+               test_cmp prom_before_repack "$prom"
+       )
+'
+
 test_done