From: Eric Wong Date: Tue, 5 Jan 2016 00:37:39 +0000 (+0000) Subject: repobrowse: only show --combined diff for merges X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d199aa5c589367547dd4a55c9f991c7bb86a95ad;p=thirdparty%2Fpublic-inbox.git repobrowse: only show --combined diff for merges --cc diffs are less useful out-of-context to a casual reader, and showing too many options is confusing and bloats the page. --- diff --git a/lib/PublicInbox/RepoBrowseGitCommit.pm b/lib/PublicInbox/RepoBrowseGitCommit.pm index 73d6b8474..6278c53ad 100644 --- a/lib/PublicInbox/RepoBrowseGitCommit.pm +++ b/lib/PublicInbox/RepoBrowseGitCommit.pm @@ -54,10 +54,11 @@ sub git_commit_stream { } $x .= "\n author $au\t$ad\ncommitter $cu\t$cd\n"; - if (scalar(@p) == 1) { + my $np = scalar @p; + if ($np == 1) { my $p = $p[0]; $x .= git_parent_line(' parent', $p, $q, $git, $rel, $path); - } elsif (scalar(@p) > 1) { + } elsif ($np > 1) { my @common = ($q, $git, $rel, $path); my @t = @p; my $p = shift @t; @@ -72,23 +73,10 @@ sub git_commit_stream { local $/ = "\0"; $l = <$log>; chomp $l; - $x = utf8_html($l); # body - $fh->write($x."---\n"); + $fh->write(utf8_html($l)."---\n"); git_show_diffstat($req, $h, $fh, $log); - - if (scalar @p > 1) { - my $m = ' This is a merge, showing combined diff: '; - if ($q->{c}) { - my $qs = $q->qs(c => '', id => $h); - $m .= qq{[--cc (less)}; - $m .= q{|-c (more)]}; - } else { - $m .= q{[--cc (less)}; - my $qs = $q->qs(c => 1, id => $h); - $m .= qq{|-c (more)]}; - } - $fh->write($m .= "\n\n"); - } + my $help; + $help = " This is a merge, showing combined diff:\n\n" if ($np > 1); # diff local $/ = "\n"; @@ -96,6 +84,10 @@ sub git_commit_stream { my $diff = { h => $h, p => \@p, rel => $rel }; my $cc_add; while (defined($l = <$log>)) { + if ($help) { + $fh->write($help); + $help = undef; + } if ($l =~ m{^diff --git ("?a/.+) ("?b/.+)$}) { # regular $l = git_diff_ab_hdr($diff, $1, $2) . "\n"; } elsif ($l =~ m{^diff --(cc|combined) (.+)$}) { @@ -116,6 +108,10 @@ sub git_commit_stream { } $fh->write($l); } + + if ($help) { + $fh->write(" This is a merge, combined diff is empty.\n"); + } $fh->write(''); } @@ -127,8 +123,7 @@ sub call_git_commit { $id eq '' and $id = 'HEAD'; my $git = $req->{repo_info}->{git}; my @cmd = qw(show -z --numstat -p --encoding=UTF-8 - --no-notes --no-color --abbrev=10); - push @cmd, ($q->{c} ? '-c' : '--cc'); + --no-notes --no-color --abbrev=10 -c); my @path; # kill trailing slash diff --git a/lib/PublicInbox/RepoBrowseQuery.pm b/lib/PublicInbox/RepoBrowseQuery.pm index 5118f0b45..861e587b6 100644 --- a/lib/PublicInbox/RepoBrowseQuery.pm +++ b/lib/PublicInbox/RepoBrowseQuery.pm @@ -6,7 +6,7 @@ package PublicInbox::RepoBrowseQuery; use strict; use warnings; use PublicInbox::Hval; -my @KNOWN_PARAMS = qw(id id2 h showmsg ofs c); +my @KNOWN_PARAMS = qw(id id2 h showmsg ofs); sub new { my ($class, $cgi) = @_;