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

Re: dependable submodules

From
Avery Pennarun <apenwarr@gmail.com>
Date
Mar 22, 2011, 05:13 UTC
Message-ID
<AANLkTi=yb24MDN8JzBa0WFaZ+g4iF5a=OQNw0yOM0k73@mail.gmail.com>
In-Reply-To
<AANLkTikv+Wf_nSt0GZj0WgPjpbk6Kr_WG-ueO6US9bUM@mail.gmail.com>
On Mon, Mar 21, 2011 at 8:56 PM, Daniel <daniel@netwalk.org> wrote:
Show 7 quoted lines
> I tried git-subtree. thanks but this is not what I wanted. This
> removed the .git dir for the subtree and hence updating the subtree is
> not easy.
>
> I want the functionality of git submodule except that I don't want the
> version checked in as part of the superproject to have to be fetched
> remotely.

Well, as the logic goes, you commit to the imported project a lot more often than you submit upstream, so git-subtree makes the common part much easier and the less-common part slightly harder, which is a better tradeoff than git submodules. But it does seem to be a matter of preference.

If you just want the submodule's commit to be auto-fetched from the same repo as the supermodule, I've been experimenting with a tool I've created called 'git tie' that makes this possible. It's not yet ready for prime time, but you can use the same trick yourself if you're in a hurry. The idea is simple enough: just maintain a branch named refs/heads/tie that is a continually updated "merge -s ours" of all your submodule commits, all jammed together in a single branch that nobody will ever look at.

Then when you 'git fetch origin', it'll fetch both the 'tie' branch and all your other branches, which have references to the commits in the 'tie' branch. The 'tie' branch is what makes it so they'll get auto-downloaded. (Don't forget to push it, too, when you push master.)

The tool I'm working on is basically just one that will auto-maintain the 'tie' branch for you.

Oh, and the second half of this is to just use '.' in your .gitmodules as the path to your submodule repo. It would be nice if 'git submodule update' would use the alternates mechanism (git clone --reference) to get all objects from your subproject's local repo, since we know they're there anyway. I was going to make 'git tie' do this part right too, so you wouldn't even need a .gitmodules file. But either way, you'll survive, it might just be slower than optimal if it downloads everything twice.

And there you go... I've now told you my secrets and regaled you with vapourware. Hope that helps more than it hurts :)

Have fun,
Avery
Previous: DanielNext: in-gitvger@baka.org
Message 8 of 11 in “dependable submodules”
  1. DanielMar 20, 2011
  2. Junio C HamanoMar 20, 2011
  3. DanielMar 20, 2011
  4. Jens LehmannMar 20, 2011
  5. DanielMar 20, 2011
  6. Robert PollakMar 21, 2011
  7. DanielMar 22, 2011
  8. Avery PennarunMar 22, 2011
  9. in-gitvger@baka.orgMar 22, 2011
  10. DanielMar 22, 2011
  11. Jens LehmannMar 22, 2011

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.