Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion git/config.py
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
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