]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
solver_git: workaround truncated `b' path in patch
authorEric Wong <e@80x24.org>
Tue, 11 Jun 2024 18:54:42 +0000 (18:54 +0000)
committerEric Wong <e@80x24.org>
Wed, 12 Jun 2024 11:19:23 +0000 (11:19 +0000)
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

index b5f6b96eb1d9e500609a3b5d682335eee04ed3d8..898ca72deb77fe0c10c6c5d63c190d4132cd198e 100644 (file)
@@ -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/'