git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v10 4/4] t1006: add tests for git cat-file --allow-unknown-type

From
Karthik Nayak <karthik.188@gmail.com>
Date
May 3, 2015, 14:30 UTC
Message-ID
<1430663402-26717-4-git-send-email-karthik.188@gmail.com>
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
Previous: Eric SunshineNext: Eric Sunshine
Message 6 of 22 in “cat-file: add support for "-allow-unknown-type"”
  1. 0/4 cat-file: add support for "-allow-unknown-type"karthik nayak, May 3, 2015
  2. 1/4 sha1_file: support reading from a loose object of unknown typeKarthik Nayak, May 3, 2015
  3. 2/4 cat-file: make the options mutually exclusiveKarthik Nayak, May 3, 2015
  4. 3/4 cat-file: teach cat-file a '--allow-unknown-type' optionKarthik Nayak, May 3, 2015
  5. Eric SunshineMay 5, 2015
  6. 4/4 t1006: add tests for git cat-file --allow-unknown-typeKarthik Nayak, May 3, 2015
  7. Eric SunshineMay 5, 2015
  8. karthik nayakMay 5, 2015
  9. Junio C HamanoMay 6, 2015
  10. Eric SunshineMay 4, 2015
  11. karthik nayakMay 5, 2015
  12. Junio C HamanoMay 4, 2015
  13. Junio C HamanoMay 4, 2015
  14. Eric SunshineMay 4, 2015
  15. Eric SunshineMay 4, 2015
  16. karthik nayakMay 4, 2015
  17. karthik nayakMay 6, 2015
  18. Junio C HamanoMay 6, 2015
  19. Karthik NayakMay 7, 2015
  20. Junio C HamanoMay 7, 2015
  21. karthik nayakMay 4, 2015
  22. Junio C HamanoMay 4, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.