threads / bug / 56334

[BUG] git commit -a doesn't ignore inactive/ignore-all submodules

Subject: [BUG] git commit -a doesn't ignore inactive/ignore-all submodules

## tl;dr

2 messages between Aug 20, 2021 and Aug 24, 2021.

replies: 1people: 1as markdown or json

Alexey Izbyshev· Aug 20, 2021, 17:02 UTC · lore
Hi,

I've been surprised to discover that "git commit -a" stages submodules that have been explicitly made inactive via "submodule.NAME.active=false" and/or hidden from status/diff via "submodule.NAME.ignore=all":

git init repo git -C repo commit --allow-empty -m "initial" git -C repo submodule add "$PWD"/repo git -C repo commit -m "add sm" git -C repo config submodule.repo.ignore all git -C repo config submodule.repo.active false git -C repo/repo pull

After executing the above commands, "git -C repo commit -a" will show "repo" in "Changes to be committed" list. I think this behavior is dangerous because it makes it easy to accidentally "update" the submodule commit in the main repo while committing other changes. Does this qualify as a bug?

Reproduced on 2.33 and 2.17.1. Does not reproduce on 2.7.4 (Ubuntu 16.04). This discussion[1] and this question[2] also indicate that "git commit -a" honored at least "ignore all" setting in older git.

Alexey

[1] https://public-inbox.org/git/CABxC_L92v=cV=+e_DNa0L6f21LB0BRP5duai2h_heGJN_PRoUQ@mail.gmail.com/#t [2] https://superuser.com/questions/1301581/get-git-commit-a-to-ignore-submodules

Alexey Izbyshev· Aug 24, 2021, 15:49 UTC · re: Alexey Izbyshev · lore

Re: [BUG] git commit -a doesn't ignore inactive/ignore-all submodules

On 2021-08-20 20:02, Alexey Izbyshev wrote:
> Reproduced on 2.33 and 2.17.1. Does not reproduce on 2.7.4 (Ubuntu
> 16.04).
Bisected to:
commit 5556808690ea245708fb80383be5c1afee2fb3eb
Author: Brandon Williams <bmwill@google.com>
Date:   Tue Jul 25 14:39:16 2017 -0700
     add, reset: ensure submodules can be added or reset
     Commit aee9c7d65 (Submodules: Add the new "ignore" config option for
     diff and status) introduced the ignore configuration option for
     submodules so that configured submodules could be omitted from the
     status and diff commands.  Because this flag is respected in the 
diff
     machinery it has the unintended consequence of potentially 
prohibiting
     users from adding or resetting a submodule, even when a path to the
     submodule is explicitly given.
     Ensure that submodules can be added or set, even if they are 
configured
     to be ignored, by setting the `DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG` 
diff
     flag.
Was the change of "git commit -a" behavior intended?

To be clear, I don't understand what problem this patch solves exactly. The commit message mentions issues with "adding or resetting a submodule", but with git 2.7.4 (older than this patch) I can explicitly "git add" and "git commit" a submodule which has "ignore = all" set without problems, though "git status" and "git commit -a" ignore it, as I would expect.

I've also performed another test uncovering that "submodule.active" appears to have never been honored by "git commit -a" at all. Is this intended behavior?

 From my perspective, it's surprising that "git status" and "git commit 
-a" take inactive submodules into account. Given that "git help config" 
says that "submodule.active" is a "Boolean value indicating if the 
submodule is of interest to git commands", it would seem to me that 
"active = false" should beat everything else, making git behave as if 
submodule were not initialized. Is there a way to keep a submodule 
checked out but make "git commit -a" ignore it?
Alexey

← back to recent threads