]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
repobrowse: fixup revision handling
authorEric Wong <e@80x24.org>
Wed, 22 Feb 2017 03:01:24 +0000 (03:01 +0000)
committerEric Wong <e@80x24.org>
Wed, 22 Feb 2017 03:01:24 +0000 (03:01 +0000)
Revisions passed in the URL must not be ignored.
This fixes some bugs introduced in commit
f6244586ba4f5a5e7575e1254be8c9bbe303fce9
("repobrowse: switch to new URL format to avoid query strings")

lib/PublicInbox/RepoGitAtom.pm
lib/PublicInbox/RepoGitCommit.pm
lib/PublicInbox/RepoGitDiff.pm
lib/PublicInbox/RepoGitLog.pm
lib/PublicInbox/RepoGitRaw.pm
lib/PublicInbox/RepoGitSnapshot.pm
lib/PublicInbox/RepoGitTag.pm
lib/PublicInbox/RepoGitTree.pm
lib/PublicInbox/Repobrowse.pm

index 615c8927ccdeb6a1ea9270e7ba1219c11480674e..c30c61840b5e0549bde18c3d2a094578642af410 100644 (file)
@@ -141,7 +141,7 @@ sub call_git_atom {
 
        my $git = $repo->{git};
        my $env = $req->{env};
-       my $tip = $req->{h} || $repo->tip;
+       my $tip = $req->{tip} || $repo->tip;
        my $read_log = sub {
                my $cmd = $git->cmd(qw(log --no-notes --no-color
                                        --abbrev-commit), $git->abbrev,
index 22a2742c483ba7ecb9339bec8bb3ecda75a408a0..34f7acc3b54cf4a17d2238f850b348c5ac9dbd5c 100644 (file)
@@ -124,11 +124,11 @@ sub call_git_commit { # RepoBase calls this
                my $relup = join('', map { '../' } @{$req->{extra}});
                return $self->r(301, $req, "$relup#".to_attr($expath));
        }
-
+       my $tip = $req->{tip} || $req->{-repo}->tip;
        my $git = $req->{-repo}->{git};
        my $cmd = $git->cmd(qw(show -z --numstat -p --encoding=UTF-8
                        --no-notes --no-color -c --no-abbrev),
-                       GIT_FMT, $req->{-repo}->tip, '--');
+                       GIT_FMT, $tip, '--');
        my $rdr = { 2 => $git->err_begin };
        my $qsp = PublicInbox::Qspawn->new($cmd, undef, $rdr);
        $env->{'qspawn.quiet'} = 1;
index 267284021019c8a81715b0b71dc0af1936b01e2a..643d5cb74a6a64aaae0a8f36f70d231ab50e32dc 100644 (file)
@@ -32,9 +32,10 @@ sub git_diff_sed ($$) {
        }
 }
 
+# $REPO/diff/$BEFORE..$AFTER
 sub call_git_diff {
        my ($self, $req) = @_;
-       my ($id, $id2) = split(/\.\./, $req->{h});
+       my ($id, $id2) = split(/\.\./, $req->{tip});
        my $env = $req->{env};
        my $git = $req->{-repo}->{git};
        my $cmd = $git->cmd(qw(diff-tree -z --numstat -p --encoding=UTF-8
index 38097ed3484912b5f963289ea19cd6d6e4a513b2..1ad83fc0536145074f1dba29d4c571ec043c563b 100644 (file)
@@ -124,22 +124,16 @@ sub call_git_log {
        my ($self, $req) = @_;
        my $repo = $req->{-repo};
        my $max = $repo->{max_commit_count} || 50;
-       my $h = $req->{h};
+       my $tip = $req->{tip} || $repo->tip;
+       $req->{lpfx} = $req->{relcmd};
        $max = int($max);
        $max = 50 if $max == 0;
        my $env = $req->{env};
        my $git = $repo->{git};
-       my $tip = $req->{-repo}->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) {
-               $title .= ' ('. utf8_html($h). ')';
-               $req->{lpfx} = $req->{relcmd};
-       } else {
-               $req->{lpfx} = $req->{relcmd} . $tip;
-       }
+       my $title = 'log: '.$repo->{repo}.' ('.utf8_html($tip).')';
        $req->{lhtml} = $self->html_start($req, $title) . "\n\n";
        my $qsp = PublicInbox::Qspawn->new($cmd, undef, $rdr);
        $qsp->psgi_return($env, undef, sub {
index a38d7deb6f01f36a60470be277b78c138f9ccd04..f02439ad9eb39a551ad639931bbd7621cc3efdbb 100644 (file)
@@ -12,7 +12,8 @@ sub call_git_raw {
        my ($self, $req) = @_;
        my $repo = $req->{-repo};
        my $git = $repo->{git};
-       my $id = $repo->tip . ':' . $req->{expath};
+       my $tip = $req->{tip} || $repo->tip;
+       my $id = $tip . ':' . $req->{expath};
        my ($cat, $hex, $type, $size) = $git->cat_file_begin($id);
        return unless defined $cat;
 
index 3d53fa6d9a2ae3823a3f6372c6cc9cbe235f81bd..49d5103330e1f668268fa00b42937d563f054e29 100644 (file)
@@ -36,7 +36,7 @@ our %FMT_TYPES = (
 sub call_git_snapshot ($$) { # invoked by PublicInbox::RepoBase::call
        my ($self, $req) = @_;
 
-       my $ref = $req->{h} || $req->{-repo}->tip;
+       my $ref = $req->{tip} || $req->{-repo}->tip;
        my $orig_fn = $ref;
 
        # just in case git changes refname rules, don't allow wonky filenames
index 6a35f61c527a21ccbb88b9dd4aa9a0c7bbe32a5f..785de6b1e739d9b115ba6506daafdb0cd9b2cbd3 100644 (file)
@@ -19,11 +19,11 @@ my %cmd_map = ( # type => action
 sub call_git_tag {
        my ($self, $req) = @_;
 
-       my $h = $req->{h};
-       defined $h or return git_tag_list($self, $req);
+       my $tip = $req->{tip};
+       defined $tip or return git_tag_list($self, $req);
        sub {
                my ($res) = @_;
-               git_tag_show($self, $req, $h, $res);
+               git_tag_show($self, $req, $tip, $res);
        }
 }
 
index 5e880ee3b6efbd26040b7b57c24cd63b5bd87c43..64ab9e6f9cd1ebdcb5abc0e335323a37d6e7d0a7 100644 (file)
@@ -22,7 +22,7 @@ sub call_git_tree {
        my @extra = @{$req->{extra}};
        my $repo = $req->{-repo};
        my $git = $repo->{git};
-       my $tip = $repo->tip;
+       my $tip = $req->{tip} || $repo->tip;
        my $obj = "$tip:$req->{expath}";
        my ($hex, $type, $size) = $git->check($obj);
 
@@ -31,8 +31,7 @@ sub call_git_tree {
        }
 
        my $opts = { nofollow => 1 };
-       my $title = $req->{expath};
-       $title = $title eq '' ? 'tree' : utf8_html($title);
+       my $title = "tree: ".utf8_html($req->{expath});
        if ($type eq 'tree') {
                $opts->{noindex} = 1;
                $req->{thtml} = $self->html_start($req, $title, $opts) . "\n";
@@ -193,8 +192,8 @@ sub git_tree_show {
        $req->{thtml} .= "\npath: $t\n\n<b>mode\tsize\tname</b>\n";
        if (defined(my $last = $req->{extra}->[-1])) {
                $pfx = PublicInbox::Hval->utf8($last)->as_path;
-       } elsif (defined $req->{h}) {
-               $pfx = $req->{-repo}->tip;
+       } elsif (defined(my $tip = $req->{tip})) {
+               $pfx = $tip;
        } else {
                $pfx = 'tree/' . $req->{-repo}->tip;
        }
index 94e78b80f156c7d8dc4c48408c5524908babeb40..aad0e8ba200dcf5bfd4eff55706b7011eae7fb8a 100644 (file)
@@ -118,11 +118,11 @@ sub call {
        my $vcs_lc = $repo->{vcs};
        my $vcs = $VCS{$vcs_lc} or return r404();
        my $mod;
-       my $h;
+       my $tip;
        if (defined $cmd && length $cmd) {
                $mod = $CMD{$cmd};
                if ($mod) {
-                       $h = shift @extra if @extra;
+                       $tip = shift @extra if @extra;
                } else {
                        unshift @extra, $cmd;
                        $mod = 'Fallback';
@@ -141,7 +141,7 @@ sub call {
        while (@extra && $extra[-1] eq '') {
                pop @extra;
        }
-       $req->{h} = $h;
+       $req->{tip} = $tip;
        $mod = load_once("PublicInbox::Repo$vcs$mod");
        $vcs = load_once("PublicInbox::$vcs");