Last active
February 27, 2024 05:51
-
-
Save jitran/2680dd53a61a8cb94d545d78050161ba to your computer and use it in GitHub Desktop.
Calculates the size of each commit in the current branch
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
#!/usr/bin/env bash -e | |
for commit in $(git log --format="%H"); do | |
size=0 | |
blobs=0 | |
IFS=$'\n' | |
for line in $(git log -1 --raw --no-merges --no-renames --no-abbrev --full-index --raw --pretty=oneline $commit | tail -n +2); do | |
id=$(echo $line | cut -d' ' -f4) | |
blob_size=$(git cat-file -s $id 2>/dev/null || echo 0) | |
(( size += blob_size )) | |
(( blobs += 1 )) | |
done | |
echo $commit $blobs $size | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The output format is: