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

[PATCH v3 4/4] submodules: fix ambiguous absolute paths under Windows

From
Jens Lehmann <jens.lehmann@web.de>
Date
Mar 4, 2012, 21:16 UTC
Message-ID
<4F53DBA3.4010500@web.de>
In-Reply-To
<4F53DA95.2020402@web.de>
From: Johannes Sixt <j6t@kdbg.org>

Under Windows the "git rev-parse --git-dir" and "pwd" commands may return either drive-letter-colon or POSIX style paths. This makes module_clone() behave badly because it expects absolute paths to always start with a '/'.

Fix that by always converting the "c:/" notation into "/c/" when computing the relative paths from gitdir to the submodule work tree and back.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 git-submodule.sh |    3 +++
 1 file changed, 3 insertions(+)
diff --git a/git-submodule.sh b/git-submodule.sh
index a9e9822..efc86ad 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -151,6 +151,9 @@ module_clone()

 	a=$(cd "$gitdir" && pwd)/
 	b=$(cd "$path" && pwd)/
+	# normalize Windows-style absolute paths to POSIX-style absolute paths
+	case $a in [a-zA-Z]:/*) a=/${a%%:*}${a#*:} ;; esac
+	case $b in [a-zA-Z]:/*) b=/${b%%:*}${b#*:} ;; esac
 	# Remove all common leading directories after a sanity check
 	if test "${a#$b}" != "$a" || test "${b#$a}" != "$b"; then
 		die "$(eval_gettext "Gitdir '\$a' is part of the submodule path '\$b' or vice versa")"
-- 
1.7.9.2.362.g684a8
Previous: Jens LehmannNext: Junio C Hamano
Message 5 of 7 in “submodules: Use relative paths to gitdir and work tree”
  1. 0/4 submodules: Use relative paths to gitdir and work treeJens Lehmann, Mar 4, 2012
  2. 1/4 submodules: always use a relative path to gitdirJens Lehmann, Mar 4, 2012
  3. 2/4 submodules: always use a relative path from gitdir to work treeJens Lehmann, Mar 4, 2012
  4. 3/4 submodules: refactor computation of relative gitdir pathJens Lehmann, Mar 4, 2012
  5. 4/4 submodules: fix ambiguous absolute paths under WindowsJens Lehmann, Mar 4, 2012
  6. Junio C HamanoMar 7, 2012
  7. Johannes SixtMar 7, 2012

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.