Skip to content

Commit 70718c9

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 1863e40 commit 70718c9

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
@@ -980,11 +980,19 @@ unsigned int sleep (unsigned int seconds)
980980
char *mingw_mktemp(char *template)
981981
{
982982
wchar_t wtemplate[MAX_PATH];
983+
int offset = 0;
984+
983985
if (xutftowcs_path(wtemplate, template) < 0)
984986
return NULL;
987+
988+
if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
989+
iswalpha(wtemplate[0]) && wtemplate[1] == L':') {
990+
/* We have an absolute path missing the drive prefix */
991+
offset = 2;
992+
}
985993
if (!_wmktemp(wtemplate))
986994
return NULL;
987-
if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0)
995+
if (xwcstoutf(template, wtemplate + offset, strlen(template) + 1) < 0)
988996
return NULL;
989997
return template;
990998
}

t/t5580-unc-paths.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ case "$UNCPATH" in
2929
;;
3030
esac
3131

32-
test_expect_failure 'clone into absolute path lacking a drive prefix' '
32+
test_expect_success 'clone into absolute path lacking a drive prefix' '
3333
USINGBACKSLASHES="$(echo "$WITHOUTDRIVE"/without-drive-prefix |
3434
tr / \\\\)" &&
3535
git clone . "$USINGBACKSLASHES" &&

0 commit comments

Comments
 (0)