i want to see the number of removed/added line, grouped by author for a given branch in git history. there is git shortlog -s
which shows me the number of commits per author. is there anything similar to get an overall diffstat?
views:
180answers:
1
+1
A:
Since the SO question "How to count total lines changed by a specific author in a Git repository?" is not completely satisfactory, commandlinefu has alternatives (albeit not per branch):
git ls-files | while read i; do git blame $i | sed -e 's/^[^(]*(//' -e 's/^\([^[:digit:]]*\)[[:space:]]\+[[:digit:]].*/\1/'; done | sort | uniq -ic | sort -nr
It includes binary files, which is not good, so you could:
git ls-files -x "*pdf" -x "*psd" -x "*tif"
to remove really random binary files. Or:
git ls-files "*.py" "*.html" "*.css"
to only include specific file types.
Still, a "git log
"-based solution should be better, like:
git log --numstat --pretty="%H" --author="Your Name" commit1..commit2 | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
but again, this is for one path (here 2 commits), not for all branches per branches.
VonC
2010-05-07 11:17:06