threads / discuss / 18885

"git cat-file <sha1>" shows usage but should not?

Subject: "git cat-file <sha1>" shows usage but should not?

## tl;dr

8 messages between Apr 15, 2009 and Apr 15, 2009.

replies: 7people: 4as markdown or json

Sebastian Pipping· Apr 15, 2009, 16:50 UTC · lore
Here is what I did:

$ git cat-file -t b8c11fbbffbe171c4960058fa2d96f708e57a80c commit

$ git cat-file b8c11fbbffbe171c4960058fa2d96f708e57a80c
usage: git cat-file [-t|-s|-e|-p|<type>] <sha1>
   or: git cat-file [--batch|--batch-check] < <list_of_sha1s>
[..]

$ git --version git version 1.6.3.rc0.1.gf800.dirty

Sebastian
Jeff King· Apr 15, 2009, 16:54 UTC · re: Sebastian Pipping · lore

Re: "git cat-file <sha1>" shows usage but should not?

On Wed, Apr 15, 2009 at 06:50:47PM +0200, Sebastian Pipping wrote:
Show 9 quoted lines
> Here is what I did:
> 
> $ git cat-file -t b8c11fbbffbe171c4960058fa2d96f708e57a80c
> commit
> 
> $ git cat-file b8c11fbbffbe171c4960058fa2d96f708e57a80c
> usage: git cat-file [-t|-s|-e|-p|<type>] <sha1>
>    or: git cat-file [--batch|--batch-check] < <list_of_sha1s>
> [..]

That usage message is misleading. You need to use one of -t, -s, -e, -p, or <type>. So it should perhaps just be:

  git cat-file -t|-s|-e|-p|<type> <sha1>
though that looks terribly ugly. Suggestions welcome.
-Peff
P.S. Depending on what you're trying to accomplish, "git show <sha1>"
     may be a better choice.
Sebastian Pipping· Apr 15, 2009, 16:56 UTC · re: Jeff King · lore

Re: "git cat-file <sha1>" shows usage but should not?

Jeff King wrote:
Show 6 quoted lines
> That usage message is misleading. You need to use one of -t, -s, -e, -p,
> or <type>. So it should perhaps just be:
> 
>   git cat-file -t|-s|-e|-p|<type> <sha1>
> 
> though that looks terribly ugly. Suggestions welcome.
Thanks for making that clear.  How about round or curly brackets?
Sebastian
Jeff King· Apr 15, 2009, 17:04 UTC · re: Sebastian Pipping · lore

Re: "git cat-file <sha1>" shows usage but should not?

On Wed, Apr 15, 2009 at 06:56:05PM +0200, Sebastian Pipping wrote:
Show 9 quoted lines
> Jeff King wrote:
> > That usage message is misleading. You need to use one of -t, -s, -e, -p,
> > or <type>. So it should perhaps just be:
> > 
> >   git cat-file -t|-s|-e|-p|<type> <sha1>
> > 
> > though that looks terribly ugly. Suggestions welcome.
> 
> Thanks for making that clear.  How about round or curly brackets?

I think curly makes the most sense for grouping, though I still think it is a bit ugly. Patch is below.

-- >8 --
Subject: [PATCH] fix cat-file usage message and documentation

cat-file with an object on the command line requires an option to tell it what to output (type, size, pretty-print, etc). However, the square brackets in the usage imply that those options are not required. This patch switches them to curly braces to indicate "required but grouped-OR".

While we're at it, let's change the <sha1> specifier in the usage to <object>. That's what the documentation uses, and it does actually use the regular object lookup. --- The curly braces seem to render fine via asciidoc (presumably because there is no entity with that name), but I'm not sure if that will work with all asciidoc versions.

 Documentation/git-cat-file.txt |    2 +-
 builtin-cat-file.c             |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt
index b191276..0856568 100644
--- a/Documentation/git-cat-file.txt
+++ b/Documentation/git-cat-file.txt
@@ -9,7 +9,7 @@ git-cat-file - Provide content or type and size information for repository objec
 SYNOPSIS
 --------
 [verse]
-'git cat-file' [-t | -s | -e | -p | <type>] <object>
+'git cat-file' {-t | -s | -e | -p | <type>} <object>
 'git cat-file' [--batch | --batch-check] < <list-of-objects>
 
 DESCRIPTION
