← 返回首页
Handle relative `include.path` when root config is provided as a relative path by Copilot · Pull Request #2104 · gitpython-developers/GitPython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected Viewed files
Conversations
Failed to load comments. Retry
Loading
Jump to
Jump to file
Failed to load files. Retry
Loading
Diff view
Unified
Split
Hide whitespace
Apply and reload
Show whitespace
Diff view
Unified
Split
Hide whitespace
Apply and reload
3 changes: 2 additions & 1 deletion git/config.py
Show comments View file Edit file Delete file Open in desktop
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
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ def read(self) -> None: # type: ignore[override]
continue
# END ignore relative paths if we don't know the configuration file path
file_path = cast(PathLike, file_path)
assert osp.isabs(file_path), "Need absolute paths to be sure our cycle checks will work"
if not osp.isabs(file_path):
file_path = osp.abspath(file_path)
include_path = osp.join(osp.dirname(file_path), include_path)
# END make include path absolute
include_path = osp.normpath(include_path)
Expand Down
11 changes: 11 additions & 0 deletions test/test_config.py
Show comments View file Edit file Delete file Open in desktop
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
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ def check_test_value(cr, value):
with GitConfigParser(fpa, read_only=True) as cr:
check_test_value(cr, tv)

@with_rw_directory
def test_relative_include_with_relative_config_path(self, rw_dir):
fpa = osp.join(rw_dir, "a")
fpb = osp.join(rw_dir, "b")
with GitConfigParser(fpb, read_only=False) as cw:
cw.set_value("b", "value", "b")
with GitConfigParser(fpa, read_only=False) as cw:
cw.set_value("include", "path", "b")
with GitConfigParser(osp.relpath(fpa), read_only=True) as cr:
assert cr.get_value("b", "value") == "b"

@with_rw_directory
def test_multiple_include_paths_with_same_key(self, rw_dir):
"""Test that multiple 'path' entries under [include] are all respected.
Expand Down
Toggle all file notes Toggle all file annotations

Footer

© 2026 GitHub, Inc.