Subject: Re: git diff-tree do not honor diff.orderfile config

From: Junio C Hamano <[email-masked]>
Date: Sat, 06 Jul 2024 00:38:28 -0700

Tiago de Bem Natel de Moura <[email-masked]> writes:

> What did you do before the bug happened? (Steps to reproduce your issue)
> The config `diff.orderfile` is not being honored in the `git diff-tree` command
> as stated by the documentation.
>
> What did you expect to happen? (Expected behavior)
> The output ordered by the pattern file.
>
> What happened instead? (Actual behavior)
> Output has normal order.

The diff-files, diff-index, and diff-tree ignore most (if not all)
of the end-user configuration variables in order to give a stable
output, which writers of scripts would expect to see out of these
plumbing commands.

Those who use these plumbing commands should still be able to use
the equivalent command line option to afffect their behaviour.  In
this case, something like

	orderfile=$(git config diff.orderfile)
	git diff-tree ${orderfile:+"-O$orderfile"} ...

would be what script writers would do when the output is not for
machine consumption inside the script, but is to be shown to the
end-user directly and they want to pretend as if they used the 'git
diff' Porcelain command, which pays attention to the configuration
variable".

But when the command is the final output phase (as opposed to a step
in the multi-step logic your script implements, e.g. diff-files
produces a list of changed files to be read by other commands and
processed by your other commands in the downstream on the same
pipeline) and that is why it is a good idea to pay attention to the
configuration, using "git diff" not "diff-tree" may be more natural
thing to do.

Thanks.