git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: diff --check is stupid about blank lines

From
Jeff King <peff@peff.net>
Date
Aug 20, 2008, 17:28 UTC
Message-ID
<20080820172825.GC27773@sigill.intra.peff.net>
In-Reply-To
<20080820140517.GA1304@atjola.homenet>
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
Previous: Björn SteinbrinkNext: Junio C Hamano
Message 2 of 7 in “diff --check is stupid about blank lines”
  1. Björn SteinbrinkAug 20, 2008
  2. Jeff KingAug 20, 2008
  3. Junio C HamanoAug 20, 2008
  4. Junio C HamanoAug 20, 2008
  5. Björn SteinbrinkAug 20, 2008
  6. Jeff KingAug 20, 2008
  7. Junio C HamanoAug 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.