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