Skip to content

Commit b4379e6

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 118d5e5 commit b4379e6

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
@@ -817,12 +817,20 @@ unsigned int sleep (unsigned int seconds)
817817
char *mingw_mktemp(char *template)
818818
{
819819
wchar_t wtemplate[MAX_PATH];
820+
int offset = 0;
821+
820822
/* we need to return the path, thus no long paths here! */
821823
if (xutftowcs_path(wtemplate, template) < 0)
822824
return NULL;
825+
826+
if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
827+
iswalpha(wtemplate[0]) && wtemplate[1] == L':') {
828+
/* We have an absolute path missing the drive prefix */
829+
offset = 2;
830+
}
823831
if (!_wmktemp(wtemplate))
824832
return NULL;
825-
if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0)
833+
if (xwcstoutf(template, wtemplate + offset, strlen(template) + 1) < 0)
826834
return NULL;
827835
return template;
828836
}

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)