magit shows ANSI color sequences from git #208

Closed
Wilfred opened this Issue May 26, 2011 · 2 comments

4 participants

@Wilfred

If colour is enabled for git, e.g.:

$ git config --global color.diff always

then M-x magit-status shows the colour sequences, e.g:

Head:   �[33md47a03d�[m my last commit message

Thanks for a great utility :)

@pjweisberg pjweisberg was assigned Jun 13, 2011
@pjweisberg pjweisberg added a commit that closed this issue Jun 13, 2011
@pjweisberg pjweisberg Filter out ANSI color sequences
Add new functions `magit-cmd-output` and `magit-cmd-insert`, generic
versions of `magit-git-output` and `magit-git-insert`.  Use
`magit-cmd-insert` in `magit-insert-section` instead of calling
`process-file` directly.

Since all the text to insert goes through `magit-cmd-output`, put the
regexp to filter out ANSI color sequences there.

Closes #208
8a81e7c
@mee
mee commented Sep 6, 2011

Note that you probably want

$ git config --global color.diff true

(ie. 'true', not 'always')

from git-config(1):

   color.diff
       When set to always, always use colors in patch. When false (or
       never), never. When set to true or auto, use colors only when the
       output is to the terminal. Defaults to false.

This way, git will DTRT before magit deals with it.

@tiagosab

I'm sure there was some reason for me wanting to have color=always...

Or not...

Just as a side note, I've seen the bug has been closed anyway, filtering out ansi commands. Would it not be faster simply passing the --no-color to git? I had a patch which was working most of the time with it, but never got the time to find where were the other git invocations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment