{"thread":{"id":"11171","subject":"After-the-fact submodule detection or creation","startedAt":"2007-12-07T03:01:04Z","lastAt":"2007-12-07T21:35:43Z","messageCount":3,"participants":["Michael Poole","Alex Riesen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"62230","messageId":"87ir3bp5sf.fsf@graviton.dyn.troilus.org","threadId":"11171","inReplyTo":null,"subject":"After-the-fact submodule detection or creation","fromName":"Michael Poole","fromEmail":"mdpoole@troilus.org","sentAt":"2007-12-07T03:01:04Z","receivedAt":"2007-12-07T03:01:04Z","isPatch":false,"sender":{"key":"mdpoole@troilus.org","avatar":null},"body":"I have a project where most branches have one subdirectory for the\ncore program and other subdirectories for support scripts, programs\nand libraries.  The supporting subdirectories vary from branch to\nbranch.  However, some branches contain just the core program, with no\nsubdirectories.  Starting from scratch, I would say the core program\nshould be a submodule, but historically it was not populated as one.\n\nIs there a way to easily create such a pseudo-submodule branch in git,\nor are real submodules strongly preferred for this kind of scenario?\n\n(The added twist: I ran into this while importing a Subversion\nrepository.  git-svn identified two trees of history in the repository\n-- one history containing the core plus support trees, one history\ncontaining just the core program.  Since the trees do have the same\ncontents, only the commits are duplicated, but that is not quite\nideal.\n\nIt seems like using the current submodule code would mean that this\nkind of import would need two passes over the foreign repository,\nrather than one if the branch could be created after the parent tree\nis initially imported.  I can live with that -- it is a rather unusual\ncase -- but maybe there is a better way.)\n\nMichael Poole\n"},{"id":"62255","messageId":"20071207073728.GA2847@steel.home","threadId":"11171","inReplyTo":"87ir3bp5sf.fsf@graviton.dyn.troilus.org","subject":"Re: After-the-fact submodule detection or creation","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-12-07T07:37:28Z","receivedAt":"2007-12-07T07:37:28Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Michael Poole, Fri, Dec 07, 2007 04:01:04 +0100:\n> It seems like using the current submodule code would mean that this\n> kind of import would need two passes over the foreign repository,\n> rather than one if the branch could be created after the parent tree\n> is initially imported.  I can live with that -- it is a rather unusual\n> case -- but maybe there is a better way.)\n\nImport the core module in a branch all by itself, and merge it in\nevery support branch?\n\n\n    Supp1: o-o-o-----o-o-o-o-o-o-o\n\t\t    /\n    Core:  o-o-o-o-o\n\t\t    \\\n    Supp2: o-o-------o-o-o-o\n"},{"id":"62326","messageId":"87abomp4r4.fsf@graviton.dyn.troilus.org","threadId":"11171","inReplyTo":"20071207073728.GA2847@steel.home","subject":"Re: After-the-fact submodule detection or creation","fromName":"Michael Poole","fromEmail":"mdpoole@troilus.org","sentAt":"2007-12-07T21:35:43Z","receivedAt":"2007-12-07T21:35:43Z","isPatch":false,"sender":{"key":"mdpoole@troilus.org","avatar":null},"body":"Alex Riesen writes:\n\n> Michael Poole, Fri, Dec 07, 2007 04:01:04 +0100:\n>> It seems like using the current submodule code would mean that this\n>> kind of import would need two passes over the foreign repository,\n>> rather than one if the branch could be created after the parent tree\n>> is initially imported.  I can live with that -- it is a rather unusual\n>> case -- but maybe there is a better way.)\n>\n> Import the core module in a branch all by itself, and merge it in\n> every support branch?\n>\n>\n>     Supp1: o-o-o-----o-o-o-o-o-o-o\n> \t\t    /\n>     Core:  o-o-o-o-o\n> \t\t    \\\n>     Supp2: o-o-------o-o-o-o\n\nYes, that's the obvious way to do it with submodules.  Teaching\ngit-svn to use that is the hard part.\n\nSince the core code was first branched independently at r734 in the\nexisting repository, the import (either automated or manual) would\nneed to go through once to identify what subdirectories are actually\nsubmodules in git terminology, and make a second pass to actually\nperform the imports.  If the submodule creation could happen after the\nfact, it would only need one pass.\n\nMaybe the right question to ask is whether having a partial-tree\nbranch can be reasonably handled by git (in particular, detecting a\nrename of the core subtree to the top-level tree in the new branch's\nfirst commit).  If git understand that operation, then what I would\nlike to do would be reasonably straightforward.  If it does not make\nsense, then I'll think about how to teach git-svn that certain\nsubdirectories should be promoted to submodules.\n\nMichael Poole\n"}]}