Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Here is a sample implementation:

    git log --author=rav --numstat --no-merges --pretty=format: |
        awk -e '{ a += $1; b += $2; } END { print a; print b; print a-b; }'
produces this output (sum additions, sum deletions, net line additions):

    112529
    85383
    27146


To count by author:

    git log --numstat --no-merges --pretty=format:%an
        | awk '
          author == "" { author = $0; next }
          /^$/ { author = ""; next }
          { added[author] += $1; removed[author] += $2 }
          END { for (author in added) {
            print author, "added", added[author], "removed", removed[author], "sum", added[author]-removed[author]
          } }'
        | sort -n -k 7


That is great! Thank you.


Ha, nice, there's two options that definitely would've simplified my code (--numstat and --no-merges).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: