- foreach my $line (run_or_non("git", "show", $sha1)) {
- if (@lines || $line=~/^diff --git/) {
- push @lines, $line."\n";
- }
- }
+ my $addlines=sub {
+ my $line=shift;
+ return if defined $maxlines && @lines == $maxlines;
+ push @lines, $line."\n"
+ if (@lines || $line=~/^diff --git/);
+ return 1;
+ };
+ safe_git(undef, $addlines, "git", "show", $sha1);