Open-source Languages & Tools for z/OS

 View Only
  • 1.  Colors are not interpreted correctly when using git diff

    Posted 05-19-2017 15:55

    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.



  • 2.  RE: Colors are not interpreted correctly when using git diff

    Posted 05-19-2017 18:31

    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.  RE: Colors are not interpreted correctly when using git diff

    Posted 05-19-2017 19:05

    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.  RE: Colors are not interpreted correctly when using git diff

    Posted 11-26-2018 18:43

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



  • 5.  RE: Colors are not interpreted correctly when using git diff

    Posted 05-22-2017 07:48

    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


  • 6.  RE: Colors are not interpreted correctly when using git diff

    Posted 04-07-2019 07:21

    I was able to get colors in the diff output by changing the pager to “pg”.

    git config core.pager 'pg'



  • 7.  RE: Colors are not interpreted correctly when using git diff

    Posted 09-02-2019 15:35

    Another way to break git color support in the default set up, is to set the LESS environment variable. I was bit by this when I set LESS=-i to have default case insenitive search. Then I didn’t use the notebook for a week . Then I used git diff and it was “broken” I had forgotten that I set LESS, so spent a lot of time figuring out that setting LESS had broken the git default pager (less).

    Fairly well docummented here:

    https://git-scm.com/docs/git-config#Documentation/git-config.txt-corepager

    I added this to my .gitconfig; you may also want to add X there:

    [core]
      pager = less -FR