{"thread":{"id":"61680","subject":"Problem with multiples levels of submodules","startedAt":"2024-06-25T22:54:39Z","lastAt":"2024-07-02T00:08:23Z","messageCount":2,"participants":["Jeppe Øland"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"497661","messageId":"CA+osTZWaDpH_ZcEhHKrzcaWmHjTAiiWfPmf6C9u3NnzmY0PghQ@mail.gmail.com","threadId":"61680","inReplyTo":null,"subject":"Problem with multiples levels of submodules","fromName":"Jeppe Øland","fromEmail":"joland@gmail.com","sentAt":"2024-06-25T22:54:28Z","receivedAt":"2024-06-25T22:54:39Z","isPatch":false,"sender":{"key":"joland@gmail.com","avatar":null},"body":"Hi there,\n\nI'm seeing a strange thing with multi-level submodules.\nNot sure what's going on, but it feels like a bug.\n(I'm doing this on git \"2.45.2.windows.1\").\n\nFor a while, I've been globally setting the recursive and active config options:\n    git config --global submodule.recurse true\n    git config --global submodule.active .\nThis has the benefit that I don't need to \"git submodule init\" new\nmodules since everything is active.\n\nThe weirdness happens when there are submodules within a submodule.\n\nI can reproduce it by just creating 3 git repositories (I have only\ntried with GH hosted repos, maybe its different if done locally).\nEach repo has a directory within it, and that directory is a submodule\nof the next one.\n    top -> middle -> bottom\n\nNow, if I don't set the global config above, I can:\n    \"git clone --recurse-submodules <PATH>\" to get everything.\nOr:\n    \"git clone <PATH>\", \"cd\", \"git submodule init\", \"git pull\" etc. to\nagain get everything.\n\nBut if I set the global options, I can do:\n    \"git clone <PATH>\" to clone the top level.\n    \"cd top\" to go in there.\n    \"git pull\" to update everything, including submodules.\nBut while cloning \"middle\", it gives me an error:\n    fatal: not a git repository: ../../.git/modules/middle/modules/bottom\n\nSomething is getting confused and thinks there are worktrees involved:\n    \".git/modules/middle/config\" has \"worktree\" line in the [core]\nsection (this appears to be normal).\n    \".git/modules/middle/modules/bottom/config\" is not a repository,\nbut just a \"[core] worktree\" section (definitely not normal).\n\nThis all works fine if there is only one level of submodules (top->middle).\n\nAny ideas?\n\nRegards,\n-Jeppe\n"},{"id":"497948","messageId":"CA+osTZVMiZDihhiALb7fDO=Q5ntSmUFe6q1YpL=pkzC_tsmoBw@mail.gmail.com","threadId":"61680","inReplyTo":"CA+osTZWaDpH_ZcEhHKrzcaWmHjTAiiWfPmf6C9u3NnzmY0PghQ@mail.gmail.com","subject":"Re: Problem with multiples levels of submodules","fromName":"Jeppe Øland","fromEmail":"joland@gmail.com","sentAt":"2024-07-02T00:08:11Z","receivedAt":"2024-07-02T00:08:23Z","isPatch":false,"sender":{"key":"joland@gmail.com","avatar":null},"body":"Hi again,\n\nSo I made a repro - it even fails locally (you have to explicitly\nallow submodules to work with \"file\" transport).\n\nTry the following:\ngit config --global protocol.file.allow always\n\nmkdir bottom\ncd bottom\ngit init\necho hello > bottom.txt\ngit add .\ngit commit -m Bottom\ncd ..\n\nmkdir middle\ncd middle\ngit init\necho hello > middle.txt\ngit add .\ngit commit -m Middle\ngit submodule add ../bottom bottom\ngit commit -m MiddleSub\ncd ..\n\nmkdir top\ncd top\ngit init\necho hello > top.txt\ngit add .\ngit commit -m Top\ngit submodule add ../middle middle\ngit commit -m TopSub\ncd ..\n\ngit clone --recurse-submodules top clone_ok\n\ngit config --global submodule.recurse true\ngit config --global submodule.active .\n\ngit clone --recurse-submodules top clone_err\n\nNote: If those submodule settings are set initially, then even\ncreating the top repository fails.\n\nRegards,\n-Jeppe\n\nOn Tue, Jun 25, 2024 at 3:54 PM Jeppe Øland <joland@gmail.com> wrote:\n>\n> Hi there,\n>\n> I'm seeing a strange thing with multi-level submodules.\n> Not sure what's going on, but it feels like a bug.\n> (I'm doing this on git \"2.45.2.windows.1\").\n>\n> For a while, I've been globally setting the recursive and active config options:\n>     git config --global submodule.recurse true\n>     git config --global submodule.active .\n> This has the benefit that I don't need to \"git submodule init\" new\n> modules since everything is active.\n>\n> The weirdness happens when there are submodules within a submodule.\n>\n> I can reproduce it by just creating 3 git repositories (I have only\n> tried with GH hosted repos, maybe its different if done locally).\n> Each repo has a directory within it, and that directory is a submodule\n> of the next one.\n>     top -> middle -> bottom\n>\n> Now, if I don't set the global config above, I can:\n>     \"git clone --recurse-submodules <PATH>\" to get everything.\n> Or:\n>     \"git clone <PATH>\", \"cd\", \"git submodule init\", \"git pull\" etc. to\n> again get everything.\n>\n> But if I set the global options, I can do:\n>     \"git clone <PATH>\" to clone the top level.\n>     \"cd top\" to go in there.\n>     \"git pull\" to update everything, including submodules.\n> But while cloning \"middle\", it gives me an error:\n>     fatal: not a git repository: ../../.git/modules/middle/modules/bottom\n>\n> Something is getting confused and thinks there are worktrees involved:\n>     \".git/modules/middle/config\" has \"worktree\" line in the [core]\n> section (this appears to be normal).\n>     \".git/modules/middle/modules/bottom/config\" is not a repository,\n> but just a \"[core] worktree\" section (definitely not normal).\n>\n> This all works fine if there is only one level of submodules (top->middle).\n>\n> Any ideas?\n>\n> Regards,\n> -Jeppe\n"}]}