From: "Avery Pennarun" <apenwarr@gmail.com>
To: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Cc: "Tim Harper" <timcharper@gmail.com>, git@vger.kernel.org
Subject: Re: Making submodules easier to work with (auto-update on checkout or merge, stash & restore submodules)
Date: Wed, 30 Apr 2008 12:47:47 -0400 [thread overview]
Message-ID: <32541b130804300947s6083156etc6514cc13c24af13@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.00.0804301121240.17469@eeepc-johanness>
On 4/30/08, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> On Tue, 29 Apr 2008, Tim Harper wrote:
>
> > 1) The submodule stays in the working copy when changing to a branch
> > that does not have a submodule. This can break a build and cause
> > problems. To work around, I have to delete the folder completely
> > (git-clean). Then, when I switch back to the branch again, I have to
> > re-download the submodule.
>
> The problem, of course, is that you can easily have valuable, but
> not-tracked, files in there. Deleting the submodule is therefore no
> option.
I agree that blindly deleting isn't a good choice. For example, what
if I've checked stuff into the submodule but never pushed it anywhere?
Ugh.
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.
> 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.
> 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.
> The whole idea about submodules is that they are repositories of their own
> right, and therefore the superproject should not mess with them, _unless_
> explicitely asked to, with "submodule update".
I think perhaps this is the root of the problem; you're thinking of
the superproject as (A) "a tool for helping me track multiple
subprojects automatically", while I think most people (or at least I)
think of submodules as (B) "folders that have their own series of
commits and thus can be shared between projects."
If you think of it as (A), it's inconvenient to have them shuffling
around automatically. But if you're in the (B) camp, having it not
update automatically seems insane.
I actually don't know any use cases for (A). If my app depends on a
library in a submodule, for example, and I switch to a branch of my
app that uses a different version of the submodule, why would I ever
*not* want the submodule to switch too? If it doesn't, it'll probably
break the compile.
> > 3) If I don't run "git submodule update", and carelessly run "git commit
> > -a" or "git add .", I risk propagating a submodule version from
> > another branch or undoing an important change.
>
> git commit -a is something that might make sense for newbies, but you
> really should learn to use git add -p and commit without -a.
This is a matter of opinion; pretty much every other major VCS does
the equivalent of "git commit -a" when you commit, and most people
don't seem to mind. It is therefore possible that git is the weird
one, not every other VCS.
In particular, in this case what git is doing is, "You checked out a
new branch, but I don't really trust you, so I actually made this
modification in your tree for you. Now if you commit, you can check
in that change that I think you meant to check in." Wouldn't you
expect "git checkout branch; git commit -a" on a clean tree to never
commit anything?
> > 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.
Have fun,
Avery
next prev parent reply other threads:[~2008-04-30 16:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-30 4:08 Making submodules easier to work with (auto-update on checkout or merge, stash & restore submodules) Tim Harper
2008-04-30 4:47 ` Tim Harper
2008-04-30 6:14 ` Andreas Ericsson
2008-04-30 10:31 ` Johannes Schindelin
2008-04-30 16:47 ` Avery Pennarun [this message]
2008-04-30 17:21 ` Ping Yin
2008-04-30 19:55 ` Roman Shaposhnik
2008-04-30 20:26 ` Avery Pennarun
2008-04-30 20:19 ` Tim Harper
2008-04-30 20:31 ` Avery Pennarun
2008-04-30 21:37 ` Tim Harper
2008-04-30 21:48 ` Avery Pennarun
2008-04-30 22:23 ` Roman Shaposhnik
2008-04-30 22:28 ` Avery Pennarun
2008-05-01 18:38 ` Making submodules easier to work with Finn Arne Gangstad
2008-05-01 19:55 ` Avery Pennarun
2008-05-06 23:47 ` Roman Shaposhnik
2008-05-07 16:14 ` Avery Pennarun
2008-05-08 1:13 ` Ping Yin
2008-05-01 23:29 ` Steven Grimm
2008-05-06 23:17 ` Roman Shaposhnik
2008-05-01 4:56 ` Making submodules easier to work with (auto-update on checkout or merge, stash & restore submodules) Ping Yin
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=32541b130804300947s6083156etc6514cc13c24af13@mail.gmail.com \
--to=apenwarr@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=timcharper@gmail.com \
/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).