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

Re: [PATCHv2 3/7] cat-file: do not die on --textconv without textconv filters

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 23, 2013, 15:15 UTC
Message-ID
<7v61zdl1m6.fsf@alter.siamese.dyndns.org>
In-Reply-To
<10c691f7003f1f211f265abb177dd2a1b511b7e2.1366718624.git.git@drmicha.warpmail.net>
Michael J Gruber <git@drmicha.warpmail.net> writes:
Show 29 quoted lines
> 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           | 18 ++++++++----------
>  t/t8007-cat-file-textconv.sh | 20 +++++---------------
>  2 files changed, 13 insertions(+), 25 deletions(-)
>
> diff --git a/builtin/cat-file.c b/builtin/cat-file.c
> index 045cee7..bd62373 100644
> --- a/builtin/cat-file.c
> +++ b/builtin/cat-file.c
> @@ -48,6 +48,14 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
>  	case 'e':
>  		return !has_sha1_file(sha1);
>  
> +	case 'c':
> +		if (!obj_context.path[0])
> +			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))
> +			break;
> +
>  	case 'p':
Yeah, falling back to the 'p' case is a lot more sensible.
Show 76 quoted lines
>  		type = sha1_object_info(sha1, NULL);
>  		if (type < 0)
> @@ -70,16 +78,6 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
>  		/* otherwise just spit out the data */
>  		break;
>  
> -	case 'c':
> -		if (!obj_context.path[0])
> -			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;
> -
>  	case 0:
>  		if (type_from_string(exp_type) == OBJ_BLOB) {
>  			unsigned char blob_sha1[20];
> 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
>  '
Previous: Michael J GruberNext: Michael J Gruber
Message 37 of 77 in “grep with textconv”
  1. 0/6 grep with textconvMichael J Gruber, Apr 19, 2013
  2. 1/6 t4030: demonstrate behavior of show with textconvMichael J Gruber, Apr 19, 2013
  3. Jeff KingApr 20, 2013
  4. Michael J GruberApr 20, 2013
  5. 2/6 show: obey --textconv for blobsMichael J Gruber, Apr 19, 2013
  6. Jeff KingApr 20, 2013
  7. Michael J GruberApr 20, 2013
  8. Jeff KingApr 21, 2013
  9. Michael J GruberApr 22, 2013
  10. Junio C HamanoApr 22, 2013
  11. Jeff KingApr 22, 2013
  12. Jeremy RosenApr 22, 2013
  13. Matthieu MoyApr 22, 2013
  14. Michael J GruberApr 23, 2013
  15. 3/6 cat-file: do not die on --textconv without textconv filtersMichael J Gruber, Apr 19, 2013
  16. Junio C HamanoApr 19, 2013
  17. Jeff KingApr 20, 2013
  18. Michael J GruberApr 20, 2013
  19. 4/6 t7008: demonstrate behavior of grep with textconvMichael J Gruber, Apr 19, 2013
  20. 5/6 grep: allow to use textconv filtersMichael J Gruber, Apr 19, 2013
  21. Jeff KingApr 20, 2013
  22. 6/6 grep: obey --textconv for the case rev:pathMichael J Gruber, Apr 19, 2013
  23. Jeff KingApr 20, 2013
  24. Michael J GruberApr 20, 2013
  25. Jeff KingApr 21, 2013
  26. Junio C HamanoApr 19, 2013
  27. Jeff KingApr 20, 2013
  28. Michael J GruberApr 20, 2013
  29. 0/7 grep with textconvMichael J Gruber, Apr 23, 2013
  30. 1/7 t4030: demonstrate behavior of show with textconvMichael J Gruber, Apr 23, 2013
  31. Junio C HamanoApr 23, 2013
  32. 2/7 show: obey --textconv for blobsMichael J Gruber, Apr 23, 2013
  33. Junio C HamanoApr 23, 2013
  34. Michael J GruberApr 24, 2013
  35. Junio C HamanoApr 24, 2013
  36. 3/7 cat-file: do not die on --textconv without textconv filtersMichael J Gruber, Apr 23, 2013
  37. Junio C HamanoApr 23, 2013
  38. 4/7 t7008: demonstrate behavior of grep with textconvMichael J Gruber, Apr 23, 2013
  39. Junio C HamanoApr 23, 2013
  40. Michael J GruberApr 24, 2013
  41. Junio C HamanoApr 24, 2013
  42. 5/7 grep: allow to use textconv filtersMichael J Gruber, Apr 23, 2013
  43. 6/7 grep: honor --textconv for the case rev:pathMichael J Gruber, Apr 23, 2013
  44. 7/7 git grep: honor textconv by defaultMichael J Gruber, Apr 23, 2013
  45. Junio C HamanoApr 23, 2013
  46. Michael J GruberApr 24, 2013
  47. Junio C HamanoApr 24, 2013
  48. Matthieu MoyApr 24, 2013
  49. Junio C HamanoApr 24, 2013
  50. Michael J GruberApr 26, 2013
  51. Matthieu MoyApr 26, 2013
  52. Michael J GruberApr 29, 2013
  53. Junio C HamanoApr 29, 2013
  54. 1/7 t4030: demonstrate behavior of show with textconvMichael J Gruber, May 10, 2013
  55. 2/7 diff_opt: track whether flags have been set explicitlyMichael J Gruber, May 10, 2013
  56. Eric SunshineMay 10, 2013
  57. 3/7 show: honor --textconv for blobsMichael J Gruber, May 10, 2013
  58. Junio C HamanoMay 10, 2013
  59. Jeff KingMay 10, 2013
  60. Junio C HamanoMay 10, 2013
  61. Jeff KingMay 11, 2013
  62. Junio C HamanoMay 11, 2013
  63. Michael J GruberMay 11, 2013
  64. Michael J GruberMay 11, 2013
  65. Junio C HamanoMay 13, 2013
  66. Jeff KingMay 13, 2013
  67. Michael J GruberMay 13, 2013
  68. Junio C HamanoMay 13, 2013
  69. Jeff KingMay 16, 2013
  70. Junio C HamanoMay 11, 2013
  71. Michael J GruberMay 12, 2013
  72. 4/7 cat-file: do not die on --textconv without textconv filtersMichael J Gruber, May 10, 2013
  73. 5/7 t7008: demonstrate behavior of grep with textconvMichael J Gruber, May 10, 2013
  74. 6/7 grep: allow to use textconv filtersMichael J Gruber, May 10, 2013
  75. 7/7 grep: honor --textconv for the case rev:pathMichael J Gruber, May 10, 2013
  76. Junio C HamanoMay 10, 2013
  77. Junio C HamanoMay 10, 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.