Skip to content

Instantly share code, notes, and snippets.

@amaslenn
Created February 13, 2017 07:30
Show Gist options
  • Save amaslenn/de76b7bca22716c7ad7a46bf6ebf23bd to your computer and use it in GitHub Desktop.
Save amaslenn/de76b7bca22716c7ad7a46bf6ebf23bd to your computer and use it in GitHub Desktop.
Get size of commits using perl
# found here: http://stackoverflow.com/questions/1286183/git-find-fat-commit
#!/usr/bin/perl
foreach my $rev (`git rev-list --all --pretty=oneline`) {
my $tot = 0;
($sha = $rev) =~ s/\s.*$//;
foreach my $blob (`git diff-tree -r -c -M -C --no-commit-id $sha`) {
$blob = (split /\s/, $blob)[3];
next if $blob == "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);
# if ($tot > 1000000) {
print "$tot $revn " . `git show --pretty="format:" --name-only $revn | wc -l` ;
# }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment