Skip to content

Instantly share code, notes, and snippets.

@wchristian
Created April 29, 2014 12:49
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 wchristian/11399320 to your computer and use it in GitHub Desktop.
Save wchristian/11399320 to your computer and use it in GitHub Desktop.
git-size.pl - size of each commit in a git repository
#!/usr/bin/perl
use strictures;
for my $rev ( `git rev-list --all --pretty=oneline` ) {
my $tot = 0;
$rev =~ s/\s+$//;
( my $sha = $rev ) =~ s/\s.*$//;
( my $msg = $rev ) =~ s/^$sha //;
for my $blob ( `git diff-tree -r -c -M -C --no-commit-id $sha` ) {
$blob = ( split /\s/, $blob )[3];
next if $blob eq "0000000000000000000000000000000000000000"; # Deleted
my $size = `echo $blob | git cat-file --batch-check`;
$size = ( split /\s/, $size )[2];
$tot += int( $size );
}
my $revn = substr( $rev, 0, 40 );
next if $tot < 10000;
printf "% 8d %s % 4d %s\n", $tot, $revn, `git show --pretty="format:" --name-only $revn | wc -l`, $msg;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment