Skip to content

Fixed: dont colorize diff output #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2020
Merged

Conversation

james2doyle
Copy link
Contributor

No description provided.

@frou
Copy link
Owner

frou commented Jul 28, 2020

Hi there - As far as I understand it, the git command-line program already automatically disables coloured output, because it can tell it's not outputting to a terminal. Am I missing something?

The colours we see when viewing the commit in Sublime Text are due to the "Diff" syntax highlighting being applied by the code here:

view.assign_syntax("Packages/Diff/Diff.sublime-syntax")

@james2doyle
Copy link
Contributor Author

I'm not familiar with the internals of git, but I have a feel that a global .gitconfig that contains --color might just apply regardless. I'm also using Fish shell so maybe there is something related there where my shell ENV is being applied. I know sublime does eval $PATH so its possible there is a hiccup there too.

Anyway, here is my original output without --no-color:

Screen Shot 2020-07-28 at 9 08 57 AM

You can see hidden characters in the output that stop the diff from being properly highlighted. This isnt the first time Ive encountered this issue before where there are ANSI color codes in the git diff output. I actually have a command in my terminal I wrote called strip-colors so I can copy the output of git diff and patch generation properly.

And with --no-color:

Screen Shot 2020-07-28 at 9 10 10 AM

You can see the hidden characters are gone and everything highlights properly.

Regardless, I can't imagine this should cause any issues right? It sounds like the default assumption is the the output shouldn’t be colorized anyway.

What do you think?

@frou frou merged commit 2069a95 into frou:master Jul 28, 2020
@frou
Copy link
Owner

frou commented Jul 28, 2020

Thanks for elaborating - That all makes sense. I actually had to do similar to your strip-colors when making a command to reformat the output of the Elm compiler (used this library).

It'll be a couple of days before your fix makes it out to users via Package Control, because I need to sort out master and tag a new version.

@frou
Copy link
Owner

frou commented Aug 9, 2020

The version available via Package Control now includes this fix

frou added a commit that referenced this pull request Dec 6, 2021
Just in case. See #51 for why it was already added to `get_commit_fulltext` previously.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants