git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas T.Auer" <andreas.t.auer_gtml_37453@ursus.ath.cx>
To: git@vger.kernel.org
Subject: Re: Auto update submodules after merge and reset
Date: Wed, 07 Dec 2011 10:07:34 +0100	[thread overview]
Message-ID: <jbnadt$hf8$1@dough.gmane.org> (raw)
In-Reply-To: 4ED5E9D2.4060503@web.de

Jens Lehmann wrote:

> 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".

  parent reply	other threads:[~2011-12-07  9:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-30  0:55 Auto update submodules after merge and reset Max Krasnyansky
2011-11-30  8:31 ` Jens Lehmann
2011-12-06  1:06   ` Max Krasnyansky
2011-12-06 21:32     ` Jens Lehmann
2011-12-07  9:07   ` Andreas T.Auer [this message]
2011-12-07 22:23     ` Jens Lehmann
2011-12-08  9:13       ` andreas.t.auer_gtml_37453
2011-12-09 23:57         ` Phil Hord
2011-12-10  1:41           ` Andreas T.Auer
2011-12-11 14:43             ` Phil Hord
2011-12-11 21:15           ` Andreas T.Auer
2011-12-12 22:39             ` Jens Lehmann
2011-12-12 23:43               ` Phil Hord
2011-12-13  7:52                 ` Jens Lehmann
2011-12-13  9:45               ` Andreas T.Auer
2011-12-13 21:44                 ` Jens Lehmann
2011-12-13 23:05                   ` Andreas T.Auer
2011-12-14 15:16                     ` Marc Branchaud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='jbnadt$hf8$1@dough.gmane.org' \
    --to=andreas.t.auer_gtml_37453@ursus.ath.cx \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).