1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-07 19:46:08 +02:00

Merge branch 'ab/doc-synopsis-and-cmd-usage'

The short-help text shown by "git cmd -h" and the synopsis text
shown at the beginning of "git help cmd" have been made more
consistent.

* ab/doc-synopsis-and-cmd-usage: (34 commits)
  tests: assert consistent whitespace in -h output
  tests: start asserting that *.txt SYNOPSIS matches -h output
  doc txt & -h consistency: make "worktree" consistent
  worktree: define subcommand -h in terms of command -h
  reflog doc: list real subcommands up-front
  doc txt & -h consistency: make "commit" consistent
  doc txt & -h consistency: make "diff-tree" consistent
  doc txt & -h consistency: use "[<label>...]" for "zero or more"
  doc txt & -h consistency: make "annotate" consistent
  doc txt & -h consistency: make "stash" consistent
  doc txt & -h consistency: add missing options
  doc txt & -h consistency: use "git foo" form, not "git-foo"
  doc txt & -h consistency: make "bundle" consistent
  doc txt & -h consistency: make "read-tree" consistent
  doc txt & -h consistency: make "rerere" consistent
  doc txt & -h consistency: add missing options and labels
  doc txt & -h consistency: make output order consistent
  doc txt & -h consistency: add or fix optional "--" syntax
  doc txt & -h consistency: fix mismatching labels
  doc SYNOPSIS & -h: use "-" to separate words in labels, not "_"
  ...
This commit is contained in:
Junio C Hamano 2022-10-28 11:26:54 -07:00
commit 7b9b634ca5
82 changed files with 594 additions and 199 deletions

View File

