git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] Submodules in GIT

From
Linus Torvalds <torvalds@osdl.org>
Date
Dec 1, 2006, 23:30 UTC
Message-ID
<Pine.LNX.4.64.0612011510290.3695@woody.osdl.org>
In-Reply-To
<200612012355.03493.Josef.Weidendorfer@gmx.de>
On Fri, 1 Dec 2006, Josef Weidendorfer wrote:
Show 7 quoted lines
> 
> What about my other argument for a submodule namespace:
> You want to be able to move the relative root path of a submodule
> inside of your supermodule, but yet want to have a unique name
> for the submodule:
> - to be able to just clone a submodule without having to know
> the current position in HEAD

Umm? I don't get the issue. A submodule is a git repo in its own right, and you clone it exactly like you'd clone any other repo. It _does_ have a HEAD. It has it's own branches. It has everything.

So when you clone a submodule, you always get all those branches. The supermodule will not _point_ to them all (the branches are local to the submodule, and _will_ depend on things like "which upstreams module am I tracking"), but they'll have to be there, exactly _because_ the submodule has an existence and is tracked on its own.

In the trivial case where the submodule doesn't even _have_ any external existence at all (ie it's always maintained as _just_ a submodule, it would probably tend to have just one branch, and a clone would get whatever that branch is), but that's just a degenerate special case of the much richer "this submodule actually has a life of its own" case.

> - more practically, e.g. to be able to name a submodule
> independent from any current commit you are on in the supermodule,
> e.g. to be able to store some meta information about a submodule:

The current commit within the supermodule would be _totally_ invisible to the submodule.

Of course, if HEAD _differs_ from that commit within the supermodule, then a "git diff" (when done from within the supermodule) should show that, but again, that's actually only as seen from the _supermodule_.

> - "Where is the official upstream of this submodule?"

That's entirely a question for the submodule. You cannot ask that question within the confines of the supermodule, because it's not even a relevant question in that context. Two different supermodule repositories may well decide to get their submodules from difference places, just because they got cloned from different places (or even just for practical reasons like "that other site is closer to me").

So the official upstream of a submodule must NOT be encoded inside the supermodule (or at least not within its _objects_). Exactly because the upstream location is not a "global" thing - it's per-repository, and thus must not be encoded in the global data (ie the objects).

It should be be encoded in some _ephemeral_ place, eg in the ".git/config" file or in a ".git/remotes/origin"-like file (either in the supermodule or the submodule, and I would seriously suggest you do it within in the submodule itself, because you'll want it exactly when you decide to work on the submodule and upgrade _that_).

Show 5 quoted lines
> - "Should git allow to commit rewind actions of this submodule
>    in the supermodule?" (which, AFAICS, exactly has the same
>    problems as publishing a rewound branch: you will get into
>    merge hell when you want to pull upstream changes into the
>    supermodule)

