{"thread":{"id":"61739","subject":"git diff-tree do not honor diff.orderfile config","startedAt":"2024-07-05T10:28:37Z","lastAt":"2024-07-08T12:49:39Z","messageCount":6,"participants":["Tiago de Bem Natel de Moura","Taylor Blau","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"498106","messageId":"CAJFVNCfz_-Dvd0ctc4w-2jsthyPFxy=HOutj=3PbNnQ-Gsz84A@mail.gmail.com","threadId":"61739","inReplyTo":null,"subject":"git diff-tree do not honor diff.orderfile config","fromName":"Tiago de Bem Natel de Moura","fromEmail":"t.nateldemoura@gmail.com","sentAt":"2024-07-05T10:28:23Z","receivedAt":"2024-07-05T10:28:37Z","isPatch":false,"sender":{"key":"t.nateldemoura@gmail.com","avatar":null},"body":"What did you do before the bug happened? (Steps to reproduce your issue)\nThe config `diff.orderfile` is not being honored in the `git diff-tree` command\nas stated by the documentation.\n\nWhat did you expect to happen? (Expected behavior)\nThe output ordered by the pattern file.\n\nWhat happened instead? (Actual behavior)\nOutput has normal order.\n\nWhat's different between what you expected and what actually happened?\n\nThe order.\n\nAnything else you want to add:\n\nThe complete command that I'm running is:\ngit diff-tree -r --relative --name-only HEAD main\n\nif I provide -O ~/ordefile it works but if I add it to my config it does not.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.44.0\ncpu: arm64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nfeature: fsmonitor--daemon\nuname: Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:14:38\nPDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020 arm64\ncompiler info: clang: 15.0.0 (clang-1500.1.0.2.5)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n\n[Enabled Hooks]\n"},{"id":"498125","messageId":"Zohf7LzaRHaG9vX6@nand.local","threadId":"61739","inReplyTo":"CAJFVNCfz_-Dvd0ctc4w-2jsthyPFxy=HOutj=3PbNnQ-Gsz84A@mail.gmail.com","subject":"Re: git diff-tree do not honor diff.orderfile config","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-07-05T21:04:44Z","receivedAt":"2024-07-05T21:04:47Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Fri, Jul 05, 2024 at 11:28:23AM +0100, Tiago de Bem Natel de Moura wrote:\n> What did you do before the bug happened? (Steps to reproduce your issue)\n> The config `diff.orderfile` is not being honored in the `git diff-tree` command\n> as stated by the documentation.\n\nMakes sense... the diff.orderFile configuration is part of the \"UI\" set\nof diff.* configuration options, which are honored by porcelain commands\nlike commit, diff, log, etc., but not by plumbing commands like\ndiff-tree.\n\nI think from 6d8940b562 (diff: add diff.orderfile configuration\nvariable, 2013-12-18) adding it to the UI-only configuration set was\nintentional, but it is somewhat awkward that we respect -O but not the\nconfiguration it falls back on.\n\nSo I suppose the question is whether supporting -O from diff-tree is\nsensible. If it is, then reading the diff.orderFile configuration option\nis a no-brainer. But if it isn't, then we should probably not make a bad\nsituation worse by adding support for it.\n\nThanks,\nTaylor\n"},{"id":"498157","messageId":"20240706070201.GA702644@coredump.intra.peff.net","threadId":"61739","inReplyTo":"Zohf7LzaRHaG9vX6@nand.local","subject":"Re: git diff-tree do not honor diff.orderfile config","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-07-06T07:02:01Z","receivedAt":"2024-07-06T07:02:03Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jul 05, 2024 at 05:04:44PM -0400, Taylor Blau wrote:\n\n> On Fri, Jul 05, 2024 at 11:28:23AM +0100, Tiago de Bem Natel de Moura wrote:\n> > What did you do before the bug happened? (Steps to reproduce your issue)\n> > The config `diff.orderfile` is not being honored in the `git diff-tree` command\n> > as stated by the documentation.\n> \n> Makes sense... the diff.orderFile configuration is part of the \"UI\" set\n> of diff.* configuration options, which are honored by porcelain commands\n> like commit, diff, log, etc., but not by plumbing commands like\n> diff-tree.\n> \n> I think from 6d8940b562 (diff: add diff.orderfile configuration\n> variable, 2013-12-18) adding it to the UI-only configuration set was\n> intentional, but it is somewhat awkward that we respect -O but not the\n> configuration it falls back on.\n\nI don't think it's awkward at all. The plumbing commands should provide\nmost every option that the porcelain ones support, but should do so\nbased only on the options given by the caller. I.e., imagine you were\nwriting \"git diff\" (or a similar command) as a script and you wanted to\nsupport something like diff.orderfile. You'd do it by parsing\ndiff.orderfile yourself and passing \"-O\" where it made sense to do so.\n\n> So I suppose the question is whether supporting -O from diff-tree is\n> sensible. If it is, then reading the diff.orderFile configuration option\n> is a no-brainer. But if it isn't, then we should probably not make a bad\n> situation worse by adding support for it.\n\nNo, I don't think we ever want diff-tree (or other plumbing commands) to\nsupport diff.orderFile. It will cause unexpected results for consumers\nof the plumbing output. E.g., it would probably at least screw up\npatch-id.\n\nSo this all just looks like the usual \"plumbing does not respect some\nconfig\" situation.\n\n-Peff\n"},{"id":"498161","messageId":"xmqqsewn2cnf.fsf@gitster.g","threadId":"61739","inReplyTo":"CAJFVNCfz_-Dvd0ctc4w-2jsthyPFxy=HOutj=3PbNnQ-Gsz84A@mail.gmail.com","subject":"Re: git diff-tree do not honor diff.orderfile config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-07-06T07:38:28Z","receivedAt":"2024-07-06T07:38:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tiago de Bem Natel de Moura <t.nateldemoura@gmail.com> writes:\n\n> What did you do before the bug happened? (Steps to reproduce your issue)\n> The config `diff.orderfile` is not being honored in the `git diff-tree` command\n> as stated by the documentation.\n>\n> What did you expect to happen? (Expected behavior)\n> The output ordered by the pattern file.\n>\n> What happened instead? (Actual behavior)\n> Output has normal order.\n\nThe diff-files, diff-index, and diff-tree ignore most (if not all)\nof the end-user configuration variables in order to give a stable\noutput, which writers of scripts would expect to see out of these\nplumbing commands.\n\nThose who use these plumbing commands should still be able to use\nthe equivalent command line option to afffect their behaviour.  In\nthis case, something like\n\n\torderfile=$(git config diff.orderfile)\n\tgit diff-tree ${orderfile:+\"-O$orderfile\"} ...\n\nwould be what script writers would do when the output is not for\nmachine consumption inside the script, but is to be shown to the\nend-user directly and they want to pretend as if they used the 'git\ndiff' Porcelain command, which pays attention to the configuration\nvariable\".\n\nBut when the command is the final output phase (as opposed to a step\nin the multi-step logic your script implements, e.g. diff-files\nproduces a list of changed files to be read by other commands and\nprocessed by your other commands in the downstream on the same\npipeline) and that is why it is a good idea to pay attention to the\nconfiguration, using \"git diff\" not \"diff-tree\" may be more natural\nthing to do.\n\nThanks.\n"},{"id":"498177","messageId":"xmqqy16ematj.fsf@gitster.g","threadId":"61739","inReplyTo":"Zohf7LzaRHaG9vX6@nand.local","subject":"Re: git diff-tree do not honor diff.orderfile config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-07-06T22:10:00Z","receivedAt":"2024-07-06T22:10:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Taylor Blau <me@ttaylorr.com> writes:\n\n> So I suppose the question is whether supporting -O from diff-tree is\n> sensible. If it is, then reading the diff.orderFile configuration option\n> is a no-brainer. But if it isn't, then we should probably not make a bad\n> situation worse by adding support for it.\n\nIf plumbing commands paid attention to the end-user configuration,\nthey will not serve as a reliable building blocks for script\nwriters.  The would instead change their behaviour in a way not\nexpected by script writers.\n\nOn the other hand, we do want to give script writers an option to\nutilize power of the underlying machinery.  If they want to specify\na particular order of paths in the output, they are welcome to feed\nan orderfile via the command line and that is why we have an option.\n\nSupporting \"-O <orderfile>\" and ignoring \"diff.orderfile\" are both\nvery sensible thing for the plumbing commands and it is the result\nof deliberate design.\n\nThanks.\n"},{"id":"498242","messageId":"CAJFVNCcrURr7h25BE76jd19=qO0e3umP5_Hhp1mHFrhXDB+DLA@mail.gmail.com","threadId":"61739","inReplyTo":"xmqqy16ematj.fsf@gitster.g","subject":"Re: git diff-tree do not honor diff.orderfile config","fromName":"Tiago de Bem Natel de Moura","fromEmail":"t.nateldemoura@gmail.com","sentAt":"2024-07-08T12:49:26Z","receivedAt":"2024-07-08T12:49:39Z","isPatch":false,"sender":{"key":"t.nateldemoura@gmail.com","avatar":null},"body":"I agree with pretty much everything said here but then the\ndocumentation must be fixed here:\nhttps://git-scm.com/docs/git-diff-tree#Documentation/git-diff-tree.txt--Oltorderfilegt\n\nI use diff-tree in a Go program[1] and I expected it to be plumbing\nbut I got an error report that was hard to reproduce then I read in\nthe documentation that diff-tree also relies on the configuration but\nwhen I tried it didn't work, hence this report.\nIf you folks say it does not depend on the config and never will, then all good.\n\nThank you.\n\n1: https://github.com/terramate-io/terramate/blob/af73c2b688fae94360169da6ab8de49ea5b07649/git/git.go#L466-L482\n"}]}