From: Jay Soffian <jaysoffian@gmail.com>
To: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Cc: Jay Soffian <jaysoffian@gmail.com>
Subject: [PATCH] Fix line numbers emitted by "git diff --check"
Date: Fri, 15 Feb 2008 18:33:43 -0500 [thread overview]
Message-ID: <1203118423-32642-1-git-send-email-jaysoffian@gmail.com> (raw)
In-Reply-To: 76718490802151218s62c4f884u39353b66540b347a@mail.gmail.com
Fixes a problem where git diff --check was emitting incorrect lines
numbers. Adds a test to verify the fix.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
diff.c | 4 +++-
t/t4015-diff-whitespace.sh | 9 +++++++++
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/diff.c b/diff.c
index cd8bc4d..a002573 100644
--- a/diff.c
+++ b/diff.c
@@ -1023,8 +1023,10 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
if (line[0] == '+') {
data->status = check_and_emit_line(line + 1, len - 1,
data->ws_rule, NULL, NULL, NULL, NULL);
- if (!data->status)
+ if (!data->status) {
+ data->lineno++;
return;
+ }
err = whitespace_error_string(data->status);
printf("%s:%d: %s.\n", data->filename, data->lineno, err);
free(err);
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index d30169f..83c54b7 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -326,4 +326,13 @@ test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab:
! git diff --check
'
+
+test_expect_success 'line numbers in --check output are correct' '
+
+ echo "" > x &&
+ echo "foo(); " >> x &&
+ git diff --check | grep "x:2:"
+
+'
+
test_done
--
1.5.4.1.1281.g75df
next reply other threads:[~2008-02-15 23:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-15 23:33 Jay Soffian [this message]
2008-02-16 7:04 ` [PATCH] Fix line numbers emitted by "git diff --check" 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=1203118423-32642-1-git-send-email-jaysoffian@gmail.com \
--to=jaysoffian@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).