unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] solver: fix and improve ambiguous OID debug messages
@ 2024-12-09 20:01 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2024-12-09 20:01 UTC (permalink / raw)
  To: meta

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;
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-09 20:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-09 20:01 [PATCH] solver: fix and improve ambiguous OID debug messages Eric Wong

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).