From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: Wincent Colaiuta <win@wincent.com>
Subject: [PATCH] diff --check: do not discard error status upon seeing a good line
Date: Thu, 26 Jun 2008 13:22:24 -0700 [thread overview]
Message-ID: <7vwskcosjj.fsf@gitster.siamese.dyndns.org> (raw)
"git diff --check" should return non-zero when there was any whitespace
errors but the code only paid attention to the error status of the last
new line in the patch.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* c1795bb (Unify whitespace checking, 2007-12-13) broke this part of the
code.
diff.c | 8 +++++---
t/t4017-diff-retval.sh | 8 ++++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 5262490..f281c5b 100644
--- a/diff.c
+++ b/diff.c
@@ -1150,12 +1150,14 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
char *err;
if (line[0] == '+') {
+ unsigned bad;
data->lineno++;
- data->status = check_and_emit_line(line + 1, len - 1,
+ bad = check_and_emit_line(line + 1, len - 1,
data->ws_rule, NULL, NULL, NULL, NULL);
- if (!data->status)
+ if (!bad)
return;
- err = whitespace_error_string(data->status);
+ data->status |= bad;
+ err = whitespace_error_string(bad);
fprintf(data->file, "%s:%d: %s.\n", data->filename, data->lineno, err);
free(err);
emit_line(data->file, set, reset, line, 1);
diff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh
index dc0b712..0d0fb87 100755
--- a/t/t4017-diff-retval.sh
+++ b/t/t4017-diff-retval.sh
@@ -105,4 +105,12 @@ test_expect_success '--check with --no-pager returns 2 for dirty difference' '
'
+
+test_expect_success 'check should test not just the last line' '
+ echo "" >>a &&
+ git --no-pager diff --check
+ test $? = 2
+
+'
+
test_done
--
1.5.6.1.78.gde8d9
reply other threads:[~2008-06-26 20:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=7vwskcosjj.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=win@wincent.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