git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jim Meyering <jim@meyering.net>
Date
Oct 25, 2006, 07:15 UTC
Message-ID
<871wowzx15.fsf@rho.meyering.net>
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?
Next: Junio C Hamano
Message 1 of 4 in “an option to make "git-diff Z A" prints Z's diff before A's”
  1. Jim MeyeringOct 25, 2006
  2. Junio C HamanoOct 25, 2006
  3. Karl HasselströmOct 26, 2006
  4. Linus TorvaldsOct 26, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.