From: Junio C Hamano <gitster@pobox.com>
To: Wincent Colaiuta <win@wincent.com>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH 3/5] Unify whitespace checking
Date: Thu, 13 Dec 2007 16:03:15 -0800 [thread overview]
Message-ID: <7vd4taywfw.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1197552751-53480-4-git-send-email-win@wincent.com> (Wincent Colaiuta's message of "Thu, 13 Dec 2007 14:32:29 +0100")
Wincent Colaiuta <win@wincent.com> writes:
> The new function is called check_and_emit_line() and it does two things:
> checks a line for whitespace errors and optionally emits it. The checking
> is based on lines of content rather than patch lines (in other words, the
> caller must strip the leading "+" or "-"); this was suggested by Junio on
> the mailing list to allow for a future extension to "git show" to display
> whitespace errors in blobs.
I do not think "git show" is a realistic "future extension", by the
way. But at least from the interface-cleanliness point of view, I think
not passing the leading "+" to the function is a right thing to do.
> diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
> index dc538b3..a0a47dd 100755
> --- a/t/t4015-diff-whitespace.sh
> +++ b/t/t4015-diff-whitespace.sh
> @@ -121,7 +121,7 @@ test_expect_success 'check mixed spaces and tabs in indent' '
>
> # This is indented with SP HT SP.
> echo " foo();" > x &&
> - git diff --check | grep "space before tab"
> + git diff --check | grep "Space in indent is followed by a tab"
>
> '
Hmph. I think with the multiple detection this rewording would make the
error message very long to read. Was the rewording really necessary?
> +/* If stream is non-NULL, emits the line after checking. */
> +unsigned check_and_emit_line(const char *line, int len, unsigned ws_rule,
> + FILE *stream, const char *set,
> + const char *reset, const char *ws)
> +{
Honestly, I regretted suggesting this, fearing that it might make the
checking too costly, but the code is clean, readable, and does not look
costly at all. Nice job.
next prev parent reply other threads:[~2007-12-14 0:04 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-13 13:32 [PATCH 0/5] "diff --check" and whitespace enhancements Wincent Colaiuta
2007-12-13 13:32 ` [PATCH 1/5] "diff --check" should affect exit status Wincent Colaiuta
2007-12-13 13:32 ` [PATCH 2/5] New version of pre-commit hook Wincent Colaiuta
2007-12-13 13:32 ` [PATCH 3/5] Unify whitespace checking Wincent Colaiuta
2007-12-13 13:32 ` [PATCH 4/5] Make "diff --check" output match "git apply" Wincent Colaiuta
2007-12-13 13:32 ` [PATCH 5/5] Add tests for "git diff --check" with core.whitespace options Wincent Colaiuta
2007-12-14 0:55 ` Junio C Hamano
2007-12-14 0:12 ` [PATCH 4/5] Make "diff --check" output match "git apply" Junio C Hamano
2007-12-13 13:40 ` [PATCH 3/5] Unify whitespace checking Andreas Ericsson
2007-12-14 0:03 ` Junio C Hamano [this message]
2007-12-14 7:36 ` Wincent Colaiuta
2007-12-14 0:17 ` [PATCH 2/5] New version of pre-commit hook Jakub Narebski
2007-12-14 7:24 ` Wincent Colaiuta
2007-12-14 10:23 ` Jakub Narebski
2007-12-13 19:45 ` [PATCH] Don't use the pager when running "git diff --check" Wincent Colaiuta
2007-12-14 4:51 ` Jeff King
2007-12-14 5:11 ` Junio C Hamano
2007-12-14 7:33 ` Junio C Hamano
2007-12-14 7:51 ` Wincent Colaiuta
2007-12-14 7:57 ` Junio C Hamano
2007-12-14 7:47 ` Wincent Colaiuta
2007-12-14 20:54 ` Junio C Hamano
2007-12-13 23:51 ` [PATCH 1/5] "diff --check" should affect exit status Junio C Hamano
2007-12-14 2:10 ` 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=7vd4taywfw.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;
as well as URLs for NNTP newsgroup(s).