[RFC PATCH 05/13] b4: normalise git-reported absolute paths with os.path.normpath
Adrian Neftali Sanchez <[email protected]>
| Newsgroups | org.kernel.linux.tools |
|---|---|
| Message-ID | <[email protected]> |
git rev-parse --git-common-dir emits forward-slash paths on Windows even though the OS uses backslashes. Pass the result through os.path.normpath so all callers receive a path in the native format on every platform. Signed-off-by: Adrian Neftali Sanchez <[email protected]> --- src/b4/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/b4/__init__.py b/src/b4/__init__.py index bddf2db..262668f 100644 --- a/src/b4/__init__.py +++ b/src/b4/__init__.py @@ -4534,6 +4534,11 @@ def git_get_common_dir(path: Optional[str] = None) -> Optional[str]: topdir = git_get_toplevel(path) if topdir: result = os.path.normpath(os.path.join(topdir, result)) + else: + # Normalize absolute paths to use the OS-native separator. + # On Windows, git outputs forward-slash paths; normpath converts + # them to backslashes so all callers see a consistent format. + result = os.path.normpath(result) return result return None -- 2.45.0.windows.1