]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SolverGit.pm
config: support "inboxdir" in addition to "mainrepo"
[public-inbox.git] / lib / PublicInbox / SolverGit.pm
index cd0f94a10c831b2caa8325f8b14bc1f05a2cc3a5..8878961e93506c0783fb7aad0fcf656f3850b664 100644 (file)
@@ -13,9 +13,9 @@ use warnings;
 use File::Temp qw();
 use Fcntl qw(SEEK_SET);
 use PublicInbox::Git qw(git_unquote git_quote);
-use PublicInbox::Spawn qw(spawn popen_rd);
 use PublicInbox::MsgIter qw(msg_iter msg_part_text);
 use PublicInbox::Qspawn;
+use PublicInbox::Tmpfile;
 use URI::Escape qw(uri_escape_utf8);
 
 # POSIX requires _POSIX_ARG_MAX >= 4096, and xargs is required to
@@ -85,7 +85,8 @@ sub solve_existing ($$) {
                # push @ambiguous, [ $git, @oids ];
 
                dbg($self, "`$oid_b' ambiguous in " .
-                               join("\n\t", $git->pub_urls) . "\n" .
+                               join("\n\t", $git->pub_urls($self->{psgi_env}))
+                                . "\n" .
                                join('', map { "$_ blob\n" } @oids));
        }
        scalar(@ambiguous) ? \@ambiguous : undef;
@@ -205,7 +206,7 @@ sub find_extract_diff ($$$) {
        }
 
        my $msgs = $srch->query($q, { relevance => 1 });
-       my $re = qr/\Aindex ($pre[a-f0-9]*)\.\.($post[a-f0-9]*)(?: (\d+))?/;
+       my $re = qr/\Aindex ($pre[a-f0-9]*)\.\.($post[a-f0-9]*)(?: ([0-9]+))?/;
 
        my $di;
        foreach my $smsg (@$msgs) {
@@ -235,13 +236,13 @@ sub prepare_index ($) {
        my $path_a = $di->{path_a} or die "BUG: path_a missing for $oid_full";
        my $mode_a = $di->{mode_a} || extract_old_mode($di);
 
-       open my $in, '+>', undef or die "open: $!";
+       my $in = tmpfile("update-index.$oid_full") or die "tmpfile: $!";
        print $in "$mode_a $oid_full\t$path_a\0" or die "print: $!";
        $in->flush or die "flush: $!";
        sysseek($in, 0, 0) or die "seek: $!";
 
        dbg($self, 'preparing index');
-       my $rdr = { 0 => fileno($in) };
+       my $rdr = { 0 => fileno($in), -hold => $in };
        my $cmd = [ qw(git update-index -z --index-info) ];
        my $qsp = PublicInbox::Qspawn->new($cmd, $self->{git_env}, $rdr);
        $qsp->psgi_qx($self->{psgi_env}, undef, sub {
@@ -483,7 +484,7 @@ sub resolve_patch ($$) {
        if (my $existing = solve_existing($self, $want)) {
                my ($found_git, undef, $type, undef) = @$existing;
                dbg($self, "found $cur_want in " .
-                       join("\n", $found_git->pub_urls));
+                       join("\n", $found_git->pub_urls($self->{psgi_env})));
 
                if ($cur_want eq $self->{oid_want} || $type ne 'blob') {
                        eval { delete($self->{user_cb})->($existing) };