+ my $psgi = "$tmpdir/pfx.psgi";
+ {
+ open my $psgi_fh, '>', $psgi or xbail "open: $!";
+ print $psgi_fh <<'EOM' or xbail "print $!";
+use PublicInbox::WWW;
+use Plack::Builder;
+my $www = PublicInbox::WWW->new;
+builder {
+ enable 'Head';
+ mount '/pfx/' => sub { $www->call(@_) }
+}
+EOM
+ close $psgi_fh or xbail "close: $!";
+ }
+
+ # ensure prefixed mount full clones work:
+ $td = start_script([@$cmd, $psgi], $env, { 3 => $sock });
+ my $opt = { 2 => \(my $clone_err = '') };
+ ok(run_script(['-clone', "http://$host:$port/pfx", "$tmpdir/pfx" ],
+ undef, $opt), 'pfx clone w/pfx') or diag "clone_err=$clone_err";
+
+ open my $mh, '<', "$tmpdir/pfx/manifest.js.gz" or xbail "open: $!";
+ gunzip(\(do { local $/; <$mh> }) => \(my $mjs = ''));
+ my $mf = $json->decode($mjs);
+ is_deeply([sort keys %$mf], [ qw(/alt /bare /v2/git/0.git
+ /v2/git/1.git /v2/git/2.git) ],
+ 'manifest saved');
+ for (keys %$mf) { ok(-d "$tmpdir/pfx$_", "pfx/$_ cloned") }
+ open my $desc, '<', "$tmpdir/pfx/v2/description" or xbail "open: $!";
+ $desc = <$desc>;
+ is($desc, "a v2 inbox\n", 'v2 description retrieved');
+
+ $clone_err = '';
+ ok(run_script(['-clone', '--include=*/alt',
+ "http://$host:$port/pfx", "$tmpdir/incl" ],
+ undef, $opt), 'clone w/include') or diag "clone_err=$clone_err";
+ ok(-d "$tmpdir/incl/alt", 'alt cloned');
+ ok(!-d "$tmpdir/incl/v2" && !-d "$tmpdir/incl/bare", 'only alt cloned');
+ is(xqx([qw(git config -f), "$tmpdir/incl/alt/config", 'gitweb.owner']),
+ "lorelei \xc4\x80\n", 'gitweb.owner set by -clone');
+
+ $clone_err = '';
+ ok(run_script(['-clone', '--dry-run',
+ "http://$host:$port/pfx", "$tmpdir/dry-run" ],
+ undef, $opt), 'clone --dry-run') or diag "clone_err=$clone_err";
+ ok(!-d "$tmpdir/dry-run", 'nothing cloned with --dry-run');
+
+ undef $td;
+
+ open $mh, '<', "$tmpdir/incl/manifest.js.gz" or xbail "open: $!";
+ gunzip(\(do { local $/; <$mh> }) => \($mjs = ''));
+ $mf = $json->decode($mjs);
+ is_deeply([keys %$mf], [ '/alt' ], 'excluded keys skipped in manifest');
+