git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Björn Steinbrink" <B.Steinbrink@gmx.de>, git@vger.kernel.org
Subject: Re: diff --check is stupid about blank lines
Date: Wed, 20 Aug 2008 11:42:34 -0700	[thread overview]
Message-ID: <7vskszr0it.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7v7iabsgfk.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Wed, 20 Aug 2008 11:13:35 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> Jeff King <peff@peff.net> writes:
>
>> ... 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...".
>
> Instead, data.trailing_blanks_start is supposed to be reset to 0 every
> time we see non-blank newline, a copied context line, or new hunk.
>
> So if this triggers with -U0 I'd understand, but otherwise I do not see
> how.

Ahhh, what idiot wrote the logic for checking trailing blank lines in
checkdiff_consume().

It does not ask for any context lines.  Sheesh.

This should fix it.


diff --git i/diff.c w/diff.c
index 10d5440..5923fe2 100644
--- i/diff.c
+++ w/diff.c
@@ -1628,6 +1628,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
 		xdemitcb_t ecb;
 
 		memset(&xecfg, 0, sizeof(xecfg));
+		xecfg.ctxlen = 1; /* at least one context line */
 		xpp.flags = XDF_NEED_MINIMAL;
 		xdi_diff_outf(&mf1, &mf2, checkdiff_consume, &data,
 			      &xpp, &xecfg, &ecb);

  reply	other threads:[~2008-08-20 18:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-20 14:05 diff --check is stupid about blank lines Björn Steinbrink
2008-08-20 17:28 ` Jeff King
2008-08-20 18:13   ` Junio C Hamano
2008-08-20 18:42     ` Junio C Hamano [this message]
2008-08-20 20:02       ` Björn Steinbrink
2008-08-20 22:20       ` Jeff King
2008-08-20 22:39         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vskszr0it.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=B.Steinbrink@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).