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

Re: Sort output of diff --stat?

From
Jeff King <peff@peff.net>
Date
Oct 17, 2018, 18:47 UTC
Message-ID
<20181017184720.GF28326@sigill.intra.peff.net>
In-Reply-To
<CAHd499BSVRytaFKOUhE=A4Zv+MMx=uKrWKUcT13QwzOCZWhEtg@mail.gmail.com>
On Wed, Oct 17, 2018 at 01:15:18PM -0500, Robert Dailey wrote:
Show 5 quoted lines
> I'd like to sort the output of `git diff --stat` such that files are
> listed in descending order based on number of lines changed. The
> closest solution I've found online[1] has several readability issues.
> I'd rather see a built-in solution in git, if one exists. Can anyone
> recommend a solution?

Hmm, I feel like another person asked for this recently, but I can't seem to find the thread.

Anyway, no, I don't think there's a solution short of parsing the output (you could parse --numstat, which is at least sane, but then you'd have to generate your own visual diffstat, which has a lot of corner cases).

We have --orderfile, but that's about a static order based on filename. It seems reasonable to me for "--stat" to learn an option to sort (that would not affect, say, the total diff order, since sorting by line count makes very little sense for most other formats).

-Peff
Previous: Robert DaileyNext: Robert Dailey
Message 2 of 4 in “Sort output of diff --stat?”
  1. Robert DaileyOct 17, 2018
  2. Jeff KingOct 17, 2018
  3. Robert DaileyOct 17, 2018
  4. Jeff KingOct 17, 2018

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.