Skip to content

Commit 2375bc0

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 f28b9f2 commit 2375bc0

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
@@ -806,12 +806,20 @@ unsigned int sleep (unsigned int seconds)
806806
char *mingw_mktemp(char *template)
807807
{
808808
wchar_t wtemplate[MAX_PATH];
809+
int offset = 0;
810+
809811
/* we need to return the path, thus no long paths here! */
810812
if (xutftowcs_path(wtemplate, template) < 0)
811813
return NULL;
814+
815+
if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
816+
iswalpha(wtemplate[0]) && wtemplate[1] == L':') {
817+
/* We have an absolute path missing the drive prefix */
818+
offset = 2;
819+
}
812820
if (!_wmktemp(wtemplate))
813821
return NULL;
814-
if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0)
822+
if (xwcstoutf(template, wtemplate + offset, strlen(template) + 1) < 0)
815823
return NULL;
816824
return template;
817825
}

t/t5580-clone-push-unc.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)