X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FSolverGit.pm;h=8878961e93506c0783fb7aad0fcf656f3850b664;hb=3c39f9c942a6975245fda878e9b957d8d3367662;hp=cd0f94a10c831b2caa8325f8b14bc1f05a2cc3a5;hpb=4123a89e08e145405fa781be7f4590c4d13f4138;p=public-inbox.git diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index cd0f94a1..8878961e 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -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) };