Skip to content

Commit 8ba105d

Browse files
committed
Merge branch 'jl/maint-1.7.10-recurse-submodules-with-symlink' into maint
When "git submodule add" clones a submodule repository, it can get confused where to store the resulting submodule repository in the superproject's .git/ directory when there is a symbolic link in the path to the current directory. * jl/maint-1.7.10-recurse-submodules-with-symlink: submodules: don't stumble over symbolic links when cloning recursively
2 parents 80ffb75 + 6eafa6d commit 8ba105d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

git-submodule.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ module_clone()
150150
die "$(eval_gettext "Clone of '\$url' into submodule path '\$sm_path' failed")"
151151
fi
152152

153-
a=$(cd "$gitdir" && pwd)/
154-
b=$(cd "$sm_path" && pwd)/
153+
# We already are at the root of the work tree but cd_to_toplevel will
154+
# resolve any symlinks that might be present in $PWD
155+
a=$(cd_to_toplevel && cd "$gitdir" && pwd)/
156+
b=$(cd_to_toplevel && cd "$sm_path" && pwd)/
155157
# normalize Windows-style absolute paths to POSIX-style absolute paths
156158
case $a in [a-zA-Z]:/*) a=/${a%%:*}${a#*:} ;; esac
157159
case $b in [a-zA-Z]:/*) b=/${b%%:*}${b#*:} ;; esac

t/t7406-submodule-update.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,4 +636,17 @@ test_expect_success 'submodule update properly revives a moved submodule' '
636636
)
637637
'
638638

639+
test_expect_success SYMLINKS 'submodule update can handle symbolic links in pwd' '
640+
mkdir -p linked/dir &&
641+
ln -s linked/dir linkto &&
642+
(
643+
cd linkto &&
644+
git clone "$TRASH_DIRECTORY"/super_update_r2 super &&
645+
(
646+
cd super &&
647+
git submodule update --init --recursive
648+
)
649+
)
650+
'
651+
639652
test_done

0 commit comments

Comments
 (0)