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

Re: [PATCH 0/2] submodules: Use relative paths to gitdir and work tree

From
Johannes Sixt <j6t@kdbg.org>
Date
Feb 26, 2012, 17:38 UTC
Message-ID
<4F4A6DFA.5080709@kdbg.org>
In-Reply-To
<4F32F252.7050105@web.de>
Am 08.02.2012 23:08, schrieb Jens Lehmann:
Show 11 quoted lines
> This patch series replaces all absolute paths pointing from submodule work
> trees to its gitdir and back with relative paths as discussed in $gmane/187785.
> 
> The motivation is to make superprojects movable again. They lost this ability
> with the move of the git directory of submodules into the .git/modules directory
> of the superproject. While fixing that a bug which would hit when moving the
> submodule inside the superproject was also fixed.
> 
> Jens Lehmann (2):
>   submodules: always use a relative path to gitdir
>   submodules: always use a relative path from gitdir to work tree

This series, with the tip at e3307adaba in Junio's repo causes major headaches on Windows.

First, a check for an absolute path must be extended to take Windows-style paths into account.

Second, the a's and b's are filled with different forms of absolute paths (/c/there vs. c:/there), and as a consequence the subsequent loops do not find a suitable relative path.

The below is a minimal hack that passes all t/*submod* tests, but it works only on Windows, where the pwd utility has an option -W that prints a Windows style absolute path.

How would you have this solved? One option would be to introduce a function
  pwd() { builtin pwd -W "$@"; }

in git-sh-setup conditionally on Windows (but that would affect other shell scripts, too).

Any other ideas?
diff --git a/git-submodule.sh b/git-submodule.sh
index 3463d6d..f37745e 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -139,8 +139,8 @@ module_clone()
 	gitdir="$gitdir/modules/$path"

 	case $gitdir in
-	/*)
-		a="$(cd_to_toplevel && pwd)/"
+	/* | [a-z]:/*)
+		a="$(cd_to_toplevel && pwd -W)/"
 		b=$gitdir
 		while [ "$b" ] && [ "${a%%/*}" = "${b%%/*}" ]
 		do
@@ -170,8 +170,8 @@ module_clone()

 	echo "gitdir: $rel_gitdir" >"$path/.git"

-	a=$(cd "$gitdir" && pwd)
-	b=$(cd "$path" && pwd)
+	a=$(cd "$gitdir" && pwd -W)
+	b=$(cd "$path" && pwd -W)
 	while [ "$b" ] && [ "${a%%/*}" = "${b%%/*}" ]
 	do
 		a=${a#*/} b=${b#*/};
-- 
1.7.8.216.g2e426
Previous: Jens LehmannNext: Jens Lehmann
Message 14 of 21 in “submodules: Use relative paths to gitdir and work tree”
  1. 0/2 submodules: Use relative paths to gitdir and work treeJens Lehmann, Feb 8, 2012
  2. 1/2 submodules: always use a relative path to gitdirJens Lehmann, Feb 8, 2012
  3. 1/2 submodules: always use a relative path to gitdirJens Lehmann, Feb 9, 2012
  4. Junio C HamanoFeb 9, 2012
  5. Junio C HamanoFeb 9, 2012
  6. Jens LehmannFeb 9, 2012
  7. 2/2 submodules: always use a relative path from gitdir to work treeJens Lehmann, Feb 8, 2012
  8. 2/2 submodules: always use a relative path from gitdir to work treeJens Lehmann, Feb 9, 2012
  9. Junio C HamanoFeb 13, 2012
  10. Jens LehmannFeb 14, 2012
  11. Junio C HamanoFeb 14, 2012
  12. Junio C HamanoFeb 14, 2012
  13. Jens LehmannFeb 15, 2012
  14. Johannes SixtFeb 26, 2012
  15. Jens LehmannFeb 26, 2012
  16. Johannes SixtFeb 27, 2012
  17. Johannes SchindelinFeb 27, 2012
  18. Johannes SixtFeb 28, 2012
  19. Junio C HamanoFeb 28, 2012
  20. Jens LehmannFeb 28, 2012
  21. Jens LehmannFeb 28, 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.