Hi Matthieu,

Matthieu Herrb wrote on Mon, Oct 07, 2013 at 10:25:36PM +0200:

> git 1.8.4 likes to put colors in its output, especially in 'git log'. 
> But for historical reasons, I've LESS="-e -P%f (%pB\%)" in my
> environment. With those setups and TERM=xterm in an xterm, git log
> shows the control sequences used to set colors instead. 

Try:

  export LESS="-Re -P%f (%pB\%)"

> Even setting LESS="" still produces the same (ugly) result.
> 
> unsetting LESS gives the expected result.
> 
> I must admit that I fail to understand what's going on.

Sure, git likes to follow the principle of greatest surprise.

  ischwarze@isnote $ cd /usr/ports/pobj/git-1.8.4/git-1.8.4
  ischwarze@isnote $ less pager.c
  [...]
        /* spawn the pager */
        pager_argv[0] = pager;
        pager_process.use_shell = 1;
        pager_process.argv = pager_argv;
        pager_process.in = -1;
        if (!getenv("LESS")) {
                static const char *env[] = { "LESS=FRSX", NULL };
                pager_process.env = env;
        }
        if (start_command(&pager_process))
                return;
  [...]

So, if you define LESS yourself, git uses that, even if it is
inappropriate, even if it is empty.  If you do not define it,
git uses its own, hard-coded defaults.

Hope that helps,
  Ingo

> PS: this is not a plea to turn off colors in git output. I know how to
> do it if needed (git config --global color.pager false).

Reply via email to