]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: simplify merge display code
authorEric Wong <e@80x24.org>
Thu, 24 Dec 2015 11:35:41 +0000 (11:35 +0000)
committerEric Wong <e@80x24.org>
Tue, 5 Apr 2016 18:58:27 +0000 (18:58 +0000)
lib/PublicInbox/RepoBrowseGitCommit.pm

index 16c14928f19e437a36d8ae7a36a50299dfae02b2..c70b1d1b4ba85d73d178d0415cb26f300602b69c 100644 (file)
@@ -55,21 +55,14 @@ sub git_commit_stream {
 
        $x .= "\n   author $au\t$ad\ncommitter $cu\t$cd\n";
        if (scalar(@p) == 1) {
-               $x .= '   parent ';
                my $p = $p[0];
-               my $t = git_commit_title_html($git, $p);
-               $qs = $q->qs(id => $p);
-               $x .= qq(<a\nhref="${rel}commit$path$qs">$p</a> $t\n);
+               $x .= git_parent_line('   parent', $p, $q, $git, $rel, $path);
        } elsif (scalar(@p) > 1) {
-               foreach my $p (@p) {
-                       $x .= '    merge ';
-                       $qs = $q->qs(id => $p);
-                       $x .= "<a\nhref=\"${rel}commit$path$qs\">$p</a> (";
-                       $qs = $q->qs(id => $p, id2 => $h);
-                       $x .= "<a\nhref=\"${rel}diff$path$qs\">";
-                       $x .= "diff</a>) ";
-                       $x .= git_commit_title_html($git, $p);
-                       $x .= "\n";
+               my @common = ($q, $git, $rel, $path);
+               my $p = shift @p;
+               $x .= git_parent_line('  parents', $p, @common);
+               foreach $p (@p) {
+                       $x .= git_parent_line('         ', $p, @common);
                }
        }
        $fh->write($x .= "\n<b>$s</b>\n\n");
@@ -322,13 +315,6 @@ sub git_diff_cc_hunk {
        $rv .= " $at" . utf8_html($ctx);
 }
 
-sub git_commit_title_html {
-       my ($git, $id) = @_;
-       my $t = git_commit_title($git, $id);
-       return '' unless defined $t; # BUG?
-       '[' . utf8_html($t) . ']';
-}
-
 sub git_diffstat_rename {
        my ($rel, $h, $from, $to) = @_;
        my @from = split('/', $from);
@@ -365,4 +351,12 @@ sub git_diff_mod {
        $pfx . (length($l) ? "<$t>$l</$t>" : $l);
 }
 
+sub git_parent_line {
+       my ($pfx, $p, $q, $git, $rel, $path) = @_;
+       my $qs = $q->qs(id => $p);
+       my $t = git_commit_title($git, $p);
+       $t = defined $t ? utf8_html($t) : '';
+       $pfx . " <a\nhref=\"${rel}commit$path$qs\">$p</a> ". $t . "\n";
+}
+
 1;