Skip to content

Commit d0b6a28

Browse files
LorenzoPegorarigitster
authored andcommitted
t7700: test for promisor file content after repack
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. Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a3627be commit d0b6a28

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

t/t7700-repack.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,4 +904,64 @@ test_expect_success 'pending objects are repacked appropriately' '
904904
)
905905
'
906906

907+
test_expect_success 'check one .promisor file content after repack' '
908+
test_when_finished rm -rf prom_test prom_before_repack &&
909+
git init prom_test &&
910+
path=prom_test/.git/objects/pack &&
911+
912+
(
913+
test_commit_bulk -C prom_test 1 &&
914+
915+
# Simulate .promisor file by creating it manually
916+
prom=$(ls $path/*.pack | sed "s/\.pack/.promisor/") &&
917+
oid=$(git -C prom_test rev-parse HEAD) &&
918+
echo "$oid ref" >"$prom" &&
919+
920+
# Repack, and check if correct
921+
git -C prom_test repack -a -d -f &&
922+
prom=$(ls $path/*.promisor) &&
923+
# $prom should contain "$oid ref <time>"
924+
test_grep "$prom_before_repack " "$prom" &&
925+
926+
# Save the current .promisor content, repack, and check if correct
927+
cp "$prom" prom_before_repack &&
928+
git -C prom_test repack -a -d -f &&
929+
prom=$(ls $path/*.promisor) &&
930+
# $prom should be exactly the same as prom_before_repack
931+
test_cmp prom_before_repack "$prom"
932+
)
933+
'
934+
935+
test_expect_success 'check multiple .promisor file content after repack' '
936+
test_when_finished rm -rf prom_test prom_before_repack &&
937+
git init prom_test &&
938+
path=prom_test/.git/objects/pack &&
939+
940+
(
941+
# Create 2 packs and simulate .promisor files by creating them manually
942+
test_commit_bulk -C prom_test 1 &&
943+
prom=$(ls $path/*.pack | sed "s/\.pack/.promisor/") &&
944+
oid1=$(git -C prom_test rev-parse HEAD) &&
945+
echo "$oid1 ref1" >"$prom" &&
946+
test_commit_bulk -C prom_test 1 &&
947+
prom=$(ls $path/*.pack | sed "s/\.pack/.promisor/; \|$prom|d") &&
948+
oid2=$(git -C prom_test rev-parse HEAD) &&
949+
echo "$oid2 ref2" >"$prom" &&
950+
951+
# Repack, and check if correct
952+
git -C prom_test repack -a -d -f &&
953+
prom=$(ls $path/*.promisor) &&
954+
# $prom should contain "$oid1 ref1 <time>" & "$oid2 ref2 <time>"
955+
test_grep "$oid1 ref1 " "$prom" &&
956+
test_grep "$oid2 ref2 " "$prom" &&
957+
958+
# Save the current .promisor content, repack, and check if correct
959+
cp "$prom" prom_before_repack &&
960+
git -C prom_test repack -a -d -f &&
961+
prom=$(ls $path/*.promisor) &&
962+
# $prom should be exactly the same as prom_before_repack
963+
test_cmp prom_before_repack "$prom"
964+
)
965+
'
966+
907967
test_done

0 commit comments

Comments
 (0)