Subject: Re: Why does 'submodule add' stage the relevant portions?

From: Jens Lehmann <[email-masked]>
Date: Mon, 25 Mar 2013 09:35:51 +0100

Am 24.03.2013 18:38, schrieb Ramkumar Ramachandra:
> I find this behavior very inconsistent and annoying.  Why would I want
> to commit the submodule change immediately?  Maybe I want to batch it
> up with other changes and stage it at a later time.  Why should I have
> to unstage them manually now?  I get the other side of the argument:
> what if the user commits the .gitmodule change at a different time
> from the file change?  In other words, the user should have a way of
> saying 'submodule stage' and 'submodule unstage'.

Hmm, AFAIK you are the first to bring up such a feature, as in most
use cases doing a "git (submodule) add <path>" is expected to stage
what you added. Maybe you could teach the stage/unstage code to also
stage/unstage the corresponding part of the .gitmodules file, but
I'm not sure it is worth the hassle.

> Now, for the implementation.  Do we have existing infrastructure to
> stage a hunk non-interactively?  (The ability to select a hunk to
> stage/ unstage programmatically).  If not, it might be quite a
> non-trivial thing to write.

Have fun when adding two submodules and unstage only one of them
later. I think this feature will not work unless you analyze
.gitmodules and stage/unstage section-wise.