]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/t1006-cat-file-objectsize-disk' into maint-2.43
authorJunio C Hamano <gitster@pobox.com>
Fri, 9 Feb 2024 00:22:11 +0000 (16:22 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Feb 2024 00:22:11 +0000 (16:22 -0800)
Test update.

* jk/t1006-cat-file-objectsize-disk:
  t1006: prefer shell loop to awk for packed object sizes
  t1006: add tests for %(objectsize:disk)

1  2 
t/t1006-cat-file.sh

diff --combined t/t1006-cat-file.sh
index 271c5e4fd38cb367b302de00ae49cfdf454d2ae6,5ea33261289486def635bbbf75c683358357e3ad..e0c6482797e1203a9e97ec27714d5ea48aaf1b6c
@@@ -6,7 -6,7 +6,7 @@@ test_description='git cat-file
  
  test_cmdmode_usage () {
        test_expect_code 129 "$@" 2>err &&
 -      grep "^error:.*is incompatible with" err
 +      grep "^error: .* cannot be used together" err
  }
  
  for switches in \
@@@ -1100,6 -1100,42 +1100,42 @@@ test_expect_success 'cat-file --batch="
        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 &&