+sub git_blame_flush_chunk {
+ my ($name, $revdata, $color, $rev, @line) = @_;
+ my $label = substr($rev, 0, 8);
+ my $line = scalar(@line);
+ my $cnt = 0;
+ my $pop = '';
+
+ if ($revdata->{$rev} ne '') {
+ $pop = ' title="' . esc_html($revdata->{$rev}) . '"';
+ }
+
+ for (@line) {
+ my ($lineno, $data) = @$_;
+ $cnt++;
+ print "<tr class=\"$color\">\n";
+ if ($cnt == 1) {
+ print "<td class=\"sha1\"$pop";
+ if ($line > 1) {
+ print " rowspan=\"$line\"";
+ }
+ print ">";
+ print $cgi->a({-href => href(action=>"commit",
+ hash=>$rev,
+ file_name=>$name)},
+ $label);
+ print "</td>\n";
+ }
+ print "<td class=\"linenr\">".
+ "<a id=\"l$lineno\" href=\"#l$lineno\" class=\"linenr\">" .
+ esc_html($lineno) . "</a></td>\n";
+ print "<td class=\"pre\">" . esc_html($data) . "</td>\n";
+ print "</tr>\n";
+ }
+}
+
+# We can have up to N*2 lines. If it is more than N lines, split it
+# into two to avoid orphans.
+sub git_blame_flush_chunk_1 {
+ my ($chunk_cap, $name, $revdata, $color, $rev, @chunk) = @_;
+ if ($chunk_cap < @chunk) {
+ my @first = splice(@chunk, 0, @chunk/2);
+ git_blame_flush_chunk($name,
+ $revdata,
+ $color,
+ $rev,
+ @first);
+ }
+ git_blame_flush_chunk($name,
+ $revdata,
+ $color,
+ $rev,
+ @chunk);
+}
+