]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: index_diff: allow /^$/ line as diff context
authorEric Wong <e@80x24.org>
Fri, 3 Jan 2020 08:45:58 +0000 (08:45 +0000)
committerEric Wong <e@80x24.org>
Sat, 4 Jan 2020 09:34:47 +0000 (09:34 +0000)
As discovered by solver bug hunting, "git apply" also handles
the case where blank lines w/o leading space are treated as diff
context, apparently because GNU diff once did it:

https://public-inbox.org/git/b507b465f7831612b9d9fc643e3e5218b64e5bfa/s/

lib/PublicInbox/SearchIdx.pm

index 21ab8119e70fe559fbe5435fea50a443b0b1459a..4cfbc4aae36577f87ec11191ff2f9e4dfd7d2f5d 100644 (file)
@@ -255,7 +255,9 @@ sub index_diff ($$$) {
                                /^Binary files .* differ/) {
                        push @xnq, $_;
                } elsif ($_ eq '') {
-                       $in_diff = undef;
+                       # possible to be in diff context, some mail may be
+                       # stripped by MUA or even GNU diff(1).  "git apply"
+                       # treats a bare "\n" as diff context, too
                } else {
                        push @xnq, $_;
                        warn "non-diff line: $_\n" if DEBUG && $_ ne '';