Skip to content

Commit 57d6a1c

Browse files
avargitster
authored andcommitted
cat-file: correct and improve usage information
Change the usage output emitted on "git cat-file -h" to group related options, making it clear to users which options go with which other ones. The new output is: Check object existence or emit object contents -e check if <object> exists -p pretty-print <object> content Emit [broken] object attributes -t show object type (one of 'blob', 'tree', 'commit', 'tag', ...) -s show object size --allow-unknown-type allow -s and -t to work with broken/corrupt objects Batch objects requested on stdin (or --batch-all-objects) --batch[=<format>] show full <object> or <rev> contents --batch-check[=<format>] like --batch, but don't emit <contents> --batch-all-objects with --batch[-check]: ignores stdin, batches all known objects Change or optimize batch output --buffer buffer --batch output --follow-symlinks follow in-tree symlinks --unordered do not order objects before emitting them Emit object (blob or tree) with conversion or filter (stand-alone, or with batch) --textconv run textconv on object's content --filters run filters on object's content --path blob|tree use a <path> for (--textconv | --filters ); Not with 'batch' The old usage was: <type> can be one of: blob, tree, commit, tag -t show object type -s show object size -e exit with zero when there's no error -p pretty-print object's content --textconv for blob objects, run textconv on object's content --filters for blob objects, run filters on object's content --batch-all-objects show all objects with --batch or --batch-check --path <blob> use a specific path for --textconv/--filters --allow-unknown-type allow -s and -t to work with broken/corrupt objects --buffer buffer --batch output --batch[=<format>] show info and content of objects fed from the standard input --batch-check[=<format>] show info about objects fed from the standard input --follow-symlinks follow in-tree symlinks (used with --batch or --batch-check) --unordered do not order --batch-all-objects output While shorter, I think the new one is easier to understand, as e.g. "--allow-unknown-type" is grouped with "-t" and "-s", as it can only be combined with those options. The same goes for "--buffer", "--unordered" etc. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b3fe468 commit 57d6a1c

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

builtin/cat-file.c

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -666,35 +666,44 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
666666
NULL
667667
};
668668
const struct option options[] = {
669-
OPT_GROUP(N_("<type> can be one of: blob, tree, commit, tag")),
670-
OPT_CMDMODE('t', NULL, &opt, N_("show object type"), 't'),
671-
OPT_CMDMODE('s', NULL, &opt, N_("show object size"), 's'),
669+
/* Simple queries */
670+
OPT_GROUP(N_("Check object existence or emit object contents")),
672671
OPT_CMDMODE('e', NULL, &opt,
673-
N_("exit with zero when there's no error"), 'e'),
674-
OPT_CMDMODE('p', NULL, &opt, N_("pretty-print object's content"), 'p'),
675-
OPT_CMDMODE(0, "textconv", &opt,
676-
N_("for blob objects, run textconv on object's content"), 'c'),
677-
OPT_CMDMODE(0, "filters", &opt,
678-
N_("for blob objects, run filters on object's content"), 'w'),
679-
OPT_CMDMODE(0, "batch-all-objects", &opt,
680-
N_("show all objects with --batch or --batch-check"), 'b'),
681-
OPT_STRING(0, "path", &force_path, N_("blob"),
682-
N_("use a specific path for --textconv/--filters")),
672+
N_("check if <object> exists"), 'e'),
673+
OPT_CMDMODE('p', NULL, &opt, N_("pretty-print <object> content"), 'p'),
674+
675+
OPT_GROUP(N_("Emit [broken] object attributes")),
676+
OPT_CMDMODE('t', NULL, &opt, N_("show object type (one of 'blob', 'tree', 'commit', 'tag', ...)"), 't'),
677+
OPT_CMDMODE('s', NULL, &opt, N_("show object size"), 's'),
683678
OPT_BOOL(0, "allow-unknown-type", &unknown_type,
684679
N_("allow -s and -t to work with broken/corrupt objects")),
685-
OPT_BOOL(0, "buffer", &batch.buffer_output, N_("buffer --batch output")),
686-
OPT_CALLBACK_F(0, "batch", &batch, "format",
687-
N_("show info and content of objects fed from the standard input"),
680+
/* Batch mode */
681+
OPT_GROUP(N_("Batch objects requested on stdin (or --batch-all-objects)")),
682+
OPT_CALLBACK_F(0, "batch", &batch, N_("format"),
683+
N_("show full <object> or <rev> contents"),
688684
PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
689685
batch_option_callback),
690-
OPT_CALLBACK_F(0, "batch-check", &batch, "format",
691-
N_("show info about objects fed from the standard input"),
686+
OPT_CALLBACK_F(0, "batch-check", &batch, N_("format"),
687+
N_("like --batch, but don't emit <contents>"),
692688
PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
693689
batch_option_callback),
690+
OPT_CMDMODE(0, "batch-all-objects", &opt,
691+
N_("with --batch[-check]: ignores stdin, batches all known objects"), 'b'),
692+
/* Batch-specific options */
693+
OPT_GROUP(N_("Change or optimize batch output")),
694+
OPT_BOOL(0, "buffer", &batch.buffer_output, N_("buffer --batch output")),
694695
OPT_BOOL(0, "follow-symlinks", &batch.follow_symlinks,
695-
N_("follow in-tree symlinks (used with --batch or --batch-check)")),
696+
N_("follow in-tree symlinks")),
696697
OPT_BOOL(0, "unordered", &batch.unordered,
697-
N_("do not order --batch-all-objects output")),
698+
N_("do not order objects before emitting them")),
699+
/* Textconv options, stand-ole*/
700+
OPT_GROUP(N_("Emit object (blob or tree) with conversion or filter (stand-alone, or with batch)")),
701+
OPT_CMDMODE(0, "textconv", &opt,
702+
N_("run textconv on object's content"), 'c'),
703+
OPT_CMDMODE(0, "filters", &opt,
704+
N_("run filters on object's content"), 'w'),
705+
OPT_STRING(0, "path", &force_path, N_("blob|tree"),
706+
N_("use a <path> for (--textconv | --filters ); Not with 'batch'")),
698707
OPT_END()
699708
};
700709

0 commit comments

Comments
 (0)