From: Eric Wong Date: Thu, 24 Dec 2015 11:35:41 +0000 (+0000) Subject: repobrowse: simplify merge display code X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4be6ef4cf0d38a45fc22f0d92ab24e0b04639030;p=thirdparty%2Fpublic-inbox.git repobrowse: simplify merge display code --- diff --git a/lib/PublicInbox/RepoBrowseGitCommit.pm b/lib/PublicInbox/RepoBrowseGitCommit.pm index 16c14928f..c70b1d1b4 100644 --- a/lib/PublicInbox/RepoBrowseGitCommit.pm +++ b/lib/PublicInbox/RepoBrowseGitCommit.pm @@ -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($p $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 .= "$p ("; - $qs = $q->qs(id => $p, id2 => $h); - $x .= ""; - $x .= "diff) "; - $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$s\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" : $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 . " $p ". $t . "\n"; +} + 1;