我可以使用git log
找到我關心所有提交,然後用git ls-tree -r
找到一個提交所有的斑點,然後使用Perl只保留斑點我很感興趣:
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 { [email protected]\s.*@@s; $_ ? ($_=>1) :() } <$f>;
while (<STDIN>) {
die "bad: $_\n" if [email protected]^\S+\sblob\s([0-9a-f]{40})\[email protected]@;
my $blobid=$1;
chomp;
print "git show \x27$commitid:$_\x27\n" if $h{$blobid} }' -- "$COMMITID"
done
斑的ID我感興趣的是存儲在文件中blobid.lst
的名單,每行一個ID。
來源
2015-10-19 10:49:09
pts
我想爲了得到這些信息,你需要遍歷所有的提交,然後(遞歸地)遍歷所有的樹並檢查一個blob id是否與你的hash匹配。由於如何構建Git對象樹,我不認爲有任何其他方法。 – poke