Skip to content

Commit f015fbb

Browse files
LorenzoPegorarigitster
authored andcommitted
t7703: test for promisor file content after geometric repack
Add test that checks if the content of ".promisor" files are correctly copied inside the ".promisor" files created by a geometric repack. Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8e537d0 commit f015fbb

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

t/t7703-repack-geometric.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,4 +541,46 @@ test_expect_success 'geometric repack works with promisor packs' '
541541
)
542542
'
543543

544+
test_expect_success 'check .promisor file content after geometric repack' '
545+
test_when_finished rm -rf prom_test &&
546+
git init prom_test &&
547+
path=prom_test/.git/objects/pack &&
548+
549+
(
550+
# Create 2 packs with 3 objs each, and manually create .promisor files
551+
test_commit_bulk -C prom_test --start=1 1 && # 3 objects
552+
prom=$(ls $path/*.pack | sed "s/\.pack/.promisor/") &&
553+
oid=$(git -C prom_test rev-parse HEAD) &&
554+
echo "$oid ref" >$prom &&
555+
prom_before_repack1=$(cat $prom) &&
556+
test_commit_bulk -C prom_test --start=2 1 && # 3 objects
557+
prom=$(ls -t $path/*.pack | head -n 1 | sed "s/\.pack/.promisor/") &&
558+
oid=$(git -C prom_test rev-parse HEAD) &&
559+
echo "$oid ref" >$prom &&
560+
prom_before_repack2=$(cat $prom) &&
561+
562+
# Create 2 packs with 12 and 24 objs, and manually create .promisor files
563+
test_commit_bulk -C prom_test --start=3 4 && # 12 objects
564+
prom=$(ls -t $path/*.pack | head -n 1 | sed "s/\.pack/.promisor/") &&
565+
oid=$(git -C prom_test rev-parse HEAD) &&
566+
echo "$oid ref" >$prom &&
567+
prom_before_repack3=$(cat $prom) &&
568+
test_commit_bulk -C prom_test --start=7 8 && # 24 objects
569+
prom=$(ls -t $path/*.pack | head -n 1 | sed "s/\.pack/.promisor/") &&
570+
oid=$(git -C prom_test rev-parse HEAD) &&
571+
echo "$oid ref" >$prom &&
572+
prom_before_repack4=$(cat $prom) &&
573+
574+
# Geometric repack, and check if correct compared to previous saved .promisor content
575+
git -C prom_test repack --geometric 2 -d &&
576+
prom=$(ls -t $path/*.pack | head -n 1 | sed "s/\.pack/.promisor/") &&
577+
# $prom should have repacked only the first 2 small packs, so it should only contain
578+
# the following: "$prom_before_repack1 <date>" & "$prom_before_repack2 <date>"
579+
test_grep "$prom_before_repack1 " $prom &&
580+
test_grep "$prom_before_repack2 " $prom &&
581+
test_grep ! $prom_before_repack3 $prom &&
582+
test_grep ! $prom_before_repack4 $prom
583+
)
584+
'
585+
544586
test_done

0 commit comments

Comments
 (0)