]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: stop abbreviating commit hashes
authorEric Wong <e@80x24.org>
Tue, 21 Feb 2017 23:05:46 +0000 (23:05 +0000)
committerEric Wong <e@80x24.org>
Tue, 21 Feb 2017 23:05:46 +0000 (23:05 +0000)
Abbreviations can become ambiguous over time, and it seems other
tools are fine with displaying unabbreviated hashes for commits.
This should reduce workload for the search engines, too.

lib/PublicInbox/RepoGitCommit.pm
lib/PublicInbox/RepoGitDiffCommon.pm
lib/PublicInbox/RepoGitLog.pm

index 2d4234cc1a490bfc872a94d30011e61365202bca..22a2742c483ba7ecb9339bec8bb3ecda75a408a0 100644 (file)
@@ -22,7 +22,7 @@ use PublicInbox::Qspawn;
 
 use constant {
        GIT_FMT => '--pretty=format:'.join('%n',
-               '%H', '%h', '%s', '%an <%ae>', '%ai', '%cn <%ce>', '%ci',
+               '%H', '%s', '%an <%ae>', '%ai', '%cn <%ce>', '%ci',
                '%t', '%p', '%D', '%b%x00'),
        CC_EMPTY => " This is a merge, and the combined diff is empty.\n",
        CC_MERGE => " This is a merge, showing combined diff:\n\n"
@@ -30,8 +30,8 @@ use constant {
 
 sub commit_header {
        my ($self, $req) = @_;
-       my ($H, $h, $s, $au, $ad, $cu, $cd, $t, $p, $D, $rest) =
-               split("\n", $req->{dbuf}, 11);
+       my ($H, $s, $au, $ad, $cu, $cd, $t, $p, $D, $rest) =
+               split("\n", $req->{dbuf}, 10);
        $s = utf8_html($s);
        $au = utf8_html($au);
        $cu = utf8_html($cu);
@@ -39,8 +39,8 @@ sub commit_header {
 
        my $rel = $req->{relcmd};
        my $x = $self->html_start($req, $s) . "\n" .
-               qq(   commit $H (<a\nhref="${rel}patch/$h">patch</a>)\n) .
-               qq(     tree <a\nrel=nofollow\nhref="${rel}tree/$h">$t</a>);
+               qq(   commit $H (<a\nhref="${rel}patch/$H">patch</a>)\n) .
+               qq(     tree <a\nrel=nofollow\nhref="${rel}tree/$H">$t</a>);
 
        my $git = $req->{-repo}->{git};
        # extra show path information, if any
@@ -55,7 +55,7 @@ sub commit_header {
                        my $e = PublicInbox::Hval->utf8($_, join('/', @t));
                        $ep = $e->as_path;
                        my $eh = $e->as_html;
-                       $ep = "${rel}tree/$ep/$h";
+                       $ep = "${rel}tree/$ep/$H";
                        qq(<a\nrel=nofollow\nhref="$ep">$eh</a>);
                } @$extra);
                $path = "/$ep";
@@ -84,7 +84,7 @@ sub commit_header {
        # FIXME: deal with excessively long commit message bodies
        ($bx00, $req->{dbuf}) = split("\0", $rest, 2);
        $req->{anchors} = {};
-       $req->{h} = $h;
+       $req->{H} = $H;
        $req->{p} = \@p;
        $x .= utf8_html($bx00) . "<a\nid=D>---</a>\n";
 }
@@ -127,8 +127,8 @@ sub call_git_commit { # RepoBase calls this
 
        my $git = $req->{-repo}->{git};
        my $cmd = $git->cmd(qw(show -z --numstat -p --encoding=UTF-8
-                       --no-notes --no-color -c),
-                       $git->abbrev, GIT_FMT, $req->{-repo}->tip, '--');
+                       --no-notes --no-color -c --no-abbrev),
+                       GIT_FMT, $req->{-repo}->tip, '--');
        my $rdr = { 2 => $git->err_begin };
        my $qsp = PublicInbox::Qspawn->new($cmd, undef, $rdr);
        $env->{'qspawn.quiet'} = 1;
@@ -164,7 +164,8 @@ sub git_parent_line {
        my ($pfx, $p, $git, $rel) = @_;
        my $t = git_commit_title($git, $p);
        $t = defined $t ? utf8_html($t) : '';
-       $pfx . qq( <a\nid=P\nhref="${rel}commit/$p">$p</a> $t\n);
+       my $pad = ' ' x length($pfx);
+       $pfx . qq( <a\nid=P\nhref="${rel}commit/$p">$p</a>\n $pad$t\n);
 }
 
 # do not break anchor links if the combined diff doesn't show changes:
index 67adca682d0c357d0c7f420081b18837fe8808e4..46e243ed0277b7a757196e1987d76e7d8776c2a3 100644 (file)
@@ -126,9 +126,9 @@ sub git_diff_cc_hunk {
        if ($n == 0) { # deleted file (does this happen with --cc?)
                $rv .= " $last";
        } else {
-               my $h = $req->{h};
+               my $H = $req->{H};
                $rv .= qq( <a\nrel=nofollow);
-               $rv .= qq(\nhref="${rel}tree/$h/$path#n$n">$last</a>);
+               $rv .= qq(\nhref="${rel}tree/$H/$path#n$n">$last</a>);
        }
        $rv .= " $at" . utf8_html($ctx);
 }
index 4e0997e036abc99ed12d64fed3c8bcc8fc8b50a6..38097ed3484912b5f963289ea19cd6d6e4a513b2 100644 (file)
@@ -10,16 +10,17 @@ use base qw(PublicInbox::RepoBase);
 use PublicInbox::RepoGit qw(git_dec_links git_commit_title);
 use PublicInbox::Qspawn;
 # cannot rely on --date=format-local:... yet, it is too new (September 2015)
-use constant STATES => qw(h p D ai an s b);
+use constant STATES => qw(H p D ai an s b);
 use constant STATE_BODY => (scalar(STATES) - 1);
 my $LOG_FMT = '--pretty=tformat:'.  join('%n', map { "%$_" } STATES).'%x00';
 
 sub parent_links {
        if (@_ == 1) { # typical, single-parent commit
-               qq( / parent <a\nhref="#p$_[0]">$_[0]</a>);
+               qq(\n  parent <a\nhref="#p$_[0]">$_[0]</a>);
        } elsif (@_ > 0) { # merge commit
-               ' / parents ' .
-                       join(' ', map { qq(<a\nhref="#p$_">$_</a>) } @_);
+               "\n parents " .
+                       join("\n         ",
+                       map { qq(<a\nhref="#p$_">$_</a>) } @_);
        } else {
                ''; # root commit
        }
@@ -30,7 +31,7 @@ sub flush_log_hdr ($$$) {
        my $lpfx = $req->{lpfx};
        my $seen = $req->{seen};
        $$dst .= '<hr /><pre>' if scalar keys %$seen;
-       my $id = $hdr->{h};
+       my $id = $hdr->{H};
        $seen->{$id} = 1;
        $$dst .= qq(<a\nid=p$id\n);
        $$dst .= qq(href="${lpfx}commit/$id"><b>);
@@ -129,9 +130,8 @@ sub call_git_log {
        my $env = $req->{env};
        my $git = $repo->{git};
        my $tip = $req->{-repo}->tip;
-       my $cmd = $git->cmd(qw(log --no-notes --no-color --abbrev-commit),
-                               $git->abbrev, $LOG_FMT, "-$max",
-                               $tip, '--');
+       my $cmd = $git->cmd(qw(log --no-notes --no-color --no-abbrev),
+                               $LOG_FMT, "-$max", $tip, '--');
        my $rdr = { 2 => $git->err_begin };
        my $title = "log: $repo->{repo}";
        if (defined $h) {