Top contributors by lines changed (not just commits) using git
If you want to rank contributors by the number of lines changed (insertions + deletions), use:
Assistant
You can get the top contributors by lines changed using this git command:
bash
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
The issue is with how the author name is being captured. When git log --pretty="%aN" --numstat outputs data, it shows the author name on one line, then the file stats on subsequent lines. Your awk script is trying to capture the author from $1 when NF!=3, but that's not quite right.
git log --format='%aN' --numstat | \
awk '
NF==1 {author=$0}
NF==3 {plus[author]+=$1; minus[author]+=$2}
END {
for (a in plus)
printf "%10d lines changed (%6d insertions, %6d deletions): %s\n", plus[a]+minus[a], plus[a], minus[a], a
}
' | sort -rn
The key difference is that we capture the author when NF==1 (a line with just the author name), and then accumulate stats when NF==3 (the numstat lines with additions, deletions, and filename).
User
stil no names and only one row in the answer
Assistant
The issue is that the output format of git log with --pretty and --numstat might not be what we expect. Let me suggest a more robust approach:
bash
git log --format='AUTHOR:%aN' --numstat | \
awk '
/^AUTHOR:/ {author=substr($0, 8)}
/^[0-9]+\t[0-9]+\t/ {plus[author]+=$1; minus[author]+=$2}
END {
for (a in plus)
printf "%10d lines changed (%6d insertions, %6d deletions): %s\n", plus[a]+minus[a], plus[a], minus[a], a
}
' | sort -rn
Or, try this alternative that's been tested to work reliably: