diff options
| author | James Liu <james@jamesliu.io> | 2024-05-03 17:17:06 +1000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-05-03 10:36:59 -0700 |
| commit | b79deeb55444f9e01a3f6335d7e0507e23e90190 (patch) | |
| tree | 44ece5c77a73a7c18a5c5c4939f481b172e44901 /git.c | |
| parent | 5bd8811a734536186dd69ae767a9d58ce01ad7cb (diff) | |
advice: add --no-advice global option
Advice hints must be disabled individually by setting the relevant
advice.* variables to false in the Git configuration. For server-side
and scripted usages of Git where hints can be a hindrance, it can be
cumbersome to maintain configuration to ensure all advice hints are
disabled in perpetuity. This is a particular concern in tests, where
new or changed hints can result in failed assertions.
Add a --no-advice global option to disable all advice hints from being
displayed. This is independent of the toggles for individual advice
hints. Use an internal environment variable (GIT_ADVICE) to ensure this
configuration is propagated to the usage site, even if it executes in a
subprocess.
Signed-off-by: James Liu <james@jamesliu.io>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git.c')
| -rw-r--r-- | git.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -37,8 +37,9 @@ const char git_usage_string[] = N_("git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\n" " [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n" " [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--no-lazy-fetch]\n" - " [--no-optional-locks] [--bare] [--git-dir=<path>] [--work-tree=<path>]\n" - " [--namespace=<name>] [--config-env=<name>=<envvar>] <command> [<args>]"); + " [--no-optional-locks] [--no-advice] [--bare] [--git-dir=<path>]\n" + " [--work-tree=<path>] [--namespace=<name>] [--config-env=<name>=<envvar>]\n" + " <command> [<args>]"); const char git_more_info_string[] = N_("'git help -a' and 'git help -g' list available subcommands and some\n" @@ -337,6 +338,10 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) setenv(GIT_ATTR_SOURCE_ENVIRONMENT, cmd, 1); if (envchanged) *envchanged = 1; + } else if (!strcmp(cmd, "--no-advice")) { + setenv(GIT_ADVICE_ENVIRONMENT, "0", 1); + if (envchanged) + *envchanged = 1; } else { fprintf(stderr, _("unknown option: %s\n"), cmd); usage(git_usage_string); |
