Skip to content

Commit 685c954

Browse files
committed
mingw: demonstrate a problem with certain absolute paths
On Windows, there are several categories of absolute paths. One such category starts with a backslash and is implicitly relative to the drive associated with the current working directory. Example: c: git clone https://github.com/git-for-windows/git \G4W should clone into C:\G4W. There is currently a problem with that, in that mingw_mktemp() does not expect the _wmktemp() function to prefix the absolute path with the drive prefix, and as a consequence, the resulting path does not fit into the originally-passed string buffer. The symptom is a "Result too large" error. Reported by Juan Carlos Arevalo Baeza. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 9595243 commit 685c954

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

t/t5580-clone-push-unc.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
11
#!/bin/sh
22

3-
test_description='various UNC path tests (Windows-only)'
3+
test_description='various Windows path tests'
44
. ./test-lib.sh
55

66
if ! test_have_prereq MINGW; then
7-
skip_all='skipping UNC path tests, requires Windows'
7+
skip_all='skipping Windows-specific path tests'
88
test_done
99
fi
1010

1111
UNCPATH="$(pwd)"
1212
case "$UNCPATH" in
1313
[A-Z]:*)
14+
WITHOUTDRIVE="${UNCPATH#?:}"
1415
# Use administrative share e.g. \\localhost\C$\git-sdk-64\usr\src\git
1516
# (we use forward slashes here because MSYS2 and Git accept them, and
1617
# they are easier on the eyes)
17-
UNCPATH="//localhost/${UNCPATH%%:*}\$/${UNCPATH#?:}"
18-
test -d "$UNCPATH" || {
19-
skip_all='could not access administrative share; skipping'
20-
test_done
21-
}
18+
UNCPATH="//localhost/${UNCPATH%%:*}\$$WITHOUTDRIVE"
2219
;;
2320
*)
2421
skip_all='skipping UNC path tests, cannot determine current path as UNC'
2522
test_done
2623
;;
2724
esac
2825

26+
test_expect_failure 'clone into absolute path lacking a drive prefix' '
27+
USINGBACKSLASHES="$(echo "$WITHOUTDRIVE"/without-drive-prefix |
28+
tr / \\)" &&
29+
git clone . "$USINGBACKSLASHES" &&
30+
test -f without-drive-prefix/.git/HEAD
31+
'
32+
33+
test -d "$UNCPATH" || {
34+
skip_all='could not access administrative share; skipping'
35+
test_done
36+
}
37+
2938
test_expect_success setup '
3039
test_commit initial
3140
'

0 commit comments

Comments
 (0)