Created
April 5, 2022 23:57
-
-
Save eboye/1739aef9ff422373a52717dcf4b490eb to your computer and use it in GitHub Desktop.
list the given file's filesize next to each commit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# list the given file's filesize next to each commit | |
# usage: git-fs-history path/to/file | |
# | |
if [ $# -ne 1 ]; then | |
echo "Error: invalid number of arguments." | |
exit 1 | |
fi | |
# for all commits on this file | |
for commit in $(git log --format=%H $1); do | |
# get raw filesize | |
fs_raw=$(git cat-file -s $commit:$1) | |
# convert to kilobytes | |
fs=$(echo "scale=1; $fs_raw/1024" | bc)k | |
# grab the commit msg | |
msg=$(git log -1 --format=%s $commit) | |
echo $fs $msg | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment