Posting an answer to my own question, it's a works albeit a little hacky.
This simply pipes git-grep to sort.
Create an executable shell script wrapper for git: ~/emacs.d/bin/git_sorted
#!/bin/bash
exec git ${1+"$@"} | sort -V
And in your emacs.d/init.el
:
(setq
counsel-git-grep-cmd-default
"~/.emacs.d/bin/git_sorted --no-pager grep --full-name -n --no-color -e %S")
sort -V
happens to sort line numbers correctly (-n
, -h
... don't).
Note, it would be nice if there was a way to only sort the file-list which git-grep uses, instead of having to sort the entire output.