From f7f6e090b0f8bb177d171f34f6a5a629a280e4ff Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 3 Aug 2019 12:11:56 +1000 Subject: [PATCH] extract: allow blank lines in unified diffs. When a unified diff report that both files have a blank line, it shows this as a line containing just a space. Sometimes that space can go missing (spaces at the end of a line are like that). So if we find a completely empty line, treat it like a line containing just a space. Resolves-github-issue: #12 Reported-by: luckydonald @ github.com Signed-off-by: NeilBrown --- extract.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extract.c b/extract.c index c3c47e6..ac61421 100644 --- a/extract.c +++ b/extract.c @@ -199,6 +199,12 @@ int split_patch(struct stream f, struct stream *f1, struct stream *f2) cp++; copyline(&r2, &cp, end); bcnt--; + } else if (*cp == '\n') { + /* Empty line - treat like " \n" - a blank line in both */ + char *cp2 = cp; + copyline(&r1, &cp, end); + copyline(&r2, &cp2, end); + acnt --; bcnt--; } else { fprintf(stderr, "%s: bad unified patch at line %d\n", Cmd, lineno); -- 2.39.5