Skip to contentSkip to conversation

How do I get colored diff output?

StGit Peter Baumann 3 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

Is there a way to get colored diff output, preferable from the native git diff without having to specify stg diff -O --color everytime? It seems that stg doesn't honor color.diff config entry, so I am a little lost.

(And yes I now that I could use the pager setting given in examples/gitconfig,

	stgit.pager = filterdiff --annotate | colordiff | less -FRX

but I really prefere the native git coloring, which looks a loot nicer and does also highlight traling whitespace)

-Peter

#1 lore raw
Quoted 11 lines · Peter Baumann

Is there a way to get colored diff output, preferable from the native git diff without having to specify stg diff -O --color everytime? It seems that stg doesn't honor color.diff config entry, so I am a little lost.

(And yes I now that I could use the pager setting given in examples/gitconfig,

	stgit.pager = filterdiff --annotate | colordiff | less -FRX

but I really prefere the native git coloring, which looks a loot nicer and does also highlight traling whitespace)

There isn't any other way at the moment. There were ideas of adding support for default command line options for various commands but I haven't looked at this.

I now tried the example stgit.pager option and it looks bad indeed. In the meantime, there is a diffcol.sh script in the contrib directory, I use this instead and it looks much nicer.

Signature · 1 line
Catalin
#2 lore raw
Quoted 13 lines · Catalin Marinas
Quoted 11 lines · Peter Baumann

Is there a way to get colored diff output, preferable from the native git diff without having to specify stg diff -O --color everytime? It seems that stg doesn't honor color.diff config entry, so I am a little lost.

(And yes I now that I could use the pager setting given in examples/gitconfig,

	stgit.pager = filterdiff --annotate | colordiff | less -FRX

but I really prefere the native git coloring, which looks a loot nicer and does also highlight traling whitespace)

Quoted 8 lines

There isn't any other way at the moment. There were ideas of adding support for default command line options for various commands but I haven't looked at this.

I now tried the example stgit.pager option and it looks bad indeed. In the meantime, there is a diffcol.sh script in the contrib directory, I use this instead and it looks much nicer.

Ah. I didn't find that while searching for the color ouput.

Thx for your help,
Peter

#3 lore raw
In reply to Catalin Marinas
Quoted 3 lines · Catalin Marinas

I now tried the example stgit.pager option and it looks bad indeed. In the meantime, there is a diffcol.sh script in the contrib directory, I use this instead and it looks much nicer.

That means it should be not removed even though git-diff learned --color...

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#4 lore raw
Quoted 8 lines · Jakub Narebski
Quoted 3 lines · Catalin Marinas

I now tried the example stgit.pager option and it looks bad indeed. In the meantime, there is a diffcol.sh script in the contrib directory, I use this instead and it looks much nicer.

That means it should be not removed even though git-diff learned --color...

It looks nicer than "filterdiff | colordiff" (and probably pretty similar to the git-diff --color output).

It shouldn't be removed yet because there is no support in StGIT to pass these options automatically. Since StGIT uses git-diff-tree/index directly, always passing the --color option to these tools is not feasible as they cannot detect whether the output is tty or file. This functionality is currently handled by the pydoc.pager function.

Using git-diff would require a bit of work as well since StGIT first captures the output and displays it afterwards via pydoc.pager. We might change this at some point since GIT now has proper support for PAGER.

Signature · 1 line
Catalin