Products Resources Support About Us

Colors are not interpreted correctly when using git diff


#1

Has anyone had this issue where git diff does not show colors correctly? Clearly it’s trying to display the escape sequences but they aren’t coming out right. It works fine for git branch -v so just wondering if there is something I’m doing wrong.


Git log Colors are not interpreted correctly in more
#2

Actually, git log also does not interpret colors correctly so there is a general issue with escape sequences that works for the git branch -v but not other commands.

/u/devcgc/repos/zeke_test []$ git log
33mcommit 3aae8ee22a8b11e3f6d5de59a0a79ae47b9f62aam
Author: Clay Crowell <clay.crowell@asg.com>
Date:   Fri Apr 21 12:07:18 2017 -0400

    zteam-999: ptf z620tac - change to zekeca4 in zeke01a

33mcommit d047d268220a8eeb2f8d1466ee6dfbdba6c86b6bm
Author: Clay Crowell <clay.crowell@asg.com>
Date:   Fri Apr 21 11:37:11 2017 -0400

    ZTEAM-999: ptf z620taa - change to the zekeca3 are of zeke01a

#3

I found the issue. One of our developers recently installed “less” on our system. That caused the colors to not work.

I found another forum that mentioned setting core.pager. That sort of worked although it caused a new issue, essentially removing “less” from the picture. Any ideas how to set core.pager so I don’t have the issue you see below and still get my colors?


#4

Hi Clay,

Notice, GIT_SHELL has to specify executable file:
export GIT_SHELL=/some/path/bash-4.3_b017.170426/bin/bash
instead of
export GIT_SHELL=/some/path/bash-4.3_b017.170426/bin

Also if you use additional bash scripts for git (not from Rocket’s archive), you should replace numeric values in escape sequences. E.g.:

  • replace \x1b, \x1B or \033 with \e
  • \x0A with \n
  • \x0D with \r

#5

This works for me. Does your user have permissions to execute less?