gitweb: Cleanup git_print_log()

When we see a signed-off-by line (and its friends), we set $signoff to true, but then we process the next line after we are done without giving control to the rest of the loop. And when the line we saw is not a signed-off-by line, we reset $signoff to false before running the remainder of the loop. Hence, the check for $signoff that attempts to remove an extra empty line between two signed-off-by line was not doing anything useful. Rename $empty to a more explicit name $skip_blank_line to tell us to skip a blank line when we see one, set it after we see and emit a blank line (to avoid showing more than one empty lines in a raw) or after we handle a signed-off-by line (to avoid empty lines after such a line), to fix this bug, and get rid of the $signoff variable that is not useful. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Namhyung Kim committed Jul 4, 2012 at 11:47 UTC 5a45c0cafe6d73f6026bd0ea525da2f9765b112d
1 file changed +7 -14
gitweb/gitweb.perl
+7 -14
@@ -4460,30 +4460,23 @@ sub git_print_log {
4460 }
4461
4462 # print log
4463 - my $signoff = 0;
4464 - my $empty = 0;
4463 + my $skip_blank_line = 0;
4464 foreach my $line (@$log) {
4465 if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
4467 - $signoff = 1;
4468 - $empty = 0;
4466 if (! $opts{'-remove_signoff'}) {
4467 print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
4471 - next;
4472 - } else {
4473 - # remove signoff lines
4474 - next;
4468 + $skip_blank_line = 1;
4469 }
4476 - } else {
4477 - $signoff = 0;
4470 + next;
4471 }
4472
4473 # print only one empty line
4474 # do not print empty line after signoff
4475 if ($line eq "") {
4483 - next if ($empty || $signoff);
4484 - $empty = 1;
4476 + next if ($skip_blank_line);
4477 + $skip_blank_line = 1;
4478 } else {
4486 - $empty = 0;
4479 + $skip_blank_line = 0;
4480 }
4481
4482 print format_log_line_html($line) . "<br/>\n";
@@ -4491,7 +4484,7 @@ sub git_print_log {
4484
4485 if ($opts{'-final_empty_line'}) {
4486 # end with single empty line
4494 - print "<br/>\n" unless $empty;
4487 + print "<br/>\n" unless $skip_blank_line;
4488 }
4489 }
4490