]> Sergey Matveev's repositories - public-inbox.git/commitdiff
solver: early make hints detection more robust
authorEric Wong <e@80x24.org>
Mon, 29 Aug 2022 09:26:43 +0000 (09:26 +0000)
committerEric Wong <e@80x24.org>
Mon, 29 Aug 2022 19:05:53 +0000 (19:05 +0000)
Hints fields can change, so we'll use a simple boolean rather
than checking a static count.  We'll also short-circuit out
reliably regardless of hints when a full OID is given.

lib/PublicInbox/SolverGit.pm

index 52dfaf3df942676a5cbdb432160a8e9068f69502..1e96d042e9d7ccd788354fc86fca034cb5e24195 100644 (file)
@@ -81,9 +81,8 @@ sub solve_existing ($$) {
        my $oid_b = $want->{oid_b};
        my ($oid_full, $type, $size) = $git->check($oid_b);
 
-       # other than {oid_b, try_gits, try_ibxs}
-       my $have_hints = scalar keys %$want > 3;
-       if (defined($type) && (!$have_hints || $type eq 'blob')) {
+       if ($oid_b eq ($oid_full // '') || (defined($type) &&
+-                              (!$self->{have_hints} || $type eq 'blob'))) {
                delete $want->{try_gits};
                return [ $git, $oid_full, $type, int($size) ]; # done, success
        }
@@ -683,6 +682,7 @@ sub solve ($$$$$) {
        $self->{seen_oid} = {};
        $self->{tot} = 0;
        $self->{psgi_env} = $env;
+       $self->{have_hints} = 1 if scalar keys %$hints;
        $self->{todo} = [ { %$hints, oid_b => $oid_want } ];
        $self->{patches} = []; # [ $di, $di, ... ]
        $self->{found} = {}; # { abbr => [ ::Git, oid, type, size, $di ] }