From 26fbad62229a5f4b3e422c67d96e4d152dfaee2d Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Singh Date: Thu, 10 Oct 2019 18:06:26 +0530 Subject: [PATCH 1/2] Fixed#731 Added check for local file url starting with `$HOME` / `~` to expand them using `os.path.expanduser`. --- git/cmd.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/git/cmd.py b/git/cmd.py index 50b1e3212..d07af4521 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -330,6 +330,10 @@ def polish_url(cls, url, is_cygwin=None): but git stops liking them as it will escape the backslashes. Hence we undo the escaping just to be sure. """ + if url.startswith('$HOME/'): + url = url.replace('$HOME/', '~/') + if url.startswith('~'): + url = os.path.expanduser(url) url = url.replace("\\\\", "\\").replace("\\", "/") return url From 942f46709dc25e524b6d8e65f74d12f1b52e5dc9 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Singh Date: Wed, 16 Oct 2019 21:57:51 +0530 Subject: [PATCH 2/2] Update cmd.py --- git/cmd.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/git/cmd.py b/git/cmd.py index d07af4521..d41f8f89a 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -330,8 +330,7 @@ def polish_url(cls, url, is_cygwin=None): but git stops liking them as it will escape the backslashes. Hence we undo the escaping just to be sure. """ - if url.startswith('$HOME/'): - url = url.replace('$HOME/', '~/') + url = os.path.expandvars(url) if url.startswith('~'): url = os.path.expanduser(url) url = url.replace("\\\\", "\\").replace("\\", "/")