From: Junio C Hamano <gitster@pobox.com>
To: "Jay Soffian" <jaysoffian@gmail.com>
Cc: "Git Mailing List" <git@vger.kernel.org>
Subject: [PATCH/maint] diff: Fix miscounting of --check output
Date: Fri, 15 Feb 2008 20:30:05 -0800 [thread overview]
Message-ID: <7vk5l5frqq.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <76718490802151218s62c4f884u39353b66540b347a@mail.gmail.com> (Jay Soffian's message of "Fri, 15 Feb 2008 15:18:45 -0500")
"Jay Soffian" <jaysoffian@gmail.com> writes:
> Apparently somewhere in the bowels of the "Crazy xdl interfaces", empty
> lines are skipped over, thus the line number counting in
> checkdiff_consume() is off? I dunno, I briefly looked into fixing it but
> it didn't seem like a quick fix.
Good catch, thanks.
This is not xdl interface, but simply a miscounting by the user
of xdl interface. Here is a fix.
-- >8 --
diff: Fix miscounting of --check output
c1795bb (Unify whitespace checking) incorrectly made the
checking function return without incrementing the line numbers
when there is no whitespace problem is found on a '+' line.
This resurrects the earlier behaviour.
Noticed and reported by Jay Soffian.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/diff.c b/diff.c
index 047310f..90af600 100644
--- a/diff.c
+++ b/diff.c
@@ -1021,6 +1021,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
char *err;
if (line[0] == '+') {
+ data->lineno++;
data->status = check_and_emit_line(line + 1, len - 1,
data->ws_rule, NULL, NULL, NULL, NULL);
if (!data->status)
@@ -1031,13 +1032,12 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
emit_line(set, reset, line, 1);
(void)check_and_emit_line(line + 1, len - 1, data->ws_rule,
stdout, set, reset, ws);
- data->lineno++;
} else if (line[0] == ' ')
data->lineno++;
else if (line[0] == '@') {
char *plus = strchr(line, '+');
if (plus)
- data->lineno = strtol(plus, NULL, 10);
+ data->lineno = strtol(plus, NULL, 10) - 1;
else
die("invalid diff");
}
prev parent reply other threads:[~2008-02-16 4:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-15 20:18 diff --check line number bug Jay Soffian
2008-02-16 4:30 ` Junio C Hamano [this message]
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=7vk5l5frqq.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jaysoffian@gmail.com \
/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).