mirror of
https://github.com/git/git.git
synced 2026-06-24 08:48:31 +00:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
5bd8811a73
commit
b79deeb554
9
git.c
9
git.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user