Subject: Re: git commit vs. ignore-submodules

From: Jens Lehmann <[email-masked]>
Date: Fri, 28 Mar 2014 17:47:08 +0100

Am 28.03.2014 00:36, schrieb Ronald Weiss:
> Hello.
> 
> As this is my first post to this list, let me first thank all the
> people involved in Git development - it's really a great tool.

Welcome and thanks for the feedback!

> Now to the point. Since Git 1.8 (I think), git commit command honours
> the submodules' ignore settings, configured either in .gitmodules, or
> in .git/config. That's very nice and certainly correct for "git commit
> -a", but it's less clear if one explicitely stages an updated
> submodule using git add. Git commit will ignore it anyway, if
> ignore=all is configured in .gitmodules. Maybe that's correct too, I'm
> not sure about that, but it's inconvenient in our use case, especially
> combined with the lack of --ignore-submodule parameter to git commit,
> as git status and git diff have.
> 
> We use submodules in such a way that normally we don't ever want to
> see changes in them in output of git diff and git status. So we set
> ignore=all in .gitmodules for each submodule. But occasionally, we
> need to add a new submodule, and sometimes also commit changed
> submodule. This got harder with Git 1.8, we have to "git config
> submodule.<name>.ignore none" before the commit, and "git config
> --unset ..." after.
> 
> I'd like to at least add an --ignore-submodules parameter to git
> commit. I though about posting a patch, but as I looked into the
> commit source file, I didn't see any straightforward way to implement
> it. I don't have enough free time for a deeper analysis of the
> sources, I'm sorry.
> 
> So please, let me first know, whether you could possibly accept such
> patch, and if so, then I'd really appreciate some hints on how to do
> it.

Such a patch would be very much appreciated. You might want to look
into other commands that already have the --ignore-submodules option
to get an idea how to do that. cmd_status() in builtin/commit.c
should be a good starting point.

> And also, I'd like to know git folks' opinion on whether it's OK that
> git commit with ignore=all in .gitmodules ignores submodules even when
> they are explicitely staged with git add.

No, they should be visible in status and commit when the user chose
to add them. I see if I can hack something up (as I've been bitten
myself by that recently ;-).