git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] mingw: demonstrate a problem with certain absolute paths

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 10, 2018, 18:47 UTC
Message-ID
<09a73fe1d30c9fedc2f010fe4df75a9cb000389c.1544467631.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.96.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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 <johannes.schindelin@gmx.de>
---
 t/t5580-clone-push-unc.sh | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/t/t5580-clone-push-unc.sh b/t/t5580-clone-push-unc.sh
index ba548df4a9..c2b0082296 100755
--- a/t/t5580-clone-push-unc.sh
+++ b/t/t5580-clone-push-unc.sh
@@ -17,14 +17,11 @@ fi
 UNCPATH="$(winpwd)"
 case "$UNCPATH" in
 [A-Z]:*)
+	WITHOUTDRIVE="${UNCPATH#?:}"
 	# Use administrative share e.g. \\localhost\C$\git-sdk-64\usr\src\git
 	# (we use forward slashes here because MSYS2 and Git accept them, and
 	# they are easier on the eyes)
-	UNCPATH="//localhost/${UNCPATH%%:*}\$/${UNCPATH#?:}"
-	test -d "$UNCPATH" || {
-		skip_all='could not access administrative share; skipping'
-		test_done
-	}
+	UNCPATH="//localhost/${UNCPATH%%:*}\$$WITHOUTDRIVE"
 	;;
 *)
 	skip_all='skipping UNC path tests, cannot determine current path as UNC'
@@ -32,6 +29,18 @@ case "$UNCPATH" in
 	;;
 esac
 
+test_expect_failure 'clone into absolute path lacking a drive prefix' '
+	USINGBACKSLASHES="$(echo "$WITHOUTDRIVE"/without-drive-prefix |
+		tr / \\\\)" &&
+	git clone . "$USINGBACKSLASHES" &&
+	test -f without-drive-prefix/.git/HEAD
+'
+
+test -d "$UNCPATH" || {
+	skip_all='could not access administrative share; skipping'
+	test_done
+}
+
 test_expect_success setup '
 	test_commit initial
 '
-- 
gitgitgadget
Previous: Johannes Schindelin
Message 10 of 10 in “mingw: support absolute paths without a drive prefix”
  1. 0/2 mingw: support absolute paths without a drive prefixJohannes Schindelin via GitGitGadget, Dec 10, 2018
  2. 2/2 mingw: allow absolute paths without drive prefixJohannes Schindelin via GitGitGadget, Dec 10, 2018
  3. Johannes SixtDec 10, 2018
  4. Johannes SchindelinDec 11, 2018
  5. Johannes SixtDec 11, 2018
  6. Junio C HamanoDec 13, 2018
  7. Johannes SixtDec 13, 2018
  8. Johannes SixtDec 13, 2018
  9. Johannes SchindelinDec 14, 2018
  10. 1/2 mingw: demonstrate a problem with certain absolute pathsJohannes Schindelin via GitGitGadget, Dec 10, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.