From: Eric Wong Date: Tue, 11 Jun 2024 18:54:42 +0000 (+0000) Subject: solver_git: workaround truncated `b' path in patch X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c765b05f90f4ce55b2411a1facd7156c8fcc7f9b;p=thirdparty%2Fpublic-inbox.git solver_git: workaround truncated `b' path in patch For messages like <780a3faf-9e44-64f4-a354-bdee39af3af5@redhat.com> where the "diff --git" line is truncated, favor the filename from the "+++ b/" line. --- diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index b5f6b96eb..898ca72de 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/'