Merge branch 'jk/cat-file-regression-fix'
authorJunio C Hamano <gitster@pobox.com>
Fri, 27 Dec 2013 22:58:11 +0000 (14:58 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Dec 2013 22:58:11 +0000 (14:58 -0800)
"git cat-file --batch=", an admittedly useless command, did not
behave very well.

* jk/cat-file-regression-fix:
cat-file: handle --batch format with missing type/size
cat-file: pass expand_data to print_object_or_die

1  2 
t/t1006-cat-file.sh
diff --combined t/t1006-cat-file.sh
index 8a1bc5c53281eb6f44c15d68dd0ae737bc0125f3,df2ae67189184bde3ff0e809d79c7c0bcd84e8b8..1687098355b710850a04769512320930d9b8b27b
@@@ -85,6 -85,28 +85,28 @@@ $content
                git cat-file --batch-check="%(objecttype) %(rest)" >actual &&
        test_cmp expect actual
      '
+     test -z "$content" ||
+     test_expect_success "--batch without type ($type)" '
+       {
+               echo "$size" &&
+               maybe_remove_timestamp "$content" $no_ts
+       } >expect &&
+       echo $sha1 | git cat-file --batch="%(objectsize)" >actual.full &&
+       maybe_remove_timestamp "$(cat actual.full)" $no_ts >actual &&
+       test_cmp expect actual
+     '
+     test -z "$content" ||
+     test_expect_success "--batch without size ($type)" '
+       {
+               echo "$type" &&
+               maybe_remove_timestamp "$content" $no_ts
+       } >expect &&
+       echo $sha1 | git cat-file --batch="%(objecttype)" >actual.full &&
+       maybe_remove_timestamp "$(cat actual.full)" $no_ts >actual &&
+       test_cmp expect actual
+     '
  }
  
  hello_content="Hello World"
@@@ -194,12 -216,6 +216,12 @@@ test_expect_success "--batch-check for 
      test " missing" = "$(echo | git cat-file --batch-check)"
  '
  
 +test_expect_success 'empty --batch-check notices missing object' '
 +      echo "$_z40 missing" >expect &&
 +      echo "$_z40" | git cat-file --batch-check="" >actual &&
 +      test_cmp expect actual
 +'
 +
  batch_input="$hello_sha1
  $commit_sha1
  $tag_sha1