git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>,
	"Frank Schäfer" <fschaefer.oss@googlemail.com>,
	git@vger.kernel.org
Subject: Re: BUG: CR marker ^M doesn't show up in '-' lines of diffs when the ending of the removed line is CR+LF
Date: Thu, 29 Nov 2018 11:11:14 +0900	[thread overview]
Message-ID: <xmqqk1kwr5tp.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <3e24a770-47fc-50e4-d757-1e4a28dcd019@kdbg.org> (Johannes Sixt's message of "Tue, 27 Nov 2018 19:15:31 +0100")

Johannes Sixt <j6t@kdbg.org> writes:

> Am 27.11.18 um 00:31 schrieb Junio C Hamano:
>> Johannes Sixt <j6t@kdbg.org> writes:
>>> Am 26.11.18 um 04:04 schrieb Junio C Hamano:
>>> ... this goes too far, IMO. It is the pager's task to decode control
>>> characters.
>>
>> It was tongue-in-cheek suggestion to split a CR into caret-em on our
>> end, but we'd get essentially the same visual effect if we added a
>> rule:
>>
>> 	When producing a colored output (not limited to whitespace
>> 	error coloring of diff output), insert <RESET> before a CR
>> 	that comes immediately before a LF.

This was misspoken a bit.  Let's revise it to

 	When producing a colored output (not limited to whitespace
 	error coloring of diff output) for contents that are not
 	marked as eol=crlf (and other historical means), insert
 	<RESET> before a CR that comes immediately before a LF.

to exempt CR in CRLF sequence that the contents and the user agree
to be part of the end-of-line marker.

> I wouldn't want that to happen for all output (context lines, - lines,
> + lines): I really am not interested to see all the CRs in my CRLF
> files.

So your CRLF files will not give caret-em.

>> And a good thing is that I do not think that new rule is doing any
>> decode of control chars on our end.  We are just producing colored
>> output normally.
>
> But we already have it, as Brian pointed out:
>
>    git diff --ws-error-highlight=old,new
>
> or by setting diff.wsErrorHighlight accordingly.

Not really.  If the context lines end with CRLF and the material is
not CRLF, I do not think CR at the end of them should be highlighted
as whitespace errors (as we tell to detect errors on "old" and "new"
lines), but I think we still should make an effort to help them be
visible to the users.  Otherwise, next Frank will come and complain
after seeing

	-something
	 some common thing
	+something_new^M

With the suggested change, you can distinguish the following two
(and use your imagination that there are many "some common thing"
lines), which would help the user guide if the file should be marked
as CRLF file, or the contents mistakenly has some lines that end
with CRLF by mistake.  The corrective action between the two cases
would vastly be different.

	-something^M          	-something          
	 some common thing^M  	 some common thing
	 some common thing^M  	 some common thing
	 some common thing^M  	 some common thing
	+something_new^M      	+something_new^M      

Without, both would look like the RHS of the illustration, and with
the "highlight both", you'd only get an extra caret-em on the
removed line, and need to judge without the help from common context
lines.

Besides, --ws-error-highlight shows all whitespace errors, and
showing CR as caret-em is mere side effect of the interaction
between its coloring and the pager.


  parent reply	other threads:[~2018-11-29  2:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-23 18:19 BUG: CR marker ^M doesn't show up in '-' lines of diffs when the ending of the removed line is CR+LF Frank Schäfer
2018-11-23 21:47 ` Johannes Sixt
2018-11-24 14:51   ` Frank Schäfer
2018-11-24 15:25     ` Torsten Bögershausen
2018-11-24 22:07     ` Johannes Sixt
2018-11-25 14:03       ` Frank Schäfer
2018-11-25 21:39         ` Johannes Sixt
2018-11-26  4:02           ` Junio C Hamano
     [not found]           ` <xmqqzhtwzghr.fsf@gitster-ct.c.googlers.com>
2018-11-26 19:49             ` Johannes Sixt
2018-11-26 23:31               ` Junio C Hamano
2018-11-27 18:15                 ` Johannes Sixt
2018-11-27 20:09                   ` Frank Schäfer
2018-11-29  2:11                   ` Junio C Hamano [this message]
2018-12-02 19:31                     ` Frank Schäfer
2018-12-02 21:22                       ` Johannes Sixt
2018-12-05 19:29                         ` Frank Schäfer
2018-12-05 21:31                           ` Johannes Sixt
2018-12-03  1:15                       ` Junio C Hamano
2018-12-05 19:43                         ` Frank Schäfer
2018-12-06  0:58                           ` Junio C Hamano
2018-12-06 18:42                             ` Frank Schäfer
2018-11-27 20:06                 ` Frank Schäfer
2018-11-25 23:50         ` brian m. carlson

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=xmqqk1kwr5tp.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=fschaefer.oss@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=sandals@crustytoothpaste.net \
    /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).