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

[RFC/PATCH 2/4] cat-file: do not die on --textconv without textconv filters

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Feb 6, 2013, 15:08 UTC
Message-ID
<b20e91bc71e59b5390005f2e6428e69a467e80b5.1360162813.git.git@drmicha.warpmail.net>
In-Reply-To
<20130205201106.GA29248@sigill.intra.peff.net>

When a command is supposed to use textconv filters (by default or with "--textconv") and none are configured then the blob is output without conversion; the only exception to this rule is "cat-file --textconv".

Make it behave like the rest of textconv aware commands.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 builtin/cat-file.c           |  9 +++++----
 t/t8007-cat-file-textconv.sh | 20 +++++---------------
 2 files changed, 10 insertions(+), 19 deletions(-)
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 00528dd..6912dc2 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -146,10 +146,11 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
 			die("git cat-file --textconv %s: <object> must be <sha1:path>",
 			    obj_name);
 
-		if (!textconv_object(obj_context.path, obj_context.mode, sha1, 1, &buf, &size))
-			die("git cat-file --textconv: unable to run textconv on %s",
-			    obj_name);
-		break;
+		if (textconv_object(obj_context.path, obj_context.mode, sha1, 1, &buf, &size))
+			break;
+
+		/* otherwise expect a blob */
+		exp_type = "blob";
 
 	case 0:
 		if (type_from_string(exp_type) == OBJ_BLOB) {
diff --git a/t/t8007-cat-file-textconv.sh b/t/t8007-cat-file-textconv.sh
index 78a0085..83c6636 100755
--- a/t/t8007-cat-file-textconv.sh
+++ b/t/t8007-cat-file-textconv.sh
@@ -22,11 +22,11 @@ test_expect_success 'setup ' '
 '
 
 cat >expected <<EOF
-fatal: git cat-file --textconv: unable to run textconv on :one.bin
+bin: test version 2
 EOF
 
 test_expect_success 'no filter specified' '
-	git cat-file --textconv :one.bin 2>result
+	git cat-file --textconv :one.bin >result &&
 	test_cmp expected result
 '
 
@@ -36,10 +36,6 @@ test_expect_success 'setup textconv filters' '
 	git config diff.test.cachetextconv false
 '
 
-cat >expected <<EOF
-bin: test version 2
-EOF
-
 test_expect_success 'cat-file without --textconv' '
 	git cat-file blob :one.bin >result &&
 	test_cmp expected result
@@ -73,25 +69,19 @@ test_expect_success 'cat-file --textconv on previous commit' '
 '
 
 test_expect_success SYMLINKS 'cat-file without --textconv (symlink)' '
+	printf "%s" "one.bin" >expected &&
 	git cat-file blob :symlink.bin >result &&
-	printf "%s" "one.bin" >expected
 	test_cmp expected result
 '
 
 
 test_expect_success SYMLINKS 'cat-file --textconv on index (symlink)' '
-	! git cat-file --textconv :symlink.bin 2>result &&
-	cat >expected <<\EOF &&
-fatal: git cat-file --textconv: unable to run textconv on :symlink.bin
-EOF
+	git cat-file --textconv :symlink.bin >result &&
 	test_cmp expected result
 '
 
 test_expect_success SYMLINKS 'cat-file --textconv on HEAD (symlink)' '
-	! git cat-file --textconv HEAD:symlink.bin 2>result &&
-	cat >expected <<EOF &&
-fatal: git cat-file --textconv: unable to run textconv on HEAD:symlink.bin
-EOF
+	git cat-file --textconv HEAD:symlink.bin >result &&
 	test_cmp expected result
 '
 
-- 
1.8.1.2.752.g32d147e
Previous: Jeff KingNext: Junio C Hamano
Message 21 of 37 in “grep: allow to use textconv filters”
  1. grep: allow to use textconv filtersMichael J Gruber, Feb 4, 2013
  2. Junio C HamanoFeb 4, 2013
  3. Michael J GruberFeb 5, 2013
  4. Jeff KingFeb 5, 2013
  5. Michael J GruberFeb 5, 2013
  6. Jeff KingFeb 5, 2013
  7. 0/4 textconv for show and grepMichael J Gruber, Feb 6, 2013
  8. Junio C HamanoFeb 6, 2013
  9. 1/4 show: obey --textconv for blobsMichael J Gruber, Feb 6, 2013
  10. Junio C HamanoFeb 6, 2013
  11. Jeff KingFeb 6, 2013
  12. Junio C HamanoFeb 6, 2013
  13. Jeff KingFeb 7, 2013
  14. Junio C HamanoFeb 7, 2013
  15. Michael J GruberFeb 7, 2013
  16. Jeff KingFeb 6, 2013
  17. Michael J GruberFeb 7, 2013
  18. Jeff KingFeb 7, 2013
  19. Michael J GruberFeb 7, 2013
  20. Jeff KingFeb 7, 2013
  21. 2/4 cat-file: do not die on --textconv without textconv filtersMichael J Gruber, Feb 6, 2013
  22. Junio C HamanoFeb 6, 2013
  23. Jeff KingFeb 6, 2013
  24. Junio C HamanoFeb 6, 2013
  25. Jeff KingFeb 6, 2013
  26. 3/4 grep: allow to use textconv filtersMichael J Gruber, Feb 6, 2013
  27. Matthieu MoyFeb 6, 2013
  28. Jeff KingFeb 6, 2013
  29. 4/4 grep: obey --textconv for the case rev:pathMichael J Gruber, Feb 6, 2013
  30. Jeff KingFeb 6, 2013
  31. Michael J GruberFeb 7, 2013
  32. Jeff KingFeb 7, 2013
  33. Michael J GruberFeb 7, 2013
  34. Jeff KingFeb 7, 2013
  35. Michael J GruberFeb 7, 2013
  36. Junio C HamanoFeb 7, 2013
  37. Michael J GruberFeb 8, 2013

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.