an option to make "git-diff Z A" prints Z's diff before A's

From: Jim Meyering <hidden>
Date: 2016-08-11 19:45:26
Subsystem: the rest · Maintainer: Linus Torvalds

Hello,

In a recent patch set I prepared, I placed the names of the
more relevant files at the front of the list given to "git-diff".
So I was surprised to see diff output in which the blocks of output
are sorted by file name.  The parts I'd tried to put at the "top"
ended up being buried in the latter part of the patch.

Here's a small test case:

mkdir d && cd d && touch x y && git-init-db
git-add x y && git-commit -m. x y
echo a > x && echo a > y
git-diff y x|grep '^d'

I expected this git-diff output, with "y's" diff first:
diff --git a/y b/y
diff --git a/x b/x
but got this, where x's come first:
diff --git a/x b/x
diff --git a/y b/y
I know about the -O<orderfile> option, and it can make git-diff do
what I want, but only if I first create a separate file containing
the names that I'm already providing to git-diff in the very same order.

Is there an easier way?

If not, would you be amenable to a new option enabling this behavior
without requiring a temporary file?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help