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 <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Mar 31, 2016 at 14:04 UTC 3fea121df31c108ee9c52fd888a90d68a3bbb2b2
1 file changed +41
t/t7400-submodule-basic.sh
+41
@@ -818,6 +818,47 @@ test_expect_success 'submodule add --name allows to replace a submodule with ano
818 )
819 '
820
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 +
862 test_expect_success 'submodule add with an existing name fails unless forced' '
863 (
864 cd addtest2 &&