{"thread":{"id":"51563","subject":"Support for --stdin-paths in commit, add, etc","startedAt":"2019-07-31T15:59:58Z","lastAt":"2019-08-02T15:11:27Z","messageCount":23,"participants":["Alexandr Miloslavskiy","Junio C Hamano","Jeff King","René Scharfe","Phillip Wood","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"379689","messageId":"a38bc928-7ccd-e2d9-b89b-23298e9fa95d@syntevo.com","threadId":"51563","inReplyTo":null,"subject":"Support for --stdin-paths in commit, add, etc","fromName":"Alexandr Miloslavskiy","fromEmail":"alexandr.miloslavskiy@syntevo.com","sentAt":"2019-07-31T15:45:12Z","receivedAt":"2019-07-31T15:59:58Z","isPatch":false,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"Hello,\n\nHello,\n\nThis is a follow-up for previous discussion [1].\n\nIn our git UI, we sometimes run into OS commandline length limit when\ntrying to specify a list of pathspecs. For example, this happens when\nuser selects a large set of files and wants to commit them. As a\nworkaround, we split files and issue multiple git commands.\n\nThis has multiple disadvantages:\n1) Some commands are a lot slower this way. For example, commit-amend\n    can take 45 minutes instead of 30 seconds, because git will do a lot\n    of unnecessary work.\n2) The operation is no longer completed in one \"transaction\".\n3) This makes our code more complicated.\n\nOur suggestion is to change commands such as 'commit', 'add', etc to\nalso work with --stdin-paths. If a command already supports stdin for\nany purpose, then trying to use both options will return an error.\n\nWe're ready to develop the necessary patches to make this possible.\n\n[1] \nhttps://public-inbox.org/git/c3be6eff-365b-96b8-16d2-0528612fc1fc@syntevo.com/T/#u\n"},{"id":"379693","messageId":"xmqqa7cuqg6g.fsf@gitster-ct.c.googlers.com","threadId":"51563","inReplyTo":"a38bc928-7ccd-e2d9-b89b-23298e9fa95d@syntevo.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-07-31T17:15:03Z","receivedAt":"2019-07-31T17:15:13Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com> writes:\n\n> In our git UI, we sometimes run into OS commandline length limit when\n> trying to specify a list of pathspecs. For example, this happens when\n> user selects a large set of files and wants to commit them. As a\n> workaround, we split files and issue multiple git commands.\n\nYes, for plumbing commands meant for scripting, we really should\nstrive to give scriptors way(s) to avoid the command line limit,\nand --stdin-paths is a very good approach to do so.\n\n"},{"id":"379695","messageId":"20190731171956.GA26746@sigill.intra.peff.net","threadId":"51563","inReplyTo":"a38bc928-7ccd-e2d9-b89b-23298e9fa95d@syntevo.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-07-31T17:19:57Z","receivedAt":"2019-07-31T17:19:59Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jul 31, 2019 at 05:45:12PM +0200, Alexandr Miloslavskiy wrote:\n\n> In our git UI, we sometimes run into OS commandline length limit when\n> trying to specify a list of pathspecs. For example, this happens when\n> user selects a large set of files and wants to commit them. As a\n> workaround, we split files and issue multiple git commands.\n> \n> This has multiple disadvantages:\n> 1) Some commands are a lot slower this way. For example, commit-amend\n>    can take 45 minutes instead of 30 seconds, because git will do a lot\n>    of unnecessary work.\n> 2) The operation is no longer completed in one \"transaction\".\n> 3) This makes our code more complicated.\n> \n> Our suggestion is to change commands such as 'commit', 'add', etc to\n> also work with --stdin-paths. If a command already supports stdin for\n> any purpose, then trying to use both options will return an error.\n\nI don't have any real objection to adding stdin support for more\ncommands. Bu tin the specific case you're discussing, it seems like\nusing \"git update-index\" might already solve your problem. It's the\nintended plumbing for scripted index updates, and it already supports\nreceiving paths from stdin.\n\n-Peff\n"},{"id":"379715","messageId":"xmqqblx9q4rw.fsf@gitster-ct.c.googlers.com","threadId":"51563","inReplyTo":"20190731171956.GA26746@sigill.intra.peff.net","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-07-31T21:21:23Z","receivedAt":"2019-07-31T21:21:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> ... But in the specific case you're discussing, it seems like\n> using \"git update-index\" might already solve your problem. It's the\n> intended plumbing for scripted index updates, and it already supports\n> receiving paths from stdin.\n\nSounds good.\n"},{"id":"379740","messageId":"ab333992-35c6-a5a9-0bcb-cef51f004679@syntevo.com","threadId":"51563","inReplyTo":"20190731171956.GA26746@sigill.intra.peff.net","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Alexandr Miloslavskiy","fromEmail":"alexandr.miloslavskiy@syntevo.com","sentAt":"2019-08-01T13:25:59Z","receivedAt":"2019-08-01T13:26:05Z","isPatch":false,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"On 31.07.2019 19:19, Jeff King wrote:\n> I don't have any real objection to adding stdin support for more\n> commands. Bu tin the specific case you're discussing, it seems like\n> using \"git update-index\" might already solve your problem. It's the\n> intended plumbing for scripted index updates, and it already supports\n> receiving paths from stdin.\n\nI have now studied which git commands already use commandline splitting\nin our application. For some of them, I didn't find comparable plumbing;\nfor others, I feel that a lot of new edge cases will arise, and it will\nneed a lot of testing to make sure things work as expected.\n\nTherefore, for us it would be best if high-level commands also accepted\n--stdin-paths. If I develop good enough patches for that, will you\naccept them?\n\nWe're interested in these high-level commands:\n1) git add\n2) git rm\n3) git checkout\n4) git reset\n5) git stash\n6) git commit\n\nHere's the list of detailed commands and plumbings I found:\n01) git add\n     'git update-index' doesn't seem to be able to skip ignored files.\n02) git add --force\n     Probably 'git update-index --add --stdin'.\n03) git checkout\n     Probably 'git checkout-index --stdin'\n04) git checkout HEAD\n     Didn't find a plumbing to only affect named paths.\n05) git checkout --ours\n     Probably 'git checkout-index --stage=2 --force --stdin'\n06) git checkout --theirs\n     Probably 'git checkout-index --stage=3 --force --stdin'\n07) git rm [--force] [--cached]\n     Probably 'git update-index --force-remove'\n     Didn't find how to delete files from working tree.\n08) git reset -q HEAD\n     Didn't find a plumbing to only affect named paths.\n09) git add --update\n     Probably 'git update-index --again --add --stdin'\n     Not sure that --again is good replacement.\n10) git stash push [--keep-index] [--include-untracked] [--message]\n     Didn't find plumbing for stashes.\n11) git commit [--allow-empty] [--amend] [--signoff] [--no-verify]\n       --file=CommitMessage.txt -o\n     Didn't find a plumbing to only affect named staged paths.\n"},{"id":"379743","messageId":"066cfd61-9700-e154-042f-fc9cffbd6346@web.de","threadId":"51563","inReplyTo":"a38bc928-7ccd-e2d9-b89b-23298e9fa95d@syntevo.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2019-08-01T14:26:23Z","receivedAt":"2019-08-01T14:26:47Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 31.07.19 um 17:45 schrieb Alexandr Miloslavskiy:\n> Our suggestion is to change commands such as 'commit', 'add', etc to\n> also work with --stdin-paths. If a command already supports stdin for\n> any purpose, then trying to use both options will return an error.\n\nWould it make sense to have a --paths-file parameter instead that allows\nreading paths from a given file and honors the convention of reading\nfrom stdin with the special argument \"-\"?  Reading from stdin would\nstill only work for one parameter at a time, but paths could also be\npassed via a regular file or named pipe, allowing for more flexibility.\n\nRené\n"},{"id":"379744","messageId":"a5c7d7af-b83c-5ea7-b8bf-1e4a4e986469@syntevo.com","threadId":"51563","inReplyTo":"066cfd61-9700-e154-042f-fc9cffbd6346@web.de","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Alexandr Miloslavskiy","fromEmail":"alexandr.miloslavskiy@syntevo.com","sentAt":"2019-08-01T14:33:45Z","receivedAt":"2019-08-01T14:46:31Z","isPatch":false,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"On 01.08.2019 16:26, René Scharfe wrote:\n> Would it make sense to have a --paths-file parameter instead\n\nBoth approaches (stdin or file) will work well for us. File sounds\neasier from programming perspective. However, in previous discussion, \nthere was some concern about possible security problems with this approach.\n"},{"id":"379751","messageId":"xmqqef24op5q.fsf@gitster-ct.c.googlers.com","threadId":"51563","inReplyTo":"066cfd61-9700-e154-042f-fc9cffbd6346@web.de","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-08-01T15:56:17Z","receivedAt":"2019-08-01T15:56:23Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n> Would it make sense to have a --paths-file parameter instead that allows\n> reading paths from a given file and honors the convention of reading\n> from stdin with the special argument \"-\"?  Reading from stdin would\n> still only work for one parameter at a time, but paths could also be\n> passed via a regular file or named pipe, allowing for more flexibility.\n\nThe command's primary function itself may want to use the standard\ninput stream to read things other than the list of paths; if we are\nnot limiting ourselves to plumbing (i.e. doing one thing well), the\n\"--stdin-paths\" may not be a general solution that is good enough.\n\nSo, reading paths from a file (which could be \"-\" as you suggest)\nwould be a good solution for that.\n\n"},{"id":"379754","messageId":"a6610e94-6318-b962-5dd0-ca379def3bba@syntevo.com","threadId":"51563","inReplyTo":"xmqqef24op5q.fsf@gitster-ct.c.googlers.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Alexandr Miloslavskiy","fromEmail":"alexandr.miloslavskiy@syntevo.com","sentAt":"2019-08-01T16:04:17Z","receivedAt":"2019-08-01T16:04:24Z","isPatch":false,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"On 01.08.2019 17:56, Junio C Hamano wrote:\n> So, reading paths from a file (which could be \"-\" as you suggest)\n> would be a good solution for that.\n\nTo summarize:\n1) Implement --paths-file for high-level commands.\n2) '--paths-file -' would mean reading from stdin.\n\nIs that something you're ready to accept patches for?\n"},{"id":"379762","messageId":"06daa8c1-d955-1e49-e5e6-85d53ffce6e6@gmail.com","threadId":"51563","inReplyTo":"ab333992-35c6-a5a9-0bcb-cef51f004679@syntevo.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2019-08-01T17:35:26Z","receivedAt":"2019-08-01T17:35:31Z","isPatch":false,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 01/08/2019 14:25, Alexandr Miloslavskiy wrote:\n> On 31.07.2019 19:19, Jeff King wrote:\n>> I don't have any real objection to adding stdin support for more\n>> commands. Bu tin the specific case you're discussing, it seems like\n>> using \"git update-index\" might already solve your problem. It's the\n>> intended plumbing for scripted index updates, and it already supports\n>> receiving paths from stdin.\n> \n> I have now studied which git commands already use commandline splitting\n> in our application. For some of them, I didn't find comparable plumbing;\n> for others, I feel that a lot of new edge cases will arise, and it will\n> need a lot of testing to make sure things work as expected.\n> \n> Therefore, for us it would be best if high-level commands also accepted\n> --stdin-paths. If I develop good enough patches for that, will you\n> accept them?\n> \n> We're interested in these high-level commands:\n> 1) git add\n> 2) git rm\n> 3) git checkout\n> 4) git reset\n> 5) git stash\n> 6) git commit\n> \n> Here's the list of detailed commands and plumbings I found:\n> 01) git add\n>      'git update-index' doesn't seem to be able to skip ignored files.\n\nNo but it only takes paths not pathspecs, can you filter out the ignored \npaths first? From a UI point of view it would be better not to allow \nusers to select ignored files if you don't want to be able to add them. \nIf you want to use a pathspec then you can do 'git ls-files \n--exclude-standard -o -z <pathspec ...> | git update-index --add -z --stdin'\ngit check-ignore --stdin should help if you have a list of paths and you \nwant to remove the ignored ones (it's not great as it tells you which \nones are ignored rather than filtering the list for you)\n\n> 02) git add --force\n>      Probably 'git update-index --add --stdin'.\n> 03) git checkout\n>      Probably 'git checkout-index --stdin'\n> 04) git checkout HEAD\n>      Didn't find a plumbing to only affect named paths.\n\nYou can use a temporary index and do\nGIT_INDEX_FILE=$tmp_index git read-tree HEAD && \nGIT_INDEX_FILE=$tmp_index git checkout-index --stdin &&\nrm $tmp_index\n\n> 05) git checkout --ours\n>      Probably 'git checkout-index --stage=2 --force --stdin'\n> 06) git checkout --theirs\n>      Probably 'git checkout-index --stage=3 --force --stdin'\n> 07) git rm [--force] [--cached]\n>      Probably 'git update-index --force-remove'\n>      Didn't find how to delete files from working tree.\n\nYou have to delete them yourself.\n\n> 08) git reset -q HEAD\n>      Didn't find a plumbing to only affect named paths.\n\nIt's a bit of a pain but you can use 'git update-index -q --unmerged \n--refresh && git diff-index --cached -z HEAD' to get a list of paths in \nthe index that differ from HEAD. The list contains the old oid for each \npath (see the man page for the format) and you can feed those into 'git \nupdate-index --index-info' to update the index.\n\n> 09) git add --update\n>      Probably 'git update-index --again --add --stdin'\n>      Not sure that --again is good replacement.\n\nor something like 'git update-index -q --refresh && git diff-files \n--name-only -z | git update-index -z --stdin'\n\n> 10) git stash push [--keep-index] [--include-untracked] [--message]\n>      Didn't find plumbing for stashes.\n\nstashes are just commits really so there are no plumbing commands \nspecifically related to them.\n\n> 11) git commit [--allow-empty] [--amend] [--signoff] [--no-verify]\n>        --file=CommitMessage.txt -o\n>      Didn't find a plumbing to only affect named staged paths.\n\nYou can use a temporary index, add the files you want to commit with \nupdate-index --stdin and then run 'git commit'\n\nWhen I've been scripting I've sometimes wished that diff-index and \ndiff-files had a --stdin option.\n\nBest Wishes\n\nPhillip\n"},{"id":"379773","messageId":"xmqqmugsmy2e.fsf@gitster-ct.c.googlers.com","threadId":"51563","inReplyTo":"06daa8c1-d955-1e49-e5e6-85d53ffce6e6@gmail.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-08-01T20:26:49Z","receivedAt":"2019-08-01T20:26:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood123@gmail.com> writes:\n\n> No but it only takes paths not pathspecs, can you filter out the\n> ignored paths first? From a UI point of view it would be better not to\n> allow users to select ignored files if you don't want to be able to\n> add them. If you want to use a pathspec then you can do 'git ls-files\n> --exclude-standard -o -z <pathspec ...> | git update-index --add -z\n> --stdin'\n> ...\n> You can use a temporary index, add the files you want to commit with\n> update-index --stdin and then run 'git commit'\n\nAll true.  Perhaps we need a separate tutorial for scripters to\nteach them how to properly combine the plumbing commands?\n\n> When I've been scripting I've sometimes wished that diff-index and\n> diff-files had a --stdin option.\n\nSounds fair.\n"},{"id":"379774","messageId":"27220d22-8c9a-dda2-764b-709dcd85d788@syntevo.com","threadId":"51563","inReplyTo":"xmqqmugsmy2e.fsf@gitster-ct.c.googlers.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Alexandr Miloslavskiy","fromEmail":"alexandr.miloslavskiy@syntevo.com","sentAt":"2019-08-01T20:40:23Z","receivedAt":"2019-08-01T20:40:28Z","isPatch":false,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"On 01.08.2019 22:26, Junio C Hamano wrote:\n> All true.  Perhaps we need a separate tutorial for scripters to\n> teach them how to properly combine the plumbing commands?\n\n@Phillip thanks for your effort!\n\nHowever, I must admit that for us, this cure is worse then the problem.\n\nWe're not exactly scripting, rather we're assisting users to make\ntheir work with git more convenient/efficient. If we replace all the\nfamiliar commands with exotic combinations of 2-3 chained plumbing,\nthis will definitely leave most users completely clueless about what\nour UI is doing (we have a window that shows all executed commands).\n\nOn top of that, I think that my quick analysis only uncovered like\n1/3 of all the new edge cases (compared to using high-level commands)\nand the solutions already look quite scary to me. Taking the other 2/3\ninto account, it really feels that this would be a path of lots of pain\nand many bugfixes.\n"},{"id":"379775","messageId":"xmqqimrgmx6k.fsf@gitster-ct.c.googlers.com","threadId":"51563","inReplyTo":"a6610e94-6318-b962-5dd0-ca379def3bba@syntevo.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-08-01T20:45:55Z","receivedAt":"2019-08-01T20:46:04Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com> writes:\n\n> On 01.08.2019 17:56, Junio C Hamano wrote:\n>> So, reading paths from a file (which could be \"-\" as you suggest)\n>> would be a good solution for that.\n>\n> To summarize:\n> 1) Implement --paths-file for high-level commands.\n> 2) '--paths-file -' would mean reading from stdin.\n>\n> Is that something you're ready to accept patches for?\n\nTo be honest, I am personally not enthused to any move that\nencourages scripting around Porcelain commands, but being able to\nfeed a set of paths not from the command line may still be useful\nfor some of them and I've taken and I'll take changes that are\nagainst my taste, as long as there are wide support by others.\n\nSo I will *not* say \"I can tell you upfront that such patches will\nbe waste of time as they will not be even looked at\".\n\nThat does not mean that any patch along that line will automatically\nbe accepted, of course, so the answer to \"am I ready to accept\"\nquestion is a definite no.  No, I am not ready---we will have to\nlook at the actual patches before deciding.\n\n\n"},{"id":"379776","messageId":"f35fe280-2e26-f719-4030-faf261bc9a22@syntevo.com","threadId":"51563","inReplyTo":"xmqqimrgmx6k.fsf@gitster-ct.c.googlers.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Alexandr Miloslavskiy","fromEmail":"alexandr.miloslavskiy@syntevo.com","sentAt":"2019-08-01T20:51:03Z","receivedAt":"2019-08-01T20:51:08Z","isPatch":false,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"On 01.08.2019 22:45, Junio C Hamano wrote:\n> That does not mean that any patch along that line will automatically\n> be accepted, of course, so the answer to \"am I ready to accept\"\n> question is a definite no.  No, I am not ready---we will have to\n> look at the actual patches before deciding.\n\nThat's why I previously mentioned \"good enough\" patches :)\n\nThanks for your time! I guess we'll start with a patch for 'git commit'\nand see how it goes.\n"},{"id":"379815","messageId":"nycvar.QRO.7.76.6.1908021331590.46@tvgsbejvaqbjf.bet","threadId":"51563","inReplyTo":"ab333992-35c6-a5a9-0bcb-cef51f004679@syntevo.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-08-02T11:33:45Z","receivedAt":"2019-08-02T11:34:10Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Alexandr,\n\nOn Thu, 1 Aug 2019, Alexandr Miloslavskiy wrote:\n\n> 4) git reset\n\nPlease note that I have a patch series (currently on hold because of the\nv2.23.0 feature freeze) to teach `git reset` an `--stdin` option:\nhttps://github.com/gitgitgadget/git/pull/133\n\nCiao,\nJohannes\n"},{"id":"379816","messageId":"nycvar.QRO.7.76.6.1908021335250.46@tvgsbejvaqbjf.bet","threadId":"51563","inReplyTo":"f35fe280-2e26-f719-4030-faf261bc9a22@syntevo.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-08-02T11:40:47Z","receivedAt":"2019-08-02T11:41:12Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Alexandr,\n\nOn Thu, 1 Aug 2019, Alexandr Miloslavskiy wrote:\n\n> On 01.08.2019 22:45, Junio C Hamano wrote:\n> > That does not mean that any patch along that line will automatically\n> > be accepted, of course, so the answer to \"am I ready to accept\"\n> > question is a definite no.  No, I am not ready---we will have to\n> > look at the actual patches before deciding.\n>\n> That's why I previously mentioned \"good enough\" patches :)\n>\n> Thanks for your time! I guess we'll start with a patch for 'git commit'\n> and see how it goes.\n\nFrom past experience, I find that it is important to also implement the\n`-z` option (which traditionally means: accept items via the command\nline that are delimited by NULs).\n\nAnd you might find inspiration in my patch to read the paths passed to\n`git reset` from stdin:\nhttps://github.com/gitgitgadget/git/pull/133/commits/1db4ef0ec1ec\n\nI guess you could use a similar approach just after the\n`parse_pathspec()` call in `prepare_index()`:\nhttps://github.com/gitgitgadget/git/blob/1db4ef0ec1ec/builtin/commit.c#L339-L342\n\nCiao,\nJohannes\n"},{"id":"379817","messageId":"7edb3b11-054c-81a9-d88e-7e2325ad813f@syntevo.com","threadId":"51563","inReplyTo":"nycvar.QRO.7.76.6.1908021335250.46@tvgsbejvaqbjf.bet","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Alexandr Miloslavskiy","fromEmail":"alexandr.miloslavskiy@syntevo.com","sentAt":"2019-08-02T11:44:03Z","receivedAt":"2019-08-02T11:44:07Z","isPatch":false,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"@Johannes, thanks a lot for your tips!\n\nOn 02.08.2019 13:40, Johannes Schindelin wrote:\n>  From past experience, I find that it is important to also implement the\n> `-z` option (which traditionally means: accept items via the command\n> line that are delimited by NULs).\n> \n> And you might find inspiration in my patch to read the paths passed to\n> `git reset` from stdin:\n> https://github.com/gitgitgadget/git/pull/133/commits/1db4ef0ec1ec\n> \n> I guess you could use a similar approach just after the\n> `parse_pathspec()` call in `prepare_index()`:\n> https://github.com/gitgitgadget/git/blob/1db4ef0ec1ec/builtin/commit.c#L339-L342\n\n\n"},{"id":"379818","messageId":"2ed82d63-2a53-4aa8-a60b-d69150290a7f@syntevo.com","threadId":"51563","inReplyTo":"nycvar.QRO.7.76.6.1908021331590.46@tvgsbejvaqbjf.bet","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Alexandr Miloslavskiy","fromEmail":"alexandr.miloslavskiy@syntevo.com","sentAt":"2019-08-02T11:45:05Z","receivedAt":"2019-08-02T11:45:08Z","isPatch":false,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"On 02.08.2019 13:33, Johannes Schindelin wrote:\n> Please note that I have a patch series (currently on hold because of the\n> v2.23.0 feature freeze) to teach `git reset` an `--stdin` option:\n> https://github.com/gitgitgadget/git/pull/133\n\nPerfect! Less work for me :)\nOnce your patch is accepted, could you please send me a mail?\n"},{"id":"379819","messageId":"ed45493e-2a99-1137-cdf1-9a14b9c3bf7e@syntevo.com","threadId":"51563","inReplyTo":"nycvar.QRO.7.76.6.1908021331590.46@tvgsbejvaqbjf.bet","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Alexandr Miloslavskiy","fromEmail":"alexandr.miloslavskiy@syntevo.com","sentAt":"2019-08-02T11:52:23Z","receivedAt":"2019-08-02T11:52:26Z","isPatch":false,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"On 02.08.2019 13:33, Johannes Schindelin wrote:\n> to teach `git reset` an `--stdin` option:\n\nI think it should be changed to follow the approach decided\nhere [1] - that is, use '--paths-file', and '--paths-file -'\nwill mean \"from stdin\"\n\n[1] \nhttps://public-inbox.org/git/a6610e94-6318-b962-5dd0-ca379def3bba@syntevo.com/\n"},{"id":"379826","messageId":"nycvar.QRO.7.76.6.1908021641200.46@tvgsbejvaqbjf.bet","threadId":"51563","inReplyTo":"ed45493e-2a99-1137-cdf1-9a14b9c3bf7e@syntevo.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-08-02T14:47:29Z","receivedAt":"2019-08-02T14:47:53Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Alexandr,\n\nOn Fri, 2 Aug 2019, Alexandr Miloslavskiy wrote:\n\n> On 02.08.2019 13:33, Johannes Schindelin wrote:\n> > to teach `git reset` an `--stdin` option:\n>\n> I think it should be changed to follow the approach decided\n> here [1] - that is, use '--paths-file', and '--paths-file -'\n> will mean \"from stdin\"\n>\n> [1]\n> https://public-inbox.org/git/a6610e94-6318-b962-5dd0-ca379def3bba@syntevo.com/\n\nI am actually not sure about that. The use case I have for `git reset\n--stdin` is an IDE which wants to bulk-reset paths (and runs into\ncommand-line limitations without `--stdin`!), and definitely does *not*\nwant to write a file.\n\nSo I _really_ do not need `--paths-file`, and I doubt that anybody else\nneeds it.\n\nBesides...\n\n-- snip --\n$ git grep -l -e --stdin v2.23.0-rc0 -- Documentation/git-\\*.txt\nv2.23.0-rc0:Documentation/git-check-attr.txt\nv2.23.0-rc0:Documentation/git-check-ignore.txt\nv2.23.0-rc0:Documentation/git-check-mailmap.txt\nv2.23.0-rc0:Documentation/git-checkout-index.txt\nv2.23.0-rc0:Documentation/git-cherry-pick.txt\nv2.23.0-rc0:Documentation/git-commit-graph.txt\nv2.23.0-rc0:Documentation/git-diff-tree.txt\nv2.23.0-rc0:Documentation/git-fetch-pack.txt\nv2.23.0-rc0:Documentation/git-hash-object.txt\nv2.23.0-rc0:Documentation/git-http-fetch.txt\nv2.23.0-rc0:Documentation/git-index-pack.txt\nv2.23.0-rc0:Documentation/git-ls-tree.txt\nv2.23.0-rc0:Documentation/git-name-rev.txt\nv2.23.0-rc0:Documentation/git-notes.txt\nv2.23.0-rc0:Documentation/git-rev-list.txt\nv2.23.0-rc0:Documentation/git-send-pack.txt\nv2.23.0-rc0:Documentation/git-svn.txt\nv2.23.0-rc0:Documentation/git-update-index.txt\nv2.23.0-rc0:Documentation/git-update-ref.txt\n\n-- snap --\n\nSo. Lots of precedent. Conversely:\n\n-- snip --\n$ git grep -l -e --paths v2.23.0-rc0 -- Documentation/git-\\*.txt\n\n-- snap --\n\nZilch. So I find the advice you received, let's say, interesting.\n\nIn `git hash-object`, where it isn't obvious whether you would want to\npass in options or paths via stdin, there seems to be `--stdin-paths`. I\nam open to that.\n\nI am not open to implementing `--paths` nor `--paths-file` in `git\nreset`.\n\nCiao,\nJohannes\n"},{"id":"379827","messageId":"nycvar.QRO.7.76.6.1908021647550.46@tvgsbejvaqbjf.bet","threadId":"51563","inReplyTo":"2ed82d63-2a53-4aa8-a60b-d69150290a7f@syntevo.com","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-08-02T14:48:29Z","receivedAt":"2019-08-02T14:48:48Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Alexandr,\n\nOn Fri, 2 Aug 2019, Alexandr Miloslavskiy wrote:\n\n> On 02.08.2019 13:33, Johannes Schindelin wrote:\n> > Please note that I have a patch series (currently on hold because of the\n> > v2.23.0 feature freeze) to teach `git reset` an `--stdin` option:\n> > https://github.com/gitgitgadget/git/pull/133\n>\n> Perfect! Less work for me :)\n> Once your patch is accepted, could you please send me a mail?\n\nHow about subscribing to that PR so you get updates without requiring me\nto remember to send you a manual email?\n\nCiao,\nJohannes\n"},{"id":"379828","messageId":"4435f31d-ac6c-6569-7bac-2bd363fe5df3@syntevo.com","threadId":"51563","inReplyTo":"nycvar.QRO.7.76.6.1908021647550.46@tvgsbejvaqbjf.bet","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Alexandr Miloslavskiy","fromEmail":"alexandr.miloslavskiy@syntevo.com","sentAt":"2019-08-02T14:52:19Z","receivedAt":"2019-08-02T14:52:22Z","isPatch":false,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"On 02.08.2019 16:48, Johannes Schindelin wrote:\n> How about subscribing to that PR so you get updates without requiring me\n> to remember to send you a manual email?\n\nThis option evaded me :) Subscribed, thanks!\n"},{"id":"379829","messageId":"b736296c-c964-6096-bf36-99d31ccf8fee@syntevo.com","threadId":"51563","inReplyTo":"nycvar.QRO.7.76.6.1908021641200.46@tvgsbejvaqbjf.bet","subject":"Re: Support for --stdin-paths in commit, add, etc","fromName":"Alexandr Miloslavskiy","fromEmail":"alexandr.miloslavskiy@syntevo.com","sentAt":"2019-08-02T15:11:24Z","receivedAt":"2019-08-02T15:11:27Z","isPatch":false,"sender":{"key":"alexandr.miloslavskiy@syntevo.com","avatar":null},"body":"On 02.08.2019 16:47, Johannes Schindelin wrote:\n\n > and definitely does *not* want to write a file.\n\nIn this case it can use `--paths-file -`, which means stdin.\n\n> Zilch. So I find the advice you received, let's say, interesting.\n\nI understood that `--paths-file` is suggested to avoid possible\nstdin collisions in high-level commands.\n\nIt seems that only plumbing commands accept --stdin for paths now.\n\nBoth me and you are now trying to address high-level commands, which is\nnew. This explains why grep doesn't currently find `--paths-file`.\n\nThe approach sounds reasonable to me as a long-term strategy:\n1) Won't require rework if someone wants file instead\n2) stdin is still supported for those who want it\n3) There's a way to avoid potential collisions in stdin\n"}]}