Skip to content

Commit 4c3074c

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
mingw: allow absolute paths without drive prefix
When specifying an absolute path without a drive prefix, we convert that path internally. Let's make sure that we handle that case properly, too ;-) This fixes the command git clone https://github.com/git-for-windows/git \G4W Signed-off-by: Johannes Schindelin <[email protected]>
1 parent b8ef56e commit 4c3074c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

compat/mingw.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,12 +804,20 @@ unsigned int sleep (unsigned int seconds)
804804
char *mingw_mktemp(char *template)
805805
{
806806
wchar_t wtemplate[MAX_PATH];
807+
int offset = 0;
808+
807809
/* we need to return the path, thus no long paths here! */
808810
if (xutftowcs_path(wtemplate, template) < 0)
809811
return NULL;
812+
813+
if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
814+
iswalpha(wtemplate[0]) && wtemplate[1] == L':') {
815+
/* We have an absolute path missing the drive prefix */
816+
offset = 2;
817+
}
810818
if (!_wmktemp(wtemplate))
811819
return NULL;
812-
if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0)
820+
if (xwcstoutf(template, wtemplate + offset, strlen(template) + 1) < 0)
813821
return NULL;
814822
return template;
815823
}

t/t5580-clone-push-unc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ case "$UNCPATH" in
2323
;;
2424
esac
2525

26-
test_expect_failure 'clone into absolute path lacking a drive prefix' '
26+
test_expect_success 'clone into absolute path lacking a drive prefix' '
2727
USINGBACKSLASHES="$(echo "$WITHOUTDRIVE"/without-drive-prefix |
2828
tr / \\)" &&
2929
git clone . "$USINGBACKSLASHES" &&

0 commit comments

Comments
 (0)