threads / patch / 38323

patchcat-file: add short option '-c' for 'cat-file --textconv'

Subject: [PATCH] cat-file: add short option '-c' for 'cat-file --textconv'

## tl;dr

2 messages between Jan 9, 2015 and Jan 9, 2015. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Alexander Kuleshov· Jan 9, 2015, 08:47 UTC · lore
Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
 Documentation/git-cat-file.txt |  5 +++--
 builtin/cat-file.c             |  4 ++--
 t/t8007-cat-file-textconv.sh   | 10 ++++++++++
 3 files changed, 15 insertions(+), 4 deletions(-)
Show changes to 3 files +15 −4

Documentation/git-cat-file.txt, builtin/cat-file.c, t/t8007-cat-file-textconv.sh

diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt
index f6a16f4..b346a5d 100644
--- a/Documentation/git-cat-file.txt
+++ b/Documentation/git-cat-file.txt
@@ -9,14 +9,14 @@ git-cat-file - Provide content or type and size information for repository objec
 SYNOPSIS
 --------
 [verse]
-'git cat-file' (-t | -s | -e | -p | <type> | --textconv ) <object>
+'git cat-file' (-t | -s | -e | -p | <type> | (-c | --textconv) ) <object>
 'git cat-file' (--batch | --batch-check) < <list-of-objects>
 
 DESCRIPTION
 -----------
 In its first form, the command provides the content or the type of an object in
 the repository. The type is required unless '-t' or '-p' is used to find the
-object type, or '-s' is used to find the object size, or '--textconv' is used
+object type, or '-s' is used to find the object size, or '-c/--textconv' is used
 (which implies type "blob").
 
 In the second form, a list of objects (separated by linefeeds) is provided on
@@ -52,6 +52,7 @@ OPTIONS
 	or to ask for a "blob" with <object> being a tag object that
 	points at it.
 
+-c
 --textconv::
 	Show the content as transformed by a textconv filter. In this case,
 	<object> has be of the form <tree-ish>:<path>, or :<path> in order
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index f8d8129..a8154a0 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -329,7 +329,7 @@ static int batch_objects(struct batch_options *opt)
 }
 
 static const char * const cat_file_usage[] = {
-	N_("git cat-file (-t|-s|-e|-p|<type>|--textconv) <object>"),
+	N_("git cat-file (-t|-s|-e|-p|<type>|(-c|--textconv)) <object>"),
 	N_("git cat-file (--batch|--batch-check) < <list_of_objects>"),
 	NULL
 };
@@ -373,7 +373,7 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
 		OPT_SET_INT('e', NULL, &opt,
 			    N_("exit with zero when there's no error"), 'e'),
 		OPT_SET_INT('p', NULL, &opt, N_("pretty-print object's content"), 'p'),
-		OPT_SET_INT(0, "textconv", &opt,
+		OPT_SET_INT('c', "textconv", &opt,
 			    N_("for blob objects, run textconv on object's content"), 'c'),
 		{ OPTION_CALLBACK, 0, "batch", &batch, "format",
 			N_("show info and content of objects fed from the standard input"),
diff --git a/t/t8007-cat-file-textconv.sh b/t/t8007-cat-file-textconv.sh
index eacd49a..994c5b0 100755
--- a/t/t8007-cat-file-textconv.sh
+++ b/t/t8007-cat-file-textconv.sh
@@ -24,6 +24,11 @@ bin: test version 2
 EOF
 
 test_expect_success 'no filter specified' '
+	git cat-file -c :one.bin >result &&
+	test_cmp expected result
+'
+
+test_expect_success 'no filter specified' '
 	git cat-file --textconv :one.bin >result &&
 	test_cmp expected result
 '
@@ -52,6 +57,11 @@ cat >expected <<EOF
 converted: test version 2
 EOF
 
+test_expect_success 'cat-file -c on last commit' '
+	git cat-file -c :one.bin >result &&
+	test_cmp expected result
+'
+
 test_expect_success 'cat-file --textconv on last commit' '
 	git cat-file --textconv :one.bin >result &&
 	test_cmp expected result
-- 
2.2.1.522.g2561c04.dirty
Junio C Hamano· Jan 9, 2015, 22:48 UTC · re: Alexander Kuleshov · lore

Re: [PATCH] cat-file: add short option '-c' for 'cat-file --textconv'

Alexander Kuleshov <kuleshovmail@gmail.com> writes:
Show 17 quoted lines
> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
> ---
>  Documentation/git-cat-file.txt |  5 +++--
>  builtin/cat-file.c             |  4 ++--
>  t/t8007-cat-file-textconv.sh   | 10 ++++++++++
>  3 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt
> index f6a16f4..b346a5d 100644
> --- a/Documentation/git-cat-file.txt
> +++ b/Documentation/git-cat-file.txt
> @@ -9,14 +9,14 @@ git-cat-file - Provide content or type and size information for repository objec
>  SYNOPSIS
>  --------
>  [verse]
> -'git cat-file' (-t | -s | -e | -p | <type> | --textconv ) <object>
> +'git cat-file' (-t | -s | -e | -p | <type> | (-c | --textconv) ) <object>
Do we use "-c" for a shorthand for "--textconv" anywhere else?

Is there any other command that has "--textconv" where "-c" does not mean "--textconv"? Or worse yet, where "-c" already means something completely different from "--textconv"?

Unlike end-user facing Porcelain commands, plumbing commands are primarily meant to be used in scripts, and I am not sure how much benefit we are getting by introducing new short options to them.

Ancient plumbing commands do have many single-letter options but they were added back when more modern set of end-user facing Porcelain commands did not exist.

← back to recent threads