@matheusbsbs / matheus-bagliano / commits / b7f9253df9
Fork 0

gitweb: Make git_print_log generic; git_print_simplified_log uses it

Collapse git_print_log and git_print_simplified_log into one subroutine git_print_log. git_print_simplified_log now simply calls git_print_log with proper options. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Aug 28, 2006 at 14:48 UTC b7f9253df9bf351527f319d67bf67a95a4b8d79a
1 file changed +31 -32
gitweb/gitweb.perl
+31 -32
@@ -1377,9 +1377,15 @@ sub git_print_page_path {
1377 }
1378 }
1379
1380 -sub git_print_log {
1380 +# sub git_print_log (\@;%) {
1381 +sub git_print_log ($;%) {
1382 my $log = shift;
1383 + my %opts = @_;
1384
1385 + if ($opts{'-remove_title'}) {
1386 + # remove title, i.e. first line of log
1387 + shift @$log;
1388 + }
1389 # remove leading empty lines
1390 while (defined $log->[0] && $log->[0] eq "") {
1391 shift @$log;
@@ -1389,6 +1395,19 @@ sub git_print_log {
1395 my $signoff = 0;
1396 my $empty = 0;
1397 foreach my $line (@$log) {
1398 + if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1399 + $signoff = 1;
1400 + if (! $opts{'-remove_signoff'}) {
1401 + print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
1402 + next;
1403 + } else {
1404 + # remove signoff lines
1405 + next;
1406 + }
1407 + } else {
1408 + $signoff = 0;
1409 + }
1410 +
1411 # print only one empty line
1412 # do not print empty line after signoff
1413 if ($line eq "") {
@@ -1397,13 +1416,13 @@ sub git_print_log {
1416 } else {
1417 $empty = 0;
1418 }
1400 - if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1401 - $signoff = 1;
1402 - print "<span class=\"signoff\">" . esc_html($line) . "</span><br/>\n";
1403 - } else {
1404 - $signoff = 0;
1405 - print format_log_line_html($line) . "<br/>\n";
1406 - }
1419 +
1420 + print format_log_line_html($line) . "<br/>\n";
1421 + }
1422 +
1423 + if ($opts{'-final_empty_line'}) {
1424 + # end with single empty line
1425 + print "<br/>\n" unless $empty;
1426 }
1427 }
1428
@@ -1411,30 +1430,10 @@ sub git_print_simplified_log {
1430 my $log = shift;
1431 my $remove_title = shift;
1432
1414 - shift @$log if $remove_title;
1415 - # remove leading empty lines
1416 - while (defined $log->[0] && $log->[0] eq "") {
1417 - shift @$log;
1418 - }
1419 -
1420 - # simplify and print log
1421 - my $empty = 0;
1422 - foreach my $line (@$log) {
1423 - # remove signoff lines
1424 - if ($line =~ m/^ *(signed[ \-]off[ \-]by[ :]|acked[ \-]by[ :]|cc[ :])/i) {
1425 - next;
1426 - }
1427 - # print only one empty line
1428 - if ($line eq "") {
1429 - next if $empty;
1430 - $empty = 1;
1431 - } else {
1432 - $empty = 0;
1433 - }
1434 - print format_log_line_html($line) . "<br/>\n";
1435 - }
1436 - # end with single empty line
1437 - print "<br/>\n" unless $empty;
1433 + git_print_log($log,
1434 + -final_empty_line=> 1,
1435 + -remove_signoff => 1,
1436 + -remove_title => $remove_title);
1437 }
1438
1439 ## ......................................................................