Skip to content

Commit fb3ead6

Browse files
committed
Merge branch 'jk/t1006-cat-file-objectsize-disk' into maint-2.43
Test update. * jk/t1006-cat-file-objectsize-disk: t1006: prefer shell loop to awk for packed object sizes t1006: add tests for %(objectsize:disk)
2 parents 5a322a2 + 54d8a25 commit fb3ead6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

t/t1006-cat-file.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,42 @@ test_expect_success 'cat-file --batch="batman" with --batch-all-objects will wor
11001100
cmp expect actual
11011101
'
11021102

1103+
test_expect_success 'cat-file %(objectsize:disk) with --batch-all-objects' '
1104+
# our state has both loose and packed objects,
1105+
# so find both for our expected output
1106+
{
1107+
find .git/objects/?? -type f |
1108+
awk -F/ "{ print \$0, \$3\$4 }" |
1109+
while read path oid
1110+
do
1111+
size=$(test_file_size "$path") &&
1112+
echo "$oid $size" ||
1113+
return 1
1114+
done &&
1115+
rawsz=$(test_oid rawsz) &&
1116+
find .git/objects/pack -name "*.idx" |
1117+
while read idx
1118+
do
1119+
git show-index <"$idx" >idx.raw &&
1120+
sort -nr <idx.raw >idx.sorted &&
1121+
packsz=$(test_file_size "${idx%.idx}.pack") &&
1122+
end=$((packsz - rawsz)) &&
1123+
while read start oid rest
1124+
do
1125+
size=$((end - start)) &&
1126+
end=$start &&
1127+
echo "$oid $size" ||
1128+
return 1
1129+
done <idx.sorted ||
1130+
return 1
1131+
done
1132+
} >expect.raw &&
1133+
sort <expect.raw >expect &&
1134+
git cat-file --batch-all-objects \
1135+
--batch-check="%(objectname) %(objectsize:disk)" >actual &&
1136+
test_cmp expect actual
1137+
'
1138+
11031139
test_expect_success 'set up replacement object' '
11041140
orig=$(git rev-parse HEAD) &&
11051141
git cat-file commit $orig >orig &&

0 commit comments

Comments
 (0)