Skip to content

Commit 1e6abbf

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 21e16ba commit 1e6abbf

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
@@ -854,12 +854,20 @@ unsigned int sleep (unsigned int seconds)
854854
char *mingw_mktemp(char *template)
855855
{
856856
wchar_t wtemplate[MAX_PATH];
857+
int offset = 0;
858+
857859
/* we need to return the path, thus no long paths here! */
858860
if (xutftowcs_path(wtemplate, template) < 0)
859861
return NULL;
862+
863+
if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
864+
iswalpha(wtemplate[0]) && wtemplate[1] == L':') {
865+
/* We have an absolute path missing the drive prefix */
866+
offset = 2;
867+
}
860868
if (!_wmktemp(wtemplate))
861869
return NULL;
862-
if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0)
870+
if (xwcstoutf(template, wtemplate + offset, strlen(template) + 1) < 0)
863871
return NULL;
864872
return template;
865873
}

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)