sub call {
my ($self, $cmd, $req) = @_;
- my $vcs = $req->{repo_info}->{vcs};
+ my $vcs = $req->{-repo}->{vcs};
my $rv = eval {
no strict 'refs';
my $sub = "call_${vcs}_$cmd";
# starts an HTML page for Repobrowse in a consistent way
sub html_start {
my ($self, $req, $title_html, $opts) = @_;
- my $desc = $req->{repo_info}->desc_html;
+ my $desc = $req->{-repo}->desc_html;
my $meta = '';
if ($opts) {
my $buf = '';
my $state = 0;
my $rel = $req->{relcmd};
- my $repo_info = $req->{repo_info};
- my $title = join('/', $repo_info->{repo}, @{$req->{extra}});
+ my $repo = $req->{-repo};
+ my $title = join('/', $repo->{repo}, @{$req->{extra}});
$title = utf8_html("$title, $req->{-tip}");
my $url = repo_root_url($self, $req);
my $hdr = {};
- my $subtitle = $repo_info->desc_html;
+ my $subtitle = $repo->desc_html;
$req->{axml} = qq(<?xml version="1.0"?>\n) .
qq(<feed\nxmlns="http://www.w3.org/2005/Atom">) .
qq(<title>$title</title>) .
my ($r) = @_;
my $env = $req->{env};
if (!defined $r) {
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
return [ 400, [ 'Content-Type', 'text/plain' ],
[ $git->err ] ];
}
sub call_git_atom {
my ($self, $req) = @_;
- my $repo_info = $req->{repo_info};
- my $max = $repo_info->{max_commit_count} || 10;
+ my $repo = $req->{-repo};
+ my $max = $repo->{max_commit_count} || 10;
$max = int($max);
$max = 50 if $max == 0;
- my $git = $repo_info->{git};
+ my $git = $repo->{git};
my $env = $req->{env};
my $tip = $req->{-tip};
my $read_log = sub {
sub call_git_blob {
my ($self, $req) = @_;
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
my $id = $req->{-tip} . ':' . $req->{expath};
my ($cat, $hex, $type, $size) = $git->cat_file_begin($id);
$to_read = $$left if $to_read > $$left;
my $r = read($cat, $$buf, $to_read);
if (!defined $r || $r <= 0) {
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
$git->cat_file_finish($$left);
return;
}
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_info}->{git};
+ my $git = $req->{-repo}->{git};
# extra show path information, if any
my $extra = $req->{extra};
my $path = '';
return $self->r(301, $req, "$relup#".to_attr($expath));
}
- my $git = $req->{repo_info}->{git};
+ 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, $tip, '--');
my ($self, $req) = @_;
my ($id, $id2) = split(/\.\./, $req->{h});
my $env = $req->{env};
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
my $cmd = $git->cmd(qw(diff-tree -z --numstat -p --encoding=UTF-8
--no-color -M -B -D -r), $id2, $id, '--');
my $expath = $req->{expath};
my ($self, undef, $req) = @_;
my $expath = $req->{expath};
return if index($expath, '..') >= 0; # prevent path traversal
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
PublicInbox::GitHTTPBackend::serve($req->{env}, $git, $expath);
}
my $m = '';
my $np = 0;
my $seen = $req->{seen};
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
my $lpfx = $req->{lpfx};
foreach my $p (@{$req->{parents}}) {
next if $seen->{$p};
sub call_git_log {
my ($self, $req) = @_;
- my $repo_info = $req->{repo_info};
- my $max = $repo_info->{max_commit_count} || 50;
+ my $repo = $req->{-repo};
+ my $max = $repo->{max_commit_count} || 50;
my $h = $req->{h};
$max = int($max);
$max = 50 if $max == 0;
my $env = $req->{env};
- my $git = $repo_info->{git};
+ my $git = $repo->{git};
my $cmd = $git->cmd(qw(log --no-notes --no-color --abbrev-commit),
$git->abbrev, $LOG_FMT, "-$max",
$req->{-tip}, '--');
my $rdr = { 2 => $git->err_begin };
- my $title = "log: $repo_info->{repo}";
+ my $title = "log: $repo->{repo}";
if (defined $h) {
$title .= ' ('. utf8_html($h). ')';
$req->{lpfx} = $req->{relcmd};
sub call_git_patch {
my ($self, $req) = @_;
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
my $env = $req->{env};
my $tip = $req->{-tip};
$tip =~ /\A[\w-]+([~\^][~\^\d])*\z/;
sub call_git_plain {
my ($self, $req) = @_;
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
my $id = $req->{-tip} . ':' . $req->{expath};
my ($cat, $hex, $type, $size) = $git->cat_file_begin($id);
return unless defined $cat;
return $self->r(404) unless ($ref =~ s/\.($SUFFIX)\z//o);
my $fmt = $1;
my $env = $req->{env};
- my $repo_info = $req->{repo_info};
+ my $repo = $req->{-repo};
# support disabling certain snapshots types entirely to twart
# URL guessing since it could burn server resources.
- return $self->r(404) if $repo_info->{snapshots_disabled}->{$fmt};
+ return $self->r(404) if $repo->{snapshots_disabled}->{$fmt};
# strip optional basename (may not exist)
- $ref =~ s/$repo_info->{snapshot_re}//;
+ $ref =~ s/$repo->{snapshot_re}//;
# don't allow option/command injection, git refs do not start with '-'
return $self->r(404) if $ref =~ /\A-/;
- my $git = $repo_info->{git};
+ my $git = $repo->{git};
my $tree = '';
my $last_cb = sub {
delete $env->{'repobrowse.tree_cb'};
delete $env->{'qspawn.quiet'};
- my $pfx = "$repo_info->{snapshot_pfx}-$ref/";
+ my $pfx = "$repo->{snapshot_pfx}-$ref/";
my $cmd = $git->cmd('archive',
"--prefix=$pfx", "--format=$fmt", $tree);
my $rdr = { 2 => $git->err_begin };
sub call_git_summary {
my ($self, $req) = @_;
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
my $env = $req->{env};
# n.b. we would use %(HEAD) in for-each-ref --format if we could
my ($self, $req, $res, $head_ref) = @_;
my $count = 10; # TODO: configurable
my $fh;
- my $repo_info = $req->{repo_info};
- my $git = $repo_info->{git};
+ my $repo = $req->{-repo};
+ my $git = $repo->{git};
my $refs = $git->popen(qw(for-each-ref --sort=-creatordate),
EACH_REF_FMT, "--count=$count",
qw(refs/heads/ refs/tags/));
$fh = $res->([200, ['Content-Type'=>'text/html; charset=UTF-8']]);
# ref names are unpredictable in length and requires tables :<
$fh->write($self->html_start($req,
- "$repo_info->{repo}: overview") .
+ "$repo->{repo}: overview") .
'</pre><table>');
my $rel = $req->{relcmd};
$fh->write('</table>');
# some people will use README.md or even README.sh here...
- my $readme = $repo_info->{readme};
+ my $readme = $repo->{readme};
defined $readme or $readme = [ 'README', 'README.md' ];
$readme = [ $readme ] if (ref($readme) ne 'ARRAY');
foreach my $r (@$readme) {
sub git_tag_show {
my ($self, $req, $h, $res) = @_;
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
my $fh;
my $hdr = ['Content-Type', 'text/html; charset=UTF-8'];
sub git_each_tag_sed ($$) {
my ($self, $req) = @_;
- my $repo_info = $req->{repo_info};
+ my $repo = $req->{-repo};
my $buf = '';
my $nr = 0;
- $req->{thtml} = $self->html_start($req, "$repo_info->{repo}: tag list") .
+ $req->{thtml} = $self->html_start($req, "$repo->{repo}: tag list") .
'</pre><table><tr>' .
join('', map { "<th><tt>$_</tt></th>" } qw(tag date subject)).
'</tr>';
sub git_tag_list {
my ($self, $req) = @_;
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
# TODO: use Xapian so we can more easily handle offsets/limits
# for pagination instead of limiting
sub unknown_tag_type {
my ($self, $fh, $req, $h, $type, $hex) = @_;
- my $repo_info = $req->{repo_info};
+ my $repo = $req->{-repo};
$h = $h->as_html;
my $rel = $req->{relcmd};
my $label = "$type $hex";
my $obj_link = qq(<a\nhref="$rel$cmd/$hex">$label</a>\n);
$fh->write($self->html_start($req,
- "$repo_info->{repo}: ref: $h") .
+ "$repo->{repo}: ref: $h") .
"\n\n <b>$h</b> (lightweight tag)\nobject $obj_link\n");
}
sub call_git_tree {
my ($self, $req) = @_;
my @extra = @{$req->{extra}};
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
my $obj = "$req->{-tip}:$req->{expath}";
my ($hex, $type, $size) = $git->check($obj);
sub git_tree_show {
my ($req, $hex) = @_;
- my $git = $req->{repo_info}->{git};
+ my $git = $req->{-repo}->{git};
my $cmd = $git->cmd(qw(ls-tree -l -z), $git->abbrev, $hex);
my $rdr = { 2 => $git->err_begin };
my $qsp = PublicInbox::Qspawn->new($cmd, undef, $rdr);
return $self->root_index($self) unless length($repo_path);
my $rconfig = $self->{rconfig}; # RepoConfig
- my $repo_info;
- until ($repo_info = $rconfig->lookup($repo_path)) {
+ my $repo;
+ until ($repo = $rconfig->lookup($repo_path)) {
my $p = shift @extra or last;
$repo_path .= "/$p";
}
- return r404() unless $repo_info;
+ return r404() unless $repo;
my $req = {
- repo_info => $repo_info,
+ -repo => $repo,
extra => \@extra, # path
rconfig => $rconfig,
env => $env,
};
my $tslash = 0;
my $cmd = shift @extra;
- my $vcs_lc = $repo_info->{vcs};
+ my $vcs_lc = $repo->{vcs};
my $vcs = $VCS{$vcs_lc} or return r404();
my $mod;
my $h;
$mod = load_once("PublicInbox::Repo$vcs$mod");
$vcs = load_once("PublicInbox::$vcs");
- # $repo_info->{git} ||= PublicInbox::Git->new(...)
- $repo_info->{$vcs_lc} ||= $vcs->new($repo_info->{path});
+ # $repo->{git} ||= PublicInbox::Git->new(...)
+ $repo->{$vcs_lc} ||= $vcs->new($repo->{path});
$req->{expath} = join('/', @extra);
my $rv = eval { $mod->new->call($cmd, $req) }; # RepoBase::call