Subject: Re: Making submodules easier to work with (auto-update on checkout or merge, stash & restore submodules)

From: Roman Shaposhnik <[email-masked]>
Date: Wed, 30 Apr 2008 12:55:45 -0700

On Wed, 2008-04-30 at 12:47 -0400, Avery Pennarun wrote:
> On 4/30/08, Johannes Schindelin <[email-masked]> wrote:
> That said, it makes submodule folders act completely inconsistently
> with normal folders, which is highly undesirable.  The current
> behaviour strongly encourages me to avoid submodules when I would
> otherwise like to use them, just to keep the rest of my team members
> (who are not git experts) from going insane.

Well said. I find myself in exactly the same situation wrt. submodules.
To give an analogy imagine that everytime you had a mount-point in
your path you'd have to do something special in order to cross it.
IOW, open("/tmp/foo/bar/baz.c") would just work, where
open("/mnt/point1/foo.c") would require you to first cross /mnt/point1
somehow. Currently submodules feel very much like the second case
to me. Now, I've shut up for the time being on that other thread,
since I'd like to come up with a clearly defined workflow first.
But for the record: the way submodules are implemented right now
in a porcelain make them pretty much an impossible sell to those
in my org who don't want to know much about SCMs.

> >  But once you did "submodule init", you will never need to run it again,
> >  since it edits your .git/config, which does not change when switching
> >  branches.
> 
> Not true.  If ".gitmodules" is different between branches, then
> .git/config will have the wrong information.  I think this was the
> reason for the "read .gitmodules directly and don't worry about
> .git/config" discussion/patches earlier.

Exactly!

> >  And as for "submodule update", I like the fact that the submodule is not
> >  updated automatically.  For example, when I actively develop a submodule,
> >  but have to rebase the superproject, I would _hate_ it if the submodule
> >  wass updated.
> 
> Why?  Every other folder in your entire project gets updated when you
> "git checkout".  Why are submodules different?  I can personally vouch
> that this is confusing for almost everyone I've seen who tried it.

+1 ;-)

> >  > PITFALLS:
> >  > pitfall)
> >  > If you commit a change on a submodule that's not on a branch, auto-updating
> >  > submodules will make it difficult to revive that change.
> >  >
> >  > workaround)
> >  > Don't allow the user to commit unless they are on a branch.
> >  >
> >  > ... couldn't think of anymore.  Anyone?
> 
> We had some discussion on the list earlier about having submodule
> checkouts automatically acquire a branch name, so that commits don't
> get lost as easily.  I was going to think about this more and
> eventually submit a patch, but I haven't gotten to it yet.  Anyway,
> the idea is that you have a branch by default, so that you don't end
> up in the useless situation of not being on a branch, which encourages
> checking in without being on a branch, in the first place.

Can you give a gmane pointer to that thread?

Thanks,
Roman.