Skip to content

Instantly share code, notes, and snippets.

@jthodge
Created July 19, 2021 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jthodge/bfd3b5a9da480713a04c185fea5cbf1f to your computer and use it in GitHub Desktop.
Save jthodge/bfd3b5a9da480713a04c185fea5cbf1f to your computer and use it in GitHub Desktop.
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