Skip to content

Instantly share code, notes, and snippets.

@jakub-g
Last active March 7, 2024 01:07
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jakub-g/7599177 to your computer and use it in GitHub Desktop.
Save jakub-g/7599177 to your computer and use it in GitHub Desktop.
sort git diff --stat starting from the files that have most lines changed
git show HEAD --stat=200 | tail +7 | awk '{ print $3 " "$4 " " $1}' | sort -n -r | less
5430 +++++++++++++++++++++++++++++++++++++++++++-------------------------------------------- src/aria/utils/SynEvents.j
3566 ++++++++++++++++++++++++++++----------------------------- src/aria/utils/Date.js
3182 +++++++++++++++++++++++++-------------------------- src/aria/Aria.js
2276 ++++++++++++++++++------------------- src/aria/templates/CfgBeans.js
1764 ++++++++++++++-------------- src/aria/core/JsObject.js
1204 ++++++++++---------- src/aria/templates/Repeater.js
998 ++++++++-------- src/aria/core/Interfaces.js
972 ++++++++-------- src/aria/templates/ClassWriter.js
846 +++++++------- test/aria/utils/DeviceTest.js
764 ++++++------- src/aria/core/Log.js
752 ++++++------ src/aria/templates/Modifiers.js
738 ++++++------ src/aria/templates/Layout.js
698 ++++++------ src/aria/tester/runner/ModuleController.js
634 +++++------ src/aria/utils/FrameATLoader.js
556 ++++----- src/aria/widgets/frames/TableFrame.js
474 ++++---- src/aria/utils/DomOverlay.js
474 ++++---- src/aria/core/ResClassLoader.js
454 ++++---- src/aria/utils/Device.js
..
1 - build/README.md
changed, 18963 1025
@rcdailey
Copy link

Needs improvements:

  1. Needs color (e.g. same coloring as in diff --stat)
  2. File names need to be aligned on the same column, which requires the width of the diffstat graph on the left to be fixed.

@milo-minderbinder
Copy link

milo-minderbinder commented Jan 3, 2020

@rcdaily, I agree! This should do the trick: https://gist.github.com/milo-minderbinder/28d8a81bf2335dc51bec36cd24394c8f

*edit for the lazy:
git diff --stat --stat-width "$(tput cols)" --color=always | sort -t '|' -n -k2 "$@"
or, even better, as a git alias:
git config --global alias.diff-stat-sort '!git diff --stat --stat-width "$(tput cols)" --color=always | sort -t "|" -n -k2'

@FlashSheridan
Copy link

*edit for the lazy:
git diff --stat --stat-width "$(tput cols)" --color=always | sort -k3 "$@"

sort should also have -nr, e.g. (for diffing two commits):

git diff --stat --stat-width "$(tput cols)" --color=always 5c68a1cb123..a2589f19e6de | sort -nr -k3 "$@" | head

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment