You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The git.Client tests build much of Git's output themselves, so they mostly describe the fake process rather than repository behaviour. Their subprocess helpers also discard the environment needed by Go's coverage instrumentation.
This PR adds a temporary-repository harness and converts the branch, configuration, working-tree, remote-resolution and ignore scenarios to real Git. It also isolates inherited repository and configuration settings so test writes stay in test-owned files.
How did you test this change?
Not tested manually. This changes test infrastructure rather than user-facing command behaviour.
Key points
IsolateConfig clears inherited repository, index, object, template and configuration routing, then restores the original environment during cleanup.
The containment scenarios check that separate repositories and configuration files remain unchanged.
Repository tests stay serial because configuration isolation changes the process environment.
The remaining subprocess helpers inherit the coverage environment. Later layers remove those mock protocols.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The repository test harness still inherits the operator’s default Git ignore file, allowing personal ignore rules to break tests unless core.excludesFile points to a test-owned empty file.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Unbounded repository discovery and unisolated default global attributes leave the tests dependent on ambient Git state, causing environment-dependent failures.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Bound Git discovery to isolate non-repository test
git/client_test.go:2227
🛑 Requirement: Bound repository discovery in the non-repository test
If TMPDIR points inside a checkout, the temporary directory is still within that worktree. Git discovers the parent repository, especially since IsolateConfig clears GIT_CEILING_DIRECTORIES, so checking an unignored path returns no error and the subsequent require.Error fails. Set a discovery ceiling at the temporary directory's parent so this scenario reliably exercises the fatal non-repository path without reading an ambient repository.
Isolate Git global attributes from caller configuration
git/test.go:51
🛑 Requirement: Isolate the default global attributes file too
Setting GIT_CONFIG_GLOBAL does not disable Git's default $XDG_CONFIG_HOME/git/attributes (or ~/.config/git/attributes). For example, an inherited '*.txt working-tree-encoding=UTF-16' rule makes the new working-tree scenario fail at git add tracked.txt because its fixture lacks a UTF-16 BOM. Point core.attributesFile at the test-owned empty file too, so these real-Git tests do not depend on the caller's global attributes.
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
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.
Description
Relates to #14349
The
git.Clienttests build much of Git's output themselves, so they mostly describe the fake process rather than repository behaviour. Their subprocess helpers also discard the environment needed by Go's coverage instrumentation.This PR adds a temporary-repository harness and converts the branch, configuration, working-tree, remote-resolution and ignore scenarios to real Git. It also isolates inherited repository and configuration settings so test writes stay in test-owned files.
How did you test this change?
Not tested manually. This changes test infrastructure rather than user-facing command behaviour.
Key points
IsolateConfigclears inherited repository, index, object, template and configuration routing, then restores the original environment during cleanup.Notes for reviewers
Start with
IsolateConfigand its containment scenarios, then readnewTestRepoand the converted scenarios.This is the bottom of the existing stack. #14349 builds the graph and worktree scenarios on this harness.
Authorship and follow-up
Who wrote this:
Who answers review comments: