]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: use symbolic-ref instead of ugly rev-parse match
authorEric Wong <e@80x24.org>
Mon, 18 Jan 2016 07:29:04 +0000 (07:29 +0000)
committerEric Wong <e@80x24.org>
Tue, 5 Apr 2016 18:58:27 +0000 (18:58 +0000)
Oops, forgot about this old command :x

lib/PublicInbox/RepobrowseGitSummary.pm

index db601ad986fb0ed967a617a0c3df4c107245a5b4..0dffd5cc7e7945851bbb4881b63f52d14ba6235c 100644 (file)
@@ -29,7 +29,7 @@ sub emit_summary {
 
        # n.b. we would use %(HEAD) in for-each-ref --format if we could
        # rely on git 1.9.0+, but it's too soon for that in early 2016...
-       chomp(my $head_ref = $git->qx(qw(rev-parse HEAD~0)));
+       chomp(my $head_ref = $git->qx(qw(symbolic-ref HEAD)));
 
        my $refs = $git->popen(qw(for-each-ref --sort=-creatordate),
                                EACH_REF_FMT, "--count=$count",
@@ -43,6 +43,7 @@ sub emit_summary {
        my $rel = $req->{relcmd};
        foreach (<$refs>) {
                my ($ref, $type, $hex, $date, $s) = split(' ', $_, 5);
+               my $x = $ref eq $head_ref ? ' (HEAD)' : '';
                $ref =~ s!\Arefs/(?:heads|tags)/!!;
                $ref = PublicInbox::Hval->utf8($ref);
                my $h = $ref->as_html;
@@ -60,7 +61,6 @@ sub emit_summary {
                        next;
                }
                chomp $s;
-               my $x = $hex eq $head_ref ? ' (HEAD)' : '';
                $fh->write(qq(<tr><td><tt><a\nhref="$ref">$h</a>$x</tt></td>) .
                        qq(<td><tt>$date <a\nhref="$sref">) . utf8_html($s) .
                        '</a></tt></td></tr>');