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, T_SCC_BODY_TEXT_LINE 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 6049C1F7BE for ; Tue, 11 Jun 2024 18:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1718132082; bh=+V8sCIJDAv/Y6Rzgx17bs59Hylj0nD6IVSHo0H15XMc=; h=From:To:Subject:Date:From; b=gZ5wPOGNjweogYpRDwsssgq+R0C+AYi/Oy+OPqy0qAQs8BleUs/LaKQopUkNnCa5t X6iY8CyP8LSl8i/YXre25xWMTAwm5sY91KvEhSSdIBGZTsfbVeWy4EUeNF4Z68dH+5 HxGpW8rjjtkVu4cVpe7+qSyuKZ4+LJ3VJ7TtRPQo= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] solver_git: workaround truncated `b' path in patch Date: Tue, 11 Jun 2024 18:54:42 +0000 Message-ID: <20240611185442.2654967-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: For messages like <780a3faf-9e44-64f4-a354-bdee39af3af5@redhat.com> where the "diff --git" line is truncated, favor the filename from the "+++ b/" line. --- lib/PublicInbox/SolverGit.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index b5f6b96e..898ca72d 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -176,7 +176,7 @@ sub extract_diff ($$) { (?:^---\x20$FN$LF) # "+++ b/foo.c" sets post-filename ($11) in case - # $3 is missing + # $3 is missing or truncated (?:^\+{3}\x20$FN$LF) # the meat of the diff, including "^\\No newline ..." @@ -193,7 +193,8 @@ sub extract_diff ($$) { mode_a => $5 // $8 // $4, # new (file) // unchanged // old }; my $path_a = $2 // $10; - my $path_b = $3 // $11; + my $path_b = defined $11 && defined $3 && length $11 > length $3 ? + $11 // $3 : $3 // $11; my $patch = $9; # don't care for leading 'a/' and 'b/'