@matheusbsbs / matheus-bagliano / commits / 62e1aeabc0
Fork 0

git-svn: allow both diff.color and color.diff

The list concensus is to group color related configuration under "color.*" so let's be consistent. Inspired by Andy Parkins's patch to do the same for diff/log family. With fixes from Eric Wong. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 13, 2006 at 15:58 UTC 62e1aeabc095a02fd3fb7ef46a6884d76da5ce67
1 file changed +25 -6
git-svn.perl
+25 -6
@@ -925,19 +925,38 @@ sub cmt_showable {
925
926 sub log_use_color {
927 return 1 if $_color;
928 - my $dc;
929 - chomp($dc = `git-repo-config --get diff.color`);
928 + my ($dc, $dcvar);
929 + $dcvar = 'color.diff';
930 + $dc = `git-repo-config --get $dcvar`;
931 + if ($dc eq '') {
932 + # nothing at all; fallback to "diff.color"
933 + $dcvar = 'diff.color';
934 + $dc = `git-repo-config --get $dcvar`;
935 + }
936 + chomp($dc);
937 if ($dc eq 'auto') {
931 - if (-t *STDOUT || (defined $_pager &&
932 - `git-repo-config --bool --get pager.color` !~ /^false/)) {
938 + my $pc;
939 + $pc = `git-repo-config --get color.pager`;
940 + if ($pc eq '') {
941 + # does not have it -- fallback to pager.color
942 + $pc = `git-repo-config --bool --get pager.color`;
943 + }
944 + else {
945 + $pc = `git-repo-config --bool --get color.pager`;
946 + if ($?) {
947 + $pc = 'false';
948 + }
949 + }
950 + chomp($pc);
951 + if (-t *STDOUT || (defined $_pager && $pc eq 'true')) {
952 return ($ENV{TERM} && $ENV{TERM} ne 'dumb');
953 }
954 return 0;
955 }
956 return 0 if $dc eq 'never';
957 return 1 if $dc eq 'always';
939 - chomp($dc = `git-repo-config --bool --get diff.color`);
940 - $dc eq 'true';
958 + chomp($dc = `git-repo-config --bool --get $dcvar`);
959 + return ($dc eq 'true');
960 }
961
962 sub git_svn_log_cmd {