@ -663,8 +663,8 @@ Writing Documentation:
(One or more of <file>.)
Optional parts are enclosed in square brackets:
[<extra>]
(Zero or one <extra>.)
[<file>...]
(Zero or more of <file>.)
--exec-path[=<path>]
(Option with an optional argument. Note that the "=" is inside the
@ -678,6 +678,16 @@ Writing Documentation:
[-q | --quiet]
[--utf8 | --no-utf8]
Use spacing around "|" token(s), but not immediately after opening or
before closing a [] or () pair:
Do: [-q | --quiet]
Don't: [-q|--quiet]
Don't use spacing around "|" tokens when they're used to seperate the
alternate arguments of an option:
Do: --track[=(direct|inherit)]
Don't: --track[=(direct | inherit)]
Parentheses are used for grouping:
[(<rev> | <range>)...]
(Any number of either <rev> or <range>. Parens are needed to make

View File

@ -8,7 +8,7 @@ git-annotate - Annotate file lines with commit information
SYNOPSIS
--------
[verse]
'git annotate' [<options>] <file> [<revision>]
'git annotate' [<options>] [<rev-opts>] [<rev>] [--] <file>
DESCRIPTION
-----------

View File

@ -8,7 +8,7 @@ git-clean - Remove untracked files from the working tree
SYNOPSIS
--------
[verse]
'git clean' [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...
'git clean' [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] [<pathspec>...]
DESCRIPTION
-----------
@ -20,16 +20,16 @@ Normally, only files unknown to Git are removed, but if the `-x`
option is specified, ignored files are also removed. This can, for
example, be useful to remove all build products.
If any optional `<path>...` arguments are given, only those paths
are affected.
If any optional `<pathspec>...` arguments are given, only those paths
that match the pathspec are affected.
OPTIONS
-------
-d::
Normally, when no <path> is specified, git clean will not
Normally, when no <pathspec> is specified, git clean will not
recurse into untracked directories to avoid removing too much.
Specify -d to have it recurse into such directories as well.
If any paths are specified, -d is irrelevant; all untracked
If a <pathspec> is specified, -d is irrelevant; all untracked
files matching the specified paths (with exceptions for nested
git directories mentioned under `--force`) will be removed.

View File

@ -10,7 +10,10 @@ SYNOPSIS
--------
[verse]
'git commit-graph verify' [--object-dir <dir>] [--shallow] [--[no-]progress]
'git commit-graph write' <options> [--object-dir <dir>] [--[no-]progress]
'git commit-graph write' [--object-dir <dir>] [--append]
[--split[=<strategy>]] [--reachable | --stdin-packs | --stdin-commits]
[--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress]
<split options>
DESCRIPTION

View File

@ -8,7 +8,7 @@ git-credential-cache--daemon - Temporarily store user credentials in memory
SYNOPSIS
--------
[verse]
'git credential-cache{litdd}daemon' [--debug] <socket>
'git credential-cache{litdd}daemon' [--debug] <socket-path>
DESCRIPTION
-----------
@ -16,7 +16,7 @@ DESCRIPTION
NOTE: You probably don't want to invoke this command yourself; it is
started automatically when you use linkgit:git-credential-cache[1].
This command listens on the Unix domain socket specified by `<socket>`
This command listens on the Unix domain socket specified by `<socket-path>`
for `git-credential-cache` clients. Clients may store and retrieve
credentials. Each credential is held for a timeout specified by the
client; once no credentials are held, the daemon exits.

View File

@ -9,7 +9,7 @@ git-diff-files - Compares files in the working tree and the index
SYNOPSIS
--------
[verse]
'git diff-files' [-q] [-0|-1|-2|-3|-c|--cc] [<common-diff-options>] [<path>...]
'git diff-files' [-q] [-0 | -1 | -2 | -3 | -c | --cc] [<common-diff-options>] [<path>...]
DESCRIPTION
-----------

View File

@ -9,7 +9,7 @@ git-fast-export - Git data exporter
SYNOPSIS
--------
[verse]
'git fast-export [<options>]' | 'git fast-import'
'git fast-export' [<options>] | 'git fast-import'
DESCRIPTION
-----------

View File

@ -9,7 +9,8 @@ git-hash-object - Compute object ID and optionally creates a blob from a file
SYNOPSIS
--------
[verse]
'git hash-object' [-t <type>] [-w] [--path=<file>|--no-filters] [--stdin [--literally]] [--] <file>...
'git hash-object' [-t <type>] [-w] [--path=<file> | --no-filters]
[--stdin [--literally]] [--] <file>...
'git hash-object' [-t <type>] [-w] --stdin-paths [--no-filters]
DESCRIPTION

View File

@ -8,8 +8,9 @@ git-interpret-trailers - Add or parse structured information in commit messages
SYNOPSIS
--------
[verse]
'git interpret-trailers' [<options>] [(--trailer <token>[(=|:)<value>])...] [<file>...]
'git interpret-trailers' [<options>] [--parse] [<file>...]
'git interpret-trailers' [--in-place] [--trim-empty]
[(--trailer <token>[(=|:)<value>])...]
[--parse] [<file>...]
DESCRIPTION
-----------

View File

@ -9,8 +9,8 @@ git-merge-base - Find as good common ancestors as possible for a merge
SYNOPSIS
--------
[verse]
'git merge-base' [-a|--all] <commit> <commit>...
'git merge-base' [-a|--all] --octopus <commit>...
'git merge-base' [-a | --all] <commit> <commit>...
'git merge-base' [-a | --all] --octopus <commit>...
'git merge-base' --is-ancestor <commit> <commit>
'git merge-base' --independent <commit>...
'git merge-base' --fork-point <ref> [<commit>]

View File

@ -9,7 +9,7 @@ git-mv - Move or rename a file, a directory, or a symlink
SYNOPSIS
--------
[verse]
'git mv' <options>... <args>...
'git mv' [<options>] <source>... <destination>
DESCRIPTION
-----------
@ -30,7 +30,7 @@ OPTIONS
-------
-f::
--force::
Force renaming or moving of a file even if the target exists
Force renaming or moving of a file even if the <destination> exists.
-k::
Skip move or rename actions which would lead to an error
condition. An error happens when a source is neither existing nor

View File

@ -9,7 +9,7 @@ git-pack-redundant - Find redundant pack files
SYNOPSIS
--------
[verse]
'git pack-redundant' [ --verbose ] [ --alt-odb ] ( --all | <pack-filename>... )
'git pack-redundant' [--verbose] [--alt-odb] (--all | <pack-filename>...)
DESCRIPTION
-----------

View File

@ -9,7 +9,7 @@ git-prune-packed - Remove extra objects that are already in pack files
SYNOPSIS
--------
[verse]
'git prune-packed' [-n|--dry-run] [-q|--quiet]
'git prune-packed' [-n | --dry-run] [-q | --quiet]
DESCRIPTION

View File

@ -9,7 +9,7 @@ git-read-tree - Reads tree information into the index
SYNOPSIS
--------
[verse]
'git read-tree' [[-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>]
'git read-tree' [(-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>)
[-u | -i]] [--index-output=<file>] [--no-sparse-checkout]
(--empty | <tree-ish1> [<tree-ish2> [<tree-ish3>]])

View File

@ -9,7 +9,7 @@ git-receive-pack - Receive what is pushed into the repository
SYNOPSIS
--------
[verse]
'git-receive-pack' <directory>
'git receive-pack' <git-dir>
DESCRIPTION
-----------
@ -38,7 +38,7 @@ its behavior, see linkgit:git-config[1].
OPTIONS
-------
<directory>::
<git-dir>::
The repository to sync into.
--http-backend-info-refs::

View File

@ -9,15 +9,7 @@ git-reflog - Manage reflog information
SYNOPSIS
--------
[verse]
'git reflog' <subcommand> <options>
DESCRIPTION
-----------
The command takes various subcommands, and different options
depending on the subcommand:
[verse]
'git reflog' ['show'] [<log-options>] [<ref>]
'git reflog' [show] [<log-options>] [<ref>]
'git reflog expire' [--expire=<time>] [--expire-unreachable=<time>]
[--rewrite] [--updateref] [--stale-fix]
[--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>...]
@ -25,6 +17,10 @@ depending on the subcommand:
[--dry-run | -n] [--verbose] <ref>@{<specifier>}...
'git reflog exists' <ref>
DESCRIPTION
-----------
This command manages the information recorded in the reflogs.
Reference logs, or "reflogs", record when the tips of branches and
other references were updated in the local repository. Reflogs are
useful in various Git commands, to specify the old value of a
@ -33,7 +29,8 @@ moves ago", `master@{one.week.ago}` means "where master used to point
to one week ago in this local repository", and so on. See
linkgit:gitrevisions[7] for more details.
This command manages the information recorded in the reflogs.
The command takes various subcommands, and different options
depending on the subcommand:
The "show" subcommand (which is also the default, in the absence of
any subcommands) shows the log of the reference provided in the

View File

@ -8,7 +8,7 @@ git-rerere - Reuse recorded resolution of conflicted merges
SYNOPSIS
--------
[verse]
'git rerere' ['clear'|'forget' <pathspec>|'diff'|'remaining'|'status'|'gc']
'git rerere' [clear | forget <pathspec>... | diff | status | remaining | gc]
DESCRIPTION
-----------

View File

@ -9,7 +9,7 @@ git-rev-list - Lists commit objects in reverse chronological order
SYNOPSIS
--------
[verse]
'git rev-list' [<options>] <commit>... [[--] <path>...]
'git rev-list' [<options>] <commit>... [--] [<path>...]
DESCRIPTION
-----------

View File

@ -9,9 +9,10 @@ git-send-pack - Push objects over Git protocol to another repository
SYNOPSIS
--------
[verse]
'git send-pack' [--dry-run] [--force] [--receive-pack=<git-receive-pack>]
'git send-pack' [--mirror] [--dry-run] [--force]
[--receive-pack=<git-receive-pack>]
[--verbose] [--thin] [--atomic]
[--[no-]signed|--signed=(true|false|if-asked)]
[--[no-]signed | --signed=(true|false|if-asked)]
[<host>:]<directory> (--all | <ref>...)
DESCRIPTION

View File

@ -8,12 +8,12 @@ git-show-branch - Show branches and their commits
SYNOPSIS
--------
[verse]
'git show-branch' [-a|--all] [-r|--remotes] [--topo-order | --date-order]
'git show-branch' [-a | --all] [-r | --remotes] [--topo-order | --date-order]
[--current] [--color[=<when>] | --no-color] [--sparse]
[--more=<n> | --list | --independent | --merge-base]
[--no-name | --sha1-name] [--topics]
[(<rev> | <glob>)...]
'git show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]
'git show-branch' (-g | --reflog)[=<n>[,<base>]] [--list] [<ref>]
DESCRIPTION
-----------

View File

@ -8,8 +8,8 @@ git-show-ref - List references in a local repository
SYNOPSIS
--------
[verse]
'git show-ref' [-q|--quiet] [--verify] [--head] [-d|--dereference]
[-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]
'git show-ref' [-q | --quiet] [--verify] [--head] [-d | --dereference]
[-s | --hash[=<n>]] [--abbrev[=<n>]] [--tags]
[--heads] [--] [<pattern>...]
'git show-ref' --exclude-existing[=<pattern>]

View File

@ -9,7 +9,7 @@ git-sparse-checkout - Reduce your working tree to a subset of tracked files
SYNOPSIS
--------
[verse]
'git sparse-checkout <subcommand> [<options>]'
'git sparse-checkout' (init | list | set | add | reapply | disable) [<options>]
DESCRIPTION

View File

@ -9,17 +9,20 @@ SYNOPSIS
--------
[verse]
'git stash' list [<log-options>]
'git stash' show [-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>]
'git stash' drop [-q|--quiet] [<stash>]
'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
'git stash' show [-u | --include-untracked | --only-untracked] [<diff-options>] [<stash>]
'git stash' drop [-q | --quiet] [<stash>]
'git stash' pop [--index] [-q | --quiet] [<stash>]
'git stash' apply [--index] [-q | --quiet] [<stash>]
'git stash' branch <branchname> [<stash>]
'git stash' [push [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-q|--quiet]
[-u|--include-untracked] [-a|--all] [-m|--message <message>]
'git stash' [push [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]
[-u | --include-untracked] [-a | --all] [(-m | --message) <message>]
[--pathspec-from-file=<file> [--pathspec-file-nul]]
[--] [<pathspec>...]]
'git stash' save [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]
[-u | --include-untracked] [-a | --all] [<message>]
'git stash' clear
'git stash' create [<message>]
'git stash' store [-m|--message <message>] [-q|--quiet] <commit>
'git stash' store [(-m | --message) <message>] [-q | --quiet] <commit>
DESCRIPTION
-----------
@ -47,7 +50,7 @@ stash index (e.g. the integer `n` is equivalent to `stash@{n}`).
COMMANDS
--------
push [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-m|--message <message>] [--pathspec-from-file=<file> [--pathspec-file-nul]] [--] [<pathspec>...]::
push [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [(-m|--message) <message>] [--pathspec-from-file=<file> [--pathspec-file-nul]] [--] [<pathspec>...]::
Save your local modifications to a new 'stash entry' and roll them
back to HEAD (in the working tree and in the index).

View File

@ -9,7 +9,7 @@ git-status - Show the working tree status
SYNOPSIS
--------
[verse]
'git status' [<options>...] [--] [<pathspec>...]
'git status' [<options>] [--] [<pathspec>...]
DESCRIPTION
-----------

View File

@ -9,7 +9,7 @@ git-tag - Create, list, delete or verify a tag object signed with GPG
SYNOPSIS
--------
[verse]
'git tag' [-a | -s | -u <keyid>] [-f] [-m <msg> | -F <file>] [-e]
'git tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] [-e]
<tagname> [<commit> | <object>]
'git tag' -d <tagname>...
'git tag' [-n[<num>]] -l [--contains <commit>] [--no-contains <commit>]
@ -26,19 +26,19 @@ to delete, list or verify tags.
Unless `-f` is given, the named tag must not yet exist.
If one of `-a`, `-s`, or `-u <keyid>` is passed, the command
If one of `-a`, `-s`, or `-u <key-id>` is passed, the command
creates a 'tag' object, and requires a tag message. Unless
`-m <msg>` or `-F <file>` is given, an editor is started for the user to type
in the tag message.
If `-m <msg>` or `-F <file>` is given and `-a`, `-s`, and `-u <keyid>`
If `-m <msg>` or `-F <file>` is given and `-a`, `-s`, and `-u <key-id>`
are absent, `-a` is implied.
Otherwise, a tag reference that points directly at the given object
(i.e., a lightweight tag) is created.
A GnuPG signed tag object will be created when `-s` or `-u
<keyid>` is used. When `-u <keyid>` is not used, the
<key-id>` is used. When `-u <key-id>` is not used, the
committer identity for the current user is used to find the
GnuPG key for signing. The configuration variable `gpg.program`
is used to specify custom GnuPG binary.
@ -72,8 +72,8 @@ OPTIONS
Override `tag.gpgSign` configuration variable that is
set to force each and every tag to be signed.
-u <keyid>::
--local-user=<keyid>::
-u <key-id>::
--local-user=<key-id>::
Make a GPG-signed tag, using the given key.
-f::
@ -164,14 +164,14 @@ This option is only applicable when listing tags without annotation lines.
Use the given tag message (instead of prompting).
If multiple `-m` options are given, their values are
concatenated as separate paragraphs.
Implies `-a` if none of `-a`, `-s`, or `-u <keyid>`
Implies `-a` if none of `-a`, `-s`, or `-u <key-id>`
is given.
-F <file>::
--file=<file>::
Take the tag message from the given file. Use '-' to
read the message from the standard input.
Implies `-a` if none of `-a`, `-s`, or `-u <keyid>`
Implies `-a` if none of `-a`, `-s`, or `-u <key-id>`
is given.
-e::
@ -220,7 +220,7 @@ it in the repository configuration as follows:
-------------------------------------
[user]
signingKey = <gpg-keyid>
signingKey = <gpg-key_id>
-------------------------------------
`pager.tag` is only respected when listing tags, i.e., when `-l` is

View File

@ -9,7 +9,7 @@ git-update-server-info - Update auxiliary info file to help dumb servers
SYNOPSIS
--------
[verse]
'git update-server-info'
'git update-server-info' [-f | --force]
DESCRIPTION
-----------
@ -19,6 +19,12 @@ $GIT_OBJECT_DIRECTORY/info directories to help clients discover
what references and packs the server has. This command
generates such auxiliary files.
OPTIONS
-------
-f::
--force::
update the info files from scratch.
OUTPUT
------

View File

@ -9,7 +9,7 @@ git-upload-archive - Send archive back to git-archive
SYNOPSIS
--------
[verse]
'git upload-archive' <directory>
'git upload-archive' <repository>
DESCRIPTION
-----------
@ -54,7 +54,7 @@ access via non-smart-http.
OPTIONS
-------
<directory>::
<repository>::
The repository to get a tar archive from.
GIT

View File

@ -9,7 +9,7 @@ git-var - Show a Git logical variable
SYNOPSIS
--------
[verse]
'git var' ( -l | <variable> )
'git var' (-l | <variable>)
DESCRIPTION
-----------

View File

@ -8,7 +8,7 @@ git-verify-commit - Check the GPG signature of commits
SYNOPSIS
--------
[verse]
'git verify-commit' <commit>...
'git verify-commit' [-v | --verbose] [--raw] <commit>...
DESCRIPTION
-----------

View File

@ -9,7 +9,7 @@ git-verify-pack - Validate packed Git archive files
SYNOPSIS
--------
[verse]
'git verify-pack' [-v|--verbose] [-s|--stat-only] [--] <pack>.idx ...
'git verify-pack' [-v | --verbose] [-s | --stat-only] [--] <pack>.idx...
DESCRIPTION

View File

@ -8,7 +8,7 @@ git-verify-tag - Check the GPG signature of tags
SYNOPSIS
--------
[verse]
'git verify-tag' [--format=<format>] <tag>...
'git verify-tag' [-v | --verbose] [--format=<format>] [--raw] <tag>...
DESCRIPTION
-----------

View File

@ -9,7 +9,8 @@ git-worktree - Manage multiple working trees
SYNOPSIS
--------
[verse]
'git worktree add' [-f] [--detach] [--checkout] [--lock [--reason <string>]] [-b <new-branch>] <path> [<commit-ish>]
'git worktree add' [-f] [--detach] [--checkout] [--lock [--reason <string>]]
[-b <new-branch>] <path> [<commit-ish>]
'git worktree list' [-v | --porcelain [-z]]
'git worktree lock' [--reason <string>] <worktree>
'git worktree move' <worktree> <new-path>

View File

@ -30,6 +30,7 @@
#include "tag.h"
static char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>");
static char annotate_usage[] = N_("git annotate [<options>] [<rev-opts>] [<rev>] [--] <file>");
static const char *blame_opt_usage[] = {
blame_usage,
@ -38,6 +39,13 @@ static const char *blame_opt_usage[] = {
NULL
};
static const char *annotate_opt_usage[] = {
annotate_usage,
"",
N_("<rev-opts> are documented in git-rev-list(1)"),
NULL
};
static int longest_file;
static int longest_author;
static int max_orig_digits;
@ -899,6 +907,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
long anchor;
const int hexsz = the_hash_algo->hexsz;
long num_lines = 0;
const char *str_usage = cmd_is_annotate ? annotate_usage : blame_usage;
const char **opt_usage = cmd_is_annotate ? annotate_opt_usage : blame_opt_usage;
setup_default_color_by_age();
git_config(git_blame_config, &output_option);
@ -914,7 +924,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
parse_options_start(&ctx, argc, argv, prefix, options,
PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_ARGV0);
for (;;) {
switch (parse_options_step(&ctx, options, blame_opt_usage)) {
switch (parse_options_step(&ctx, options, opt_usage)) {
case PARSE_OPT_NON_OPTION:
case PARSE_OPT_UNKNOWN:
break;
@ -934,7 +944,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
ctx.argv[0] = "--children";
reverse = 1;
}
parse_revision_opt(&revs, &ctx, options, blame_opt_usage);
parse_revision_opt(&revs, &ctx, options, opt_usage);
}
parse_done:
revision_opts_finish(&revs);
@ -1040,7 +1050,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
switch (argc - dashdash_pos - 1) {
case 2: /* (1b) */
if (argc != 4)
usage_with_options(blame_opt_usage, options);
usage_with_options(opt_usage, options);
/* reorder for the new way: <rev> -- <path> */
argv[1] = argv[3];
argv[3] = argv[2];
@ -1051,11 +1061,11 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
argv[argc] = NULL;
break;
default:
usage_with_options(blame_opt_usage, options);
usage_with_options(opt_usage, options);
}
} else {
if (argc < 2)
usage_with_options(blame_opt_usage, options);
usage_with_options(opt_usage, options);
if (argc == 3 && is_a_rev(argv[argc - 1])) { /* (2b) */
path = add_prefix(prefix, argv[1]);
argv[1] = argv[2];
@ -1113,7 +1123,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
nth_line_cb, &sb, lno, anchor,
&bottom, &top, sb.path,
the_repository->index))
usage(blame_usage);
usage(str_usage);
if ((!lno && (top || bottom)) || lno < bottom)
die(Q_("file %s has only %lu line",
"file %s has only %lu lines",

View File

@ -60,7 +60,8 @@ static void get_populated_hooks(struct strbuf *hook_info, int nongit)
}
static const char * const bugreport_usage[] = {
N_("git bugreport [-o|--output-directory <file>] [-s|--suffix <format>] [--diagnose[=<mode>]"),
N_("git bugreport [(-o | --output-directory) <path>] [(-s | --suffix) <format>]\n"
" [--diagnose[=<mode>]]"),
NULL
};

View File

@ -11,32 +11,42 @@
* bundle supporting "fetch", "pull", and "ls-remote".
*/
static const char * const builtin_bundle_usage[] = {
N_("git bundle create [<options>] <file> <git-rev-list args>"),
N_("git bundle verify [<options>] <file>"),
N_("git bundle list-heads <file> [<refname>...]"),
N_("git bundle unbundle <file> [<refname>...]"),
NULL
#define BUILTIN_BUNDLE_CREATE_USAGE \
N_("git bundle create [-q | --quiet | --progress | --all-progress] [--all-progress-implied]\n" \
" [--version=<version>] <file> <git-rev-list-args>")
#define BUILTIN_BUNDLE_VERIFY_USAGE \
N_("git bundle verify [-q | --quiet] <file>")
#define BUILTIN_BUNDLE_LIST_HEADS_USAGE \
N_("git bundle list-heads <file> [<refname>...]")
#define BUILTIN_BUNDLE_UNBUNDLE_USAGE \
N_("git bundle unbundle [--progress] <file> [<refname>...]")
static char const * const builtin_bundle_usage[] = {
BUILTIN_BUNDLE_CREATE_USAGE,
BUILTIN_BUNDLE_VERIFY_USAGE,
BUILTIN_BUNDLE_LIST_HEADS_USAGE,
BUILTIN_BUNDLE_UNBUNDLE_USAGE,
NULL,
};
static const char * const builtin_bundle_create_usage[] = {
N_("git bundle create [<options>] <file> <git-rev-list args>"),
NULL
BUILTIN_BUNDLE_CREATE_USAGE,
NULL
};
static const char * const builtin_bundle_verify_usage[] = {
N_("git bundle verify [<options>] <file>"),
NULL
BUILTIN_BUNDLE_VERIFY_USAGE,
NULL
};
static const char * const builtin_bundle_list_heads_usage[] = {
N_("git bundle list-heads <file> [<refname>...]"),
NULL
BUILTIN_BUNDLE_LIST_HEADS_USAGE,
NULL
};
static const char * const builtin_bundle_unbundle_usage[] = {
N_("git bundle unbundle <file> [<refname>...]"),
NULL
BUILTIN_BUNDLE_UNBUNDLE_USAGE,
NULL
};
static int parse_options_cmd_bundle(int argc,

View File

@ -893,7 +893,7 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
N_("git cat-file (-t | -s) [--allow-unknown-type] <object>"),
N_("git cat-file (--batch | --batch-check | --batch-command) [--batch-all-objects]\n"
" [--buffer] [--follow-symlinks] [--unordered]\n"
" [--textconv | --filters]"),
" [--textconv | --filters] [-z]"),
N_("git cat-file (--textconv | --filters)\n"
" [<rev>:<path|tree-ish> | --path=<path|tree-ish> <rev>]"),
NULL

View File

@ -26,7 +26,7 @@ static struct string_list del_list = STRING_LIST_INIT_DUP;
static unsigned int colopts;
static const char *const builtin_clean_usage[] = {
N_("git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <paths>..."),
N_("git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] [<pathspec>...]"),
NULL
};

View File

@ -10,13 +10,13 @@
#include "tag.h"
#define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \
N_("git commit-graph verify [--object-dir <objdir>] [--shallow] [--[no-]progress]")
N_("git commit-graph verify [--object-dir <dir>] [--shallow] [--[no-]progress]")
#define BUILTIN_COMMIT_GRAPH_WRITE_USAGE \
N_("git commit-graph write [--object-dir <objdir>] [--append] " \
"[--split[=<strategy>]] [--reachable|--stdin-packs|--stdin-commits] " \
"[--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress] " \
"<split options>")
N_("git commit-graph write [--object-dir <dir>] [--append]\n" \
" [--split[=<strategy>]] [--reachable | --stdin-packs | --stdin-commits]\n" \
" [--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress]\n" \
" <split options>")
static const char * builtin_commit_graph_verify_usage[] = {
BUILTIN_COMMIT_GRAPH_VERIFY_USAGE,

View File

@ -15,8 +15,9 @@
#include "parse-options.h"
static const char * const commit_tree_usage[] = {
N_("git commit-tree [(-p <parent>)...] [-S[<keyid>]] [(-m <message>)...] "
"[(-F <file>)...] <tree>"),
N_("git commit-tree <tree> [(-p <parent>)...]"),
N_("git commit-tree [(-p <parent>)...] [-S[<keyid>]] [(-m <message>)...]\n"
" [(-F <file>)...] <tree>"),
NULL
};

View File

@ -40,12 +40,19 @@
#include "pretty.h"
static const char * const builtin_commit_usage[] = {
N_("git commit [<options>] [--] <pathspec>..."),
N_("git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]\n"
" [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>)]\n"
" [-F <file> | -m <msg>] [--reset-author] [--allow-empty]\n"
" [--allow-empty-message] [--no-verify] [-e] [--author=<author>]\n"
" [--date=<date>] [--cleanup=<mode>] [--[no-]status]\n"
" [-i | -o] [--pathspec-from-file=<file> [--pathspec-file-nul]]\n"
" [(--trailer <token>[(=|:)<value>])...] [-S[<keyid>]]\n"
" [--] [<pathspec>...]"),
NULL
};
static const char * const builtin_status_usage[] = {
N_("git status [<options>] [--] <pathspec>..."),
N_("git status [<options>] [--] [<pathspec>...]"),
NULL
};

View File

@ -267,7 +267,7 @@ int cmd_credential_cache_daemon(int argc, const char **argv, const char *prefix)
const char *socket_path;
int ignore_sighup = 0;
static const char *usage[] = {
"git-credential-cache--daemon [opts] <socket_path>",
"git credential-cache--daemon [--debug] <socket-path>",
NULL
};
int debug = 0;
@ -305,7 +305,7 @@ int cmd_credential_cache_daemon(int argc, const char **argv, const char *prefix)
int cmd_credential_cache_daemon(int argc, const char **argv, const char *prefix)
{
const char * const usage[] = {
"git credential-cache--daemon [options] <action>",
"git credential-cache--daemon [--debug] <socket-path>",
"",
"credential-cache--daemon is disabled in this build of Git",
NULL

View File

@ -23,8 +23,9 @@
define_commit_slab(commit_names, struct commit_name *);
static const char * const describe_usage[] = {
N_("git describe [<options>] [<commit-ish>...]"),
N_("git describe [<options>] --dirty"),
N_("git describe [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...]"),
N_("git describe [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]"),
N_("git describe <blob>"),
NULL
};

View File

@ -3,7 +3,8 @@
#include "diagnose.h"
static const char * const diagnose_usage[] = {
N_("git diagnose [-o|--output-directory <path>] [-s|--suffix <format>] [--mode=<mode>]"),
N_("git diagnose [(-o | --output-directory) <path>] [(-s | --suffix) <format>]\n"
" [--mode=<mode>]"),
NULL
};

View File

@ -15,6 +15,7 @@
static const char diff_files_usage[] =
"git diff-files [-q] [-0 | -1 | -2 | -3 | -c | --cc] [<common-diff-options>] [<path>...]"
"\n"
COMMON_DIFF_OPTIONS_HELP;
int cmd_diff_files(int argc, const char **argv, const char *prefix)

View File

@ -9,8 +9,9 @@
#include "submodule.h"
static const char diff_cache_usage[] =
"git diff-index [-m] [--cached] "
"git diff-index [-m] [--cached] [--merge-base] "
"[<common-diff-options>] <tree-ish> [<path>...]"
"\n"
COMMON_DIFF_OPTIONS_HELP;
int cmd_diff_index(int argc, const char **argv, const char *prefix)

View File

@ -83,8 +83,10 @@ static int diff_tree_stdin(char *line)
}
static const char diff_tree_usage[] =
"git diff-tree [--stdin] [-m] [-c | --cc] [-s] [-v] [--pretty] [-t] [-r] [--root] "
"[<common-diff-options>] <tree-ish> [<tree-ish>] [<path>...]\n"
"git diff-tree [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]\n"
" [-t] [-r] [-c | --cc] [--combined-all-paths] [--root] [--merge-base]\n"
" [<common-diff-options>] <tree-ish> [<tree-ish>] [<path>...]\n"
"\n"
" -r diff recursively\n"
" -c show combined diff for merge commits\n"
" --cc show combined diff for merge commits removing uninteresting hunks\n"

View File

@ -30,7 +30,8 @@ static const char builtin_diff_usage[] =
" or: git diff [<options>] [--merge-base] <commit> [<commit>...] <commit> [--] [<path>...]\n"
" or: git diff [<options>] <commit>...<commit> [--] [<path>...]\n"
" or: git diff [<options>] <blob> <blob>\n"
" or: git diff [<options>] --no-index [--] <path> <path>\n"
" or: git diff [<options>] --no-index [--] <path> <path>"
"\n"
COMMON_DIFF_OPTIONS_HELP;
static const char *blob_path(struct object_array_entry *entry)

View File

@ -6,7 +6,7 @@
#include "string-list.h"
static const char * const for_each_repo_usage[] = {
N_("git for-each-repo --config=<config> <command-args>"),
N_("git for-each-repo --config=<config> [--] <arguments>"),
NULL
};

View File

@ -820,7 +820,10 @@ static int mark_packed_for_connectivity(const struct object_id *oid,
}
static char const * const fsck_usage[] = {
N_("git fsck [<options>] [<object>...]"),
N_("git fsck [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]\n"
" [--[no-]full] [--strict] [--verbose] [--lost-found]\n"
" [--[no-]dangling] [--[no-]progress] [--connectivity-only]\n"
" [--[no-]name-objects] [<object>...]"),
NULL
};

View File

@ -80,8 +80,9 @@ static void hash_stdin_paths(const char *type, int no_filters, unsigned flags,
int cmd_hash_object(int argc, const char **argv, const char *prefix)
{
static const char * const hash_object_usage[] = {
N_("git hash-object [-t <type>] [-w] [--path=<file> | --no-filters] [--stdin] [--] <file>..."),
"git hash-object --stdin-paths",
N_("git hash-object [-t <type>] [-w] [--path=<file> | --no-filters]\n"
" [--stdin [--literally]] [--] <file>..."),
N_("git hash-object [-t <type>] [-w] --stdin-paths [--no-filters]"),
NULL
};
const char *type = blob_type;

View File

@ -88,7 +88,7 @@ static struct option builtin_help_options[] = {
};
static const char * const builtin_help_usage[] = {
"git help [-a|--all] [--[no-]verbose]] [--[no-]external-commands] [--[no-]aliases]",
"git help [-a|--all] [--[no-]verbose] [--[no-]external-commands] [--[no-]aliases]",
N_("git help [[-i|--info] [-m|--man] [-w|--web]] [<command>|<doc>]"),
"git help [-g|--guides]",
"git help [-c|--config]",

View File

@ -515,7 +515,10 @@ static int shared_callback(const struct option *opt, const char *arg, int unset)
}
static const char *const init_db_usage[] = {
N_("git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [<directory>]"),
N_("git init [-q | --quiet] [--bare] [--template=<template-directory>]\n"
" [--separate-git-dir <git-dir>] [--object-format=<format>]\n"
" [-b <branch-name> | --initial-branch=<branch-name>]\n"
" [--shared[=<permissions>]] [<directory>]"),
NULL
};

View File

@ -13,7 +13,9 @@
#include "config.h"
static const char * const git_interpret_trailers_usage[] = {
N_("git interpret-trailers [--in-place] [--trim-empty] [(--trailer <token>[(=|:)<value>])...] [<file>...]"),
N_("git interpret-trailers [--in-place] [--trim-empty]\n"
" [(--trailer <token>[(=|:)<value>])...]\n"
" [--parse] [<file>...]"),
NULL
};

View File

@ -7,7 +7,7 @@
static const char * const ls_remote_usage[] = {
N_("git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n"
" [-q | --quiet] [--exit-code] [--get-url]\n"
" [-q | --quiet] [--exit-code] [--get-url] [--sort=<key>]\n"
" [--symref] [<repository> [<refs>...]]"),
NULL
};

View File

@ -31,8 +31,8 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
static const char * const merge_base_usage[] = {
N_("git merge-base [-a | --all] <commit> <commit>..."),
N_("git merge-base [-a | --all] --octopus <commit>..."),
N_("git merge-base --independent <commit>..."),
N_("git merge-base --is-ancestor <commit> <commit>"),
N_("git merge-base --independent <commit>..."),
N_("git merge-base --fork-point <ref> [<commit>]"),
NULL
};

View File

@ -180,8 +180,8 @@ static inline void oe_set_delta_size(struct packing_data *pack,
#define SET_DELTA_SIBLING(obj, val) oe_set_delta_sibling(&to_pack, obj, val)
static const char *pack_usage[] = {
N_("git pack-objects --stdout [<options>...] [< <ref-list> | < <object-list>]"),
N_("git pack-objects [<options>...] <base-name> [< <ref-list> | < <object-list>]"),
N_("git pack-objects --stdout [<options>] [< <ref-list> | < <object-list>]"),
N_("git pack-objects [<options>] <base-name> [< <ref-list> | < <object-list>]"),
NULL
};

View File

@ -14,7 +14,7 @@
#define BLKSIZE 512
static const char pack_redundant_usage[] =
"git pack-redundant [--verbose] [--alt-odb] (--all | <filename.pack>...)";
"git pack-redundant [--verbose] [--alt-odb] (--all | <pack-filename>...)";
static int load_all_packs, verbose, alt_odb;

View File

@ -5,7 +5,7 @@
#include "repository.h"
static char const * const pack_refs_usage[] = {
N_("git pack-refs [<options>]"),
N_("git pack-refs [--all] [--no-prune]"),
NULL
};

View File

@ -38,7 +38,9 @@ static int list_tree(struct object_id *oid)
}
static const char * const read_tree_usage[] = {
N_("git read-tree [(-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>) [-u | -i]] [--no-sparse-checkout] [--index-output=<file>] (--empty | <tree-ish1> [<tree-ish2> [<tree-ish3>]])"),
N_("git read-tree [(-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>)\n"
" [-u | -i]] [--index-output=<file>] [--no-sparse-checkout]\n"
" (--empty | <tree-ish1> [<tree-ish2> [<tree-ish3>]])"),
NULL
};

View File

@ -10,7 +10,7 @@
#include "pathspec.h"
static const char * const rerere_usage[] = {
N_("git rerere [clear | forget <path>... | status | remaining | diff | gc]"),
N_("git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"),
NULL,
};

View File

@ -20,7 +20,8 @@
#include "packfile.h"
static const char rev_list_usage[] =
"git rev-list [<options>] <commit-id>... [-- <path>...]\n"
"git rev-list [<options>] <commit>... [--] [<path>...]\n"
"\n"
" limiting output:\n"
" --max-count=<n>\n"
" --max-age=<epoch>\n"

View File

@ -21,14 +21,15 @@
*/
static const char * const revert_usage[] = {
N_("git revert [<options>] <commit-ish>..."),
N_("git revert <subcommand>"),
N_("git revert [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>..."),
N_("git revert (--continue | --skip | --abort | --quit)"),
NULL
};
static const char * const cherry_pick_usage[] = {
N_("git cherry-pick [<options>] <commit-ish>..."),
N_("git cherry-pick <subcommand>"),
N_("git cherry-pick [--edit] [-n] [-m <parent-number>] [-s] [-x] [--ff]\n"
" [-S[<keyid>]] <commit>..."),
N_("git cherry-pick (--continue | --skip | --abort | --quit)"),
NULL
};

View File

@ -17,7 +17,9 @@
#include "pathspec.h"
static const char * const builtin_rm_usage[] = {
N_("git rm [<options>] [--] <file>..."),
N_("git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch]\n"
" [--quiet] [--pathspec-from-file=<file> [--pathspec-file-nul]]\n"
" [--] [<pathspec>...]"),
NULL
};

View File

@ -20,6 +20,7 @@ static const char * const send_pack_usage[] = {
N_("git send-pack [--mirror] [--dry-run] [--force]\n"
" [--receive-pack=<git-receive-pack>]\n"
" [--verbose] [--thin] [--atomic]\n"
" [--[no-]signed | --signed=(true|false|if-asked)]\n"
" [<host>:]<directory> (--all | <ref>...)"),
NULL,
};

View File

@ -14,7 +14,8 @@ static const char* show_branch_usage[] = {
N_("git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order]\n"
" [--current] [--color[=<when>] | --no-color] [--sparse]\n"
" [--more=<n> | --list | --independent | --merge-base]\n"
" [--no-name | --sha1-name] [--topics] [(<rev> | <glob>)...]"),
" [--no-name | --sha1-name] [--topics]\n"
" [(<rev> | <glob>)...]"),
N_("git show-branch (-g | --reflog)[=<n>[,<base>]] [--list] [<ref>]"),
NULL
};

View File

@ -9,7 +9,9 @@
#include "parse-options.h"
static const char * const show_ref_usage[] = {
N_("git show-ref [-q | --quiet] [--verify] [--head] [-d | --dereference] [-s | --hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [<pattern>...]"),
N_("git show-ref [-q | --quiet] [--verify] [--head] [-d | --dereference]\n"
" [-s | --hash[=<n>]] [--abbrev[=<n>]] [--tags]\n"
" [--heads] [--] [<pattern>...]"),
N_("git show-ref --exclude-existing[=<pattern>]"),
NULL
};

View File

@ -20,7 +20,7 @@
static const char *empty_base = "";
static char const * const builtin_sparse_checkout_usage[] = {
N_("git sparse-checkout (init|list|set|add|reapply|disable) <options>"),
N_("git sparse-checkout (init | list | set | add | reapply | disable) [<options>]"),
NULL
};

View File

@ -21,72 +21,95 @@
#define INCLUDE_ALL_FILES 2
#define BUILTIN_STASH_LIST_USAGE \
N_("git stash list [<log-options>]")
#define BUILTIN_STASH_SHOW_USAGE \
N_("git stash show [-u | --include-untracked | --only-untracked] [<diff-options>] [<stash>]")
#define BUILTIN_STASH_DROP_USAGE \
N_("git stash drop [-q | --quiet] [<stash>]")
#define BUILTIN_STASH_POP_USAGE \
N_("git stash pop [--index] [-q | --quiet] [<stash>]")
#define BUILTIN_STASH_APPLY_USAGE \
N_("git stash apply [--index] [-q | --quiet] [<stash>]")
#define BUILTIN_STASH_BRANCH_USAGE \
N_("git stash branch <branchname> [<stash>]")
#define BUILTIN_STASH_STORE_USAGE \
N_("git stash store [(-m | --message) <message>] [-q | --quiet] <commit>")
#define BUILTIN_STASH_PUSH_USAGE \
N_("git stash [push [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]\n" \
" [-u | --include-untracked] [-a | --all] [(-m | --message) <message>]\n" \
" [--pathspec-from-file=<file> [--pathspec-file-nul]]\n" \
" [--] [<pathspec>...]]")
#define BUILTIN_STASH_SAVE_USAGE \
N_("git stash save [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]\n" \
" [-u | --include-untracked] [-a | --all] [<message>]")
#define BUILTIN_STASH_CREATE_USAGE \
N_("git stash create [<message>]")
#define BUILTIN_STASH_CLEAR_USAGE \
"git stash clear"
static const char * const git_stash_usage[] = {
N_("git stash list [<options>]"),
N_("git stash show [<options>] [<stash>]"),
N_("git stash drop [-q|--quiet] [<stash>]"),
N_("git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]"),
N_("git stash branch <branchname> [<stash>]"),
"git stash clear",
N_("git stash [push [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-q|--quiet]\n"
" [-u|--include-untracked] [-a|--all] [-m|--message <message>]\n"
" [--pathspec-from-file=<file> [--pathspec-file-nul]]\n"
" [--] [<pathspec>...]]"),
N_("git stash save [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-q|--quiet]\n"
" [-u|--include-untracked] [-a|--all] [<message>]"),
BUILTIN_STASH_LIST_USAGE,
BUILTIN_STASH_SHOW_USAGE,
BUILTIN_STASH_DROP_USAGE,
BUILTIN_STASH_POP_USAGE,
BUILTIN_STASH_APPLY_USAGE,
BUILTIN_STASH_BRANCH_USAGE,
BUILTIN_STASH_PUSH_USAGE,
BUILTIN_STASH_SAVE_USAGE,
BUILTIN_STASH_CLEAR_USAGE,
BUILTIN_STASH_CREATE_USAGE,
BUILTIN_STASH_STORE_USAGE,
NULL
};
static const char * const git_stash_list_usage[] = {
N_("git stash list [<options>]"),
BUILTIN_STASH_LIST_USAGE,
NULL
};
static const char * const git_stash_show_usage[] = {
N_("git stash show [<options>] [<stash>]"),
BUILTIN_STASH_SHOW_USAGE,
NULL
};
static const char * const git_stash_drop_usage[] = {
N_("git stash drop [-q|--quiet] [<stash>]"),
BUILTIN_STASH_DROP_USAGE,
NULL
};
static const char * const git_stash_pop_usage[] = {
N_("git stash pop [--index] [-q|--quiet] [<stash>]"),
BUILTIN_STASH_POP_USAGE,
NULL
};
static const char * const git_stash_apply_usage[] = {
N_("git stash apply [--index] [-q|--quiet] [<stash>]"),
BUILTIN_STASH_APPLY_USAGE,
NULL
};
static const char * const git_stash_branch_usage[] = {
N_("git stash branch <branchname> [<stash>]"),
BUILTIN_STASH_BRANCH_USAGE,
NULL
};
static const char * const git_stash_clear_usage[] = {
"git stash clear",
BUILTIN_STASH_CLEAR_USAGE,
NULL
};
static const char * const git_stash_store_usage[] = {
N_("git stash store [-m|--message <message>] [-q|--quiet] <commit>"),
BUILTIN_STASH_STORE_USAGE,
NULL
};
static const char * const git_stash_push_usage[] = {
N_("git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]\n"
" [-u|--include-untracked] [-a|--all] [-m|--message <message>]\n"
" [--] [<pathspec>...]]"),
BUILTIN_STASH_PUSH_USAGE,
NULL
};
static const char * const git_stash_save_usage[] = {
N_("git stash save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]\n"
" [-u|--include-untracked] [-a|--all] [<message>]"),
BUILTIN_STASH_SAVE_USAGE,
NULL
};

View File

@ -5,8 +5,9 @@
#include "parse-options.h"
static const char * const git_symbolic_ref_usage[] = {
N_("git symbolic-ref [<options>] <name> [<ref>]"),
N_("git symbolic-ref -d [-q] [--no-recurse] <name>"),
N_("git symbolic-ref [-m <reason>] <name> <ref>"),
N_("git symbolic-ref [-q] [--short] [--no-recurse] <name>"),
N_("git symbolic-ref --delete [-q] <name>"),
NULL
};

View File

@ -23,11 +23,13 @@
#include "date.h"
static const char * const git_tag_usage[] = {
N_("git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>]\n"
" <tagname> [<head>]"),
N_("git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] [-e]\n"
" <tagname> [<commit> | <object>]"),
N_("git tag -d <tagname>..."),
N_("git tag -l [-n[<num>]] [--contains <commit>] [--no-contains <commit>] [--points-at <object>]\n"
" [--format=<format>] [--merged <commit>] [--no-merged <commit>] [<pattern>...]"),
N_("git tag [-n[<num>]] -l [--contains <commit>] [--no-contains <commit>]\n"
" [--points-at <object>] [--column[=<options>] | --no-column]\n"
" [--create-reflog] [--sort=<key>] [--format=<format>]\n"
" [--merged <commit>] [--no-merged <commit>] [<pattern>...]"),
N_("git tag -v [--format=<format>] <tagname>..."),
NULL
};

View File

@ -27,7 +27,7 @@ int cmd_unpack_file(int argc, const char **argv, const char *prefix)
struct object_id oid;
if (argc != 2 || !strcmp(argv[1], "-h"))
usage("git unpack-file <sha1>");
usage("git unpack-file <blob>");
if (get_oid(argv[1], &oid))
die("Not a valid object name %s", argv[1]);

View File

@ -4,7 +4,7 @@
#include "parse-options.h"
static const char * const update_server_info_usage[] = {
"git update-server-info [--force]",
"git update-server-info [-f | --force]",
NULL
};

View File

@ -10,7 +10,7 @@
#include "strvec.h"
static const char upload_archive_usage[] =
"git upload-archive <repo>";
"git upload-archive <repository>";
static const char deadchild[] =
"git upload-archive: archiver died with error";

View File

@ -8,7 +8,8 @@
#include "serve.h"
static const char * const upload_pack_usage[] = {
N_("git upload-pack [<options>] <dir>"),
N_("git-upload-pack [--[no-]strict] [--timeout=<n>] [--stateless-rpc]\n"
" [--advertise-refs] <directory>"),
NULL
};

View File

@ -16,7 +16,7 @@
#include "gpg-interface.h"
static const char * const verify_commit_usage[] = {
N_("git verify-commit [-v | --verbose] <commit>..."),
N_("git verify-commit [-v | --verbose] [--raw] <commit>..."),
NULL
};

View File

@ -56,7 +56,7 @@ static int verify_one_pack(const char *path, unsigned int flags, const char *has
}
static const char * const verify_pack_usage[] = {
N_("git verify-pack [-v | --verbose] [-s | --stat-only] <pack>..."),
N_("git verify-pack [-v | --verbose] [-s | --stat-only] [--] <pack>.idx..."),
NULL
};

View File

@ -15,7 +15,7 @@
#include "ref-filter.h"
static const char * const verify_tag_usage[] = {
N_("git verify-tag [-v | --verbose] [--format=<format>] <tag>..."),
N_("git verify-tag [-v | --verbose] [--format=<format>] [--raw] <tag>..."),
NULL
};

View File

@ -15,15 +15,73 @@
#include "worktree.h"
#include "quote.h"
static const char * const worktree_usage[] = {
N_("git worktree add [<options>] <path> [<commit-ish>]"),
N_("git worktree list [<options>]"),
N_("git worktree lock [<options>] <path>"),
N_("git worktree move <worktree> <new-path>"),
N_("git worktree prune [<options>]"),
N_("git worktree remove [<options>] <worktree>"),
N_("git worktree repair [<path>...]"),
N_("git worktree unlock <path>"),
#define BUILTIN_WORKTREE_ADD_USAGE \
N_("git worktree add [-f] [--detach] [--checkout] [--lock [--reason <string>]]\n" \
" [-b <new-branch>] <path> [<commit-ish>]")
#define BUILTIN_WORKTREE_LIST_USAGE \
N_("git worktree list [-v | --porcelain [-z]]")
#define BUILTIN_WORKTREE_LOCK_USAGE \
N_("git worktree lock [--reason <string>] <worktree>")
#define BUILTIN_WORKTREE_MOVE_USAGE \
N_("git worktree move <worktree> <new-path>")
#define BUILTIN_WORKTREE_PRUNE_USAGE \
N_("git worktree prune [-n] [-v] [--expire <expire>]")
#define BUILTIN_WORKTREE_REMOVE_USAGE \
N_("git worktree remove [-f] <worktree>")
#define BUILTIN_WORKTREE_REPAIR_USAGE \
N_("git worktree repair [<path>...]")
#define BUILTIN_WORKTREE_UNLOCK_USAGE \
N_("git worktree unlock <worktree>")
static const char * const git_worktree_usage[] = {
BUILTIN_WORKTREE_ADD_USAGE,
BUILTIN_WORKTREE_LIST_USAGE,
BUILTIN_WORKTREE_LOCK_USAGE,
BUILTIN_WORKTREE_MOVE_USAGE,
BUILTIN_WORKTREE_PRUNE_USAGE,
BUILTIN_WORKTREE_REMOVE_USAGE,
BUILTIN_WORKTREE_REPAIR_USAGE,
BUILTIN_WORKTREE_UNLOCK_USAGE,
NULL
};
static const char * const git_worktree_add_usage[] = {
BUILTIN_WORKTREE_ADD_USAGE,
NULL,
};
static const char * const git_worktree_list_usage[] = {
BUILTIN_WORKTREE_LIST_USAGE,
NULL
};
static const char * const git_worktree_lock_usage[] = {
BUILTIN_WORKTREE_LOCK_USAGE,
NULL
};
static const char * const git_worktree_move_usage[] = {
BUILTIN_WORKTREE_MOVE_USAGE,
NULL
};
static const char * const git_worktree_prune_usage[] = {
BUILTIN_WORKTREE_PRUNE_USAGE,
NULL
};
static const char * const git_worktree_remove_usage[] = {
BUILTIN_WORKTREE_REMOVE_USAGE,
NULL
};
static const char * const git_worktree_repair_usage[] = {
BUILTIN_WORKTREE_REPAIR_USAGE,
NULL
};
static const char * const git_worktree_unlock_usage[] = {
BUILTIN_WORKTREE_UNLOCK_USAGE,
NULL
};
@ -153,9 +211,10 @@ static int prune(int ac, const char **av, const char *prefix)
};
expire = TIME_MAX;
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
ac = parse_options(ac, av, prefix, options, git_worktree_prune_usage,
0);
if (ac)
usage_with_options(worktree_usage, options);
usage_with_options(git_worktree_prune_usage, options);
prune_worktrees();
return 0;
}
@ -573,7 +632,7 @@ static int add(int ac, const char **av, const char *prefix)
memset(&opts, 0, sizeof(opts));
opts.checkout = 1;
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
ac = parse_options(ac, av, prefix, options, git_worktree_add_usage, 0);
if (!!opts.detach + !!new_branch + !!new_branch_force > 1)
die(_("options '%s', '%s', and '%s' cannot be used together"), "-b", "-B", "--detach");
if (lock_reason && !keep_locked)
@ -584,7 +643,7 @@ static int add(int ac, const char **av, const char *prefix)
opts.keep_locked = _("added with --lock");
if (ac < 1 || ac > 2)
usage_with_options(worktree_usage, options);
usage_with_options(git_worktree_add_usage, options);
path = prefix_filename(prefix, av[0]);
branch = ac < 2 ? "HEAD" : av[1];
@ -772,9 +831,9 @@ static int list(int ac, const char **av, const char *prefix)
};
expire = TIME_MAX;
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
ac = parse_options(ac, av, prefix, options, git_worktree_list_usage, 0);
if (ac)
usage_with_options(worktree_usage, options);
usage_with_options(git_worktree_list_usage, options);
else if (verbose && porcelain)
die(_("options '%s' and '%s' cannot be used together"), "--verbose", "--porcelain");
else if (!line_terminator && !porcelain)
@ -811,9 +870,9 @@ static int lock_worktree(int ac, const char **av, const char *prefix)
};
struct worktree **worktrees, *wt;
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
ac = parse_options(ac, av, prefix, options, git_worktree_lock_usage, 0);
if (ac != 1)
usage_with_options(worktree_usage, options);
usage_with_options(git_worktree_lock_usage, options);
worktrees = get_worktrees();
wt = find_worktree(worktrees, prefix, av[0]);
@ -844,9 +903,9 @@ static int unlock_worktree(int ac, const char **av, const char *prefix)
struct worktree **worktrees, *wt;
int ret;
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
ac = parse_options(ac, av, prefix, options, git_worktree_unlock_usage, 0);
if (ac != 1)
usage_with_options(worktree_usage, options);
usage_with_options(git_worktree_unlock_usage, options);
worktrees = get_worktrees();
wt = find_worktree(worktrees, prefix, av[0]);
@ -914,9 +973,10 @@ static int move_worktree(int ac, const char **av, const char *prefix)
const char *reason = NULL;
char *path;
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
ac = parse_options(ac, av, prefix, options, git_worktree_move_usage,
0);
if (ac != 2)
usage_with_options(worktree_usage, options);
usage_with_options(git_worktree_move_usage, options);
path = prefix_filename(prefix, av[1]);
strbuf_addstr(&dst, path);
@ -1042,9 +1102,9 @@ static int remove_worktree(int ac, const char **av, const char *prefix)
const char *reason = NULL;
int ret = 0;
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
ac = parse_options(ac, av, prefix, options, git_worktree_remove_usage, 0);
if (ac != 1)
usage_with_options(worktree_usage, options);
usage_with_options(git_worktree_remove_usage, options);
worktrees = get_worktrees();
wt = find_worktree(worktrees, prefix, av[0]);
@ -1102,7 +1162,7 @@ static int repair(int ac, const char **av, const char *prefix)
};
int rc = 0;
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
ac = parse_options(ac, av, prefix, options, git_worktree_repair_usage, 0);
p = ac > 0 ? av : self;
for (; *p; p++)
repair_worktree_at_path(*p, report_repair, &rc);
@ -1130,6 +1190,6 @@ int cmd_worktree(int ac, const char **av, const char *prefix)
if (!prefix)
prefix = "";
ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
ac = parse_options(ac, av, prefix, options, git_worktree_usage, 0);
return fn(ac, av, prefix);
}

2
help.c
View File

@ -757,7 +757,7 @@ int cmd_version(int argc, const char **argv, const char *prefix)
struct strbuf buf = STRBUF_INIT;
int build_options = 0;
const char * const usage[] = {
N_("git version [<options>]"),
N_("git version [--build-options]"),
NULL
};
struct option options[] = {

View File

@ -6,7 +6,7 @@
#include "test-tool.h"
static const char *proc_receive_usage[] = {
"test-tool proc-receive [<options>...]",
"test-tool proc-receive [<options>]",
NULL
};

172
t/t0450-txt-doc-vs-help.sh Executable file
View File

@ -0,0 +1,172 @@
#!/bin/sh
test_description='assert (unbuilt) Documentation/*.txt and -h output
Run this with --debug to see a summary of where we still fail to make
the two versions consistent with one another.'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup: list of builtins' '
git --list-cmds=builtins >builtins
'
test_expect_success 'list of txt and help mismatches is sorted' '
sort -u "$TEST_DIRECTORY"/t0450/txt-help-mismatches >expect &&
if ! test_cmp expect "$TEST_DIRECTORY"/t0450/txt-help-mismatches
then
BUG "please keep the list of txt and help mismatches sorted"
fi
'
help_to_synopsis () {
builtin="$1" &&
out_dir="out/$builtin" &&
out="$out_dir/help.synopsis" &&
if test -f "$out"
then
echo "$out" &&
return 0
fi &&
mkdir -p "$out_dir" &&
test_expect_code 129 git $builtin -h >"$out.raw" 2>&1 &&
sed -n \
-e '1,/^$/ {
/^$/d;
s/^usage: //;
s/^ *or: //;
p;
}' <"$out.raw" >"$out" &&
echo "$out"
}
builtin_to_txt () {
echo "$GIT_BUILD_DIR/Documentation/git-$1.txt"
}
txt_to_synopsis () {
builtin="$1" &&
out_dir="out/$builtin" &&
out="$out_dir/txt.synopsis" &&
if test -f "$out"
then
echo "$out" &&
return 0
fi &&
b2t="$(builtin_to_txt "$builtin")" &&
sed -n \
-e '/^\[verse\]$/,/^$/ {
/^$/d;
/^\[verse\]$/d;
s/{litdd}/--/g;
s/'\''\(git[ a-z-]*\)'\''/\1/g;
p;
}' \
<"$b2t" >"$out" &&
echo "$out"
}
check_dashed_labels () {
! grep -E "<[^>_-]+_" "$1"
}
HT=" "
align_after_nl () {
builtin="$1" &&
len=$(printf "git %s " "$builtin" | wc -c) &&
pad=$(printf "%${len}s" "") &&
sed "s/^[ $HT][ $HT]*/$pad/"
}
test_debug '>failing'
while read builtin
do
# -h output assertions
test_expect_success "$builtin -h output has no \t" '
h2s="$(help_to_synopsis "$builtin")" &&
! grep "$HT" "$h2s"
'
test_expect_success "$builtin -h output has dashed labels" '
check_dashed_labels "$(help_to_synopsis "$builtin")"
'
test_expect_success "$builtin -h output has consistent spacing" '
h2s="$(help_to_synopsis "$builtin")" &&
sed -n \
-e "/^ / {
s/[^ ].*//;
p;
}" \
<"$h2s" >help &&
sort -u help >help.ws &&
if test -s help.ws
then
test_line_count = 1 help.ws
fi
'
txt="$(builtin_to_txt "$builtin")" &&
preq="$(echo BUILTIN_TXT_$builtin | tr '[:lower:]-' '[:upper:]_')" &&
if test -f "$txt"
then
test_set_prereq "$preq"
fi &&
# *.txt output assertions
test_expect_success "$preq" "$builtin *.txt SYNOPSIS has dashed labels" '
check_dashed_labels "$(txt_to_synopsis "$builtin")"
'
# *.txt output consistency assertions
result=
if grep -q "^$builtin$" "$TEST_DIRECTORY"/t0450/txt-help-mismatches
then
result=failure
else
result=success
fi &&
test_expect_$result "$preq" "$builtin -h output and SYNOPSIS agree" '
t2s="$(txt_to_synopsis "$builtin")" &&
if test "$builtin" = "merge-tree"
then
test_when_finished "rm -f t2s.new" &&
sed -e '\''s/ (deprecated)$//g'\'' <"$t2s" >t2s.new
t2s=t2s.new
fi &&
h2s="$(help_to_synopsis "$builtin")" &&
# The *.txt and -h use different spacing for the
# alignment of continued usage output, normalize it.
align_after_nl "$builtin" <"$t2s" >txt &&
align_after_nl "$builtin" <"$h2s" >help &&
test_cmp txt help
'
if test_have_prereq "$preq" && test -e txt && test -e help
then
test_debug '
if test_cmp txt help >cmp 2>/dev/null
then
echo "=== DONE: $builtin ==="
else
echo "=== TODO: $builtin ===" &&
cat cmp
fi >>failing
'
# Not in test_expect_success in case --run is being
# used with --debug
rm -f txt help tmp 2>/dev/null
fi
done <builtins
test_debug 'say "$(cat failing)"'
test_done

View File

@ -0,0 +1,58 @@
add
am
apply
archive
bisect
blame
branch
check-ref-format
checkout
checkout-index
clone
column
config
credential
credential-cache
credential-store
fast-export
fast-import
fetch-pack
fmt-merge-msg
for-each-ref
format-patch
fsck-objects
fsmonitor--daemon
gc
grep
index-pack
init-db
log
ls-files
ls-tree
mailinfo
mailsplit
maintenance
merge
merge-file
merge-index
merge-one-file
multi-pack-index
name-rev
notes
pack-objects
push
range-diff
rebase
remote
remote-ext
remote-fd
repack
reset
restore
rev-parse
show
stage
switch
update-index
update-ref
whatchanged