@@ -47,6 +47,18 @@ $content"
47
47
test_cmp expect actual
48
48
'
49
49
50
+ test_expect_success " Type of $type is correct using --allow-unknown-type" '
51
+ echo $type >expect &&
52
+ git cat-file -t --allow-unknown-type $sha1 >actual &&
53
+ test_cmp expect actual
54
+ '
55
+
56
+ test_expect_success " Size of $type is correct using --allow-unknown-type" '
57
+ echo $size >expect &&
58
+ git cat-file -s --allow-unknown-type $sha1 >actual &&
59
+ test_cmp expect actual
60
+ '
61
+
50
62
test -z " $content " ||
51
63
test_expect_success " Content of $type is correct" '
52
64
maybe_remove_timestamp "$content" $no_ts >expect &&
@@ -296,4 +308,37 @@ test_expect_success '%(deltabase) reports packed delta bases' '
296
308
}
297
309
'
298
310
311
+ bogus_type=" bogus"
312
+ bogus_content=" bogus"
313
+ bogus_size=$( strlen " $bogus_content " )
314
+ bogus_sha1=$( echo_without_newline " $bogus_content " | git hash-object -t $bogus_type --literally -w --stdin)
315
+
316
+ test_expect_success " Type of broken object is correct" '
317
+ echo $bogus_type >expect &&
318
+ git cat-file -t --allow-unknown-type $bogus_sha1 >actual &&
319
+ test_cmp expect actual
320
+ '
321
+
322
+ test_expect_success " Size of broken object is correct" '
323
+ echo $bogus_size >expect &&
324
+ git cat-file -s --allow-unknown-type $bogus_sha1 >actual &&
325
+ test_cmp expect actual
326
+ '
327
+ bogus_type=" abcdefghijklmnopqrstuvwxyz1234679"
328
+ bogus_content=" bogus"
329
+ bogus_size=$( strlen " $bogus_content " )
330
+ bogus_sha1=$( echo_without_newline " $bogus_content " | git hash-object -t $bogus_type --literally -w --stdin)
331
+
332
+ test_expect_success " Type of broken object is correct when type is large" '
333
+ echo $bogus_type >expect &&
334
+ git cat-file -t --allow-unknown-type $bogus_sha1 >actual &&
335
+ test_cmp expect actual
336
+ '
337
+
338
+ test_expect_success " Size of large broken object is correct when type is large" '
339
+ echo $bogus_size >expect &&
340
+ git cat-file -s --allow-unknown-type $bogus_sha1 >actual &&
341
+ test_cmp expect actual
342
+ '
343
+
299
344
test_done
0 commit comments