]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: eliminate oneline log view
authorEric Wong <e@80x24.org>
Sat, 16 Jan 2016 02:29:23 +0000 (02:29 +0000)
committerEric Wong <e@80x24.org>
Tue, 5 Apr 2016 18:58:27 +0000 (18:58 +0000)
The oneline view lacks sufficient information at times.
Reduce the number of options presented and always show
the full log message to avoid making the user follow more
links.

lib/PublicInbox/RepobrowseGitLog.pm
lib/PublicInbox/RepobrowseGitQuery.pm

index 4c1697075f52b6a8d16d4d69fa8032cd45f18c5f..36664171abe05eaaf118ca40737454158bb95d1b 100644 (file)
@@ -1,6 +1,7 @@
 # Copyright (C) 2015 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
+# show the log view
 package PublicInbox::RepobrowseGitLog;
 use strict;
 use warnings;
@@ -9,8 +10,7 @@ use base qw(PublicInbox::RepobrowseBase);
 use PublicInbox::RepobrowseGit qw(git_dec_links git_commit_title);
 # cannot rely on --date=format-local:... yet, it is too new (September 2015)
 my $LOG_FMT = '--pretty=tformat:'.
-               join('%x00', qw(%h %p %s D%D));
-my $MSG_FMT = join('%x00', '', qw(%ai a%an b%b));
+               join('%x00', qw(%h %p %s D%D %ai a%an b%b), '', '');
 
 sub call_git_log {
        my ($self, $req) = @_;
@@ -23,17 +23,14 @@ sub call_git_log {
        my $h = $q->{h};
        $h eq '' and $h = 'HEAD';
 
-       my $fmt = $LOG_FMT;
-       $fmt .= $MSG_FMT if $q->{showmsg};
-       $fmt .= '%x00%x00';
-
        my $git = $repo_info->{git};
-       my $log = $git->popen(qw(log --no-notes --no-color
-                               --abbrev-commit --abbrev=12),
-                               $fmt, "-$max", $h);
+       my $log = $git->popen(qw(log --no-notes --no-color --abbrev-commit),
+                               $LOG_FMT, "-$max", $h, '--');
        sub {
                my ($res) = @_; # Plack callback
                my $fh = $res->([200, ['Content-Type'=>'text/html']]);
+               my $title = utf8_html("log: $repo_info->{path_info} ($h)");
+               $fh->write($self->html_start($req, $title));
                git_log_stream($req, $q, $log, $fh, $git);
                $fh->close;
        }
@@ -41,25 +38,8 @@ sub call_git_log {
 
 sub git_log_stream {
        my ($req, $q, $log, $fh, $git) = @_;
-       my $desc = $req->{repo_info}->{desc_html};
-       my $showmsg = $q->{showmsg};
-
-       my $x = 'commit log ';
-       if ($showmsg) {
-               $showmsg = "&showmsg=1";
-               my $qs = $q->qs(showmsg => '');
-               $qs = $req->{cgi}->path_info if ($qs eq '');
-               $x .= qq{[<a\nhref="$qs">oneline</a>|<b>expand</b>]};
-       } else {
-               my $qs = $q->qs(showmsg => 1);
-               $x .= qq{[<b>oneline</b>|<a\nhref="$qs">expand</a>]};
-       }
 
        my $rel = $req->{relcmd};
-       $fh->write('<html><head>' . PublicInbox::Hval::STYLE .
-               "<title>$desc</title></head><body><pre><b>$desc</b>\n\n".
-               qq!commit\t\t$x\n!);
-       $fh->write($showmsg ? '</pre>' : "\n");
        my %acache;
        local $/ = "\0\0\n";
        my $nr = 0;
@@ -69,28 +49,32 @@ sub git_log_stream {
                $seen{$id} = 1;
                my @p = split(' ', $p);
                push @parents, @p;
+               my $plinks;
+               if (@p == 1) { # typical, single-parent commit
+                       $plinks = qq( / parent <a\nhref="#p$p[0]">$p[0]</a>);
+               } elsif (@p > 0) { # merge commit
+                       $plinks = ' / parents ' . join(' ', map {
+                               qq(<a\nhref="#p$_">$_</a>);
+                               } @p);
+               } else {
+                       $plinks = ''; # root commit
+               }
 
                $s = utf8_html($s);
-               $s = qq(<a\nhref="${rel}commit?id=$id">$s</a>);
+               $s = qq(<a\nid=p$id\nhref="${rel}commit?id=$id"><b>$s</b></a>);
                if ($D =~ /\AD(.+)/) {
                        $s .= ' ('. join(', ', git_dec_links($rel, $1)) . ')';
                }
 
-               if (defined $b) {
-                       $an =~ s/\Aa//;
-                       $b =~ s/\Ab//;
-                       $b =~ s/\s*\z//s;
+               $an =~ s/\Aa//;
+               $b =~ s/\Ab//;
+               $b =~ s/\s*\z//s;
 
-                       my $ah = $acache{$an} ||= utf8_html($an);
-                       my $x = "<table><tr><td\nvalign=top><pre>$id";
-                       my $nl = $b eq '' ? '' : "\n"; # empty bodies :<
-                       $b = $x . '  </pre></td><td><pre>' .
-                               "<b>$s</b>\n- $ah @ $ai\n$nl" .
-                               utf8_html($b) . '</pre></td></tr></table>';
-               } else {
-                       $b = qq($id\t$s\n);
-               }
-               $fh->write($b);
+               my $ah = $acache{$an} ||= utf8_html($an);
+               my $nl = $b eq '' ? '' : "\n"; # empty bodies :<
+               $b = "$s\n- $ah @ $ai\n  commit $id$plinks\n$nl" .
+                       utf8_html($b);
+               $fh->write("\n\n" .$b);
                ++$nr;
        }
 
@@ -100,11 +84,11 @@ sub git_log_stream {
                next if $seen{$p};
                $seen{$p} = ++$np;
                my $s = git_commit_title($git, $p);
-               $m .= qq(\n<a\nhref="?h=$p$showmsg">$p</a>\t);
+               $m .= qq(\n<a\nid=p$p\nhref="?h=$p">$p</a>\t);
                $s = defined($s) ? utf8_html($s) : '';
                $m .= qq(<a\nhref="${rel}commit?id=$p">$s</a>);
        }
-       my $foot = $showmsg ? "<pre>\t\t$x\n\n" : "\n\t\t$x\n\n";
+       my $foot = "</pre><hr /><pre>";
        if ($np == 0) {
                $foot .= "No commits follow";
        } elsif ($np > 1) {
index 018b20c92f1e68649e81a0b1dfa70cabd1ed7bf2..0ee9df046df563cb6c408d102067b89177355526 100644 (file)
@@ -6,7 +6,7 @@ package PublicInbox::RepobrowseGitQuery;
 use strict;
 use warnings;
 use PublicInbox::Hval;
-my @KNOWN_PARAMS = qw(id id2 h showmsg ofs);
+my @KNOWN_PARAMS = qw(id id2 h ofs);
 
 sub new {
        my ($class, $cgi) = @_;