4

To hide the awful ^M characters from git diff, one has to config:

[core]
    whitespace = cr-at-eol

But they are still displayed in git grep output. How to solve that?

EDIT -- The grep I'm running is:

git grep -i --line-number --break --heading -C 1 <PATTERN>

in Cygwin (on Windows) with less -R as pager.

2
  • What operating system and terminal emulator are you using? Are you using a pager, and if so, which one?
    – bk2204
    Commented Dec 14, 2019 at 3:57
  • Edited my question to answer yours. Thanks! Commented Dec 15, 2019 at 21:26

1 Answer 1

4
+50

Quoting this from a similar question (which is related to git diff),

Change the core.pager to "tr -d '\r' | less -REX"

You can either change this configuration globally like this,

git config --global core.pager "tr -d '\r' | less -REX"

or just use it once for git grep,

git -c core.pager="tr -d '\r' | less -REX" grep -i --line-number --break --heading -C 1 <PATTERN>

User Jason Pyeron provides a thorough explanation here.

5
  • Crazy to do that, IMHO, while there is a setting for the diff… not followed for the grep part… but that works, thanks! Commented Dec 18, 2019 at 8:53
  • Would appreciate if you could address the side question as well - though you've already addressed, and resolved, the initial one! Commented Dec 18, 2019 at 8:55
  • And do you know which color is used for highlighting those accents? Commented Dec 18, 2019 at 9:42
  • @user3341592, can you provide more details ? what terminal you are using? what is the command being executed ? (less displays the non-ASCII characters correctly for me), it would be better if you could open a new question Commented Dec 18, 2019 at 17:08
  • OK. See stackoverflow.com/questions/59398963/…. Thanks! Commented Dec 18, 2019 at 19:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.