Skip to content

Instantly share code, notes, and snippets.

@jthodge
Created Jul 19, 2021
Embed
What would you like to do?
Script for iterating over git revisions and computing statistics for each
#!/bin/bash
set -e
file_pattern=$1
function main {
for rev in `revisions`; do
echo "`number_of_lines` `commit_description`"
done
}
function revisions {
git rev-list --reverse HEAD
}
funtion commit_description {
git log --oneline -1 $rev
}
function number_of_lines {
git ls-tree -r $rev |
grep "$file_pattern" |
awk '{print $3}' |
xargs git show |
wc -l
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment