submodules: don't stumble over symbolic links when cloning recursively
[gitweb.git] / git-submodule.sh
index 3d94a14079ccf745b3cf3d5d5a4e471f9b5542bc..61f3b72e32ec31973c225a8534ccf3e34cc604cd 100755 (executable)
@@ -149,8 +149,10 @@ module_clone()
                die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")"
        fi
 
-       a=$(cd "$gitdir" && pwd)/
-       b=$(cd "$path" && pwd)/
+       # We already are at the root of the work tree but cd_to_toplevel will
+       # resolve any symlinks that might be present in $PWD
+       a=$(cd_to_toplevel && cd "$gitdir" && pwd)/
+       b=$(cd_to_toplevel && 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