Skip to content

Commit 5e12a91

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 9cbc716 commit 5e12a91

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Diff for: compat/mingw.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -1141,11 +1141,19 @@ unsigned int sleep (unsigned int seconds)
11411141
char *mingw_mktemp(char *template)
11421142
{
11431143
wchar_t wtemplate[MAX_PATH];
1144+
int offset = 0;
1145+
11441146
if (xutftowcs_path(wtemplate, template) < 0)
11451147
return NULL;
1148+
1149+
if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
1150+
iswalpha(wtemplate[0]) && wtemplate[1] == L':') {
1151+
/* We have an absolute path missing the drive prefix */
1152+
offset = 2;
1153+
}
11461154
if (!_wmktemp(wtemplate))
11471155
return NULL;
1148-
if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0)
1156+
if (xwcstoutf(template, wtemplate + offset, strlen(template) + 1) < 0)
11491157
return NULL;
11501158
return template;
11511159
}

Diff for: t/t5580-unc-paths.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ case "$UNCPATH" in
3232
;;
3333
esac
3434

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

0 commit comments

Comments
 (0)