From 6f5b238bae5c88b2b9b2fdf7834e17e78a33abd2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 29 Aug 2022 09:26:43 +0000 Subject: solver: early make hints detection more robust 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/SolverGit.pm') diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index 52dfaf3d..1e96d042 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -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 ] } -- cgit v1.2.3-24-ge0c7