git-number icon indicating copy to clipboard operation
git-number copied to clipboard

feature-request: display number for `git log --stat`

Open KES777 opened this issue 8 years ago • 1 comments

While I am rebasing

$ git status
interactive rebase in progress; onto 3d276f8
Last command done (1 command done):
   e ece1d11 Do not query DB if user pass wrong arguments
Next commands to do (3 remaining commands):
   pick f6ba33d Setup error if there is no user with supplied login/password
   pick d6950f0 In case of errors we should render 'error' template
  (use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch 'API_for_frontend' on '3d276f8'.
  (use "git commit --amend" to amend the current commit)
  (use "git rebase --continue" once you are satisfied with your changes)

nothing to commit, working directory clean

I often required to edit files:

commit ece1d1137f0665243a9b9ab9bcd01c3fd61e8b85
Author: Eugen Konkov <[email protected]>
Date:   Tue Dec 20 19:36:00 2016 +0200

    Do not query DB if user pass wrong arguments

 lib/ArtCoin/Controller/Auth.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

It will be handy to display numbers in this case too

KES777 avatar Dec 20 '16 18:12 KES777

The first problem with implementing this is parsing the output of git log --stat, which, like git status, is a porcelain command - their output is not guaranteed to be stable, for example if the path is long it can appear in abbreviated form path/to/.../file.txt. We can use git log --stat --raw to get the more stable output for parsing, which leads us to the next problem: git number was designed to work only with the output of git status.

I don't think you need the help of git number to edit the files changed in a given commit - you can use git difftool for that, with little work. The first thing you'll need is to let git difftool know what your editor is. I think it defaults to vi. This is how you can use git difftool to edit the files changed for a given sha1:

$ git difftool 5ebe75b482e5f3ab91460ce47bbfead2020eb9f9^..5ebe75b482e5f3ab91460ce47bbfead2020eb9f9

If that is too long to type you can make a shell script to reduce the typing, something like this:

$ cat ~/bin/gdt
#!/bin/sh
sha1=${1?need sha1}
shift
git difftool ${sha1}^..${sha1} $*

holygeek avatar Dec 21 '16 12:12 holygeek