* [PATCH] Fix line numbers emitted by "git diff --check"
@ 2008-02-15 23:33 Jay Soffian
2008-02-16 7:04 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Jay Soffian @ 2008-02-15 23:33 UTC (permalink / raw)
To: git, Junio C Hamano; +Cc: Jay Soffian
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix line numbers emitted by "git diff --check"
2008-02-15 23:33 [PATCH] Fix line numbers emitted by "git diff --check" Jay Soffian
@ 2008-02-16 7:04 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2008-02-16 7:04 UTC (permalink / raw)
To: Jay Soffian; +Cc: git
Jay Soffian <jaysoffian@gmail.com> writes:
> 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>
Ahh, our mails crossed, and our fixes are equivalent, but yours
has an additional test, which is always good.
Will steal the test part and squash it in (I've already patched
'maint' with the one I sent out), if you do not mind.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-16 7:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-15 23:33 [PATCH] Fix line numbers emitted by "git diff --check" Jay Soffian
2008-02-16 7:04 ` Junio C Hamano
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).