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

Re: Auto update submodules after merge and reset

From
ATAndreas T.Auer <andreas.t.auer_gtml_37453@ursus.ath.cx>
Date
Dec 7, 2011, 09:07 UTC
Message-ID
<jbnadt$hf8$1@dough.gmane.org>
In-Reply-To
<4ED5E9D2.4060503@web.de>
Jens Lehmann wrote:
Show 8 quoted lines
> Am 30.11.2011 01:55, schrieb Max Krasnyansky:
> I'm working on a patch series to teach Git to optionally update the
> submodules work trees on checkout, reset merge and so on, but I'm not
> there yet.
>
>> I'm thinking about adding a config option that would enable automatic
>> submodule update but wanted to see if there is some fundamental reason
>> why it would not be accepted.
Because there is no good way to do so. It would be fine when you just track 
the submodules "read-only", but if you are actually working on submodules, 
it is a bad idea to always get a detached HEAD. It is also a bad idea to 
merge or rebase on the currently checkedout branch. Because if you are 
working on a maint branch in the submodule and then you checkout a pu branch 
in the superproject, because you have forgotten that maint branch in the 
submodule then all the proposed updates go to the maintenance branch -> bad. 
So auto-update is not easy. But below I describe an idea that might solve 
these issues and help auto-udpate to work in a sane way.
 
> I think adding something like an "submodule.autoupdate" config makes lots
> of sense, but IMO it should affect all work tree updating porcelain
> commands, not just merge.

I was thinking about submodule integration and had the idea to bind a submodule to the superproject by having special references in the submodule like refs/super/master, refs/super/featureX... So these references are like tracking branches for the refs/heads/* of the superproject.

If you have tracking branches, the supermodule can just update the corresponding branch. If this branch is currently checkedout and the work area is clean, then the work area is updated, too. If there is currently a local branch or a diffent super-branch checked out then the working area should be considered "detached" from the superproject and not updated.

With this concept you could even switch branches in the superproject and the attached submodules follow - still having no detached HEAD. When you want to do some local work on the submodule you checkout a local branch and merge back into the super branch later. The head of that super branch might have changed by the update procedure meanwhile, but that is fine, then you just have a merge instead of a fast-forward.

Another nice feature would be a recursive commit. So all changed index files in the _attached_ submodules would first be committed in their submodules and then the superproject commits too - all with one command. Currently it feels a little bit like CVS - commit one file(submodule), commit the other file(submodule) and then apply a label(commit the superproject) to keep the changes together.

If the submodule is not attached the commit in the superproject can still detect changes that have been made to the corresponding tracking branch and pick these up.

As a summary: Tracking submodule branches in the superproject instead of only the current HEAD of the submodule gives you more freedom to install sane auto-update procedures. Even though it will raise a lot of detailed questions like "should the refs/super/* be pushed/pulled when syncing the submodule repositories".

Previous: Jens LehmannNext: Jens Lehmann
Message 5 of 18 in “Auto update submodules after merge and reset”
  1. Max KrasnyanskyNov 30, 2011
  2. Jens LehmannNov 30, 2011
  3. Max KrasnyanskyDec 6, 2011
  4. Jens LehmannDec 6, 2011
  5. Andreas T.AuerDec 7, 2011
  6. Jens LehmannDec 7, 2011
  7. andreas.t.auer_gtml_37453@ursus.ath.cxDec 8, 2011
  8. Phil HordDec 9, 2011
  9. Andreas T.AuerDec 10, 2011
  10. Phil HordDec 11, 2011
  11. Andreas T.AuerDec 11, 2011
  12. Jens LehmannDec 12, 2011
  13. Phil HordDec 12, 2011
  14. Jens LehmannDec 13, 2011
  15. Andreas T.AuerDec 13, 2011
  16. Jens LehmannDec 13, 2011
  17. Andreas T.AuerDec 13, 2011
  18. Marc BranchaudDec 14, 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.