-sub cgit_repo_merge ($$) {
- my ($self, $repo) = @_;
- # $repo = { url => 'foo.git', path => '/path/to/foo.git' }
- my $nick = $repo->{url};
- $self->{"coderepo.$nick.dir"} ||= $repo->{path};
- $self->{"coderepo.$nick.cgiturl"} ||= $nick;
+# XXX needs testing for cgit compatibility
+# cf. cgit/scan-tree.c::add_repo
+sub cgit_repo_merge ($$$) {
+ my ($self, $base, $repo) = @_;
+ my $path = $repo->{dir};
+ if (defined(my $se = $self->{-cgit_strict_export})) {
+ return unless -e "$path/$se";
+ }
+ return if -e "$path/noweb";
+ # $repo = { url => 'foo.git', dir => '/path/to/foo.git' }
+ my $rel = $repo->{url};
+ unless (defined $rel) {
+ my $off = index($path, $base, 0);
+ if ($off != 0) {
+ $rel = $path;
+ } else {
+ $rel = substr($path, length($base) + 1);
+ }
+
+ $rel =~ s!/\.git\z!! or
+ $rel =~ s!/+\z!!;
+
+ $self->{-cgit_remove_suffix} and
+ $rel =~ s!/?\.git\z!!;
+ }
+ $self->{"coderepo.$rel.dir"} //= $path;
+ $self->{"coderepo.$rel.cgiturl"} //= $rel;