更新时间:2023-11-10 22:59:40
我可以使用git log
查找我关心的所有提交,然后使用git ls-tree -r
查找提交中的所有blob,然后使用Perl只保留我感兴趣的斑点:
I can use git log
to find all commits I care about, and then use git ls-tree -r
to find all the blobs in a commit, and then use Perl to keep only the blobs I'm interested in:
for COMMITID in `git log --pretty=format:%H`; do
git ls-tree -r "$COMMITID" | perl -we '
use integer; use strict; my $commitid = $ARGV[0]; my $f;
die if !open($f, "<", "blobid.lst");
my %h = map { s@\s.*@@s; $_ ? ($_=>1) : () } <$f>;
while (<STDIN>) {
die "bad: $_\n" if !s@^\S+\sblob\s([0-9a-f]{40})\t@@;
my $blobid=$1;
chomp;
print "git show \x27$commitid:$_\x27\n" if $h{$blobid} }' -- "$COMMITID"
done
我感兴趣的Blob ID列表存储在文件blobid.lst
中,每行一个ID.
The list of the blob IDs I'm interested in are stored in the file blobid.lst
, one ID per line.