From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5FA0A1F4CC for ; Mon, 9 Dec 2024 20:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1733774488; bh=sm8jUurSOGuXQncbk8swLXMv6IMZEUarKlhZmSfnH2g=; h=From:To:Subject:Date:From; b=V434tMk3nmoI8pQxgCo+bJuokn8JDk7+qOwN7Cxgv4jacEK5YPKGx+3CqOsiRQSxu vL+TW46LZq67TyvU9XD9gREmZUnqDEhyun7iM8itjkBn3qqWJEwBcWhqr3l3/WNAb3 pw/AMLIIFgJtb1y99KtgQormTLVPmXLLhENbhovo= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] solver: fix and improve ambiguous OID debug messages Date: Mon, 9 Dec 2024 20:01:28 +0000 Message-ID: <20241209200128.871547-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 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;