{"thread":{"id":"56334","subject":"[BUG] git commit -a doesn't ignore inactive/ignore-all submodules","startedAt":"2021-08-20T17:02:40Z","lastAt":"2021-08-24T15:49:58Z","messageCount":2,"participants":["Alexey Izbyshev"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"433247","messageId":"1be1e064559578a190f32dddb8ad39a0@ispras.ru","threadId":"56334","inReplyTo":null,"subject":"[BUG] git commit -a doesn't ignore inactive/ignore-all submodules","fromName":"Alexey Izbyshev","fromEmail":"izbyshev@ispras.ru","sentAt":"2021-08-20T17:02:25Z","receivedAt":"2021-08-20T17:02:40Z","isPatch":false,"sender":{"key":"izbyshev@ispras.ru","avatar":null},"body":"Hi,\n\nI've been surprised to discover that \"git commit -a\" stages submodules \nthat have been explicitly made inactive via \n\"submodule.NAME.active=false\" and/or hidden from status/diff via \n\"submodule.NAME.ignore=all\":\n\ngit init repo\ngit -C repo commit --allow-empty -m \"initial\"\ngit -C repo submodule add \"$PWD\"/repo\ngit -C repo commit -m \"add sm\"\ngit -C repo config submodule.repo.ignore all\ngit -C repo config submodule.repo.active false\ngit -C repo/repo pull\n\nAfter executing the above commands, \"git -C repo commit -a\" will show \n\"repo\" in \"Changes to be committed\" list. I think this behavior is \ndangerous because it makes it easy to accidentally \"update\" the \nsubmodule commit in the main repo while committing other changes. Does \nthis qualify as a bug?\n\nReproduced on 2.33 and 2.17.1. Does not reproduce on 2.7.4 (Ubuntu \n16.04). This discussion[1] and this question[2] also indicate that \"git \ncommit -a\" honored at least \"ignore all\" setting in older git.\n\nAlexey\n\n[1] \nhttps://public-inbox.org/git/CABxC_L92v=cV=+e_DNa0L6f21LB0BRP5duai2h_heGJN_PRoUQ@mail.gmail.com/#t\n[2] \nhttps://superuser.com/questions/1301581/get-git-commit-a-to-ignore-submodules\n\n"},{"id":"433564","messageId":"128d535af65ec58af9a26b9d0e13de8e@ispras.ru","threadId":"56334","inReplyTo":"1be1e064559578a190f32dddb8ad39a0@ispras.ru","subject":"Re: [BUG] git commit -a doesn't ignore inactive/ignore-all submodules","fromName":"Alexey Izbyshev","fromEmail":"izbyshev@ispras.ru","sentAt":"2021-08-24T15:49:46Z","receivedAt":"2021-08-24T15:49:58Z","isPatch":false,"sender":{"key":"izbyshev@ispras.ru","avatar":null},"body":"On 2021-08-20 20:02, Alexey Izbyshev wrote:\n> Reproduced on 2.33 and 2.17.1. Does not reproduce on 2.7.4 (Ubuntu\n> 16.04).\n\nBisected to:\n\ncommit 5556808690ea245708fb80383be5c1afee2fb3eb\nAuthor: Brandon Williams <bmwill@google.com>\nDate:   Tue Jul 25 14:39:16 2017 -0700\n\n     add, reset: ensure submodules can be added or reset\n\n     Commit aee9c7d65 (Submodules: Add the new \"ignore\" config option for\n     diff and status) introduced the ignore configuration option for\n     submodules so that configured submodules could be omitted from the\n     status and diff commands.  Because this flag is respected in the \ndiff\n     machinery it has the unintended consequence of potentially \nprohibiting\n     users from adding or resetting a submodule, even when a path to the\n     submodule is explicitly given.\n\n     Ensure that submodules can be added or set, even if they are \nconfigured\n     to be ignored, by setting the `DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG` \ndiff\n     flag.\n\nWas the change of \"git commit -a\" behavior intended?\n\nTo be clear, I don't understand what problem this patch solves exactly. \nThe commit message mentions issues with \"adding or resetting a \nsubmodule\", but with git 2.7.4 (older than this patch) I can explicitly \n\"git add\" and \"git commit\" a submodule which has \"ignore = all\" set \nwithout problems, though \"git status\" and \"git commit -a\" ignore it, as \nI would expect.\n\nI've also performed another test uncovering that \"submodule.active\" \nappears to have never been honored by \"git commit -a\" at all. Is this \nintended behavior?\n\n From my perspective, it's surprising that \"git status\" and \"git commit \n-a\" take inactive submodules into account. Given that \"git help config\" \nsays that \"submodule.active\" is a \"Boolean value indicating if the \nsubmodule is of interest to git commands\", it would seem to me that \n\"active = false\" should beat everything else, making git behave as if \nsubmodule were not initialized. Is there a way to keep a submodule \nchecked out but make \"git commit -a\" ignore it?\n\nAlexey\n"}]}