Skip to content

Commit 4097c1d

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 <[email protected]>
1 parent 5278695 commit 4097c1d

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
@@ -1074,11 +1074,19 @@ unsigned int sleep (unsigned int seconds)
10741074
char *mingw_mktemp(char *template)
10751075
{
10761076
wchar_t wtemplate[MAX_PATH];
1077+
int offset = 0;
1078+
10771079
if (xutftowcs_path(wtemplate, template) < 0)
10781080
return NULL;
1081+
1082+
if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
1083+
iswalpha(wtemplate[0]) && wtemplate[1] == L':') {
1084+
/* We have an absolute path missing the drive prefix */
1085+
offset = 2;
1086+
}
10791087
if (!_wmktemp(wtemplate))
10801088
return NULL;
1081-
if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0)
1089+
if (xwcstoutf(template, wtemplate + offset, strlen(template) + 1) < 0)
10821090
return NULL;
10831091
return template;
10841092
}

t/t5580-unc-paths.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ case "$UNCPATH" in
3333
;;
3434
esac
3535

36-
test_expect_failure 'clone into absolute path lacking a drive prefix' '
36+
test_expect_success 'clone into absolute path lacking a drive prefix' '
3737
USINGBACKSLASHES="$(echo "$WITHOUTDRIVE"/without-drive-prefix |
3838
tr / \\\\)" &&
3939
git clone . "$USINGBACKSLASHES" &&

0 commit comments

Comments
 (0)