From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] solver: fix and improve ambiguous OID debug messages
Date: Mon, 9 Dec 2024 20:01:28 +0000 [thread overview]
Message-ID: <20241209200128.871547-1-e@80x24.org> (raw)
Ambiguous messages from git start with "hint:" (at least
nowadays) so we need to account for that in the regexp.
Furthermore, do not limit objects to just blobs since our
ViewVCS package is capable of displaying tags, trees, and
commits in addition to blobs.
Finally, we can generate full URLs so linkification can pick
them up and generate <a> tags.
---
lib/PublicInbox/SolverGit.pm | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm
index d50a2fd1..d9465771 100644
--- a/lib/PublicInbox/SolverGit.pm
+++ b/lib/PublicInbox/SolverGit.pm
@@ -107,18 +107,21 @@ sub ck_existing_cb { # async_check cb
# parse stderr of "git cat-file --batch-check", async means
# we may end up slurping output from other requests:
- my $err = $git->last_check_err;
- my $prev_oids = $git->{-prev_oids} //= [];
- my @any_oids = ($err =~ /\b([a-f0-9]{40,})\s+blob\b/g);
- push @$prev_oids, @any_oids;
- my $oid_b_re = qr/\A$want->{oid_b}/;
- my @ambig_oids = grep /$oid_b_re/, @$prev_oids;
- @$prev_oids = grep !/$oid_b_re/, @$prev_oids;
- delete $git->{-prev_oids} unless @$prev_oids;
- @ambig_oids and dbg($self, "`$want->{oid_b}' ambiguous in " .
- join("\n\t", $git->pub_urls($self->{psgi_env}))
- . "\n" .
- join('', map { "$_ blob\n" } @ambig_oids));
+ my @err = grep /\s+(?:[a-f0-9]{7,})\s+(?:blob|commit|tree|tag)\b/g,
+ split /^/ms, $git->last_check_err;
+ my $prev = $git->{-prev} //= [];
+ push @$prev, @err;
+ my $oid_b_re = qr/\s+\Q$want->{oid_b}\E[a-f0-9]*\s+/;
+ my $ambig = join '', grep /$oid_b_re/, @$prev;
+ @$prev = grep !/$oid_b_re/, @$prev;
+ delete $git->{-prev} unless @$prev;
+ if ($ambig ne '') {
+ my @urls = $git->pub_urls($self->{psgi_env});
+ rindex($urls[0], '/') >= 0 and
+ $ambig =~ s!\b([a-f0-9]{7,})\b!$urls[0]$1/s/!g;
+ dbg($self, "`$want->{oid_b}' ambiguous in " .
+ join("\n\t", @urls) . "\n" . $ambig);
+ }
return retry_current($self, $want) if @$try;
reply other threads:[~2024-12-09 20:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20241209200128.871547-1-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.
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).