3

When I run magit-status I see the following:

enter image description here

And when I run git status at the terminal I see the following:

enter image description here

What gives? I'm unable to 'stage' the modified file for commit. When I try to commit with magit, I'm told that there is nothing staged.

For reference, I've added my git config

# all the color
[color]
    ui = always
[color "diff"]
    meta = yellow bold
    commit = green bold
    frag = magenta bold
    old = red bold
    new = green bold
    whitespace = red reverse
[color "diff-highlight"]
    oldNormal = red bold
    oldHighlight = "red bold 52"
    newNormal = "green bold"
    newHighlight = "green bold 22"
[color "branch"]
    current = yellow reverse
    local = yellow
    remote = green
[color "status"]
    added = yellow
    changed = green
    untracked = cyan

# correct typos
[help]
    autocorrect = 1

# aliases
[alias]
  c = commit
  b = branch
  up = pull
  p = push
  s = status -s
  sclone = clone --depth=1
  co = checkout
  df = diff --color --color-words --abbrev
  lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --

  # Show the diff between the latest commit and the current state
  d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"

  reup = rebase-update # depot_tools specific

[user]
    email = nland@authen2cate.com
    name = Nicholas Land

[core]
    editor = nvim
    autocrlf = input
    pager = diff-highlight | diff-so-fancy | less -r

[push]
    default = simple

[difftool "kdiff3"]
  trustExitCode = false
[difftool]
  prompt = false
[diff]
  tool = kdiff3

[mergetool "kdiff3NoAuto"]
  trustExitCode = false
[mergetool]
  keepBackup = false
[merge]
  tool = kdiff3NoAuto
[mergetool "kdiff3NoAuto"]
    cmd = kdiff3 --L1 \"$MERGED (Base)\" --L2 \"$MERGED (Local)\" --L3 \"$MERGED (Remote)\" -o \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\"

[credential]
    helper = osxkeychain

[filter "lfs"]
    clean = git-lfs clean %f
    smudge = git-lfs smudge %f
    required = true

[commit]
    template = /Users/nick/.gitCommitMessage
5
  • Looks to me like the output in your magit status buffer has been polluted by some terminal escape sequences. These might well have confused magit. Do you have anything in your git config that might cause this? May 1, 2016 at 16:15
  • It sure seems that way. I've removed the git config, and as soon as I did I was seeing what I expected. For reference, I've added my git config. I wonder if it has to do with diff-so-fancy.
    – nland
    May 1, 2016 at 16:19
  • 6
    Try setting color.ui to be auto instead of always
    – nispio
    May 1, 2016 at 16:48
  • That seems to do it. Thanks @nispio.
    – nland
    May 1, 2016 at 17:23
  • @nispio Add that as an answer, please? Unanswered questions on stackexchange tend to resurface from time to time. (And then ndland should accept the answer, to really make sure the question comes back.) May 2, 2016 at 10:04

1 Answer 1

7

Git has the ability to detect in many cases whether its output is being printed to a terminal, or piped to another process. When it is being printed to a terminal, you have the option of using ascii escape sequences to provide text formatting and coloring. However, most programs are not set up to handle these escape sequences.

By specifying the --color=always argument or setting color.ui = always in your config, you are telling git to always add the ascii escape sequences for coloring. Since magit does not know how to parse these sequences, it stops working properly.

Instead, use the --color=auto argument or set color.ui = auto in your config file to tell git to apply coloring, but only in cases where it makes sense.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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