From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] diff: reset color before printing newline
Date: Tue, 17 Jun 2008 02:22:05 +0200 [thread overview]
Message-ID: <20080617002205.GD7003@neumann> (raw)
In-Reply-To: <1213653602-31307-1-git-send-email-szeder@ira.uka.de>
Junio,
On Tue, Jun 17, 2008 at 12:00:02AM +0200, SZEDER Gábor wrote:
> I'm not sure about putting a newline unconditionally at the end of the
> line, but this was the status quo before c1795bb0.
we _must_ not print a newline when there was none, as it breaks
"normal" colored diffs very badly.
Since c1795bb0, for whatever reason, checkdiff_consume() first calls
emit_line() to print only the first '+' character of the line, without
trailing newline, and then calls check_and_emit_line() to print the
rest of the line. Now if we restore the status quo prior to c1795bb0
regarding unconditional newlines in emit_line(), then there is always
a newline between the the '+' and the rest of the line, which is bad,
bad, bad.
So this should be squashed to the previous patch.
---
diff.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/diff.c b/diff.c
index f23657b..722f577 100644
--- a/diff.c
+++ b/diff.c
@@ -514,13 +514,18 @@ const char *diff_get_color(int diff_use_color, enum color_diff ix)
static void emit_line(FILE *file, const char *set, const char *reset, const char *line, int len)
{
- if (len > 0 && line[len-1] == '\n')
+ int trailing_newline = 0;
+
+ if (len > 0 && line[len-1] == '\n') {
len--;
+ trailing_newline = 1;
+ }
fputs(set, file);
fwrite(line, len, 1, file);
fputs(reset, file);
- fputc('\n', file);
+ if (trailing_newline)
+ fputc('\n', file);
}
static void emit_add_line(const char *reset, struct emit_callback *ecbdata, const char *line, int len)
next prev parent reply other threads:[~2008-06-17 0:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-16 22:00 [PATCH] diff: reset color before printing newline SZEDER Gábor
2008-06-16 23:23 ` Junio C Hamano
2008-06-17 0:22 ` SZEDER Gábor [this message]
2008-06-17 0:59 ` 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=20080617002205.GD7003@neumann \
--to=szeder@ira.uka.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.