diff --git a/builtin-cat-file.c b/builtin-cat-file.c
index 8fad19d..4e6ad73 100644
--- a/builtin-cat-file.c
+++ b/builtin-cat-file.c
@@ -201,8 +201,8 @@ static int batch_objects(int print_contents)
 }
 
 static const char * const cat_file_usage[] = {
-	"git cat-file [-t|-s|-e|-p|<type>] <sha1>",
-	"git cat-file [--batch|--batch-check] < <list_of_sha1s>",
+	"git cat-file {-t|-s|-e|-p|<type>} <object>",
+	"git cat-file [--batch|--batch-check] < <list_of_objects>",
 	NULL
 };
 
-- 
1.6.3.rc0.156.g19ef8
Junio C Hamano· Apr 15, 2009, 17:18 UTC · re: Jeff King · lore

Re: "git cat-file <sha1>" shows usage but should not?

Jeff King <peff@peff.net> writes:
Show 14 quoted lines
> On Wed, Apr 15, 2009 at 06:56:05PM +0200, Sebastian Pipping wrote:
>
>> Jeff King wrote:
>> > That usage message is misleading. You need to use one of -t, -s, -e, -p,
>> > or <type>. So it should perhaps just be:
>> > 
>> >   git cat-file -t|-s|-e|-p|<type> <sha1>
>> > 
>> > though that looks terribly ugly. Suggestions welcome.
>> 
>> Thanks for making that clear.  How about round or curly brackets?
>
> I think curly makes the most sense for grouping, though I still think it
> is a bit ugly. Patch is below.
Thanks.  Doesn't this remind us of $gmane/72243, by the way?
Jeff King· Apr 15, 2009, 17:34 UTC · re: Junio C Hamano · lore

Re: "git cat-file <sha1>" shows usage but should not?

On Wed, Apr 15, 2009 at 10:18:40AM -0700, Junio C Hamano wrote:
> > I think curly makes the most sense for grouping, though I still think it
> > is a bit ugly. Patch is below.
> 
> Thanks.  Doesn't this remind us of $gmane/72243, by the way?

Ah, yes. I felt like we had dealt with this before, but I couldn't remember for what.

That message indicates that {} is preferred to (). Interestingly, though, the stash usage and documentation still uses ().

-Peff
Julian Phillips· Apr 15, 2009, 17:33 UTC · re: Jeff King · lore

Re: "git cat-file <sha1>" shows usage but should not?

On Wed, 15 Apr 2009, Jeff King wrote:
Show 5 quoted lines
> static const char * const cat_file_usage[] = {
> -	"git cat-file [-t|-s|-e|-p|<type>] <sha1>",
> -	"git cat-file [--batch|--batch-check] < <list_of_sha1s>",
> +	"git cat-file {-t|-s|-e|-p|<type>} <object>",
> +	"git cat-file [--batch|--batch-check] < <list_of_objects>",
Shouldn't that read:
+	"git cat-file {--batch|--batch-check} < <list_of_objects>",

since, like the previous line, you are required to supply one of the two options?

-- 
Julian

  ---
DPRINTK("FAILURE, CAPUT\n");
         linux-2.6.6/drivers/net/tokenring/ibmtr.c
Jeff King· Apr 15, 2009, 17:36 UTC · re: Julian Phillips · lore

Re: "git cat-file <sha1>" shows usage but should not?

On Wed, Apr 15, 2009 at 06:33:10PM +0100, Julian Phillips wrote:
Show 14 quoted lines
> On Wed, 15 Apr 2009, Jeff King wrote:
>
>> static const char * const cat_file_usage[] = {
>> -	"git cat-file [-t|-s|-e|-p|<type>] <sha1>",
>> -	"git cat-file [--batch|--batch-check] < <list_of_sha1s>",
>> +	"git cat-file {-t|-s|-e|-p|<type>} <object>",
>> +	"git cat-file [--batch|--batch-check] < <list_of_objects>",
>
> Shouldn't that read:
>
> +	"git cat-file {--batch|--batch-check} < <list_of_objects>",
>
> since, like the previous line, you are required to supply one of the two  
> options?
Oops, yes, it should.
-Peff

← back to recent threads