{"thread":{"id":"46939","subject":"Branch switching with submodules where the submodule replaces a folder aborts unexpectedly","startedAt":"2017-10-09T21:29:08Z","lastAt":"2017-10-12T11:48:58Z","messageCount":3,"participants":["Thomas Braun","Stefan Beller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"330053","messageId":"788230417.115707.1507584541605@ox.hosteurope.de","threadId":"46939","inReplyTo":null,"subject":"Branch switching with submodules where the submodule replaces a folder aborts unexpectedly","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2017-10-09T21:29:01Z","receivedAt":"2017-10-09T21:29:08Z","isPatch":false,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"Hi,\n\nI'm currently in the progress of pulling some subprojects in a git repository of mine into their own repositories and adding these subprojects back as submodules.\n\nWhile doing this I enountered a potential bug as checkout complains on branch switching that a file already exists.\n\nI've reproduced it on debian stretch with the following git versions:\n\nmaster:\ngit version 2.15.0.rc0.39.g2f0e14e649\npu:\ngit version 2.15.0.rc0.245.g6d586db062\n\nA script to trigger it is\n\nmkdir -p test/subproject\ncd test\ngit init\ntouch subproject/1\ngit add subproject\ngit commit -m \"blah\"\ncd ..\nmkdir subproject\ncd subproject\ngit init\ntouch 1\ngit add 1\ngit commit -m \"blubb\"\ncd ../test\ngit branch old\ngit rm -rf subproject\ngit commit -m \"remove blah\"\ngit submodule add ../subproject\ngit add -A\ngit commit -m \"added subproject\"\ngit branch new\ngit checkout old\n\nand this fails with \n\n$LANG=C ./run.sh \nInitialized empty Git repository in /home/XXX/devel/test/.git/\n[master (root-commit) 33e6607] blah\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 subproject/1\nInitialized empty Git repository in /home/XXX/devel/subproject/.git/\n[master (root-commit) e817644] blubb\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 1\nrm 'subproject/1'\n[master 9cbfd57] remove blah\n 1 file changed, 0 insertions(+), 0 deletions(-)\n delete mode 100644 subproject/1\nCloning into '/home/XXX/devel/test/subproject'...\ndone.\n[master 1c67e23] added subproject\n 2 files changed, 4 insertions(+)\n create mode 100644 .gitmodules\n create mode 160000 subproject\nerror: The following untracked working tree files would be overwritten by checkout:\n        subproject/1\nPlease move or remove them before you switch branches.\nAborting\n\nIf I'm misusing git here I'm glad for any advice.\n\nThanks,\nThomas\n"},{"id":"330055","messageId":"CAGZ79kYTY6U0eNwvU0PcDyt_QXGyYGm5VkDvWLtuQgQG6BbtFA@mail.gmail.com","threadId":"46939","inReplyTo":"788230417.115707.1507584541605@ox.hosteurope.de","subject":"Re: Branch switching with submodules where the submodule replaces a folder aborts unexpectedly","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-10-09T21:59:19Z","receivedAt":"2017-10-09T21:59:26Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, Oct 9, 2017 at 2:29 PM, Thomas Braun\n<thomas.braun@virtuell-zuhause.de> wrote:\n> Hi,\n>\n> I'm currently in the progress of pulling some subprojects in a git repository of mine into their own repositories and adding these subprojects back as submodules.\n>\n> While doing this I enountered a potential bug as checkout complains on branch switching that a file already exists.\n\n(And I presume you know about --recurse-submodules as a flag for git-checkout)\n\nThis is consistent with our tests, unfortunately.\n\ngit/t$ ./t2013-checkout-submodule.sh\n...\nnot ok 15 - git checkout --recurse-submodules: replace submodule with\na directory # TODO known breakage\n...\n\n> If I'm misusing git here I'm glad for any advice.\n\nYou are not.\n\nApart from this bug report, would you think that such filtering of\ntrees into submodules (and back again) might be an interesting feature\nof Git or are these cases rare and special?\n\nThanks,\nStefan\n"},{"id":"330269","messageId":"591155758.21471.1507808930483@ox.hosteurope.de","threadId":"46939","inReplyTo":"CAGZ79kYTY6U0eNwvU0PcDyt_QXGyYGm5VkDvWLtuQgQG6BbtFA@mail.gmail.com","subject":"Re: Branch switching with submodules where the submodule replaces a folder aborts unexpectedly","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2017-10-12T11:48:50Z","receivedAt":"2017-10-12T11:48:58Z","isPatch":false,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"> Stefan Beller <sbeller@google.com> hat am 9. Oktober 2017 um 23:59 geschrieben:\n> \n> \n> On Mon, Oct 9, 2017 at 2:29 PM, Thomas Braun\n> <thomas.braun@virtuell-zuhause.de> wrote:\n> > Hi,\n> >\n> > I'm currently in the progress of pulling some subprojects in a git repository of mine into their\n> > own repositories and adding these subprojects back as submodules.\n> >\n> > While doing this I enountered a potential bug as checkout complains on branch switching that a \n> > file already exists.\n> \n> (And I presume you know about --recurse-submodules as a flag for git-checkout)\n\nNo I did not know about it. I tend to not know options which don't complete in my shell (patch follows for that).\n\n> This is consistent with our tests, unfortunately.\n> \n> git/t$ ./t2013-checkout-submodule.sh\n> ...\n> not ok 15 - git checkout --recurse-submodules: replace submodule with\n> a directory # TODO known breakage\n> ...\n> \n> > If I'm misusing git here I'm glad for any advice.\n> \n> You are not.\n\nGlad to know that.\n\n> Apart from this bug report, would you think that such filtering of\n> trees into submodules (and back again) might be an interesting feature\n> of Git or are these cases rare and special?\n\nFor me not particularly. In my case it is a one time thing going from an embedded project folder to a submodule.\n"}]}