summaryrefslogtreecommitdiff
path: root/git-author-stats
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-06-24 09:38:26 -0700
committerBen Sima <ben@bsima.me>2020-06-24 09:38:26 -0700
commit7347983866f376e579890834736cc7c9d301bf5a (patch)
tree1205c4b817bae136f374c0c62388abb238e21aa7 /git-author-stats
parentf7fadfaa9fcb24bbfce31db8a2736d74c7213fd1 (diff)
git-author-stats: cleanup and add docs
Diffstat (limited to 'git-author-stats')
-rwxr-xr-xgit-author-stats21
1 files changed, 10 insertions, 11 deletions
diff --git a/git-author-stats b/git-author-stats
index 8bd2d9b..ede4ef2 100755
--- a/git-author-stats
+++ b/git-author-stats
@@ -1,5 +1,8 @@
#!/usr/bin/env bash
-
+#
+# Print lines added/removed and number of commits by author. Optional arg is a
+# path passed to 'git log'.
+#
script=$(cat << 'EOF'
NF == 1 { name = $1; commits[name] += 1 }
NF == 3 { plus[name] += $1; minus[name] += $2 }
@@ -10,13 +13,9 @@ END {
}
EOF
)
-
-(printf $'name\tadded\tremoved\tcommits\n';
-
-git log --numstat --pretty=$'%aN' "$@" \
- | awk -F$'\t' "$script" \
- | sort --field-separator=$'\t' -k${ASTATS_SORT_COLUMN:-2} -gr
-) > /tmp/git-author-stats
-
-column -t -s $'\t' /tmp/git-author-stats
-rm /tmp/git-author-stats
+column -t -s $'\t' <(
+ printf $'name\tadded\tremoved\tcommits\n';
+ git log --numstat --pretty=$'%aN' "$@" \
+ | awk -F$'\t' "$script" \
+ | sort --field-separator=$'\t' -k${ASTATS_SORT_COLUMN:-2} -gr
+)