Skip to content

config: allow disabling config includes#2139

Open
derrickstolee wants to merge 3 commits into
gitgitgadget:masterfrom
derrickstolee:config-include-override
Open

config: allow disabling config includes#2139
derrickstolee wants to merge 3 commits into
gitgitgadget:masterfrom
derrickstolee:config-include-override

Conversation

@derrickstolee
Copy link
Copy Markdown

@derrickstolee derrickstolee commented Jun 4, 2026

This series introduces a new way to ignore config include directives via two mechanisms:

  • GIT_CONFIG_INCLUDES=0 in the environment.
  • git --no-includes ... in the command line.

My motivation is from a tricky situation where users want to do the risky thing and include a repo-tracked file for sharing aliases and other recommended config. They are then struggling in a later build step that is running Git commands (under a tool we don't control and can't change) that then cause filesystem accesses outside of the build system's sandbox.

While git config has a --no-includes option, that doesn't impact the behavior of other Git commands. We build upon that existing logic for disabling includes, though.

Having had recent luck recommending GIT_ADVICE=0 when running Git commands from third-party tools, I thought that a similar environment variable to disable this functionality would be helpful, too.

One thing I do worry about is whether or not this would cause a significant break in behavior, or if this is a relatively safe thing to allow.

The three patches are organized as follows:

  1. Patch 1 has a small typo fix in the config documentation that messes with the format of the bulleted list. I include it here because I add to that list in patch 2.
  2. Patch 2 adds the environment variable and tests it via 'git config' and the use of a Git alias.
  3. Patch 3 adds the '--no-includes' option at the top level.

Thanks,
-Stolee

cc: gitster@pobox.com

The bulletted list about environment variables is missing a '+' between
some paragraphs that belong to the same bullet item. Without it, the
bulletted list is rendered as two separate lists with "See also FILES."
as a normal paragraph between them. Adding '+' unifies the lists.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
@derrickstolee derrickstolee force-pushed the config-include-override branch from ad6549d to 31d173f Compare June 4, 2026 21:05
@derrickstolee derrickstolee changed the title Allow disabling config includes config: allow disabling config includes Jun 4, 2026
The config keys 'include.path' and 'includeIf.*' allow users to specify
config stored in a location outside of the typical list of config files
(system, global, local, etc.). For example, users who accept the risk
can specify helpful aliases via a file checked into the repo by pointing
'include.path' to the position of that file in the working directory.
This is dangerous, but people do it.

What becomes tricky is that this modifies all Git behavior, including
operations that are intended to be limited in activity or sandboxed in
some way. These include directives can provide surprising changes to
behavior, especially when expecting a specific list of allowed file
accesses. This could lead to failed builds, for instance.

To allow for these user-desired features when they are running commands,
add a new GIT_CONFIG_INCLUDES environment variable that disables these
redirections of config when set to zero. This variable can be set by
automation, such as build tooling, to avoid these strange behaviors.
This could be considered a recommended option for tools executing Git
commands, the same as GIT_ADVICE=0.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
@derrickstolee derrickstolee force-pushed the config-include-override branch from 31d173f to daa9564 Compare June 4, 2026 21:15
@derrickstolee derrickstolee marked this pull request as ready for review June 4, 2026 21:15
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>
@derrickstolee derrickstolee force-pushed the config-include-override branch from daa9564 to 1b4ae3c Compare June 4, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant