Skip to content

Commit dceab3c

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 7e2f84e commit dceab3c

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
@@ -1059,11 +1059,19 @@ unsigned int sleep (unsigned int seconds)
10591059
char *mingw_mktemp(char *template)
10601060
{
10611061
wchar_t wtemplate[MAX_PATH];
1062+
int offset = 0;
1063+
10621064
if (xutftowcs_path(wtemplate, template) < 0)
10631065
return NULL;
1066+
1067+
if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
1068+
iswalpha(wtemplate[0]) && wtemplate[1] == L':') {
1069+
/* We have an absolute path missing the drive prefix */
1070+
offset = 2;
1071+
}
10641072
if (!_wmktemp(wtemplate))
10651073
return NULL;
1066-
if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0)
1074+
if (xwcstoutf(template, wtemplate + offset, strlen(template) + 1) < 0)
10671075
return NULL;
10681076
return template;
10691077
}

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)