Skip to content

Commit 33b0cee

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 <johannes.schindelin@gmx.de>
1 parent 09a73fe commit 33b0cee

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

compat/mingw.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -928,11 +928,20 @@ unsigned int sleep (unsigned int seconds)
928928
char *mingw_mktemp(char *template)
929929
{
930930
wchar_t wtemplate[MAX_PATH];
931+
int offset = 0;
932+
931933
if (xutftowcs_path(wtemplate, template) < 0)
932934
return NULL;
935+
936+
if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
937+
wtemplate[0] < 127 && isalpha((char)wtemplate[0]) &&
938+
wtemplate[1] == L':') {
939+
/* We have an absolute path missing the drive prefix */
940+
offset = 2;
941+
}
933942
if (!_wmktemp(wtemplate))
934943
return NULL;
935-
if (xwcstoutf(template, wtemplate, strlen(template) + 1) < 0)
944+
if (xwcstoutf(template, wtemplate + offset, strlen(template) + 1) < 0)
936945
return NULL;
937946
return template;
938947
}

t/t5580-clone-push-unc.sh

+1-1
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)