From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/5] solvergit: allow searching on longer-than-needed OIDs
Date: Thu, 31 Jan 2019 04:27:22 +0000 [thread overview]
Message-ID: <20190131042724.2675-4-e@80x24.org> (raw)
In-Reply-To: <20190131042724.2675-1-e@80x24.org>
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.
---
lib/PublicInbox/SolverGit.pm | 17 ++++++++++++++++-
t/solver_git.t | 9 +++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm
index c502526..97da795 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 $@;
diff --git a/t/solver_git.t b/t/solver_git.t
index 197a003..66e6317 100644
--- a/t/solver_git.t
+++ b/t/solver_git.t
@@ -64,6 +64,15 @@ if (0) { # TODO: check this?
diag $z;
}
+my $oid = $expect;
+for my $i (1..2) {
+ my $more;
+ my $s = PublicInbox::SolverGit->new($ibx, sub { $more = $_[0] });
+ $s->solve($psgi_env, $log, $oid, {});
+ is($more->[1], $expect, 'resolved blob to long OID '.$i);
+ chop($oid);
+}
+
$solver = undef;
$res = undef;
my $wt_git_dir = $wt_git->{git_dir};
--
EW
next prev parent reply other threads:[~2019-01-31 4:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-31 4:27 [PATCH 0/5] a few more solver fixups and improvements Eric Wong
2019-01-31 4:27 ` [PATCH 1/5] t/config.t: test PublicInbox::Git sharing between inboxes Eric Wong
2019-01-31 4:27 ` [PATCH 2/5] inbox: perform cleanup of Git objects for coderepos Eric Wong
2019-01-31 4:27 ` Eric Wong [this message]
2019-01-31 4:27 ` [PATCH 4/5] solvergit: allow shorter-than-necessary OIDs from user Eric Wong
2019-01-31 4:27 ` [PATCH 5/5] viewvcs: support streaming large blobs Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190131042724.2675-4-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).