On Tue, Jan 07, 2014 at 10:15:25AM -0800, Junio C Hamano wrote:
>     submodule: respect requested branch on all clones
>     The previous code only checked out the requested branch in cmd_add
>     but not in cmd_update; this left the user on a detached HEAD after
>     an update initially cloned, and subsequent updates using rebase or
>     merge mode will kept the HEAD detached, unless the user moved to the
>     desired branch himself.
>     Move the branch-checkout logic into module_clone, where it can be
>     shared by cmd_add and cmd_update.  Also update the initial checkout
>     command to use 'rebase' to preserve branches setup during
>     module_clone.  This way, unless the user explicitly asks to work on
>     a detached HEAD, subsequent updates all happen on the specified
>     branch, which matches the end-user expectation much better.

This looks reasonable to me, but there are still changes I'd like to
make for a v3 (e.g. using submodule.<name>.update to trigger local
branch checkout).  However, I'm currently leaning towards a new 'git
submodule checkout' command with explicit preferred local submodule
branches (see [1]).  Maybe this should all wait until Jens rolls out
his update implementation [2]?

> Having writing all the above and then looking at the patch again, it
> is not immediately obvious to me where you use "rebase" when doing
> the initial checkout, though.

It's used to shift the local branch reference from from the
(arbitrary) cloned remote branch tip to the explicit submodule $sha1.
Otherwise the default method for that operation is a HEAD-detaching
'checkout'. I tried to explain it here [3].

> "W. Trevor King" <wk...@tremily.us> writes:
> > The current Documentation/git-submodule.txt has:
> >
> >   update::
> >     Update the registered submodules, i.e. clone missing submodules
> >     and checkout the commit specified in the index of the containing
> >     repository.  This will make the submodules HEAD be detached unless
> >     `--rebase` or `--merge` is specified or the key
> >     `submodule.$name.update` is set to `rebase`, `merge` or `none`.
> Side note but doesn't Francesco's "'checkout' is a valid update mode"
> need to update this part of the documentation as well?

That would be nice.  I don't think his patch changes the docs, and I
don't know if mentioning the --checkout option belongs in that patch
as well, or in a separate fixup ;).


[1]: http://article.gmane.org/gmane.comp.version-control.git/240097
[2]: http://article.gmane.org/gmane.comp.version-control.git/240117
[3]: http://article.gmane.org/gmane.comp.version-control.git/239953

This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to