config: allow disabling config includes#2139
Open
derrickstolee wants to merge 3 commits into
Open
Conversation
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>
ad6549d to
31d173f
Compare
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>
31d173f to
daa9564
Compare
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>
daa9564 to
1b4ae3c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This series introduces a new way to ignore config include directives via two mechanisms:
GIT_CONFIG_INCLUDES=0in 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 confighas a--no-includesoption, 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=0when 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:
Thanks,
-Stolee
cc: gitster@pobox.com