git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Kuleshov <kuleshovmail@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Alexander Kuleshov <kuleshovmail@gmail.com>
Subject: [PATCH] cat-file: add short option '-c' for 'cat-file --textconv'
Date: Fri,  9 Jan 2015 14:47:59 +0600	[thread overview]
Message-ID: <1420793279-27853-1-git-send-email-kuleshovmail@gmail.com> (raw)

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>
 '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

             reply	other threads:[~2015-01-09  8:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09  8:47 Alexander Kuleshov [this message]
2015-01-09 22:48 ` [PATCH] cat-file: add short option '-c' for 'cat-file --textconv' 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=1420793279-27853-1-git-send-email-kuleshovmail@gmail.com \
    --to=kuleshovmail@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).