From 09925a2587130ec413828fe7ad94f4e206c1f390 Mon Sep 17 00:00:00 2001 From: Thorsten Klein Date: Fri, 13 Nov 2026 04:01:46 +0100 Subject: [PATCH] fix: resolve relative submodule urls against a Windows path A local remote on Windows can have backslashes. posixpath took the whole path as one name, so `../foo` became just `foo`. --- src/git_nested/submodules.py | 3 +++ tests/unit/test_helpers.py | 1 + 2 files changed, 4 insertions(+) diff --git a/src/git_nested/submodules.py b/src/git_nested/submodules.py index 008ad44c..67d0c1a7 100644 --- a/src/git_nested/submodules.py +++ b/src/git_nested/submodules.py @@ -55,6 +55,9 @@ def resolve(url: str, base: str) -> str: if not url.startswith(('./', '../')): return url scheme, sep, rest = base.rpartition('://') + if not sep: + # A local path. On Windows it may have backslashes, which posixpath takes as part of a name. + rest = rest.replace('\\', '/') return f'{scheme}{sep}{posixpath.normpath(posixpath.join(rest, url))}' diff --git a/tests/unit/test_helpers.py b/tests/unit/test_helpers.py index 7eade055..84cc4286 100644 --- a/tests/unit/test_helpers.py +++ b/tests/unit/test_helpers.py @@ -277,6 +277,7 @@ def test_gitnested_is_written_with_lf(tmp_path): ('./foo.git', '/srv/git/bar.git', '/srv/git/bar.git/foo.git'), ('../foo.git', 'https://example.com/group/bar.git', 'https://example.com/group/foo.git'), ('https://example.com/x.git', '/srv/git/bar.git', 'https://example.com/x.git'), + ('../foo', 'D:\\a\\upstream\\bar', 'D:/a/upstream/foo'), ], ) def test_a_relative_submodule_url_is_resolved_like_git_does(url, base, resolved):