{"thread":{"id":"42728","subject":"[PATCH] submodule: test moving recursive submodule","startedAt":"2016-06-28T00:16:23Z","lastAt":"2016-06-28T17:52:42Z","messageCount":4,"participants":["Stefan Beller","Bart Bogaerts"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"290334","messageId":"20160628001559.29204-1-sbeller@google.com","threadId":"42728","inReplyTo":null,"subject":"[PATCH] submodule: test moving recursive submodule","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-06-28T00:15:59Z","receivedAt":"2016-06-28T00:16:23Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\nThis tries to reproduce the error as pointed out in\nhttp://stackoverflow.com/questions/32782382/git-moving-submodules-recursively-nested-submodules\nbut the tests pass. This still seems to be missing a detail.\n\nBart any idea how this setup may be different than what you have?\nInstead of applying the patch, you can also checkout \nhttps://github.com/stefanbeller/git/tree/submodule_recursive_mv_test\nwhich is the patch below applied on top of Junios (the maintainer) master branch.\nTo look around on the filesystem, you can drop \"test_pause &&\" in a test and\nthen run the test with `(cd t && ./t7001-mv.sh -v)` (more info how to run tests\nin the Git test suite in t/README, maybe -i -v -x are interested)\n\nThanks,\nStefan\n\n t/t7001-mv.sh | 43 +++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 43 insertions(+)\n\ndiff --git a/t/t7001-mv.sh b/t/t7001-mv.sh\nindex 4a2570e..404e5bd 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,27 @@ 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_success 'moving a submodule with a nested submodule' '\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+test_expect_success 'moving back the submodule with a nested submodule' '\n+\tgit mv outer_sub_moved deep/outer_sub &&\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 \"deep/outer_sub\" >expect &&\n \ttest_cmp actual expect\n '\n \n-- \n2.9.0.4.g35eb263.dirty\n\n"},{"id":"290339","messageId":"CAOG-3G+xAZQV8rPgdxz8S8bqzJfm1fFNg2Y4suC-a--tbCWXow@mail.gmail.com","threadId":"42728","inReplyTo":"20160628001559.29204-1-sbeller@google.com","subject":"Re: [PATCH] submodule: test moving recursive submodule","fromName":"Bart Bogaerts","fromEmail":"bartbogaerts@gmail.com","sentAt":"2016-06-28T06:13:54Z","receivedAt":"2016-06-28T06:14:40Z","isPatch":true,"sender":{"key":"bartbogaerts@gmail.com","avatar":"https://gravatar.com/avatar/c85570cbecf4bbdc221a0e4470af017d3c77ce80e865e2d565304ead921a2698?d=mp&s=160"},"body":"The only thing I still see that might cause the bug is that there is no\n\ngit submodule update --recursive\n\npresent in your test cases .\nThis command creates the .git file in the nested subsubmodule\nIt is that .git file that is not correctly updated in the move.\n\nSo after the line\n+       git submodule add ./outer_sub ./deep/outer_sub &&\nI would add\n+       git submodule update -- recursive &&\n\n2016-06-28 3:15 GMT+03:00 Stefan Beller <sbeller@google.com>:\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n> This tries to reproduce the error as pointed out in\n> http://stackoverflow.com/questions/32782382/git-moving-submodules-recursively-nested-submodules\n> but the tests pass. This still seems to be missing a detail.\n>\n> Bart any idea how this setup may be different than what you have?\n> Instead of applying the patch, you can also checkout\n> https://github.com/stefanbeller/git/tree/submodule_recursive_mv_test\n> which is the patch below applied on top of Junios (the maintainer) master branch.\n> To look around on the filesystem, you can drop \"test_pause &&\" in a test and\n> then run the test with `(cd t && ./t7001-mv.sh -v)` (more info how to run tests\n> in the Git test suite in t/README, maybe -i -v -x are interested)\n>\n> Thanks,\n> Stefan\n>\n>  t/t7001-mv.sh | 43 +++++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 43 insertions(+)\n>\n> diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh\n> index 4a2570e..404e5bd 100755\n> --- a/t/t7001-mv.sh\n> +++ b/t/t7001-mv.sh\n> @@ -295,6 +295,28 @@ test_expect_success 'setup submodule' '\n>         mkdir -p deep/directory/hierachy &&\n>         git submodule add ./. deep/directory/hierachy/sub &&\n>         git commit -m \"added another submodule\" &&\n> +       mkdir inner_sub &&\n> +       (\n> +               cd inner_sub &&\n> +               git init &&\n> +               test_commit initial\n> +       ) &&\n> +       mkdir outer_sub &&\n> +       (\n> +               cd outer_sub &&\n> +               git init &&\n> +               test_commit initial &&\n> +               git submodule add ../inner_sub &&\n> +               git commit -a -m \"add an inner submodule\"\n> +       ) &&\n> +       git submodule add ./outer_sub ./deep/outer_sub &&\n> +       git commit -a -m \"add outer sub\" &&\n> +       git -C deep ls-tree HEAD |cut -f 2 >actual &&\n> +       cat >expect <<-EOF &&\n> +       directory\n> +       outer_sub\n> +       EOF\n> +       test_cmp expect actual &&\n>         git branch submodule\n>  '\n>\n> @@ -488,6 +510,27 @@ test_expect_success 'moving a submodule in nested directories' '\n>                 git config -f ../.gitmodules submodule.deep/directory/hierachy/sub.path >../actual &&\n>                 echo \"directory/hierachy/sub\" >../expect\n>         ) &&\n> +       test_cmp actual expect &&\n> +       git commit -a -m \"mv a submodule in nested dir\"\n> +'\n> +\n> +test_expect_success 'moving a submodule with a nested submodule' '\n> +       git mv deep/outer_sub outer_sub_moved &&\n> +       # git status would fail if the update of linking git dir to\n> +       # work dir of the submodule failed.\n> +       git status &&\n> +       git config -f .gitmodules submodule.deep/outer_sub.path >actual &&\n> +       echo \"outer_sub_moved\" >expect &&\n> +       test_cmp actual expect\n> +'\n> +\n> +test_expect_success 'moving back the submodule with a nested submodule' '\n> +       git mv outer_sub_moved deep/outer_sub &&\n> +       # git status would fail if the update of linking git dir to\n> +       # work dir of the submodule failed.\n> +       git status &&\n> +       git config -f .gitmodules submodule.deep/outer_sub.path >actual &&\n> +       echo \"deep/outer_sub\" >expect &&\n>         test_cmp actual expect\n>  '\n>\n> --\n> 2.9.0.4.g35eb263.dirty\n>\n\n\n\n-- \nBart Bogaerts\n"},{"id":"290340","messageId":"CAOG-3G+umq4iqDz1aMu4qnjxSQrhO76N8wc4WwtBiN8n58=3Yw@mail.gmail.com","threadId":"42728","inReplyTo":"CAOG-3G+xAZQV8rPgdxz8S8bqzJfm1fFNg2Y4suC-a--tbCWXow@mail.gmail.com","subject":"Re: [PATCH] submodule: test moving recursive submodule","fromName":"Bart Bogaerts","fromEmail":"bartbogaerts@gmail.com","sentAt":"2016-06-28T06:28:08Z","receivedAt":"2016-06-28T06:29:14Z","isPatch":true,"sender":{"key":"bartbogaerts@gmail.com","avatar":"https://gravatar.com/avatar/c85570cbecf4bbdc221a0e4470af017d3c77ce80e865e2d565304ead921a2698?d=mp&s=160"},"body":"I dit some more testing.\n\nIt is important for the bug to occur that all submodules are initialised.\nSo my suggestion is not yet complete, you need to add the line\n\ngit submodule update --recursive --init\n\n\n\n\nBelow is a complete script that show the bug occurring:\n\n\n\nmkdir repo1 &&\nmkdir repo2 &&\n\n(\n  cd repo1 &&\n  git init &&\n  echo \"test\" >> test.test &&\n  git add . &&\n  git commit -m \"initial commit\"\n) &&\n\n(\n  cd repo2 &&\n  git init &&\n  git submodule add ../repo1 &&\n  git commit -a -m \"added submod\"\n) &&\n\n#create the directory to test in\n(\n  mkdir testdir &&\n  cd testdir &&\n  git init &&\n  git submodule add ../repo2 &&\n  git commit -m \"added full structure\" &&\n  #important to initialise .git files!\n  git submodule update --recursive --init\n) &&\n\n(\n  cd testdir &&\n  mkdir 2015 &&\n  git mv repo2 2015 &&\n  git status\n)\n\n2016-06-28 9:13 GMT+03:00 Bart Bogaerts <bartbogaerts@gmail.com>:\n> The only thing I still see that might cause the bug is that there is no\n>\n> git submodule update --recursive\n>\n> present in your test cases .\n> This command creates the .git file in the nested subsubmodule\n> It is that .git file that is not correctly updated in the move.\n>\n> So after the line\n> +       git submodule add ./outer_sub ./deep/outer_sub &&\n> I would add\n> +       git submodule update -- recursive &&\n>\n> 2016-06-28 3:15 GMT+03:00 Stefan Beller <sbeller@google.com>:\n>> Signed-off-by: Stefan Beller <sbeller@google.com>\n>> ---\n>> This tries to reproduce the error as pointed out in\n>> http://stackoverflow.com/questions/32782382/git-moving-submodules-recursively-nested-submodules\n>> but the tests pass. This still seems to be missing a detail.\n>>\n>> Bart any idea how this setup may be different than what you have?\n>> Instead of applying the patch, you can also checkout\n>> https://github.com/stefanbeller/git/tree/submodule_recursive_mv_test\n>> which is the patch below applied on top of Junios (the maintainer) master branch.\n>> To look around on the filesystem, you can drop \"test_pause &&\" in a test and\n>> then run the test with `(cd t && ./t7001-mv.sh -v)` (more info how to run tests\n>> in the Git test suite in t/README, maybe -i -v -x are interested)\n>>\n>> Thanks,\n>> Stefan\n>>\n>>  t/t7001-mv.sh | 43 +++++++++++++++++++++++++++++++++++++++++++\n>>  1 file changed, 43 insertions(+)\n>>\n>> diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh\n>> index 4a2570e..404e5bd 100755\n>> --- a/t/t7001-mv.sh\n>> +++ b/t/t7001-mv.sh\n>> @@ -295,6 +295,28 @@ test_expect_success 'setup submodule' '\n>>         mkdir -p deep/directory/hierachy &&\n>>         git submodule add ./. deep/directory/hierachy/sub &&\n>>         git commit -m \"added another submodule\" &&\n>> +       mkdir inner_sub &&\n>> +       (\n>> +               cd inner_sub &&\n>> +               git init &&\n>> +               test_commit initial\n>> +       ) &&\n>> +       mkdir outer_sub &&\n>> +       (\n>> +               cd outer_sub &&\n>> +               git init &&\n>> +               test_commit initial &&\n>> +               git submodule add ../inner_sub &&\n>> +               git commit -a -m \"add an inner submodule\"\n>> +       ) &&\n>> +       git submodule add ./outer_sub ./deep/outer_sub &&\n>> +       git commit -a -m \"add outer sub\" &&\n>> +       git -C deep ls-tree HEAD |cut -f 2 >actual &&\n>> +       cat >expect <<-EOF &&\n>> +       directory\n>> +       outer_sub\n>> +       EOF\n>> +       test_cmp expect actual &&\n>>         git branch submodule\n>>  '\n>>\n>> @@ -488,6 +510,27 @@ test_expect_success 'moving a submodule in nested directories' '\n>>                 git config -f ../.gitmodules submodule.deep/directory/hierachy/sub.path >../actual &&\n>>                 echo \"directory/hierachy/sub\" >../expect\n>>         ) &&\n>> +       test_cmp actual expect &&\n>> +       git commit -a -m \"mv a submodule in nested dir\"\n>> +'\n>> +\n>> +test_expect_success 'moving a submodule with a nested submodule' '\n>> +       git mv deep/outer_sub outer_sub_moved &&\n>> +       # git status would fail if the update of linking git dir to\n>> +       # work dir of the submodule failed.\n>> +       git status &&\n>> +       git config -f .gitmodules submodule.deep/outer_sub.path >actual &&\n>> +       echo \"outer_sub_moved\" >expect &&\n>> +       test_cmp actual expect\n>> +'\n>> +\n>> +test_expect_success 'moving back the submodule with a nested submodule' '\n>> +       git mv outer_sub_moved deep/outer_sub &&\n>> +       # git status would fail if the update of linking git dir to\n>> +       # work dir of the submodule failed.\n>> +       git status &&\n>> +       git config -f .gitmodules submodule.deep/outer_sub.path >actual &&\n>> +       echo \"deep/outer_sub\" >expect &&\n>>         test_cmp actual expect\n>>  '\n>>\n>> --\n>> 2.9.0.4.g35eb263.dirty\n>>\n>\n>\n>\n> --\n> Bart Bogaerts\n\n\n\n-- \nBart Bogaerts\n"},{"id":"290403","messageId":"CAGZ79kYnuVyEZSLviFq-ZrULF9EgJm18vk213Z7jBYK_UnwKrw@mail.gmail.com","threadId":"42728","inReplyTo":"CAOG-3G+umq4iqDz1aMu4qnjxSQrhO76N8wc4WwtBiN8n58=3Yw@mail.gmail.com","subject":"Re: [PATCH] submodule: test moving recursive submodule","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-06-28T17:52:36Z","receivedAt":"2016-06-28T17:52:42Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, Jun 27, 2016 at 11:28 PM, Bart Bogaerts <bartbogaerts@gmail.com> wrote:\n> I dit some more testing.\n>\n> It is important for the bug to occur that all submodules are initialised.\n> So my suggestion is not yet complete, you need to add the line\n\nOh right. I was completely oblivious to that.\n\n>\n> git submodule update --recursive --init\n\nAdding the initialization makes my test cases fail as well.\n\nThanks,\nStefan\n"}]}