Re: [PATCH 5/7] help: error if [-a|-g|-c] and [-i|-m|-w] are combined
From: Eric Sunshine <hidden>
Date: 2021-12-28 16:18:15
On Tue, Dec 28, 2021 at 10:36 AM Ævar Arnfjörð Bjarmason [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Add more sanity checking to "git help" usage by erroring out if these man viewer options are combined with incompatible command-modes that will never use these documentation viewers. This continues the work started in d35d03cf93e (help: simplify by moving to OPT_CMDMODE(), 2021-09-22) of adding more sanity checking to "git help". Doing this allows us to clarify the "SYNOPSIS" in the documentation, and the "git help -h" output. Signed-off-by: Ævar Arnfjörð Bjarmason <redacted> ---diff --git a/builtin/help.c b/builtin/help.c@@ -581,6 +581,13 @@ static void no_extra_argc(int argc) +static void no_format(void) +{ + if (help_format != HELP_FORMAT_NONE) + usage_msg_opt(_("[-a|--all] cannot be combined with [[-i|--info] [-m|--man] [-w|--web]]"), + builtin_help_usage, builtin_help_options); +}
Nit: The square brackets in the message may be unnecessarily
confusing. (Indeed, what exactly do they mean in this context?) Also,
the short options may not add much value: the user who typed `-w`
knows presumably that it is shorthand for `--web`. So, one
simplification would be:
'--all' cannot be combined with '--info', '--man', or '--web'