Skip to content

Commit 5e8068b

Browse files
avargitster
authored andcommitted
help: correct usage & behavior of "git help --all"
Do the same for the "--all" option that I did for "--guides" in 9856ea6 (help: correct usage & behavior of "git help --guides", 2021-09-22). I.e. we've documented it as ignoring non-option arguments, let's have it error out instead. As with other changes made in 62f035a (Merge branch 'ab/help-config-vars', 2021-10-13) this is technically a change in behavior, but in practice it's just a bug fix. We were ignoring this before, but by erroring we can simplify our documentation and synopsis, as well as avoid user confusion as they wonder what the difference between e.g. "git help --all" and "git help --all status" is (there wasn't any difference). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d7f817d commit 5e8068b

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Documentation/git-help.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git help' [-a|--all] [--[no-]verbose]
12-
[[-i|--info] [-m|--man] [-w|--web]] [<command>|<guide>]
12+
'git help' [[-i|--info] [-m|--man] [-w|--web]] [<command>|<guide>]
1313
'git help' [-g|--guides]
1414
'git help' [-c|--config]
1515

@@ -46,8 +46,7 @@ OPTIONS
4646
-------
4747
-a::
4848
--all::
49-
Prints all the available commands on the standard output. This
50-
option overrides any given command or guide name.
49+
Prints all the available commands on the standard output.
5150

5251
--verbose::
5352
When used with `--all` print description for all recognized

builtin/help.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ static struct option builtin_help_options[] = {
7575
};
7676

7777
static const char * const builtin_help_usage[] = {
78-
N_("git help [-a|--all] [--[no-]verbose]]\n"
79-
" [[-i|--info] [-m|--man] [-w|--web]] [<command>]"),
78+
N_("git help [-a|--all] [--[no-]verbose]]"),
79+
N_("git help [[-i|--info] [-m|--man] [-w|--web]] [<command>]"),
8080
N_("git help [-g|--guides]"),
8181
N_("git help [-c|--config]"),
8282
NULL
@@ -594,6 +594,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
594594

595595
switch (cmd_mode) {
596596
case HELP_ACTION_ALL:
597+
opt_mode_usage(argc, "--all");
597598
if (verbose) {
598599
setup_pager();
599600
list_all_cmds_help();

t/t0012-help.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ test_expect_success 'basic help commands' '
3535
'
3636

3737
test_expect_success 'invalid usage' '
38+
test_expect_code 129 git help -a add &&
39+
test_expect_code 129 git help --all add &&
40+
3841
test_expect_code 129 git help -g add &&
3942
test_expect_code 129 git help -a -c &&
4043

0 commit comments

Comments
 (0)