git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Avery Pennarun" <apenwarr@gmail.com>
To: "Junio C Hamano" <gitster@pobox.com>
Cc: "Sam Vilain" <sam@vilain.net>,
	"Eyvind Bernhardsen" <eyvind-git@orakel.ntnu.no>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: git-submodule getting submodules from the parent repository
Date: Tue, 1 Apr 2008 22:03:50 -0400	[thread overview]
Message-ID: <32541b130804011903u3b5d0794w984e26c4570c4688@mail.gmail.com> (raw)
In-Reply-To: <7vd4p9ccw8.fsf@gitster.siamese.dyndns.org>

On 4/1/08, Junio C Hamano <gitster@pobox.com> wrote:
> "Avery Pennarun" <apenwarr@gmail.com> writes:
>  > Instead of storing only the commitid of each submodule in the parent
>  > tree, store the current branch name as well.
> > ...
> > This way, cloning a project with submodules will work much like
>  > cloning the parent project; pushing and pulling the parent and the
>  > submodules will do as you expect.
>
> That goes quite against the fundamental design of git submodules in that
>  the submodules are by themselves independent entities.

Not sure what you mean here; the supermodule already stores the
commitid of the submodule.  All I'm proposing is that it also store
the default branchname (ie. the branchname that the submodule was
using when its gitlink was checked into the supermodule) along with
that commitid.  The submodule never knows anything about the
supermodule.

>  An often-cited
>  example is an appliance project, where superproject bundles a clone of
>  Linux kernel and a clone of busybox repositories as its submodules.

What a coincidence!  This is almost exactly like my situation :)

>  If your superproject (i.e. the appliance product) uses two branches to
>  manage two product lines, named "v1" and "v2", these names are local to
>  the superproject.  It should not force the projects you borrow your
>  submodules from to have branches with corresponding name.

I meant that we should store the submodule's branch name when
committing the superproject, and put it back when checking out the
submodule fresh from the superproject.

>   - When not working in a particular submodule, but using it as a component
>    to build the superproject, it would be better to leave its HEAD
>    detached to the version the superproject points at.  IOW, usually you
>    won't have to be on any branch in submodules unless you are working in
>    them.

I agree that the submodule should have its HEAD pointing at exactly
the superproject-specified commit.  However, I believe this commit
should have a local branch name (in the subproject) attached to it, or
else (as I and my co-workers have frequently experienced) people will
accidentally check in to a nameless branch, causing 'git push' to
silently not upload anything, and thus lose track of their commits.  I
have lost work this way.

The idea of naming the local-subproject-branch with the same name as
it had on checking is that then "git pull" in the subproject will work
exactly as expected: it'll get you the latest version of the branch
the superproject developer was on.  But if you *don't* explicitly "git
pull" in the subproject, I'd expect (of course) the checkout to stick
to the commit specified by the superproject - and also to leave its
local branch name pointing at exactly that commit.

>   - Sometimes you need to work in a submodule; e.g. you would want to add
>    'frotz' tool to your copy of busybox.  You chdir to the submodule
>    directory, and develop as if there is no superproject.

This is where my workflow is a bit different.  One of my subprojects
is a library that gets used by several application superprojects.  I
often add features to my library in the process of editing a
particular superproject.  I also expect my co-developers to want to do
the same.  Thus, the difference from your example is that I want to
streamline the process of working in a subproject as well as a
superproject, and minimize the chances of losing data in this case.

With the current system the way it is, it's too easy to make mistakes,
and it requires too many steps to fetch/merge/rebranch each submodule.

>    - Then work on adding that 'frotz' tool.  Make commits, test it in
>      isolation and test with superproject.  Push it out as whichever
>      remote branch the project policy asks you to.

As an orthogonal secondary wish, I'd like to have the subproject and
superproject hosted in the same remote repository.  This appears to be
possible (albeit inefficiently right now) by using "." as the remote
repo name in .gitmodules.  It would be more efficient if
git-submodule-update would use the superproject's checkout as a
--alternate when cloning the submodule... I think that would be easy
and harmless, right?

The super-summary of all that is I think I'd like to make three git
changes here:

1) When checking out a submodule from scratch, use the local
supermodule as a --alternate.  That way if both super and submodule
are hosted in the same remote repo, I don't have to clone them twice.
(And cloning my local repo to another copy doesn't stop git-submodule
from working.)

2) When checking out a submodule, give the submodule's current commit
a useful branch name (ideally, the name it had when the gitlink was
checked into the supermodule).  When updating a submodule with
git-submodule-update, quietly fixup the submodule's local branch ref
if it hasn't been changed; else produce a conflict of some sort.

3) Bonus: make "git push" operate recursively on submodules, and "git
pull" automatically run git-submodule-update.

Does that make sense?

Thanks,

Avery

  reply	other threads:[~2008-04-02  2:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-29 22:35 git-submodule getting submodules from the parent repository Avery Pennarun
2008-03-29 23:22 ` Sam Vilain
2008-03-30 13:32   ` Eyvind Bernhardsen
2008-03-30 17:48     ` Sam Vilain
2008-03-30 19:50       ` Eyvind Bernhardsen
2008-03-30 20:19         ` Sam Vilain
2008-03-31 10:05           ` Eyvind Bernhardsen
2008-03-30 23:03         ` Avery Pennarun
2008-03-31  9:29           ` Eyvind Bernhardsen
2008-03-31 21:36             ` Avery Pennarun
2008-04-01 23:05               ` Sam Vilain
2008-04-01 23:56                 ` Avery Pennarun
2008-04-02  0:35                   ` Junio C Hamano
2008-04-02  2:03                     ` Avery Pennarun [this message]
2008-04-02 20:06                       ` Sam Vilain
2008-04-02 21:32         ` Junio C Hamano
2008-03-30 23:00   ` Avery Pennarun
2008-04-01 23:10     ` Sam Vilain
2008-03-31  6:22 ` Johannes Sixt
2008-03-31 21:24   ` Avery Pennarun

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=32541b130804011903u3b5d0794w984e26c4570c4688@mail.gmail.com \
    --to=apenwarr@gmail.com \
    --cc=eyvind-git@orakel.ntnu.no \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sam@vilain.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).