Skip to content

Commit 5a45c0c

Browse files
namhyunggitster
authored andcommitted
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>
1 parent 785ee49 commit 5a45c0c

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

gitweb/gitweb.perl

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4460,38 +4460,31 @@ sub git_print_log {
44604460
}
44614461

44624462
# print log
4463-
my $signoff = 0;
4464-
my $empty = 0;
4463+
my $skip_blank_line = 0;
44654464
foreach my $line (@$log) {
44664465
if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
4467-
$signoff = 1;
4468-
$empty = 0;
44694466
if (! $opts{'-remove_signoff'}) {
44704467
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;
44754469
}
4476-
} else {
4477-
$signoff = 0;
4470+
next;
44784471
}
44794472

44804473
# print only one empty line
44814474
# do not print empty line after signoff
44824475
if ($line eq "") {
4483-
next if ($empty || $signoff);
4484-
$empty = 1;
4476+
next if ($skip_blank_line);
4477+
$skip_blank_line = 1;
44854478
} else {
4486-
$empty = 0;
4479+
$skip_blank_line = 0;
44874480
}
44884481

44894482
print format_log_line_html($line) . "<br/>\n";
44904483
}
44914484

44924485
if ($opts{'-final_empty_line'}) {
44934486
# end with single empty line
4494-
print "<br/>\n" unless $empty;
4487+
print "<br/>\n" unless $skip_blank_line;
44954488
}
44964489
}
44974490

0 commit comments

Comments
 (0)