From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: "J. Bruce Fields" <bfields@citi.umich.edu>
Subject: [PATCH] git-diff: complain about >=8 consecutive spaces in initial indent
Date: Tue, 02 Oct 2007 18:00:27 -0700 [thread overview]
Message-ID: <7vfy0thv10.fsf_-_@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1189982942187-git-send-email-bfields@citi.umich.edu> (J. Bruce Fields's message of "Sun, 16 Sep 2007 18:49:01 -0400")
This teaches coloring code in "diff" to detect indent of 8 or
more places using SP, which can and should (in some projects
including the kernel and git itself) use HT instead.
---
* This is primarily meant as a "reminder" patch, and not for
inclusion. We earlier saw a patch to "git-apply" to rewrite
them to HT but rejected it, because some projects use "no HT,
all SP" policy (e.g. Python).
We probably should resurrect the earlier "git-apply" patch,
and teach it and this patch to selectively enable/disable
detection of different kinds of whitespace breakages.
diff.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/diff.c b/diff.c
index 0ee9ea1..647377b 100644
--- a/diff.c
+++ b/diff.c
@@ -531,8 +531,10 @@ static void emit_line_with_ws(int nparents,
int i;
int tail = len;
int need_highlight_leading_space = 0;
- /* The line is a newly added line. Does it have funny leading
- * whitespaces? In indent, SP should never precede a TAB.
+ /*
+ * The line is a newly added line. Does it have funny leading
+ * whitespaces? In indent, SP should never precede a TAB, and
+ * there shouldn't be more than 8 consecutive spaces.
*/
for (i = col0; i < len; i++) {
if (line[i] == '\t') {
@@ -545,6 +547,11 @@ static void emit_line_with_ws(int nparents,
else
break;
}
+ if (0 <= last_space_in_indent && last_tab_in_indent < 0 &&
+ 8 <= (i - col0)) {
+ last_tab_in_indent = i;
+ need_highlight_leading_space = 1;
+ }
fputs(set, stdout);
fwrite(line, col0, 1, stdout);
fputs(reset, stdout);
next prev parent reply other threads:[~2007-10-03 1:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-16 22:48 whitespace-stripping J. Bruce Fields
2007-09-16 22:49 ` [PATCH 1/3] git-apply: fix whitespace stripping J. Bruce Fields
2007-09-16 22:49 ` [PATCH 2/3] git-apply: complain about >=8 consecutive spaces in initial indent J. Bruce Fields
2007-09-16 22:49 ` [PATCH 3/3] git-apply: add tests for stripping of leading and trailing whitespace J. Bruce Fields
2007-09-17 14:16 ` Krzysztof Halasa
2007-09-17 15:02 ` J. Bruce Fields
2007-09-17 23:44 ` Krzysztof Halasa
2007-09-18 0:53 ` J. Bruce Fields
2007-09-16 23:24 ` [PATCH 2/3] git-apply: complain about >=8 consecutive spaces in initial indent Martin Langhoff
2007-09-17 2:45 ` J. Bruce Fields
2007-09-17 0:24 ` Junio C Hamano
2007-09-17 2:44 ` J. Bruce Fields
2007-10-03 1:00 ` Junio C Hamano [this message]
2007-09-18 8:55 ` [PATCH 1/3] git-apply: fix whitespace stripping David Kastrup
2007-09-18 13:12 ` J. Bruce Fields
2007-09-18 14:18 ` David Kastrup
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vfy0thv10.fsf_-_@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=bfields@citi.umich.edu \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).