about summary refs log tree commit homepage
path: root/lib/PublicInbox/SolverGit.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-01-31 01:41:15 +0000
committerEric Wong <e@80x24.org>2019-01-31 01:41:15 +0000
commitcdbcf648ed1c28cc5774416f7868d78b4e0e2dba (patch)
treecf7a2811c7f8a8bc7ccb13b5f0a3ac3aaeb9a4d4 /lib/PublicInbox/SolverGit.pm
parent2d4403cf9972f8ae78aa52fe6ce7a01d9b6757c1 (diff)
downloadpublic-inbox-cdbcf648ed1c28cc5774416f7868d78b4e0e2dba.tar.gz
public-inbox can only index the abbreviated object_ids in
emails, not the full or even longer-than-necessary object_ids.
So retry failed object_ids if they're longer than 7 hex
characters.
Diffstat (limited to 'lib/PublicInbox/SolverGit.pm')
-rw-r--r--lib/PublicInbox/SolverGit.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm
index c5025269..97da7956 100644
--- a/lib/PublicInbox/SolverGit.pm
+++ b/lib/PublicInbox/SolverGit.pm
@@ -23,6 +23,7 @@ use URI::Escape qw(uri_escape_utf8);
 # headroom into this.
 use POSIX qw(sysconf _SC_ARG_MAX);
 my $ARG_SIZE_MAX = (sysconf(_SC_ARG_MAX) || 4096) - 2048;
+my $OID_MIN = 7;
 
 # By default, "git format-patch" generates filenames with a four-digit
 # prefix, so that means 9999 patch series are OK, right? :>
@@ -353,7 +354,13 @@ sub next_step ($) {
 
 sub mark_found ($$$) {
         my ($self, $oid, $found_info) = @_;
-        $self->{found}->{$oid} = $found_info;
+        my $found = $self->{found};
+        $found->{$oid} = $found_info;
+        my $oid_cur = $found_info->[1];
+        while ($oid_cur ne $oid && length($oid_cur) > $OID_MIN) {
+                $found->{$oid_cur} = $found_info;
+                chop($oid_cur);
+        }
 }
 
 sub parse_ls_files ($$$$) {
@@ -485,6 +492,14 @@ sub resolve_patch ($$) {
                 }
                 return next_step($self); # onto the next todo item
         }
+        if (length($cur_want) > $OID_MIN) {
+                chop($cur_want);
+                dbg($self, "retrying $want->{oid_b} as $cur_want");
+                $want->{oid_b} = $cur_want;
+                push @{$self->{todo}}, $want;
+                return next_step($self); # retry with shorter abbrev
+        }
+
         dbg($self, "could not find $cur_want");
         eval { delete($self->{user_cb})->(undef) }; # not found! :<
         die "E: $@" if $@;