die $err;
}
-# look for existing blobs already in git repos
+# look for existing objects already in git repos
sub solve_existing ($$) {
my ($self, $want) = @_;
my $oid_b = $want->{oid_b};
+ my $have_hints = scalar keys %$want > 1;
my @ambiguous; # Array of [ git, $oids]
foreach my $git (@{$self->{gits}}) {
my ($oid_full, $type, $size) = $git->check($oid_b);
- if (defined($type) && $type eq 'blob') {
+ if (defined($type) && (!$have_hints || $type eq 'blob')) {
return [ $git, $oid_full, $type, int($size) ];
}
# 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;
die "Loop detected solving $cur_want\n";
}
if (my $existing = solve_existing($self, $want)) {
+ my ($found_git, undef, $type, undef) = @$existing;
dbg($self, "found $cur_want in " .
- join("\n", $existing->[0]->pub_urls));
+ join("\n", $found_git->pub_urls($self->{psgi_env})));
- if ($cur_want eq $self->{oid_want}) { # all done!
+ if ($cur_want eq $self->{oid_want} || $type ne 'blob') {
eval { delete($self->{user_cb})->($existing) };
die "E: $@" if $@;
return;
}
# recreate $oid_want using $hints
+# hints keys: path_a, path_b, oid_a
# Calls {user_cb} with: [ ::Git object, oid_full, type, size, di (diff_info) ]
# with found object, or undef if nothing was found
# Calls {user_cb} with a string error on fatal errors
$self->{todo} = [ { %$hints, oid_b => $oid_want } ];
$self->{patches} = []; # [ $di, $di, ... ]
$self->{found} = {}; # { abbr => [ ::Git, oid, type, size, $di ] }
- $self->{tmp} = File::Temp->newdir('solver.tmp-XXXXXXXX', TMPDIR => 1);
+ $self->{tmp} = File::Temp->newdir("solver.$oid_want-XXXXXXXX", TMPDIR => 1);
dbg($self, "solving $oid_want ...");
my $step_cb = step_cb($self);