diff options
author | Eric Wong <e@80x24.org> | 2016-01-20 22:35:23 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-04-05 18:58:27 +0000 |
commit | f08dc18b4f5b3aa7a43bfa9ce754b23028f5babb (patch) | |
tree | e0632c5e755fb28fecc68aab02275b873de2ec0d /lib/PublicInbox/RepobrowseGitCommit.pm | |
parent | b3bc0d722aacdad5ac5e8ee7c32bda9c87d3052b (diff) | |
download | public-inbox-f08dc18b4f5b3aa7a43bfa9ce754b23028f5babb.tar.gz |
We shall save clients the overhead of making extra HTTP requests to follow partial paths. This ought to improve cache hit effectiveness on both the server and client side by reducing the potential different pages we may set.
Diffstat (limited to 'lib/PublicInbox/RepobrowseGitCommit.pm')
-rw-r--r-- | lib/PublicInbox/RepobrowseGitCommit.pm | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/lib/PublicInbox/RepobrowseGitCommit.pm b/lib/PublicInbox/RepobrowseGitCommit.pm index d6843a6d..edc27717 100644 --- a/lib/PublicInbox/RepobrowseGitCommit.pm +++ b/lib/PublicInbox/RepobrowseGitCommit.pm @@ -137,24 +137,23 @@ sub call_git_commit { my $q = PublicInbox::RepobrowseGitQuery->new($req->{cgi}); my $id = $q->{id}; $id eq '' and $id = 'HEAD'; + + my $expath = $req->{expath}; + if ($expath ne '') { + my $relup = join('', map { '../' } @{$req->{extra}}); + my $qs = $q->qs; + return $self->r(301, $req, "$relup$qs#".to_attr($expath)); + } + my $git = $req->{repo_info}->{git}; my @cmd = (qw(show -z --numstat -p --encoding=UTF-8 --no-notes --no-color -c), $git->abbrev); - my @path; - - # kill trailing slash - my $extra = $req->{extra}; - if (@$extra) { - pop @$extra if $extra->[-1] eq ''; - @path = (join('/', @$extra)); - push @cmd, '--follow'; - } - my $log = $git->popen(@cmd, GIT_FMT, $id, '--', @path); + my $log = $git->popen(@cmd, GIT_FMT, $id, '--'); my $H = <$log>; # maybe the path didn't exist, yet, zip them back up - return git_commit_404($req, $q, $path[0]) unless defined $H; + return git_commit_404($req, $q) unless defined $H; sub { my ($res) = @_; # Plack callback my $fh = $res->([200, ['Content-Type'=>'text/html']]); @@ -164,19 +163,12 @@ sub call_git_commit { } sub git_commit_404 { - my ($req, $q, $path) = @_; + my ($req, $q) = @_; my $x = 'Missing commit or path'; my $pfx = "$req->{relcmd}commit"; - # print STDERR "path: $path\n"; my $try = 'try'; $x = "<html><head><title>$x</title></head><body><pre><b>$x</b>\n\n"; - if (defined $path) { - my $qs = $q->qs; - $x .= "<a\nhref=\"$pfx$qs\">" . - "try without the path <s>$path</s></a>\n"; - $try = 'or'; - } my $qs = $q->qs(id => ''); $x .= "<a\nhref=\"$pfx$qs\">$try the latest commit in HEAD</a>\n"; $x .= '</pre></body>'; |