Merge tag 'l10n-2.5.0-rnd1' of git://github.com/git-l10n/git-po
[gitweb.git] / t / t1006-cat-file.sh
index a494013ed32d82ffa0d02d04ecf8a0836c33044b..93a4794930bfebc99504a245392f32a3c92b3dde 100755 (executable)
@@ -47,6 +47,18 @@ $content"
        test_cmp expect actual
     '
 
+    test_expect_success "Type of $type is correct using --allow-unknown-type" '
+       echo $type >expect &&
+       git cat-file -t --allow-unknown-type $sha1 >actual &&
+       test_cmp expect actual
+    '
+
+    test_expect_success "Size of $type is correct using --allow-unknown-type" '
+       echo $size >expect &&
+       git cat-file -s --allow-unknown-type $sha1 >actual &&
+       test_cmp expect actual
+    '
+
     test -z "$content" ||
     test_expect_success "Content of $type is correct" '
        maybe_remove_timestamp "$content" $no_ts >expect &&
@@ -303,6 +315,39 @@ test_expect_success '%(deltabase) reports packed delta bases' '
        }
 '
 
+bogus_type="bogus"
+bogus_content="bogus"
+bogus_size=$(strlen "$bogus_content")
+bogus_sha1=$(echo_without_newline "$bogus_content" | git hash-object -t $bogus_type --literally -w --stdin)
+
+test_expect_success "Type of broken object is correct" '
+       echo $bogus_type >expect &&
+       git cat-file -t --allow-unknown-type $bogus_sha1 >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success "Size of broken object is correct" '
+       echo $bogus_size >expect &&
+       git cat-file -s --allow-unknown-type $bogus_sha1 >actual &&
+       test_cmp expect actual
+'
+bogus_type="abcdefghijklmnopqrstuvwxyz1234679"
+bogus_content="bogus"
+bogus_size=$(strlen "$bogus_content")
+bogus_sha1=$(echo_without_newline "$bogus_content" | git hash-object -t $bogus_type --literally -w --stdin)
+
+test_expect_success "Type of broken object is correct when type is large" '
+       echo $bogus_type >expect &&
+       git cat-file -t --allow-unknown-type $bogus_sha1 >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success "Size of large broken object is correct when type is large" '
+       echo $bogus_size >expect &&
+       git cat-file -s --allow-unknown-type $bogus_sha1 >actual &&
+       test_cmp expect actual
+'
+
 # Tests for git cat-file --follow-symlinks
 test_expect_success 'prep for symlink tests' '
        echo_without_newline "$hello_content" >morx &&
@@ -501,4 +546,5 @@ test_expect_success 'git cat-file --batch --follow-symlink returns correct sha a
        echo HEAD:morx | git cat-file --batch --follow-symlinks >actual &&
        test_cmp expect actual
 '
+
 test_done