{"thread":{"id":"60276","subject":"Supporting `git add -a <exclude submodules>`","startedAt":"2023-09-28T17:07:11Z","lastAt":"2023-09-28T18:24:15Z","messageCount":4,"participants":["Joanna Wang","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"482434","messageId":"CAL-HyEbxGqxid3vsvDk3Z0Gd3swbNP4qcXhApadu8ZgvRkr3WA@mail.gmail.com","threadId":"60276","inReplyTo":null,"subject":"Supporting `git add -a <exclude submodules>`","fromName":"Joanna Wang","fromEmail":"jojwang@chromium.org","sentAt":"2023-09-28T17:06:38Z","receivedAt":"2023-09-28T17:07:11Z","isPatch":false,"sender":{"key":"jojwang@chromium.org","avatar":null},"body":"Hi,\nWe're looking for feedback on the idea of adding git support for users\nto express `git add -a <exclude submodules>`.\n\nWe recently added submodules to our project.\nA lot of our users don't like that when their submodules are on\ncommits that do not match what is pinned in the root superproject,\nrunning `git add -a` and `git commit -a` (which they are so used to),\nwill now include those submodules that 99% of the time they do not\nwant to include.\n\nSo we think supporting `git add -a <exclude submodules>` and `git\ncommit -a <exclude submodules>` might be good to do.\n(We know `git -c diff.ignoreSubmodules=all commit -a` is an option,\nbut this does not work for `git add`. However this support gets\nimplemented for `git add`, I assume it's ideal for the UX of \"don't\ninclude submodules\" to be the same for both `git commit` and `git\nadd`, though I don't think this is a requirement)\n\n\nIn a separate high-level conversation, Junio brought up going about\nthis with magic pathsepc.\nSo the work would entail:\n- adding 'native' submodule attribute support, so `git add -a\n':(exclude,attr:submodule)' can work without having to add 'submodule'\nfor every submodule path in .gitattributes\n- add magic pathspec support to `git add`\n\n(It looks like `git commit -a` does not work with pathspec. In this\ncase I think that would be fine, we can just tell users they can set\naliases for `git -c diff.ignoreSubmodules=all commit -a` and `git add\n-a ':(exclude,attr:submodule)' if they want)\n\nAny thoughts from folks on all of the above?\nThanks!\n"},{"id":"482435","messageId":"xmqqsf6yjhhm.fsf@gitster.g","threadId":"60276","inReplyTo":"CAL-HyEbxGqxid3vsvDk3Z0Gd3swbNP4qcXhApadu8ZgvRkr3WA@mail.gmail.com","subject":"Re: Supporting `git add -a <exclude submodules>`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-09-28T18:11:01Z","receivedAt":"2023-09-28T18:11:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Joanna Wang <jojwang@chromium.org> writes:\n\n> So the work would entail:\n> - adding 'native' submodule attribute support, so `git add -a\n> ':(exclude,attr:submodule)' can work without having to add 'submodule'\n> for every submodule path in .gitattributes\n\nI personally do not think it is a great interface that allows you to\nonly say \"all submodules in my tree, are equally special in the same\nway, and I do not want any of them\" without allowing you to say\n\"paths in this directory, be they files, symlinks, or submodules,\nare special and I do not want any of them\".  The former smells like\na very narrow hack that does not generally extend.  So compared to\n\"git add -a --exclude-submodules\", a solution using magic pathspec\nmechanism and syntax would be a great improvement.\n\nThe spelling of the attribute (if we were to use the \"attr\" magic,\nthat is) may want to allow a bit more flexibility, e.g.,\n\"attr:type=gitlink\", or even \"attr:bits=160000\", that would allow\nnatural extension to cover symbolic links and other oddities.\n\n> - add magic pathspec support to `git add`\n\nYup, I do not offhand remember why \"git add\" does not want to take\nthe magic pathspec with an \"attr\" component.  Whoever wants to tip\nin to this effort may want to first try what breaks when it is\nenabled without changing anything, write tests, and then fix the\nfallouts, which can be done separately and in parallel with an\neffort to design how the way to express \"does this path represent a\nsubmodule?  a regular blob?  a symbolic link?  something else?\" with\nthe magic pathspec syntax (i.e., choose among attr:submodule,\nattr:type=<what>, attr:bits=<permbits>, decide what keyword to use),\nand implement that design.\n\n> (It looks like `git commit -a` does not work with pathspec.\n\nYou should be able to do something like \n\n    $ git commit . ':(exclude)t/'\n\nI think.\n\nBy the way, I am surprised that \"diff.ignoreSubmodules=all\" is\nabused by anybody that way.  It depends on the implementation detail\nthat we internally use the diff machinery to find which paths are\nnot modified, and I would even say it is a BUG that \"commit -a\" pays\nattention to the configuration variable that way.  I would recommend\nstrongly to stay away from that approach or your tools will get\nbroken when the bug gets fixed.\n\nAlso, I have doubts on the higher level workflow issue that makes\nyour people want to keep their submodules (or any subdirectories for\nthat matter) dirty and out of sync with the superproject, and commit\ntheir work product from that state.  It means whatever their local\nbuilding and testing gave them cannot be trusted when evaluating the\nresulting commit at the superproject level.\n"},{"id":"482436","messageId":"xmqqmsx6jh8i.fsf@gitster.g","threadId":"60276","inReplyTo":"xmqqsf6yjhhm.fsf@gitster.g","subject":"Re: Supporting `git add -a <exclude submodules>`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-09-28T18:16:29Z","receivedAt":"2023-09-28T18:16:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> (It looks like `git commit -a` does not work with pathspec.\n>\n> You should be able to do something like \n>\n>     $ git commit . ':(exclude)t/'\n>\n> I think.\n\nCorrection.  You would need the \"-i(nclude)\" option if you do the\nabove, as the default is \"-o(nly)\", which will deliberately ignore\nwhat has been added to the index.\n"},{"id":"482437","messageId":"xmqqfs2yjgvr.fsf@gitster.g","threadId":"60276","inReplyTo":"xmqqsf6yjhhm.fsf@gitster.g","subject":"Re: Supporting `git add -a <exclude submodules>`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-09-28T18:24:08Z","receivedAt":"2023-09-28T18:24:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> By the way, I am surprised that \"diff.ignoreSubmodules=all\" is\n> abused by anybody that way.  It depends on the implementation detail\n> that we internally use the diff machinery to find which paths are\n> not modified, and I would even say it is a BUG that \"commit -a\" pays\n> attention to the configuration variable that way.  I would recommend\n> strongly to stay away from that approach or your tools will get\n> broken when the bug gets fixed.\n\nSorry, but I take this part back.  This is an explicitly documented\nfeature of the variable, so users and scripts alike should be able\nto depend on.  It still feels like a layering violation, but it is\ntoo late to \"fix\" it now.\n\n"}]}