Re: diff --check is stupid about blank lines
From: Jeff King <hidden>
Date: 2016-06-15 22:45:11
On Wed, Aug 20, 2008 at 04:05:17PM +0200, Björn Steinbrink wrote:
diff --check triggers not only for blank lines at the end of the file, but also at the end of the changes. That seems broken to me, unless you really dislike empty lines.
Hmm, yes, that seems wrong. The problem seems to be the conditional at
diff.c:1622:
if ((data.ws_rule & WS_TRAILING_SPACE) &&
data.trailing_blanks_start) {
fprintf(o->file, "%s:%d: ends with blank lines.\n",
data.filename, data.trailing_blanks_start);
data.status = 1; /* report errors */
}
that should probably be "if we care about trailing space, and the last
thing we saw was a trailing blank, _and_ the last hunk adds to
end-of-file, then...". However, I'm not sure what is the best way to get
that information out of xdiff. Is there a "this hunk hits eof" signal
anywhere? Is there a definitive line count we could use to calculate
that it is in the chunk of final lines in the file?
-Peff