{"thread":{"id":"42737","subject":"[PATCHv2] submodule: test moving recursive submodule","startedAt":"2016-06-28T18:24:42Z","lastAt":"2016-06-28T18:24:42Z","messageCount":1,"participants":["Stefan Beller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"290421","messageId":"20160628182419.8023-1-sbeller@google.com","threadId":"42737","inReplyTo":null,"subject":"[PATCHv2] submodule: test moving recursive submodule","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-06-28T18:24:19Z","receivedAt":"2016-06-28T18:24:42Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This reproduces the error as pointed out in [1], but the fix is not easy,\nso punt on it for now and just document what needs to be done.\n\n[1] http://stackoverflow.com/questions/32782382/git-moving-submodules-recursively-nested-submodules\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\n  Bart,\n  \n  I don't have the time fixing this properly,\n  so this is the best I can come up with for now. \n  \n  Thanks,\n  Stefan\n\n builtin/mv.c  |  4 ++++\n t/t7001-mv.sh | 34 ++++++++++++++++++++++++++++++++++\n 2 files changed, 38 insertions(+)\n\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex a201426..36dd2fd 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -264,6 +264,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \t\t\t\tconnect_work_tree_and_git_dir(dst, submodule_gitfile[i]);\n \t\t\tif (!update_path_in_gitmodules(src, dst))\n \t\t\t\tgitmodules_modified = 1;\n+\t\t\t/**\n+\t\t\t * NEEDSWORK: We need to recurse into the submodule\n+\t\t\t * and fix the nested submodules as well.\n+\t\t\t */\n \t\t}\n \n \t\tif (mode == WORKING_DIRECTORY)\ndiff --git a/t/t7001-mv.sh b/t/t7001-mv.sh\nindex 4a2570e..fe933f1 100755\n--- a/t/t7001-mv.sh\n+++ b/t/t7001-mv.sh\n@@ -295,6 +295,28 @@ test_expect_success 'setup submodule' '\n \tmkdir -p deep/directory/hierachy &&\n \tgit submodule add ./. deep/directory/hierachy/sub &&\n \tgit commit -m \"added another submodule\" &&\n+\tmkdir inner_sub &&\n+\t(\n+\t\tcd inner_sub &&\n+\t\tgit init &&\n+\t\ttest_commit initial\n+\t) &&\n+\tmkdir outer_sub &&\n+\t(\n+\t\tcd outer_sub &&\n+\t\tgit init &&\n+\t\ttest_commit initial &&\n+\t\tgit submodule add ../inner_sub &&\n+\t\tgit commit -a -m \"add an inner submodule\"\n+\t) &&\n+\tgit submodule add ./outer_sub ./deep/outer_sub &&\n+\tgit commit -a -m \"add outer sub\" &&\n+\tgit -C deep ls-tree HEAD |cut -f 2 >actual &&\n+\tcat >expect <<-EOF &&\n+\tdirectory\n+\touter_sub\n+\tEOF\n+\ttest_cmp expect actual &&\n \tgit branch submodule\n '\n \n@@ -488,6 +510,18 @@ test_expect_success 'moving a submodule in nested directories' '\n \t\tgit config -f ../.gitmodules submodule.deep/directory/hierachy/sub.path >../actual &&\n \t\techo \"directory/hierachy/sub\" >../expect\n \t) &&\n+\ttest_cmp actual expect &&\n+\tgit commit -a -m \"mv a submodule in nested dir\"\n+'\n+\n+test_expect_failure 'moving a submodule with a nested submodule' '\n+\tgit submodule update --init --recursive &&\n+\tgit mv deep/outer_sub outer_sub_moved &&\n+\t# git status would fail if the update of linking git dir to\n+\t# work dir of the submodule failed.\n+\tgit status &&\n+\tgit config -f .gitmodules submodule.deep/outer_sub.path >actual &&\n+\techo \"outer_sub_moved\" >expect &&\n \ttest_cmp actual expect\n '\n \n-- \n2.9.0.138.g8a4fcb8.dirty\n\n"}]}