{"thread":{"id":"58106","subject":"\"mixed\" or \"merged\" submodules","startedAt":"2022-07-05T20:35:58Z","lastAt":"2022-07-06T12:28:30Z","messageCount":3,"participants":["Sim Tov","Ævar Arnfjörð Bjarmason"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"458494","messageId":"CA+X_a+z-=K5BfDpMiWAnnVma6ihh6kUXb84CCrHL5gte5WykMw@mail.gmail.com","threadId":"58106","inReplyTo":null,"subject":"\"mixed\" or \"merged\" submodules","fromName":"Sim Tov","fromEmail":"smntov@gmail.com","sentAt":"2022-07-05T20:35:42Z","receivedAt":"2022-07-05T20:35:58Z","isPatch":false,"sender":{"key":"smntov@gmail.com","avatar":null},"body":"Hello,\n\nhere  https://stackoverflow.com/q/72770397/1876484\n\nI asked this question:\n\nI'm aware of git submodules which dwell each in its own separate directory.\n\n1. But is there such thing as \"mixed\" submodules whose content is\n\"merged\" together?\n\nFor instance:\n\n- Submodule1 (path ./), consist of files `a.txt`, `b.txt` and\ndirectory `C` with the file `1.txt`\n- Submodule2 (path ./), consist of files `x.txt`, `y.txt` and\ndirectory `C` with the file `2.txt`\n- Resulting \"mixed\" repo of both submodules: files `a.txt`, `b.txt`,\n`x.txt`, `y.txt` and directory `C` with the files `1.txt`, `2.txt`\n\n2. If it is not implemented in git - is there a workaround to achieve this?\n\nHere my use case:\n\nBoth submodules - independent libraries (collection of books as plain\ntext files), which have same structure (directories = book\ncategories). I want to present the combined parent git repository as\nfull collection of books, while both projects evolve independently and\ndo not overlap (in terms of file names = books).\n\nI got a very detailed and informative answer. My question now - do you\nsee any other practical use cases for such a feature? Would such a\nmore general case of submodules be a good feature in git or not?\n\nThank you!\n"},{"id":"458514","messageId":"220706.867d4qa9b3.gmgdl@evledraar.gmail.com","threadId":"58106","inReplyTo":"CA+X_a+z-=K5BfDpMiWAnnVma6ihh6kUXb84CCrHL5gte5WykMw@mail.gmail.com","subject":"Re: \"mixed\" or \"merged\" submodules","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-07-06T09:16:11Z","receivedAt":"2022-07-06T09:18:34Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Jul 05 2022, Sim Tov wrote:\n\n> Hello,\n>\n> here  https://stackoverflow.com/q/72770397/1876484\n>\n> I asked this question:\n>\n> I'm aware of git submodules which dwell each in its own separate directory.\n>\n> 1. But is there such thing as \"mixed\" submodules whose content is\n> \"merged\" together?\n>\n> For instance:\n>\n> - Submodule1 (path ./), consist of files `a.txt`, `b.txt` and\n> directory `C` with the file `1.txt`\n> - Submodule2 (path ./), consist of files `x.txt`, `y.txt` and\n> directory `C` with the file `2.txt`\n> - Resulting \"mixed\" repo of both submodules: files `a.txt`, `b.txt`,\n> `x.txt`, `y.txt` and directory `C` with the files `1.txt`, `2.txt`\n>\n> 2. If it is not implemented in git - is there a workaround to achieve this?\n>\n> Here my use case:\n>\n> Both submodules - independent libraries (collection of books as plain\n> text files), which have same structure (directories = book\n> categories). I want to present the combined parent git repository as\n> full collection of books, while both projects evolve independently and\n> do not overlap (in terms of file names = books).\n>\n> I got a very detailed and informative answer. My question now - do you\n> see any other practical use cases for such a feature? Would such a\n> more general case of submodules be a good feature in git or not?\n\nGood question, but to answer the thought experiment don't conflate\nsubmodules with this, instead suppose that you have two branches A & B,\nwhich have:\n\n    A: A.txt\n    B: B.txt\n\nHow will you create and maintain a third branch C which has the union of\nthe two?\n\nThe answer to that question will be the same as with the submodule case,\ni.e. you'd need to have some third branch that you maintain (e.g. with a\npush hook?) that would be a merge of the two, and ensure that you don't\nhave path conflicts there.\n\nThen if you wanted to use such a branch as a submodule you'd grab that\ndown like you would any other branch.\n\n"},{"id":"458517","messageId":"CA+X_a+xu3WqJH-SRh2e733Z4izARRqjWjoVEaby=0iQ+T1rfGg@mail.gmail.com","threadId":"58106","inReplyTo":"220706.867d4qa9b3.gmgdl@evledraar.gmail.com","subject":"Re: \"mixed\" or \"merged\" submodules","fromName":"Sim Tov","fromEmail":"smntov@gmail.com","sentAt":"2022-07-06T12:28:13Z","receivedAt":"2022-07-06T12:28:30Z","isPatch":false,"sender":{"key":"smntov@gmail.com","avatar":null},"body":"Thank you very much! Simple and elegant! A solution that is actually\nbetter than the hypothetical mixed submodules... no overhead on\nmaintaining several repos...\n\nOn Wed, Jul 6, 2022 at 12:18 PM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n>\n>\n> On Tue, Jul 05 2022, Sim Tov wrote:\n>\n> > Hello,\n> >\n> > here  https://stackoverflow.com/q/72770397/1876484\n> >\n> > I asked this question:\n> >\n> > I'm aware of git submodules which dwell each in its own separate directory.\n> >\n> > 1. But is there such thing as \"mixed\" submodules whose content is\n> > \"merged\" together?\n> >\n> > For instance:\n> >\n> > - Submodule1 (path ./), consist of files `a.txt`, `b.txt` and\n> > directory `C` with the file `1.txt`\n> > - Submodule2 (path ./), consist of files `x.txt`, `y.txt` and\n> > directory `C` with the file `2.txt`\n> > - Resulting \"mixed\" repo of both submodules: files `a.txt`, `b.txt`,\n> > `x.txt`, `y.txt` and directory `C` with the files `1.txt`, `2.txt`\n> >\n> > 2. If it is not implemented in git - is there a workaround to achieve this?\n> >\n> > Here my use case:\n> >\n> > Both submodules - independent libraries (collection of books as plain\n> > text files), which have same structure (directories = book\n> > categories). I want to present the combined parent git repository as\n> > full collection of books, while both projects evolve independently and\n> > do not overlap (in terms of file names = books).\n> >\n> > I got a very detailed and informative answer. My question now - do you\n> > see any other practical use cases for such a feature? Would such a\n> > more general case of submodules be a good feature in git or not?\n>\n> Good question, but to answer the thought experiment don't conflate\n> submodules with this, instead suppose that you have two branches A & B,\n> which have:\n>\n>     A: A.txt\n>     B: B.txt\n>\n> How will you create and maintain a third branch C which has the union of\n> the two?\n>\n> The answer to that question will be the same as with the submodule case,\n> i.e. you'd need to have some third branch that you maintain (e.g. with a\n> push hook?) that would be a merge of the two, and ensure that you don't\n> have path conflicts there.\n>\n> Then if you wanted to use such a branch as a submodule you'd grab that\n> down like you would any other branch.\n>\n"}]}