From b2492cc6ef642640c901ccca5ff96b9228cd10ec Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 3 Mar 2017 22:07:19 +0000 Subject: repobrowse: src/ endpoint requires a tip to be specified Implying a tip would make for ambiguous URLs and ruin caching, so try to get everybody to hit the same URL. This also simplifies some of our other code since the tip is always in the request. --- lib/PublicInbox/RepoGitSrc.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lib/PublicInbox/RepoGitSrc.pm') diff --git a/lib/PublicInbox/RepoGitSrc.pm b/lib/PublicInbox/RepoGitSrc.pm index de068940..38108442 100644 --- a/lib/PublicInbox/RepoGitSrc.pm +++ b/lib/PublicInbox/RepoGitSrc.pm @@ -23,7 +23,7 @@ sub call_git_src { my ($self, $req) = @_; my $repo = $req->{-repo}; my $git = $repo->{git}; - my $tip = $req->{tip} || $req->{repo}->tip; + my $tip = $req->{tip} or return $self->r(302, $req, $repo->tip); sub { my ($res) = @_; $git->check_async($req->{env}, "$tip:$req->{expath}", sub { @@ -57,7 +57,7 @@ sub cur_path { my ($req) = @_; my @ex = @{$req->{extra}} or return 'root'; my $s; - my $tip = $req->{tip} || $req->{repo}->tip; + my $tip = $req->{tip}; my $rel = $req->{relcmd}; # avoid relative paths, here, we don't want to propagate # trailing-slash URLs although we tolerate them @@ -81,7 +81,7 @@ sub git_blob_sed ($$$) { my @lines; my $buf = ''; my $rel = $req->{relcmd}; - my $tip = $req->{tip} || $req->{repo}->tip; + my $tip = $req->{tip}; my $raw = join('/', "${rel}raw", $tip, @{$req->{extra}}); $raw = PublicInbox::Hval->utf8($raw)->as_path; my $t = cur_path($req); @@ -220,10 +220,8 @@ sub git_tree_show { $req->{thtml} .= "\npath: $t\n\nmode\tsize\tname\n"; if (defined(my $last = $req->{extra}->[-1])) { $pfx = PublicInbox::Hval->utf8($last)->as_path; - } elsif (defined(my $tip = $req->{tip})) { - $pfx = $tip; } else { - $pfx = 'src/' . $req->{-repo}->tip; + $pfx = 'src/' . $req->{tip}; } $req->{tpfx} = $pfx; my $env = $req->{env}; -- cgit v1.2.3-24-ge0c7