t1006: add tests for git cat-file --allow-unknown-type

Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Karthik Nayak committed May 3, 2015 at 20:00 UTC 3e370f9faf0a4e26d92ae09a26baa19330887903
1 file changed +45
t/t1006-cat-file.sh
+45
@@ -47,6 +47,18 @@ $content"
47 test_cmp expect actual
48 '
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 +
62 test -z "$content" ||
63 test_expect_success "Content of $type is correct" '
64 maybe_remove_timestamp "$content" $no_ts >expect &&
@@ -296,4 +308,37 @@ test_expect_success '%(deltabase) reports packed delta bases' '
308 }
309 '
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 +
344 test_done