Skip to content

Commit daa9564

Browse files
committed
git: add --no-includes top-level option
The previous change added a GIT_CONFIG_INCLUDES=0 override in the environment, similar to GIT_ADVICE=0. Follow the same model as --no-advice to add a --no-includes option to the top-level Git options. Signed-off-by: Derrick Stolee <stolee@gmail.com>
1 parent b48fe9f commit daa9564

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

Documentation/git.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SYNOPSIS
1212
'git' [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
1313
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
1414
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--no-lazy-fetch]
15-
[--no-optional-locks] [--no-advice] [--bare] [--git-dir=<path>]
15+
[--no-optional-locks] [--no-advice] [--no-includes] [--bare] [--git-dir=<path>]
1616
[--work-tree=<path>] [--namespace=<name>] [--config-env=<name>=<envvar>]
1717
<command> [<args>]
1818

@@ -194,6 +194,10 @@ If you just want to run git as if it was started in `<path>` then use
194194
--no-advice::
195195
Disable all advice hints from being printed.
196196

197+
--no-includes::
198+
Disable all `include.path` and `includeIf.*` config directives.
199+
See linkgit::git-config[1] for more information.
200+
197201
--literal-pathspecs::
198202
Treat pathspecs literally (i.e. no globbing, no pathspec magic).
199203
This is equivalent to setting the `GIT_LITERAL_PATHSPECS` environment

git.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const char git_usage_string[] =
4040
N_("git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]\n"
4141
" [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
4242
" [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--no-lazy-fetch]\n"
43-
" [--no-optional-locks] [--no-advice] [--bare] [--git-dir=<path>]\n"
43+
" [--no-optional-locks] [--no-advice] [--no-includes] [--bare] [--git-dir=<path>]\n"
4444
" [--work-tree=<path>] [--namespace=<name>] [--config-env=<name>=<envvar>]\n"
4545
" <command> [<args>]");
4646

@@ -354,6 +354,10 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
354354
setenv(GIT_ADVICE_ENVIRONMENT, "0", 1);
355355
if (envchanged)
356356
*envchanged = 1;
357+
} else if (!strcmp(cmd, "--no-includes")) {
358+
setenv(CONFIG_INCLUDES_ENVIRONMENT, "0", 1);
359+
if (envchanged)
360+
*envchanged = 1;
357361
} else {
358362
fprintf(stderr, _("unknown option: %s\n"), cmd);
359363
usage(git_usage_string);

t/t1305-config-include.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,11 @@ test_expect_success 'GIT_CONFIG_INCLUDES=0 disables include.path and includeIf'
409409
git config get foo.baz &&
410410
test_must_fail env GIT_CONFIG_INCLUDES=0 git config get foo.bar &&
411411
test_must_fail env GIT_CONFIG_INCLUDES=0 git config get foo.baz &&
412+
test_must_fail git --no-includes config get foo.bar &&
413+
test_must_fail git --no-includes config get foo.baz &&
412414
git config get --includes foo.bar &&
413-
test_must_fail env GIT_CONFIG_INCLUDES=0 git config get --includes foo.bar
415+
test_must_fail env GIT_CONFIG_INCLUDES=0 git config get --includes foo.bar &&
416+
test_must_fail git --no-includes config get --includes foo.bar
414417
)
415418
'
416419

@@ -423,7 +426,8 @@ test_expect_success 'GIT_CONFIG_INCLUDES=0 blocks included alias override' '
423426
git config set include.path config.inc &&
424427
git config set -f .git/config.inc alias.test status &&
425428
git test &&
426-
test_must_fail env GIT_CONFIG_INCLUDES=0 git test
429+
test_must_fail env GIT_CONFIG_INCLUDES=0 git test &&
430+
test_must_fail git --no-includes test
427431
)
428432
'
429433

0 commit comments

Comments
 (0)