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

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

From
Jeff King <peff@peff.net>
Date
Apr 15, 2009, 17:04 UTC
Message-ID
<20090415170444.GA24717@coredump.intra.peff.net>
In-Reply-To
<49E611A5.8090602@hartwork.org>
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
Previous: Sebastian PippingNext: Junio C Hamano
Message 4 of 8 in “"git cat-file <sha1>" shows usage but should not?”
  1. Sebastian PippingApr 15, 2009
  2. Jeff KingApr 15, 2009
  3. Sebastian PippingApr 15, 2009
  4. Jeff KingApr 15, 2009
  5. Junio C HamanoApr 15, 2009
  6. Jeff KingApr 15, 2009
  7. Julian PhillipsApr 15, 2009
  8. Jeff KingApr 15, 2009

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.