Skip to content

Commit 3fea121

Browse files
stefanbellergitster
authored andcommitted
recursive submodules: test for relative paths
"git submodule update --init --recursive" uses full path to refer to the true location of the repository in the "gitdir:" pointer for nested submodules; the command used to use relative paths. This was reported by Norio Nomura in $gmane/290280. The root cause for that bug is in using recursive submodules as their relative path handling was broken in ee8838d (2015-09-08, submodule: rewrite `module_clone` shell function in C). Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ee8838d commit 3fea121

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

t/t7400-submodule-basic.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,47 @@ test_expect_success 'submodule add --name allows to replace a submodule with ano
818818
)
819819
'
820820

821+
test_expect_failure 'recursive relative submodules stay relative' '
822+
test_when_finished "rm -rf super clone2 subsub sub3" &&
823+
mkdir subsub &&
824+
(
825+
cd subsub &&
826+
git init &&
827+
>t &&
828+
git add t &&
829+
git commit -m "initial commit"
830+
) &&
831+
mkdir sub3 &&
832+
(
833+
cd sub3 &&
834+
git init &&
835+
>t &&
836+
git add t &&
837+
git commit -m "initial commit" &&
838+
git submodule add ../subsub dirdir/subsub &&
839+
git commit -m "add submodule subsub"
840+
) &&
841+
mkdir super &&
842+
(
843+
cd super &&
844+
git init &&
845+
>t &&
846+
git add t &&
847+
git commit -m "initial commit" &&
848+
git submodule add ../sub3 &&
849+
git commit -m "add submodule sub"
850+
) &&
851+
git clone super clone2 &&
852+
(
853+
cd clone2 &&
854+
git submodule update --init --recursive &&
855+
echo "gitdir: ../.git/modules/sub3" >./sub3/.git_expect &&
856+
echo "gitdir: ../../../.git/modules/sub3/modules/dirdir/subsub" >./sub3/dirdir/subsub/.git_expect
857+
) &&
858+
test_cmp clone2/sub3/.git_expect clone2/sub3/.git &&
859+
test_cmp clone2/sub3/dirdir/subsub/.git_expect clone2/sub3/dirdir/subsub/.git
860+
'
861+
821862
test_expect_success 'submodule add with an existing name fails unless forced' '
822863
(
823864
cd addtest2 &&

0 commit comments

Comments
 (0)