daveewart/colordiff — pull request #6 by ymattw (2013-01-22 05:49:18+00:00)
Title: fix issue 4 without changing existing behaviour, just introduce new opti...

Thanks for being looking into my request deeply.

How about just introduce a new option '--color=yes|no|auto' to override $color_patch variable (color_patches setting), and don't change the original "-f STDOUT" condition but force colors on/off according to the value of $colormode. The key change would be

-if ((-f STDOUT) && ($color_patch == 0)) {
+if (((-f STDOUT) && ($color_patch == 0)) || ($colormode eq "no")) {

I am sending a new pull request based on the start point where I forked: a79dc09.

~/ws/colordiff $ git log --pretty='%h %s (%an)' -2
a0e7e9c fix issue 4 without changing existing behaviour, just introduce new option --color=yes|no|auto (Matthew Wang)
a79dc09 Add '--fakeexitcode' option. (Dave Ewart)

I tested with following use cases:

- With `color_patches=yes`
- Expects color
- git diff a79dc0 | ./colordiff.pl
- git diff a79dc0 | ./colordiff.pl --color=yes
- git diff a79dc0 | ./colordiff.pl --color=auto
- git diff a79dc0 | ./colordiff.pl | less -r
- git diff a79dc0 | ./colordiff.pl --color=yes | less -r
- git diff a79dc0 | ./colordiff.pl --color=auto | less -r
- git diff a79dc0 | ./colordiff.pl > out
- git diff a79dc0 | ./colordiff.pl --color=yes > out
- git diff a79dc0 | ./colordiff.pl --color=auto > out
- Expects no color
- git diff a79dc0 | ./colordiff.pl --color=no
- git diff a79dc0 | ./colordiff.pl --color=no | less -r
- git diff a79dc0 | ./colordiff.pl --color=no > out
- With `color_patches=no`
- Expects color
- git diff a79dc0 | ./colordiff.pl
- git diff a79dc0 | ./colordiff.pl --color=yes
- git diff a79dc0 | ./colordiff.pl --color=auto
- git diff a79dc0 | ./colordiff.pl | less -r
- git diff a79dc0 | ./colordiff.pl --color=yes | less -r
- git diff a79dc0 | ./colordiff.pl --color=auto | less -r
- git diff a79dc0 | ./colordiff.pl --color=yes > out
- Expects no color
- git diff a79dc0 | ./colordiff.pl > out
- git diff a79dc0 | ./colordiff.pl --color=auto > out
- git diff a79dc0 | ./colordiff.pl --color=no
- git diff a79dc0 | ./colordiff.pl --color=no | less -r
- git diff a79dc0 | ./colordiff.pl --color=no > out