SLOC in git declaration

I have a file with a list of commit ids in it and I am trying to write a script that calculates the number of lines in each commit. What's the easiest / best way to do this? I already have a few lines of python written, but I'm open to any language.

+3


source to share


1 answer


Use --numstat

(for file changes) or --shortstat

(for sum of changes) as an argument git show

, git log

or git diff-tree

.

For example, in bash:



while read sha; do
  git diff-tree --shortstat $sha $sha^
done

      

Note that the various diffstat flags can be passed to almost any git command that checks a commit, but they are only documented in the git-diff-tree man page .

+1


source







All Articles