Git - get all commits and blobs they created

后端 未结 6 1300
天涯浪人
天涯浪人 2020-12-05 03:07

Is there a git command that can output for every commit:

  1. id
  2. subject
  3. blobs it created with they path and size (like git ls-tree -l -r &l
6条回答
  •  天涯浪人
    2020-12-05 03:58

    One solution based on tig's answer:

    #!/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);
      }
      print "$tot $rev" if $tot > 1000000; # Show only if > 1MiB
    }
    

    Maybe not the best code, but should get you most of the way.

提交回复
热议问题