Skip to content

Commit 5d96ded

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 5501b4a commit 5d96ded

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

t/t5580-unc-paths.sh

+14-5
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,30 @@ fi
2121
UNCPATH="$(winpwd)"
2222
case "$UNCPATH" in
2323
[A-Z]:*)
24+
WITHOUTDRIVE="${UNCPATH#?:}"
2425
# Use administrative share e.g. \\localhost\C$\git-sdk-64\usr\src\git
2526
# (we use forward slashes here because MSYS2 and Git accept them, and
2627
# they are easier on the eyes)
27-
UNCPATH="//localhost/${UNCPATH%%:*}\$/${UNCPATH#?:}"
28-
test -d "$UNCPATH" || {
29-
skip_all='could not access administrative share; skipping'
30-
test_done
31-
}
28+
UNCPATH="//localhost/${UNCPATH%%:*}\$$WITHOUTDRIVE"
3229
;;
3330
*)
3431
skip_all='skipping UNC path tests, cannot determine current path as UNC'
3532
test_done
3633
;;
3734
esac
3835

36+
test_expect_failure 'clone into absolute path lacking a drive prefix' '
37+
USINGBACKSLASHES="$(echo "$WITHOUTDRIVE"/without-drive-prefix |
38+
tr / \\\\)" &&
39+
git clone . "$USINGBACKSLASHES" &&
40+
test -f without-drive-prefix/.git/HEAD
41+
'
42+
43+
test -d "$UNCPATH" || {
44+
skip_all='could not access administrative share; skipping'
45+
test_done
46+
}
47+
3948
test_expect_success setup '
4049
test_commit initial
4150
'

0 commit comments

Comments
 (0)