From: Karthik Nayak <karthik.188@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, sunshine@sunshineco.com,
Karthik Nayak <karthik.188@gmail.com>
Subject: [PATCH v10 4/4] t1006: add tests for git cat-file --allow-unknown-type
Date: Sun, 3 May 2015 20:00:02 +0530 [thread overview]
Message-ID: <1430663402-26717-4-git-send-email-karthik.188@gmail.com> (raw)
In-Reply-To: <1430663402-26717-1-git-send-email-karthik.188@gmail.com>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
t/t1006-cat-file.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index ab36b1e..de8eaf1 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -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 &&
@@ -296,4 +308,37 @@ 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
+'
+
test_done
--
2.4.0.rc1.250.gfbd73bd
next prev parent reply other threads:[~2015-05-03 14:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-03 14:28 [PATCH v10 0/4] cat-file: add support for "-allow-unknown-type" karthik nayak
2015-05-03 14:29 ` [PATCH v10 1/4] sha1_file: support reading from a loose object of unknown type Karthik Nayak
2015-05-03 14:30 ` [PATCH v10 2/4] cat-file: make the options mutually exclusive Karthik Nayak
2015-05-03 14:30 ` [PATCH v10 3/4] cat-file: teach cat-file a '--allow-unknown-type' option Karthik Nayak
2015-05-05 1:29 ` Eric Sunshine
2015-05-03 14:30 ` Karthik Nayak [this message]
2015-05-05 1:33 ` [PATCH v10 4/4] t1006: add tests for git cat-file --allow-unknown-type Eric Sunshine
2015-05-05 2:23 ` karthik nayak
2015-05-06 4:37 ` Junio C Hamano
2015-05-04 23:34 ` [PATCH v10 1/4] sha1_file: support reading from a loose object of unknown type Eric Sunshine
2015-05-05 2:21 ` karthik nayak
2015-05-04 0:10 ` [PATCH v10 0/4] cat-file: add support for "-allow-unknown-type" Junio C Hamano
2015-05-04 0:14 ` Junio C Hamano
2015-05-04 2:55 ` Eric Sunshine
2015-05-04 3:30 ` Eric Sunshine
2015-05-04 13:31 ` karthik nayak
2015-05-06 13:37 ` karthik nayak
2015-05-06 17:16 ` Junio C Hamano
2015-05-07 3:34 ` Karthik Nayak
2015-05-07 18:35 ` Junio C Hamano
2015-05-04 13:30 ` karthik nayak
2015-05-04 20:57 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430663402-26717-4-git-send-email-karthik.188@gmail.com \
--to=karthik.188@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).