diff options
author | Junio C Hamano <gitster@pobox.com> | 2024-02-08 16:22:11 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-02-08 16:22:11 -0800 |
commit | fb3ead665bd3371e31cebe716c973c82ff8545eb (patch) | |
tree | b229c73454d5c7bd81f6284cfcd02796aa856df0 | |
parent | 5a322a2d3daff58abd3525aa9de81d188096636b (diff) | |
parent | 54d8a2531b839bb9c4e2f5aa26aae029415211f9 (diff) | |
download | git-fb3ead665bd3371e31cebe716c973c82ff8545eb.tar.gz |
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)
-rwxr-xr-x | t/t1006-cat-file.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh index 271c5e4fd3..e0c6482797 100755 --- a/t/t1006-cat-file.sh +++ b/t/t1006-cat-file.sh @@ -1100,6 +1100,42 @@ test_expect_success 'cat-file --batch="batman" with --batch-all-objects will wor cmp expect actual ' +test_expect_success 'cat-file %(objectsize:disk) with --batch-all-objects' ' + # our state has both loose and packed objects, + # so find both for our expected output + { + find .git/objects/?? -type f | + awk -F/ "{ print \$0, \$3\$4 }" | + while read path oid + do + size=$(test_file_size "$path") && + echo "$oid $size" || + return 1 + done && + rawsz=$(test_oid rawsz) && + find .git/objects/pack -name "*.idx" | + while read idx + do + git show-index <"$idx" >idx.raw && + sort -nr <idx.raw >idx.sorted && + packsz=$(test_file_size "${idx%.idx}.pack") && + end=$((packsz - rawsz)) && + while read start oid rest + do + size=$((end - start)) && + end=$start && + echo "$oid $size" || + return 1 + done <idx.sorted || + return 1 + done + } >expect.raw && + sort <expect.raw >expect && + git cat-file --batch-all-objects \ + --batch-check="%(objectname) %(objectsize:disk)" >actual && + test_cmp expect actual +' + test_expect_success 'set up replacement object' ' orig=$(git rev-parse HEAD) && git cat-file commit $orig >orig && |