mirror of
https://github.com/git/git.git
synced 2024-05-06 00:36:14 +02:00
Merge branch 'gf/shorthand-version-and-help' into next
"git -v" and "git -h" are now understood as "git --version" and "git --help". * gf/shorthand-version-and-help: cli: add -v and -h shorthands
This commit is contained in:
commit
54ca8b25e0
|
@ -9,7 +9,7 @@ git - the stupid content tracker
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
[verse]
|
[verse]
|
||||||
'git' [--version] [--help] [-C <path>] [-c <name>=<value>]
|
'git' [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
|
||||||
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
|
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
|
||||||
[-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]
|
[-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]
|
||||||
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
|
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
|
||||||
|
@ -39,6 +39,7 @@ or https://git-scm.com/docs.
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-------
|
-------
|
||||||
|
-v::
|
||||||
--version::
|
--version::
|
||||||
Prints the Git suite version that the 'git' program came from.
|
Prints the Git suite version that the 'git' program came from.
|
||||||
+
|
+
|
||||||
|
@ -46,6 +47,7 @@ This option is internally converted to `git version ...` and accepts
|
||||||
the same options as the linkgit:git-version[1] command. If `--help` is
|
the same options as the linkgit:git-version[1] command. If `--help` is
|
||||||
also given, it takes precedence over `--version`.
|
also given, it takes precedence over `--version`.
|
||||||
|
|
||||||
|
-h::
|
||||||
--help::
|
--help::
|
||||||
Prints the synopsis and a list of the most commonly used
|
Prints the synopsis and a list of the most commonly used
|
||||||
commands. If the option `--all` or `-a` is given then all
|
commands. If the option `--all` or `-a` is given then all
|
||||||
|
|
11
git.c
11
git.c
|
@ -25,7 +25,7 @@ struct cmd_struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
const char git_usage_string[] =
|
const char git_usage_string[] =
|
||||||
N_("git [--version] [--help] [-C <path>] [-c <name>=<value>]\n"
|
N_("git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\n"
|
||||||
" [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
|
" [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
|
||||||
" [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]\n"
|
" [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]\n"
|
||||||
" [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
|
" [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
|
||||||
|
@ -146,7 +146,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
|
||||||
* commands can be written with "--" prepended
|
* commands can be written with "--" prepended
|
||||||
* to make them look like flags.
|
* to make them look like flags.
|
||||||
*/
|
*/
|
||||||
if (!strcmp(cmd, "--help") || !strcmp(cmd, "--version"))
|
if (!strcmp(cmd, "--help") || !strcmp(cmd, "-h") ||
|
||||||
|
!strcmp(cmd, "--version") || !strcmp(cmd, "-v"))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -893,8 +894,10 @@ int cmd_main(int argc, const char **argv)
|
||||||
argc--;
|
argc--;
|
||||||
handle_options(&argv, &argc, NULL);
|
handle_options(&argv, &argc, NULL);
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
/* translate --help and --version into commands */
|
if (!strcmp("--version", argv[0]) || !strcmp("-v", argv[0]))
|
||||||
skip_prefix(argv[0], "--", &argv[0]);
|
argv[0] = "version";
|
||||||
|
else if (!strcmp("--help", argv[0]) || !strcmp("-h", argv[0]))
|
||||||
|
argv[0] = "help";
|
||||||
} else {
|
} else {
|
||||||
/* The user didn't specify a command; give them help */
|
/* The user didn't specify a command; give them help */
|
||||||
commit_pager_choice();
|
commit_pager_choice();
|
||||||
|
|
|
@ -181,7 +181,7 @@ for cmd in git "git help"
|
||||||
do
|
do
|
||||||
test_expect_success "'$cmd' section spacing" '
|
test_expect_success "'$cmd' section spacing" '
|
||||||
test_section_spacing_trailer git help <<-\EOF &&
|
test_section_spacing_trailer git help <<-\EOF &&
|
||||||
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
|
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
|
||||||
|
|
||||||
These are common Git commands used in various situations:
|
These are common Git commands used in various situations:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue