Skip to content

config: resolve relative includes from relative config paths#2123

Open
officialasishkumar wants to merge 1 commit intogitpython-developers:mainfrom
officialasishkumar:fix-relative-config-include
Open

config: resolve relative includes from relative config paths#2123
officialasishkumar wants to merge 1 commit intogitpython-developers:mainfrom
officialasishkumar:fix-relative-config-include

Conversation

@officialasishkumar
Copy link
Copy Markdown

Fixes #2103

Summary

  • Normalize path-based config inputs before using them for include cycle detection.
  • Resolve relative include.path entries from that normalized source path when the root config file was supplied as a relative path.
  • Add regression coverage with a relative root config and a relative include cycle.

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.py
  • git diff --check

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.
Copilot AI review requested due to automatic review settings April 11, 2026 19:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.path values 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Relative path include in .gitconfig throws AssertionError

2 participants