]> Sergey Matveev's repositories - public-inbox.git/commitdiff
viewdiff: do not break out of DSTATE_CTX on /^$/
authorEric Wong <e@80x24.org>
Fri, 26 Apr 2019 07:42:24 +0000 (07:42 +0000)
committerEric Wong <e@80x24.org>
Fri, 26 Apr 2019 07:42:24 +0000 (07:42 +0000)
It seems a common case for mangled patches is editors or MUAs
dropping trailing whitespace, and lines matching /^ $/ gets
the space dropped to only match /^$/.

lib/PublicInbox/ViewDiff.pm

index 0cce952d99011800e94904c80728f8911bc1278c..6b8d94372405486ca2223e0fc057e79cb24691ac 100644 (file)
@@ -146,7 +146,7 @@ sub flush_diff ($$$) {
                if ($s =~ /^---$/) {
                        to_state($dst, $state, DSTATE_STAT);
                        $$dst .= $s;
-               } elsif ($s =~ /^ /) {
+               } elsif ($s =~ /^ / || ($s =~ /^$/ && $state >= DSTATE_CTX)) {
                        # works for common cases, but not weird/long filenames
                        if ($state == DSTATE_STAT &&
                                        $s =~ /^ (.+)( +\| .*\z)/s) {