From: Jean-Luc Herren <jlh@gmx.ch>
To: Git List <git@vger.kernel.org>
Subject: Problem with CRLF line endings and colored diff
Date: Tue, 14 Oct 2008 23:13:59 +0200 [thread overview]
Message-ID: <48F50B97.9090106@gmx.ch> (raw)
Hello list!
I'm using CRLF line endings on the files of a project and I'm
running into odd output from 'git diff'. Here are the steps to
reproduce:
git init
echo -e 'line1\r' > file
git add file
echo -e 'line2\r' > file
PAGER='less -R' git diff --color
The output looks like this:
diff --git a/file b/file
index 495181c..a1413a4 100644
--- a/file
+++ b/file
@@ -1 +1 @@
-line1
+line2^M
Note the trailing ^M on the '+' line. After examining that line
it seems it's a bug in git, as that line really looks like this
(<...> denoting ANSI sequences or CR/LF):
<GREEN FOREGROUND>+<RESET><GREEN FOREGROUND>
line2<RESET><RED BACKGROUND><CR><RESET><LF>
The CR and the LF are not after each other, there's an ANSI
sequence in between (because the CR is being highlighted as white
space). That confuses 'less'. The '-' line above does not do
that and thus doesn't have this problem. It also doesn't reset
the color between the '-' and the line:
<RED FOREGROUND>-line1<RESET><CR><LF>
I tried poking around the code, but the diff machinery is more
complex than could be quickly grasped, so I'll let someone that
knows it already have a look.
Using git 1.6.0.2, but have the same problem with HEAD.
jlh
next reply other threads:[~2008-10-14 21:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-14 21:13 Jean-Luc Herren [this message]
2008-10-14 22:20 ` Problem with CRLF line endings and colored diff Junio C Hamano
2008-10-14 23:08 ` Jean-Luc Herren
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=48F50B97.9090106@gmx.ch \
--to=jlh@gmx.ch \
--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.
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.