Skip to content

Commit fad23e9

Browse files
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 <johannes.schindelin@gmx.de>
1 parent 8d7bc1b commit fad23e9

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
@@ -948,12 +948,20 @@ unsigned int sleep (unsigned int seconds)
948948
char *mingw_mktemp(char *template)
949949
{
950950
wchar_t wtemplate[MAX_PATH];
951+
int offset = 0;
952+
951953
/* we need to return the path, thus no long paths here! */
952954
if (xutftowcs_path(wtemplate, template) < 0)
953955
return NULL;
956+
957+
if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
958+
iswalpha(wtemplate[0]) && wtemplate[1] == L':') {
959+
/* We have an absolute path missing the drive prefix */
960+
offset = 2;
961+
}
954962
if (!_wmktemp(wtemplate))
955963
return NULL;
956-
if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0)
964+
if (xwcstoutf(template, wtemplate + offset, strlen(template) + 1) < 0)
957965
return NULL;
958966
return template;
959967
}

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)