config: resolve relative includes from relative config paths#2123
Open
officialasishkumar wants to merge 1 commit intogitpython-developers:mainfrom
Open
config: resolve relative includes from relative config paths#2123officialasishkumar wants to merge 1 commit intogitpython-developers:mainfrom
officialasishkumar wants to merge 1 commit intogitpython-developers:mainfrom
Conversation
Normalize path-based config inputs before using them for include cycle checks. This lets GitConfigParser resolve relative include.path values when the root config file was provided as a relative path, without re-reading the same config under a different spelling. Add regression coverage with a relative root config and a relative include cycle.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes relative [include] path = ... handling when the root config file is provided as a relative path (regression for #2103), by normalizing config file paths for both include-cycle detection and relative-include resolution.
Changes:
- Normalize initial config file inputs to absolute, normalized paths for include cycle detection.
- Resolve relative
include.pathvalues using the normalized absolute source config path (instead of asserting the source path is already absolute). - Add a regression test covering a relative root config path with a relative include cycle.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
git/config.py |
Normalizes config paths for seen and uses an absolute source path to resolve relative include paths without asserting the caller provided an absolute root path. |
test/test_config.py |
Adds a regression test ensuring relative root config paths correctly resolve relative includes and avoid include-cycle failures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fixes #2103
Summary
include.pathentries from that normalized source path when the root config file was supplied as a relative path.Testing
.venv/bin/pytest --no-cov -q test/test_config.py.venv/bin/pytest --no-cov -q test/test_config.py test/test_repo.py::TestRepo::test_config_reader.venv/bin/pytest --no-cov -q test/test_refs.py::TestRefs::test_set_tracking_branch_with_import.venv/bin/ruff check git/config.py test/test_config.py.venv/bin/ruff format --check git/config.py test/test_config.py.venv/bin/mypy git/config.pygit diff --check