The only thing that a submodule must NOT be allowed to do on its own is pruning (and it's distant cousin "git repack -d"). You must always prune from the supermodule, because the submodule cannot really know on its own what references point into it.

(There are alternatives. One alternative is to never allow rewinding - or deletion - of branches in a submodule, and thus solve the problem that way. That is the easier solution, because it also means that a "clone" of a supermodule can just recursively clone the submodules independently _without_ having to worry about reachability, but it's really _really_ draconian).

> - "Should this submodule be checked out?"

This, I think, requires too much configuration to say separately for every possible submodule, so I would suggest that the way to make that decision is:

 - "git clone" by default will fetch and check out all submodules (and 
   obviously they have to be described some way outside of the object 
   database, just so that you don't have to parse the _whole_ history of 
   the _whole_ supermodule just to find all possible submodules. So the 
   supermodule _will_ need some "list of submodules and where to get them" 
   in a config file or other).
 - add a flag (possibly just re-use the current "-n" flag) that disables 
   that recursive fetching of submodules entirely.
 - have a way to fetch individual submodules one-by-one (that capacity 
   obviously has to be there anyway, since the "recursive" git clone has 
   to be able to do it, so this is likely just "git clone" again, with 
   just logic added to say "when you clone something and are _already_ 
   within a superproject, the clonee becomes a subproject automatically"

I dunno. And I'd also like to point out that things don't have to all work fully before we can do at least some cases of this. For example, if the initial version just always clones everything, big deal. I'm not saying that we have to have support for things like this on "Day 1", I'm just saying that I think people will want to be able to not fetch and check out everything, so the design should _allow_ for it.

(But I also think that as long as submodules are independent enough, the "design" part should fall out on its own, and it just becomes a "small matter of programming" to actually get it to work).

Previous: Martin WaitzNext: Josef Weidendorfer
Message 120 of 160 in “Re: [RFC] Submodules in GIT”
  1. Andy ParkinsNov 28, 2006
  2. Jakub NarebskiNov 28, 2006
  3. Andy ParkinsNov 28, 2006
  4. Shawn PearceNov 28, 2006
  5. Andy ParkinsNov 28, 2006
  6. Shawn PearceNov 28, 2006
  7. Jon LoeligerNov 28, 2006
  8. Martin WaitzNov 29, 2006
  9. sfNov 30, 2006
  10. Steven GrimmNov 28, 2006
  11. Shawn PearceNov 28, 2006
  12. Martin WaitzNov 29, 2006
  13. Andy ParkinsNov 29, 2006
  14. Andreas EricssonNov 30, 2006
  15. Andy ParkinsNov 30, 2006
  16. Martin WaitzNov 30, 2006
  17. Andreas EricssonNov 30, 2006
  18. sfDec 1, 2006
  19. Martin WaitzDec 1, 2006
  20. sfDec 1, 2006
  21. Martin WaitzDec 1, 2006
  22. Stephan FederDec 1, 2006
  23. Martin WaitzDec 1, 2006
  24. Stephan FederDec 1, 2006
  25. Martin WaitzDec 1, 2006
  26. Uwe Kleine-KoenigDec 5, 2006
  27. Andreas EricssonDec 5, 2006
  28. Jakub NarebskiDec 5, 2006
  29. Uwe Kleine-KoenigDec 5, 2006
  30. Andreas EricssonDec 5, 2006
  31. Sven VerdoolaegeDec 5, 2006
  32. Andy ParkinsDec 1, 2006
  33. Martin WaitzDec 1, 2006
  34. sfDec 1, 2006
  35. Martin WaitzDec 1, 2006
  36. sfDec 1, 2006
  37. Martin WaitzDec 1, 2006
  38. Andreas EricssonDec 1, 2006
  39. Martin WaitzDec 1, 2006
  40. Andreas EricssonDec 1, 2006
  41. Martin WaitzDec 1, 2006
  42. Andreas EricssonDec 1, 2006
  43. Linus TorvaldsDec 1, 2006
  44. sfDec 1, 2006
  45. Andreas EricssonDec 1, 2006
  46. Linus TorvaldsDec 1, 2006
  47. Martin WaitzDec 1, 2006
  48. Alan ChandlerDec 1, 2006
  49. Josef WeidendorferDec 1, 2006
  50. Martin WaitzDec 1, 2006
  51. Josef WeidendorferDec 1, 2006
  52. Martin WaitzDec 1, 2006
  53. Josef WeidendorferDec 1, 2006
  54. Martin WaitzDec 2, 2006
  55. Josef WeidendorferDec 3, 2006
  56. Martin WaitzDec 3, 2006
  57. Linus TorvaldsDec 1, 2006
  58. sfDec 1, 2006
  59. Josef WeidendorferDec 1, 2006
  60. Linus TorvaldsDec 1, 2006
  61. Josef WeidendorferDec 1, 2006
  62. Linus TorvaldsDec 2, 2006
  63. Andy ParkinsDec 2, 2006
  64. Josef WeidendorferDec 2, 2006
  65. Linus TorvaldsDec 2, 2006
  66. Martin WaitzDec 2, 2006
  67. Linus TorvaldsDec 2, 2006
  68. Martin WaitzDec 2, 2006
  69. Josef WeidendorferDec 3, 2006
  70. Martin WaitzDec 2, 2006
  71. Linus TorvaldsDec 2, 2006
  72. Martin WaitzDec 2, 2006
  73. Linus TorvaldsDec 2, 2006
  74. Linus TorvaldsDec 2, 2006
  75. Thoughts about memory requirements in traversals [Was: Re: [RFC] Submodules in GIT]Josef Weidendorfer, Dec 3, 2006
  76. Linus TorvaldsDec 3, 2006
  77. Shawn PearceDec 3, 2006
  78. Josef WeidendorferDec 3, 2006
  79. Jakub NarebskiDec 3, 2006
  80. Josef WeidendorferDec 3, 2006
  81. Martin WaitzDec 3, 2006
  82. sfDec 1, 2006
  83. Torgil SvenssonDec 2, 2006
  84. Linus TorvaldsDec 2, 2006
  85. Torgil SvenssonDec 3, 2006
  86. Linus TorvaldsDec 3, 2006
  87. Torgil SvenssonDec 4, 2006
  88. Linus TorvaldsDec 4, 2006
  89. Torgil SvenssonDec 4, 2006
  90. Andreas EricssonDec 5, 2006
  91. Jakub NarebskiDec 5, 2006
  92. Andreas EricssonDec 5, 2006
  93. Jakub NarebskiDec 5, 2006
  94. Andy ParkinsDec 3, 2006
  95. Daniel BarkalowDec 5, 2006
  96. sfDec 5, 2006
  97. R. Steve McKownDec 9, 2006
  98. Torgil SvenssonDec 10, 2006
  99. Torgil SvenssonDec 14, 2006
  100. Josef WeidendorferDec 14, 2006
  101. Torgil SvenssonDec 15, 2006
  102. Josef WeidendorferDec 15, 2006
  103. Torgil SvenssonDec 15, 2006
  104. Torgil SvenssonDec 16, 2006
  105. Torgil SvenssonDec 16, 2006
  106. Jakub NarebskiDec 16, 2006
  107. Torgil SvenssonDec 16, 2006
  108. Jakub NarebskiDec 16, 2006
  109. Junio C HamanoDec 16, 2006
  110. Torgil SvenssonDec 16, 2006
  111. Torgil SvenssonDec 16, 2006
  112. Jakub NarebskiDec 16, 2006
  113. Torgil SvenssonDec 17, 2006
  114. Linus TorvaldsDec 16, 2006
  115. Linus TorvaldsDec 16, 2006
  116. Torgil SvenssonDec 16, 2006
  117. Martin WaitzDec 2, 2006
  118. Josef WeidendorferDec 1, 2006
  119. Martin WaitzDec 1, 2006
  120. Linus TorvaldsDec 1, 2006
  121. Josef WeidendorferDec 2, 2006
  122. Linus TorvaldsDec 2, 2006
  123. Andy ParkinsDec 2, 2006
  124. Michael K. EdwardsDec 4, 2006
  125. Sam VilainDec 5, 2006
  126. Sven VerdoolaegeDec 3, 2006
  127. Linus TorvaldsDec 3, 2006
  128. Jakub NarebskiDec 3, 2006
  129. Josef WeidendorferDec 4, 2006
  130. sfDec 1, 2006
  131. Jon LoeligerDec 8, 2006
  132. Sven VerdoolaegeDec 8, 2006
  133. Andreas EricssonDec 12, 2006
  134. Martin WaitzDec 1, 2006
  135. Martin WaitzDec 1, 2006
  136. Andreas EricssonDec 1, 2006
  137. Martin WaitzDec 1, 2006
  138. Stephan FederDec 1, 2006
  139. Martin WaitzDec 1, 2006
  140. Stephan FederDec 1, 2006
  141. Martin WaitzDec 1, 2006
  142. Stephan FederDec 1, 2006
  143. Martin WaitzDec 1, 2006
  144. sfDec 1, 2006
  145. Martin WaitzDec 2, 2006
  146. Andy ParkinsDec 1, 2006
  147. Martin WaitzDec 1, 2006
  148. Andy ParkinsDec 1, 2006
  149. Martin WaitzDec 1, 2006
  150. Andy ParkinsDec 1, 2006
  151. Martin WaitzDec 1, 2006
  152. Andy ParkinsDec 2, 2006
  153. Josef WeidendorferDec 2, 2006
  154. Martin WaitzDec 2, 2006
  155. Josef WeidendorferDec 3, 2006
  156. Martin WaitzDec 2, 2006
  157. Jakub NarebskiDec 2, 2006
  158. Jakub NarebskiDec 2, 2006
  159. Jakub NarebskiDec 2, 2006
  160. Andy ParkinsDec 3, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.