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

Re: git submodules

From
Avery Pennarun <apenwarr@gmail.com>
Date
Jul 28, 2008, 22:32 UTC
Message-ID
<32541b130807281532v3eed94ebv8037247618e9bd55@mail.gmail.com>
In-Reply-To
<20080728220308.GF10409@artemis.madism.org>
On 7/28/08, Pierre Habouzit <madcoder@debian.org> wrote:
Show 7 quoted lines
>  > It's unfortunate that submodules involve a commit->tree->commit link
>  > structure.
>
> Actually it's not a big problem, you just have to "dereference" twice
>  instead of one, and be prepared to the fact that the second dereference
>  may fail (because you miss some objects). I instead believe that
>  gitlinks are a good idea.

It's actually complicated to generate the log, however. To be 100% accurate in creating a combined log of the supermodule and submodule, you'd have to check *for each supermodule commit* whether there were any changes in gitlinks. And gitlinks might move around between revisions, so you can't just look up a particular path in each revision; you have to traverse the entire tree. And you can't just look at the start and end supermodule commits to see if the gitlinks changed; they might have changed and then changed back, which is quite relevant to log messages.

Probably it's more useful to just commit the git-shortlog of the submodule whenever you update the gitlink. It won't work with bisect, exactly, but that's less important than generally having an idea of what happened by reading the log. ISTR somenoe submitted a git-submodule patch for that already somewhere, but I've been known to imagine things.

Show 10 quoted lines
> Well, using the same [branch] as the supermodule is probably the less confusing
>  way. Of course, not being in the "same" branch as the supermodule would
>  clearly be a case of your tree being "dirty", and it would prevent a
>  "git checkout" to work in the very same way that git checkout doesn't
>  work if you have locally modified files.
>
>  If your submodule branching layout uses the same names as the
>  supermodule branches then yes, it's going to hurt, but I believe it to
>  be unlikely (else you would become insane just trying to remember what
>  you are doing ;p).

I think this is much more common than you think. An easy example is that I'm developing a new version of my application in the supermodule's "master", but it relies on a released version of my submodule, definitely not the experimental "master" version. Using your logic, the local branch of the submodule would be called master, but wouldn't correspond at all to the remote submodule's master.

I believe such a situation would be even worse than no branch at all. It could lead to people pushing/pulling all sorts of bad things from the wrong places. At least right now, people become confused and ask for help instead of becoming confused and making a mess.

Have fun,
Avery
Previous: Pierre HabouzitNext: Pierre Habouzit
Message 14 of 29 in “git submodules”
  1. Pierre HabouzitJul 28, 2008
  2. Pierre HabouzitJul 28, 2008
  3. Nigel MagnayJul 28, 2008
  4. Pierre HabouzitJul 28, 2008
  5. Pierre HabouzitJul 28, 2008
  6. Avery PennarunJul 28, 2008
  7. Pierre HabouzitJul 28, 2008
  8. Jakub NarebskiJul 28, 2008
  9. Junio C HamanoJul 28, 2008
  10. Pierre HabouzitAug 17, 2008
  11. Avery PennarunAug 17, 2008
  12. Junio C HamanoAug 17, 2008
  13. Pierre HabouzitAug 18, 2008
  14. Avery PennarunJul 28, 2008
  15. Pierre HabouzitJul 28, 2008
  16. Benjamin CollinsJul 29, 2008
  17. Shawn O. PearceJul 29, 2008
  18. Nigel MagnayJul 29, 2008
  19. Pierre HabouzitJul 29, 2008
  20. Pierre HabouzitJul 29, 2008
  21. Pierre HabouzitJul 29, 2008
  22. Petr BaudisJul 29, 2008
  23. Johannes SchindelinJul 29, 2008
  24. Pierre HabouzitJul 29, 2008
  25. Johannes SchindelinJul 29, 2008
  26. Pierre HabouzitJul 29, 2008
  27. Nigel MagnayJul 29, 2008
  28. Pierre HabouzitJul 29, 2008
  29. Junio C HamanoJul 29, 2008

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.