git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Symonds <dsymonds@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>, Andreas Ericsson <ae@op5.se>,
	David Symonds <dsymonds@gmail.com>
Subject: [PATCH 3/3] Act on WS_WARN for ws_mode_trailing.
Date: Sat,  3 Nov 2007 00:34:21 +1100	[thread overview]
Message-ID: <1194010463982-git-send-email-dsymonds@gmail.com> (raw)
In-Reply-To: <11940104621856-git-send-email-dsymonds@gmail.com>

Signed-off-by: David Symonds <dsymonds@gmail.com>
---
 diff.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/diff.c b/diff.c
index 6f9b624..ebcc0f3 100644
--- a/diff.c
+++ b/diff.c
@@ -544,17 +544,22 @@ static void emit_line_with_ws(int nparents,
 	tail = len - 1;
 	if (line[tail] == '\n' && i < tail)
 		tail--;
-	while (i < tail) {
-		if (!isspace(line[tail]))
-			break;
-		tail--;
+	if (ws_mode_trailing != WS_OKAY) {
+		while (i < tail) {
+			if (!isspace(line[tail]))
+				break;
+			tail--;
+		}
 	}
 	if ((i < tail && line[tail + 1] != '\n')) {
 		/* This has whitespace between tail+1..len */
-		fputs(set, stdout);
-		fwrite(line + i, tail - i + 1, 1, stdout);
-		fputs(reset, stdout);
-		emit_line(ws, reset, line + tail + 1, len - tail - 1);
+		if (ws_mode_trailing == WS_WARN) {
+			fputs(set, stdout);
+			fwrite(line + i, tail - i + 1, 1, stdout);
+			fputs(reset, stdout);
+			emit_line(ws, reset, line + tail + 1, len - tail - 1);
+		}
+		/* TODO: handle WS_ERROR and WS_AUTOFIX */
 	}
 	else
 		emit_line(set, reset, line + i, len - i);
-- 
1.5.3.1

  reply	other threads:[~2007-11-02 13:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-02 13:34 [PATCH 1/3] Implement parsing for new core.whitespace.* options David Symonds
2007-11-02 13:34 ` [PATCH 2/3] Act on WS_WARN for ws_mode_space_before_tab David Symonds
2007-11-02 13:34   ` David Symonds [this message]
2007-11-02 15:07     ` [PATCH 3/3] Act on WS_WARN for ws_mode_trailing David Symonds
2007-11-02 15:25 ` [PATCH 1/3] Implement parsing for new core.whitespace.* options Baz

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=1194010463982-git-send-email-dsymonds@gmail.com \
    --to=dsymonds@gmail.com \
    --cc=ae@op5.se \
    --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).