{"thread":{"id":"54335","subject":"Allow git submodule add in subdirectory of the working tree","startedAt":"2020-10-02T11:07:37Z","lastAt":"2020-10-02T11:07:37Z","messageCount":1,"participants":["LuKaRo"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"406810","messageId":"b56306ea-f302-a660-7d4a-a0ec096d7073@lrose.de","threadId":"54335","inReplyTo":null,"subject":"Allow git submodule add in subdirectory of the working tree","fromName":"LuKaRo","fromEmail":"lists@lrose.de","sentAt":"2020-10-02T11:00:36Z","receivedAt":"2020-10-02T11:07:37Z","isPatch":false,"sender":{"key":"lists@lrose.de","avatar":null},"body":"Hi everyone,\n\nI just stumbled upon a weird limitation that I think doesn't make sense.\nSubmodules with relative remote paths are allowed when added from the\nroot of the working tree, but not allowed when added within a\nsubdirectory. Always having to cd to the root directory first and then\nhaving to specify the full path where the submodule should reside, is\nnot a huge limitation but I don't think it's neccessary. Or am I missing\nsomething? See my bug report created with git bugreport.\n\nPlease include me in CC in replies to this message, as this is the first\ntime I'm posting to this list and I haven't subscribed yet.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\nRun `git submodule add ../foo` with a relative remote path (`../foo`) in\na subdirectory (`bar/`) of the current git tree.\n\nWhat did you expect to happen? (Expected behavior)\nThe submodule `foo` gets added under `bar/foo` with remote `../foo`.\n\nWhat happened instead? (Actual behavior)\nAn error message occured: `Relative path can only be used from the\ntoplevel of the working tree`\n\nWhat's different between what you expected and what actually happened?\nThe git cli didn't allow to use the relative remote path for the\nsubmodule in a subdirectory of the current git tree, although running\n`git submodule add ../foo` under `/bar` is equal to running `git\nsubmodule add ../foo bar/foo` from the root level directory of the\ncurrent git tree. The second version is allowed, the first one isn't,\nalthough both are equivalent.\n\nAnything else you want to add:\nI think that it doesn't make sense to forbid a relative remote path on a\nsubdirectory of the git tree. Relative remotes are a crucial feature if\nyou don't want to specify the protocol to use to fetch the submodule\n(some people working on the same repository use HTTPS, others use SSH,\nin both cases the preferred method should be used to fetch the\nsubmodule). Having to add all submodules from the top level directory is\na limitation that I think isn't neccessary.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.28.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.8.12-arch1-1 #1 SMP PREEMPT Sat, 26 Sep 2020 21:42:58\n+0000 x86_64\ncompiler info: gnuc: 10.1\nlibc info: glibc: 2.32\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\n\nThanks,\nLuKaRo\n\n"}]}