Skip to content

Instantly share code, notes, and snippets.

@hightemp
Created May 10, 2018 13:12
Show Gist options
  • Select an option

  • Save hightemp/57e69833602b809ce7cf24867e01e9f6 to your computer and use it in GitHub Desktop.

Select an option

Save hightemp/57e69833602b809ce7cf24867e01e9f6 to your computer and use it in GitHub Desktop.
Determine the Size of Each Git Commit. This script will iterate over a Git repository and return information about the size of each 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