Skip to contentSkip to conversation

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

DISCUSSION Sebastian Pipping 4 participants 8 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 9 lines · Sebastian Pipping

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.

#2 lore raw
Quoted 6 lines · Jeff King

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

#3 lore raw
Quoted 9 lines · Sebastian Pipping
Quoted 6 lines · Jeff King

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(-)
Documentation/git-cat-file.txt +1 -1
index b191276..0856568 100644
@@ -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
builtin-cat-file.c +2 -2
index 8fad19d..4e6ad73 100644
@@ -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
 };
 
Signature · 1 line
1.6.3.rc0.156.g19ef8
#4 lore raw
Quoted 6 lines · Jeff King
Quoted 4 lines · Sebastian Pipping
Quoted 3 lines · Jeff King

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

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

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?

#5 lore raw
Quoted 4 lines · Junio C Hamano
Quoted 2 lines

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

#6 lore raw
In reply to Jeff King

builtin-cat-file.c static int batch_objects(int print_contents) · line 205

Quoted 5 lines · Jeff King

static const char * const cat_file_usage[] = {

builtin-cat-file.c +2 -2
-	"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?

Signature · 5 lines
Julian

 ---
DPRINTK("FAILURE, CAPUT\n");
        linux-2.6.6/drivers/net/tokenring/ibmtr.c
#7 lore raw
Quoted 12 lines · Julian Phillips

builtin-cat-file.c static int batch_objects(int print_contents) · line 205

Quoted 5 lines · Jeff King

static const char * const cat_file_usage[] = {

builtin-cat-file.c +2 -2
-	"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:

(quoted diff) +1 -0
+	"git cat-file {--batch|--batch-check} < <list_of_objects>",
Quoted 2 lines

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

Oops, yes, it should.

-Peff