{"thread":{"id":"11466","subject":"[PATCH] add--interactive: allow diff colors without interactive colors","startedAt":"2008-01-04T08:35:21Z","lastAt":"2008-01-08T12:52:30Z","messageCount":17,"participants":["Jeff King","Junio C Hamano","Matthias Kestenholz","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"64421","messageId":"20080104083521.GB3354@coredump.intra.peff.net","threadId":"11466","inReplyTo":null,"subject":"[PATCH] add--interactive: allow diff colors without interactive colors","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-01-04T08:35:21Z","receivedAt":"2008-01-04T08:35:21Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Users with color.diff set to true/auto will not see color in\n\"git add -i\" unless they also set color.interactive.\n\nHowever, some users may want just one without the other, so\nthere's no reason to tie them together.\n\nNote that there is now no way to have color on for \"git\ndiff\" but not for diffs from \"git add -i\"; such a\nconfiguration seems unlikely, though.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n git-add--interactive.perl |   18 +++++++++---------\n 1 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 0cdd800..aaa9b24 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -22,16 +22,16 @@ if ($use_color) {\n \t$header_color = $repo->get_color(\"color.interactive.header\", \"bold\");\n \t$help_color = $repo->get_color(\"color.interactive.help\", \"red bold\");\n \t$normal_color = $repo->get_color(\"\", \"reset\");\n+}\n \n-\t# Do we also set diff colors?\n-\t$diff_use_color = $repo->get_colorbool('color.diff');\n-\tif ($diff_use_color) {\n-\t\t$new_color = $repo->get_color(\"color.diff.new\", \"green\");\n-\t\t$old_color = $repo->get_color(\"color.diff.old\", \"red\");\n-\t\t$fraginfo_color = $repo->get_color(\"color.diff.frag\", \"cyan\");\n-\t\t$metainfo_color = $repo->get_color(\"color.diff.meta\", \"bold\");\n-\t\t$whitespace_color = $repo->get_color(\"color.diff.whitespace\", \"normal red\");\n-\t}\n+# Do we also set diff colors?\n+$diff_use_color = $repo->get_colorbool('color.diff');\n+if ($diff_use_color) {\n+\t$new_color = $repo->get_color(\"color.diff.new\", \"green\");\n+\t$old_color = $repo->get_color(\"color.diff.old\", \"red\");\n+\t$fraginfo_color = $repo->get_color(\"color.diff.frag\", \"cyan\");\n+\t$metainfo_color = $repo->get_color(\"color.diff.meta\", \"bold\");\n+\t$whitespace_color = $repo->get_color(\"color.diff.whitespace\", \"normal red\");\n }\n \n sub colored {\n-- \n1.5.4.rc2.1122.g6954-dirty\n"},{"id":"64479","messageId":"7v3atdi0na.fsf@gitster.siamese.dyndns.org","threadId":"11466","inReplyTo":"20080104083521.GB3354@coredump.intra.peff.net","subject":"Re: [PATCH] add--interactive: allow diff colors without interactive colors","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-05T00:20:09Z","receivedAt":"2008-01-05T00:20:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Users with color.diff set to true/auto will not see color in\n> \"git add -i\" unless they also set color.interactive.\n>\n> However, some users may want just one without the other, so\n> there's no reason to tie them together.\n>\n> Note that there is now no way to have color on for \"git\n> diff\" but not for diffs from \"git add -i\"; such a\n> configuration seems unlikely, though.\n\nAlthough I would agree with what this patch does, I think you\nare contradicting with yourself in the above justification.\nSome users may want to color \"git diff\" output but not\ninteraction with \"git add -i\", and that's also \"just one without\nthe other\", but you just tied them together, only differently,\nand \"seems unlikely\" is a rather weak excuse.\n\nThe justification should instead be: having more independent\nknobs is not necessarily better.  The user should not have to\ntweak too many knobs.\n\nIn the longer term, I think we should try reducing the number of\nknobs by giving \"color.git\" that allows you to pretend as if all\nof the \"color.interactive\", \"color.diff\", \"color.status\",\n\"color.someothercolorizedcommand\" are all set.  I do not think\nbeing able to control the use of colors per command is giving\nmuch other than confusion to the user.\n\nThat may not be so easy with the current structure of the config\nreader, though.\n"},{"id":"64496","messageId":"20080105033713.GA26806@coredump.intra.peff.net","threadId":"11466","inReplyTo":"7v3atdi0na.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] add--interactive: allow diff colors without interactive colors","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-01-05T03:37:13Z","receivedAt":"2008-01-05T03:37:13Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jan 04, 2008 at 04:20:09PM -0800, Junio C Hamano wrote:\n\n> Although I would agree with what this patch does, I think you\n> are contradicting with yourself in the above justification.\n> Some users may want to color \"git diff\" output but not\n> interaction with \"git add -i\", and that's also \"just one without\n> the other\", but you just tied them together, only differently,\n> and \"seems unlikely\" is a rather weak excuse.\n\nThen let me state it another way that I think makes a better argument.\nYou have two knobs, color.interactive and color.diff, controlling\nmenu-coloring of git-add--interactive and controlling colorization of\ngit-diff output. Now we have a third thing that may be colorized: diff\noutput of git-add--interactive.\n\nLet's assume that we don't want to add another color.interactive-diff\nknob (though that is an option). That means that we have to tie the\ncolorization either to color.interactive or to color.diff. Right now we\nsubdivide it by command, so that the coloring of interactive diffs is\ntied to color.interactive[1]. What I am proposing is to divide it by\n_functionality_, so that by saying color.diff you mean \"I like color\ndiffs, no matter where they are.\" And by saying color.interactive, you\nmean \"I like color interactive menus, no matter where they are.\" I think\nit is much more likely that users will find that division useful. And\nit's something we already do, since color.diff is respected not just by\ngit-diff, but by diffs produced by all programs, including the git-log\nfamily.\n\n[1]: Actually, we currently tie interactive diff coloring to \"diff &&\ninteractive\" which is even less useful. If I turn on color.interactive,\nI still don't get colored diffs. But if I turn on color.diff, then\ngit-diff starts producing colored diffs. So you really can't represent\nall choices, and I think the subdivision I outlined makes more sense (at\nleast it does to me).\n\n> The justification should instead be: having more independent\n> knobs is not necessarily better.  The user should not have to\n> tweak too many knobs.\n>\n> In the longer term, I think we should try reducing the number of\n> knobs by giving \"color.git\" that allows you to pretend as if all\n> of the \"color.interactive\", \"color.diff\", \"color.status\",\n> \"color.someothercolorizedcommand\" are all set.  I do not think\n> being able to control the use of colors per command is giving\n> much other than confusion to the user.\n\nI'm not sure I agree with that; my problem here is that I _want_ to turn\na knob, but the functionality is tied to another knob. IOW, reducing the\nnumber of knobs is going to make it worse.\n\nThat being said, all of those knobs _are_ confusing. In my case, I like\ncolor. I just don't like the colors that color.interactive provides, so\nI don't want to use them.  However, you can tune that quite a bit by\nchanging color.interactive.* (and just choosing \"plain\" for things you\ndon't want marked). Of course that still doesn't allow you to have\n_different_ color settings between the diffs of git-diff and those of\ngit-add--interactive. But then, my point is that I don't think sane\nusers want that. They either want diffs colored or they don't, no matter\nwhat command is producing them.\n\n> That may not be so easy with the current structure of the config\n> reader, though.\n\nI don't think it's hard; the client code for the colors checks a\n\"color_foo\" knob. It would just check \"color_foo || color_all\".\n\n-Peff\n"},{"id":"64508","messageId":"7vk5mod7kg.fsf@gitster.siamese.dyndns.org","threadId":"11466","inReplyTo":"20080105033713.GA26806@coredump.intra.peff.net","subject":"Re: [PATCH] add--interactive: allow diff colors without interactive colors","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-05T08:01:51Z","receivedAt":"2008-01-05T08:01:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Let's assume that we don't want to add another color.interactive-diff\n> knob (though that is an option). That means that we have to tie the\n> colorization either to color.interactive or to color.diff. Right now we\n> subdivide it by command, so that the coloring of interactive diffs is\n> tied to color.interactive[1]. What I am proposing is to divide it by\n> _functionality_, so that by saying color.diff you mean \"I like color\n> diffs, no matter where they are.\" And by saying color.interactive, you\n> mean \"I like color interactive menus, no matter where they are.\" I think\n> it is much more likely that users will find that division useful. And\n> it's something we already do, since color.diff is respected not just by\n> git-diff, but by diffs produced by all programs, including the git-log\n> family.\n\nI think I understood that part.  What I was saying was that it\nis equally valid for other people to say \"I like to interact\nwith 'git add -i' without colours because coloured output\ndistracts me when I have to think, even though I usually want to\nview the whole diff in colours.\"  So yes, color.interactive-diff\nis an option to give more flexibility, but no I do not think\nthat's a good flexibility.  I'd prefer a single \"color.git\"\nenvironment that rules all, which is far simpler to explain and\nconfigure.  Either you use colour for all your interaction with\ngit, or you live in black-and-white world.\n\n> [1]: Actually, we currently tie interactive diff coloring to \"diff &&\n> interactive\" which is even less useful. If I turn on color.interactive,\n> I still don't get colored diffs. But if I turn on color.diff, then\n> git-diff starts producing colored diffs. So you really can't represent\n> all choices, and I think the subdivision I outlined makes more sense (at\n> least it does to me).\n\nAnd my point was that I doubt the change is such a big\nimprovement, certainly not in the way your justification\nclaimed, _even though I agree_ that the current \"diff &&\ninteractive\" way may not be something many people would want (by\nthe way, it happens to cover my preference, but that only means\nI am a minority).  Neither covers all cases, and as I said, I do\nnot think more flexibility to cover all cases is necessarily a\ngood thing to shoot for.\n\nAlso there is another confusion factor we haven't discussed.\n\nTo an end user, the fact that \"git add -p\" shows diff using the\nunderlying \"git diff\" machinery does not matter.  That's just an\nimplementation detail.  \"git diff\" shows the whole diff at once\nwhile \"git add -p\" shows it hunk by hunk.  It is clear they are\ndoing different things to the end user.  If he told \"git add -p\"\nto be monochrome, he has every right to expect the part to pick\nhunks to also stay monochrome.  To people who know the internal\nimplementation, it might be natural to expect the color.diff\nconfiguration variable to affect the colouring of the hunk\npicker.  To others, it is counterintuitive if color.diff had any\neffect to what \"git add -i\" did.\n\n> That being said, all of those knobs _are_ confusing. In my case, I like\n> color. I just don't like the colors that color.interactive provides, so\n> I don't want to use them.  However, you can tune that quite a bit by\n> changing color.interactive.* (and just choosing \"plain\" for things you\n> don't want marked).\n\nYes, I 100% agree with you that they are confusing, and being to\nable to futz with color.interactive.* palette would probably\nalleviate the need to have color.{diff,interactive,status,etc}.\n\n> ... Of course that still doesn't allow you to have\n> _different_ color settings between the diffs of git-diff and those of\n> git-add--interactive. But then, my point is that I don't think sane\n> users want that. They either want diffs colored or they don't, no matter\n> what command is producing them.\n\nThat point I would agree with you but only 70%.  No sane user\nwould want deleted lines in red in \"git diff\" output and in\npurple in hunk picker.  But I think it is reasonable to want to\nview them in monochrome while in hunk picker (by setting\ncolor.*.old to plain) but in red in normal diff output.\n\nPerhaps a saner alternative would be:\n\n * When color.interactive tells to use color, all interaction\n   with \"add -i\" will be in color.  There is no need to have\n   both color.diff and color.interactive set.\n\n * When color.interactive tells not to use color, everything\n   including the diff output will be monochrome.  What you have\n   in color.diff does not matter.\n\n * We could allow color.interactive.* pallete to have elements\n   that are parallel to color.diff.* palette to be used while\n   showing the colored diff.  But this would be a low priority\n   because (1) a custom setting to anything but \"plain\" does not\n   make much practical sense, as it is just introducing needless\n   inconsistency between \"git diff\" and the hunk picker, and (2)\n   custom setting to \"plain\" would be used by people who like\n   colored \"git add -i\" prompts but not colored hunk picker,\n   which would be a minority.\n\nThe point of the third item is that you enable color.interactive\nand set diff related entries of color.interactive.* palette to\nplain, if you want some color while interacting with \"add -i\"\nbut do not like colored hunk picker.  This would parallel the\nway you can selectively enable coloring in \"git diff\" output,\nwhere you enable color.diff and set metainfo color to plain if\nyou want some color in diff output but do not like colored\nmetainfo.\n\nAdmittedly, it's more work.\n"},{"id":"64513","messageId":"20080105085113.GA30598@coredump.intra.peff.net","threadId":"11466","inReplyTo":"7vk5mod7kg.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] add--interactive: allow diff colors without interactive colors","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-01-05T08:51:13Z","receivedAt":"2008-01-05T08:51:13Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jan 05, 2008 at 12:01:51AM -0800, Junio C Hamano wrote:\n\n> I think I understood that part.  What I was saying was that it\n> is equally valid for other people to say \"I like to interact\n> with 'git add -i' without colours because coloured output\n> distracts me when I have to think, even though I usually want to\n> view the whole diff in colours.\"  So yes, color.interactive-diff\n\nRight. My contention is that I think such people will be in the minority\n(though obviously I have no numbers to back it up, and nobody else is\nparticipating in this thread).\n\n> To an end user, the fact that \"git add -p\" shows diff using the\n> underlying \"git diff\" machinery does not matter.  That's just an\n> implementation detail.\n\nBut he doesn't have to care about that. He cares only that \"color.diff\"\nmeans \"diffs are displayed in color.\" And \"color.interactive\" means\n\"interactive menus are displayed in color.\" Period. There is no concern\nfor the implementation detail of the diff machinery.\n\n> \"git diff\" shows the whole diff at once while \"git add -p\" shows it\n> hunk by hunk.  It is clear they are doing different things to the end\n> user.\n\nI don't see that distinction as relevant. Diffs are diffs, whether you\nlook at them with a small viewport or the whole thing. Would you expect\n\"git diff -- file1 file2\" to have different display options than \"git\ndiff -- file\"?\n\n> If he told \"git add -p\" to be monochrome, he has every right to expect\n> the part to pick hunks to also stay monochrome.  To people who know\n\nBut he didn't. He said \"git menus should be monochrome.\"\n\nAnd yes, that's not exactly what config.txt says that color.interactive\ndoes; but I think that is probably worth fixing.\n\n> picker.  To others, it is counterintuitive if color.diff had any\n> effect to what \"git add -i\" did.\n\nThen why does it affect what \"git log\" does? Why does it affect what\n\"git reflog\" does? Why does the documentation for color.diff say \"use\ncolors in patch\" without any reference to specific programs?\n\n> Perhaps a saner alternative would be:\n> \n>  * When color.interactive tells to use color, all interaction\n>    with \"add -i\" will be in color.  There is no need to have\n>    both color.diff and color.interactive set.\n> \n>  * When color.interactive tells not to use color, everything\n>    including the diff output will be monochrome.  What you have\n>    in color.diff does not matter.\n\nI think this is equally confusing. A user who sets color.diff will see\ncolor diffs from all porcelains _except_ \"add -i\".\n\nMoreover, this doesn't allow \"I always want color in diffs, but I don't\nwant menu coloring\" which is the very thing I have been trying to\naccomplish (but yes, I can do that by individually setting\ncolor.interactive.* to plain).\n\n> The point of the third item is that you enable color.interactive\n> and set diff related entries of color.interactive.* palette to\n> plain, if you want some color while interacting with \"add -i\"\n> but do not like colored hunk picker.  This would parallel the\n> way you can selectively enable coloring in \"git diff\" output,\n> where you enable color.diff and set metainfo color to plain if\n> you want some color in diff output but do not like colored\n> metainfo.\n\nI fail to see how this is less confusing than just adding a separate\ninteractive-diff knob, since you are asking them to individually set\neach color preference to plain. I.e., \"set color.interactive to true and\ncolor.interactive-diff to false\" versus \"set color.interactive to true,\nbut then for every type of diff colorization, set the color for it in\ncolor.interactive.* to false\".\n\nI think the extra knob is not a problem; it is simply a matter of\ndefaulting the knobs based on other knobs. The rules for knobs\ninteracting may seem complex, but I think we can DWIM. E.g., given\nconfig options:\n\n  - color\n  - color.diff\n  - color.interactive\n  - color.interactive.diff\n\nThe rules for \"git add -i\" diff coloring would be:\n\n  (1) if color.interactive.diff is set to TRUE/FALSE, use that\n  (2) otherwise, if color.interactive is set to TRUE/FALSE, use that\n  (3) otherwise, if color.diff is set to TRUE/FALSE, use that\n  (4) otherwise, if color is set to TRUE/FALSE, use that\n\nIOW, even though we _have_ all of those knobs, users which don't want to\nfine-tune can just use the higher-level knobs. Those that want to can\nnegate the higher level with lower level knobs. It's flexible, and it's\neasy to tell users \"just do 'git config color true'.\"\n\n> Admittedly, it's more work.\n\nOf course. ;) But I am willing to implement what I said above if you\nagree that it is sensible.\n\n-Peff\n"},{"id":"64518","messageId":"7v3atcd3k6.fsf@gitster.siamese.dyndns.org","threadId":"11466","inReplyTo":"20080105085113.GA30598@coredump.intra.peff.net","subject":"Re: [PATCH] add--interactive: allow diff colors without interactive colors","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-05T09:28:25Z","receivedAt":"2008-01-05T09:28:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> But he doesn't have to care about that. He cares only that \"color.diff\"\n> means \"diffs are displayed in color.\" And \"color.interactive\" means\n> \"interactive menus are displayed in color.\"\n> ...\n>> If he told \"git add -p\" to be monochrome, he has every right to expect\n>> the part to pick hunks to also stay monochrome.  To people who know\n>\n> But he didn't. He said \"git menus should be monochrome.\"\n\nWho said anything about \"interactive is limited to interactive\nmenus\" anywhere?  That is where we differ and what you do not\nseem to be getting.  I am talking about color.interactive that\ncontrols the whole user experience of interacting with \"add -i\".\n\n> Moreover, this doesn't allow \"I always want color in diffs,\n> but I don't want menu coloring\" which is the very thing I have\n> been trying to accomplish (but yes, I can do that by\n> individually setting color.interactive.* to plain).\n\nAs you said earlier you may also be minority, but yes the color\npallette would help you do that.\n\n> I fail to see how this is less confusing than just adding a separate\n> interactive-diff knob, since you are asking them to individually set\n> each color preference to plain.\n\nWhat I am aiming at in longer term is to simplify things this way:\n\n * Users are categorized broadly into two groups.  The ones who\n   like colours and the ones who don't want colours at all.\n   color.git would control this (with backward compatibility\n   options per command such as color.diff and\n   color.interactive);\n\n * Minorities who want to disable colours for particular parts\n   of the UI have enough knobs to tweak in the form of palettes.\n   By definition this needs to address \"particular parts\", so\n   \"color.$command.$context\" variables (e.g. color.diff.new,\n   color.interactive.new; if somebody really really wants to\n   have different settings between diff/show/log, that person\n   could add color.{show,log}.new as well) are needed if we want\n   to do this.\n\n> E.g., given\n> config options:\n> ...\n>> Admittedly, it's more work.\n>\n> Of course. ;) But I am willing to implement what I said above if you\n> agree that it is sensible.\n\nI think we share the ultimate goal of introducing higher level\nknobs and our difference is just about minor details of how to\nget there and what the intermediate levels look like.\n\nI am trying to avoid introducing new intermediate level knobs\n(e.g. color.log vs color.diff), as it is enough to disable or in\ngeneral change the way particular parts of the UI is coloured by\npalette setting that specifically states which part of the UI is\ntweaked (e.g. color.interactive.prompt).\n"},{"id":"64521","messageId":"20080105095743.GA31220@coredump.intra.peff.net","threadId":"11466","inReplyTo":"7v3atcd3k6.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] add--interactive: allow diff colors without interactive colors","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-01-05T09:57:44Z","receivedAt":"2008-01-05T09:57:44Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jan 05, 2008 at 01:28:25AM -0800, Junio C Hamano wrote:\n\n> Who said anything about \"interactive is limited to interactive\n> menus\" anywhere?  That is where we differ and what you do not\n> seem to be getting.  I am talking about color.interactive that\n> controls the whole user experience of interacting with \"add -i\".\n\nI did, just now. I am \"getting\" it just fine, but am trying to propose\nan equally valid, and IMHO more useful, semantic for\n\"color.interactive.\" (which btw, is a horrible name if you truly mean\n\"the behavior of git add -i\" since there are _other_ interactive\ncommands. Why doesn't it turn on color for git-rebase -i?).\n\n> What I am aiming at in longer term is to simplify things this way:\n> \n>  * Users are categorized broadly into two groups.  The ones who\n>    like colours and the ones who don't want colours at all.\n>    color.git would control this (with backward compatibility\n>    options per command such as color.diff and\n>    color.interactive);\n\nOK, that makes sense. But I disagree somewhat with the phrase \"backward\ncompatibility.\"\n\n>  * Minorities who want to disable colours for particular parts\n>    of the UI have enough knobs to tweak in the form of palettes.\n\nThey do, but those knobs are a pain to use. Why are we making it so hard\nfor them when we _already_ have the nice knobs for them to use. IOW, for\nthese users, git after this change will be _more_ annoying to use. Not\nto mention that we must keep those other knobs around for historical\nreasons for some amount of time.\n\nWhy not just add the higher-level knob and leave the existing ones\n(using the priority scheme I mentioned in my last mail)?\n\n>    By definition this needs to address \"particular parts\", so\n>    \"color.$command.$context\" variables (e.g. color.diff.new,\n>    color.interactive.new; if somebody really really wants to\n>    have different settings between diff/show/log, that person\n>    could add color.{show,log}.new as well) are needed if we want\n>    to do this.\n\nSure. Though like you said previously, I think in 99% of cases, nobody\nis going to set these to something exotic; they're going to set them all\not their custom colors, or all to \"plain\". In which case, we are just\nmaking work for them by not providing \"color.show = false\".\n\n> I am trying to avoid introducing new intermediate level knobs\n> (e.g. color.log vs color.diff), as it is enough to disable or in\n> general change the way particular parts of the UI is coloured by\n> palette setting that specifically states which part of the UI is\n> tweaked (e.g. color.interactive.prompt).\n\nIt is \"enough\" but I don't think it is the sensible goal. I respect your\ndesire to keep knobs to a minimum. But I think the fact that we can\nsplit these color knobs into \"dead simple, color = true\" and \"advanced,\nsuper-picky color options\" in the documentation makes it less of an\nissue.\n\nAnyway, almost none of this is pre-1.5.4. The one thing which is, IMHO,\nis the semantics of color.interactive (since it has not yet been\nreleased, this is the best time to set it). I will summarize my stance,\nand you can do what you will. Beyond that, this discussion has already\ntaken way more time than this change is worth.\n\nMy opinion is that color.diff should be respected in \"git-add -i\"\nregardless of color.interactive because:\n  - the color.diff setting controls diffs in all porcelain parts of git\n    (diff, log, show, reflog)\n  - parts of diffs are the same as diffs. Thus, hunks should in\n    general be treated like diffs for presentation.\n  - splitting color by functionality (i.e., diff versus menus) is\n    therefore more consistent with the rest of git than splitting it by\n    program (\"git add -i\" versus \"git diff\")\n  - I also happen to think that users are more likely to find \"split by\n    functionality\" useful, but neither of us has relevant data\n    (except that you seemed to indicate that's what you would find more\n    useful, and that's what I find more useful. So it's 2-0, and clearly\n    statistically significant :) ).\n\nSo if you are swayed by that, then please apply my previous patch, and\nconsider the documentation patch below. And if not, let me know and I\nwill begin changing my color.interactive.* config. :)\n\n-- >8 --\nClarify color.interactive documentation\n\nThere are two possible confusions with the color.interactive\ndescription:\n\n  1. the short name \"interactive\" implies that it covers all\n     interactive commands; let's explicitly make it so, even\n     though there are no other interactive commands which\n     currently use it\n\n  2. Not all parts of \"git add --interactive\" are controlled\n     by color.interactive (specifically, the diffs require\n     tweaking color.diff). So let's clarify that it applies\n     only to displays and prompts.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n Documentation/config.txt |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex e1eaee9..8907e16 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -406,7 +406,8 @@ color.diff.<slot>::\n \tin color.branch.<slot>.\n \n color.interactive::\n-\tWhen set to `always`, always use colors in `git add --interactive`.\n+\tWhen set to `always`, always use colors for interactive prompts\n+\tand displays (such as those used by \"git add --interactive\").\n \tWhen false (or `never`), never.  When set to `true` or `auto`, use\n \tcolors only when the output is to the terminal. Defaults to false.\n \n-- \n1.5.4.rc2.1125.ga305e-dirty\n"},{"id":"64524","messageId":"1199530684.6209.6.camel@futex","threadId":"11466","inReplyTo":"7v3atdi0na.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH/resend] add--interactive: allow diff colors without interactive colors","fromName":"Matthias Kestenholz","fromEmail":"mk@spinlock.ch","sentAt":"2008-01-05T10:58:04Z","receivedAt":"2008-01-05T10:58:04Z","isPatch":true,"sender":{"key":"matthias@spinlock.ch","avatar":"https://gravatar.com/avatar/bc18f396e70163d09ab458a341b1decb7e8b6ee3aa2c0c954ec20162e67c4d46?d=mp&s=160"},"body":"(trying to resend because vger.kernel.org would not let the previous\nemail pass to the list. I am very sorry. The Evolution MUA is making\ntrouble.)\n\nOn Fri, 2008-01-04 at 16:20 -0800, Junio C Hamano wrote:\n> Jeff King <peff@peff.net> writes:\n> \n> > Users with color.diff set to true/auto will not see color in\n> > \"git add -i\" unless they also set color.interactive.\n> >\n> > However, some users may want just one without the other, so\n> > there's no reason to tie them together.\n> >\n> > Note that there is now no way to have color on for \"git\n> > diff\" but not for diffs from \"git add -i\"; such a\n> > configuration seems unlikely, though.\n> \n> Although I would agree with what this patch does, I think you\n> are contradicting with yourself in the above justification.\n> Some users may want to color \"git diff\" output but not\n> interaction with \"git add -i\", and that's also \"just one without\n> the other\", but you just tied them together, only differently,\n> and \"seems unlikely\" is a rather weak excuse.\n> \n> The justification should instead be: having more independent\n> knobs is not necessarily better.  The user should not have to\n> tweak too many knobs.\n> \n> In the longer term, I think we should try reducing the number of\n> knobs by giving \"color.git\" that allows you to pretend as if all\n> of the \"color.interactive\", \"color.diff\", \"color.status\",\n> \"color.someothercolorizedcommand\" are all set.  I do not think\n> being able to control the use of colors per command is giving\n> much other than confusion to the user.\n> \n> That may not be so easy with the current structure of the config\n> reader, though.\n\nI managed to throw something together which works and passes all\nthe tests. Documentation included. :-)\n\nI would be happy for feedback and suggestions.\n\n-- 8< --\n\n>From 90663fa5a7ac1a59d74aab3aa4d2bd8397340bd4 Mon Sep 17 00:00:00 2001\nFrom: Matthias Kestenholz <matthias@spinlock.ch>\nDate: Sat, 5 Jan 2008 11:20:08 +0100\nSubject: [PATCH] Add global color config switch color.git\n\nSigned-off-by: Matthias Kestenholz <matthias@spinlock.ch>\n---\n Documentation/config.txt  |    6 ++++++\n builtin-branch.c          |    4 ++--\n builtin-log.c             |    3 ++-\n cache.h                   |    1 +\n color.c                   |   12 ++++++++++++\n color.h                   |    3 +++\n diff.c                    |    4 ++--\n git-add--interactive.perl |    4 ++--\n wt-status.c               |    4 ++--\n 9 files changed, 32 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex ee08845..0a40102 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -405,6 +405,12 @@ color.diff.<slot>::\n \twhitespace errors). The values of these variables may be specified as\n \tin color.branch.<slot>.\n \n+color.git::\n+\tWhen set to `always`, always use colors in all git commands which\n+\tare capable of colored output. When false (or `never`), never. When\n+\tset to `true` or `auto`, use colors only when the output is to the\n+\tterminal. Defaults to false.\n+\n color.interactive::\n \tWhen set to `always`, always use colors in `git add --interactive`.\n \tWhen false (or `never`), never.  When set to `true` or `auto`, use\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 089cae5..8179938 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -76,12 +76,12 @@ static int git_branch_config(const char *var, const char *value)\n \tif (!strcmp(var, \"branch.autosetupmerge\"))\n \t\t\tbranch_track = git_config_bool(var, value);\n \n-\treturn git_default_config(var, value);\n+\treturn git_use_color_config(var, value) || git_default_config(var, value);\n }\n \n static const char *branch_get_color(enum color_branch ix)\n {\n-\tif (branch_use_color)\n+\tif (branch_use_color || git_use_color)\n \t\treturn branch_colors[ix];\n \treturn \"\";\n }\ndiff --git a/builtin-log.c b/builtin-log.c\nindex dcc9f81..03ba732 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -436,7 +436,8 @@ static int git_format_config(const char *var, const char *value)\n \t\tfmt_patch_suffix = xstrdup(value);\n \t\treturn 0;\n \t}\n-\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\")) {\n+\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\")\n+\t\t\t|| !strcmp(var, \"color.git\")) {\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"format.numbered\")) {\ndiff --git a/cache.h b/cache.h\nindex 39331c2..0968551 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -329,6 +329,7 @@ extern size_t packed_git_window_size;\n extern size_t packed_git_limit;\n extern size_t delta_base_cache_limit;\n extern int auto_crlf;\n+extern int git_use_color;\n \n #define GIT_REPO_VERSION 0\n extern int repository_format_version;\ndiff --git a/color.c b/color.c\nindex 7f66c29..c891fd8 100644\n--- a/color.c\n+++ b/color.c\n@@ -3,6 +3,8 @@\n \n #define COLOR_RESET \"\\033[m\"\n \n+int git_use_color = 0;\n+\n static int parse_color(const char *name, int len)\n {\n \tstatic const char * const color_names[] = {\n@@ -143,6 +145,16 @@ int git_config_colorbool(const char *var, const char *value, int stdout_is_tty)\n \treturn 0;\n }\n \n+int git_use_color_config(const char *var, const char *value)\n+{\n+\tif(!strcmp(var, \"color.git\")) {\n+\t\tgit_use_color = git_config_colorbool(var, value, -1);\n+\t\treturn 1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int color_vfprintf(FILE *fp, const char *color, const char *fmt,\n \t\tva_list args, const char *trail)\n {\ndiff --git a/color.h b/color.h\nindex ff63513..929ebf2 100644\n--- a/color.h\n+++ b/color.h\n@@ -4,7 +4,10 @@\n /* \"\\033[1;38;5;2xx;48;5;2xxm\\0\" is 23 bytes */\n #define COLOR_MAXLEN 24\n \n+extern int git_use_color;\n+\n int git_config_colorbool(const char *var, const char *value, int stdout_is_tty);\n+int git_use_color_config(const char *var, const char *value);\n void color_parse(const char *var, const char *value, char *dst);\n int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);\n int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);\ndiff --git a/diff.c b/diff.c\nindex 5bdc111..5fa6d14 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -184,7 +184,7 @@ int git_diff_ui_config(const char *var, const char *value)\n \t\treturn 0;\n \t}\n \n-\treturn git_default_config(var, value);\n+\treturn git_use_color_config(var, value) || git_default_config(var, value);\n }\n \n static char *quote_two(const char *one, const char *two)\n@@ -2021,7 +2021,7 @@ void diff_setup(struct diff_options *options)\n \n \toptions->change = diff_change;\n \toptions->add_remove = diff_addremove;\n-\tif (diff_use_color_default)\n+\tif (diff_use_color_default || git_use_color)\n \t\tDIFF_OPT_SET(options, COLOR_DIFF);\n \telse\n \t\tDIFF_OPT_CLR(options, COLOR_DIFF);\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 0cdd800..eaae888 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -11,7 +11,7 @@ my ($new_color, $old_color, $fraginfo_color, $metainfo_color, $whitespace_color)\n my ($use_color, $diff_use_color);\n my $repo = Git->repository();\n \n-$use_color = $repo->get_colorbool('color.interactive');\n+$use_color = $repo->get_colorbool('color.interactive') || $repo->get_colorbool('color.git');\n \n if ($use_color) {\n \t# Set interactive colors:\n@@ -24,7 +24,7 @@ if ($use_color) {\n \t$normal_color = $repo->get_color(\"\", \"reset\");\n \n \t# Do we also set diff colors?\n-\t$diff_use_color = $repo->get_colorbool('color.diff');\n+\t$diff_use_color = $repo->get_colorbool('color.diff') || $repo->get_colorbool('color.git');\n \tif ($diff_use_color) {\n \t\t$new_color = $repo->get_color(\"color.diff.new\", \"green\");\n \t\t$old_color = $repo->get_color(\"color.diff.old\", \"red\");\ndiff --git a/wt-status.c b/wt-status.c\nindex c0c2472..1c4169c 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -40,7 +40,7 @@ static int parse_status_slot(const char *var, int offset)\n \n static const char* color(int slot)\n {\n-\treturn wt_status_use_color ? wt_status_colors[slot] : \"\";\n+\treturn wt_status_use_color || git_use_color ? wt_status_colors[slot] : \"\";\n }\n \n void wt_status_prepare(struct wt_status *s)\n@@ -409,5 +409,5 @@ int git_status_config(const char *k, const char *v)\n \t\twt_status_relative_paths = git_config_bool(k, v);\n \t\treturn 0;\n \t}\n-\treturn git_default_config(k, v);\n+\treturn git_use_color_config(k, v) || git_default_config(k, v);\n }\n-- \n1.5.4.rc2.1105.g90663f\n"},{"id":"64526","messageId":"7vd4sga5n6.fsf@gitster.siamese.dyndns.org","threadId":"11466","inReplyTo":"1199530684.6209.6.camel@futex","subject":"Re: [PATCH/resend] add--interactive: allow diff colors without interactive colors","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-01-05T11:11:41Z","receivedAt":"2008-01-05T11:11:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Kestenholz <mk@spinlock.ch> writes:\n\n> I managed to throw something together which works and passes all\n> the tests. Documentation included. :-)\n\nIs it because we do not usually test colours and the tests run\nwithout terminals to make sure \"color.* = auto\" does not kick\nin?\n\n> I would be happy for feedback and suggestions.\n\n * Shouldn't \"color.git = true\" with \"color.diff = false\" mean\n   \"I want colour for everything by default but I do not want to\n   see coloured diff\"?\n\n * git_foo_config() callback from git_config() returns 0 on\n   success; the API change needs to be documented to warn\n   others.\n\nI haven't studied your patch very deeply so I may have misread\nwhat you tried to do, regarding the first point, though.\n"},{"id":"64527","messageId":"flnq4s$ujt$1@ger.gmane.org","threadId":"11466","inReplyTo":"1199530684.6209.6.camel@futex","subject":"Re: [PATCH/resend] add--interactive: allow diff colors without interactive colors","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-01-05T11:37:07Z","receivedAt":"2008-01-05T11:37:07Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Matthias Kestenholz wrote:\n\n> +color.git::\n> +       When set to `always`, always use colors in all git commands which\n> +       are capable of colored output. When false (or `never`), never. When\n> +       set to `true` or `auto`, use colors only when the output is to the\n> +       terminal. Defaults to false.\n> +\n\nNot \"color.ui\"?\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"64529","messageId":"1199542226.6209.34.camel@futex","threadId":"11466","inReplyTo":"7vd4sga5n6.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH/resend] add--interactive: allow diff colors without interactive colors","fromName":"Matthias Kestenholz","fromEmail":"mk@spinlock.ch","sentAt":"2008-01-05T14:10:26Z","receivedAt":"2008-01-05T14:10:26Z","isPatch":true,"sender":{"key":"matthias@spinlock.ch","avatar":"https://gravatar.com/avatar/bc18f396e70163d09ab458a341b1decb7e8b6ee3aa2c0c954ec20162e67c4d46?d=mp&s=160"},"body":"On Sat, 2008-01-05 at 03:11 -0800, Junio C Hamano wrote:\n> Matthias Kestenholz <mk@spinlock.ch> writes:\n> \n> > I managed to throw something together which works and passes all\n> > the tests. Documentation included. :-)\n> \n> Is it because we do not usually test colours and the tests run\n> without terminals to make sure \"color.* = auto\" does not kick\n> in?\n> \n\nProbably, yes. I've to confess that I have not thought too much about\nhow color output could be tested. \n\n> > I would be happy for feedback and suggestions.\n> \n>  * Shouldn't \"color.git = true\" with \"color.diff = false\" mean\n>    \"I want colour for everything by default but I do not want to\n>    see coloured diff\"?\n> \n\nThis works with the new patch below.\n\n>  * git_foo_config() callback from git_config() returns 0 on\n>    success; the API change needs to be documented to warn\n>    others.\n> \n\nI've changed the config reader. It behaves like the others now.\n\n> I haven't studied your patch very deeply so I may have misread\n> what you tried to do, regarding the first point, though.\n\nStill missing are the updates for git add -i and git svn.\n\n\nI have added a new function git_color_config() which should be called\nafter git_config() has finished its work. The function needs to run when\nall config reading has been done, because otherwise the color setup\nwould be sensitive to the order in which the variables are placed in the\nconfig file, which I'd rather avoid.\n\nI've also unified the colorbool variables, because otherwise the\nindividual colorbool variables would need to be exported into other C\nfiles, and I don't see the point of multiple colorbools anyway.\n\nThe patch got somewhat big, therefore I've splitted it up into several\npieces:\n\n[PATCH 1/4] Add infrastructure for a single color config variable\n﻿[PATCH 2/4] git branch: Use color configuration infrastructure\n﻿[PATCH 3/4] status and commit: Use color configuration infrastructure\n﻿[PATCH 4/4] diff and log: Use color configuration infrastructure\n"},{"id":"64532","messageId":"1199542299-12082-1-git-send-email-mk@spinlock.ch","threadId":"11466","inReplyTo":"1199542226.6209.34.camel@futex","subject":"[PATCH 1/4] Add infrastructure for a single color config variable","fromName":"Matthias Kestenholz","fromEmail":"mk@spinlock.ch","sentAt":"2008-01-05T14:11:36Z","receivedAt":"2008-01-05T14:11:36Z","isPatch":true,"sender":{"key":"matthias@spinlock.ch","avatar":"https://gravatar.com/avatar/bc18f396e70163d09ab458a341b1decb7e8b6ee3aa2c0c954ec20162e67c4d46?d=mp&s=160"},"body":"From: Matthias Kestenholz <matthias@spinlock.ch>\n\nSigned-off-by: Matthias Kestenholz <matthias@spinlock.ch>\n---\n Documentation/config.txt |    6 ++++++\n color.c                  |   19 +++++++++++++++++++\n color.h                  |   17 +++++++++++++++++\n 3 files changed, 42 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex ee08845..4bebd47 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -438,6 +438,12 @@ color.status.<slot>::\n commit.template::\n \tSpecify a file to use as the template for new commit messages.\n \n+color.ui::\n+\tWhen set to `always`, always use colors in all git commands which\n+\tare capable of colored output. When false (or `never`), never. When\n+\tset to `true` or `auto`, use colors only when the output is to the\n+\tterminal. Defaults to false.\n+\n diff.autorefreshindex::\n \tWhen using `git diff` to compare with work tree\n \tfiles, do not consider stat-only change as changed.\ndiff --git a/color.c b/color.c\nindex 7f66c29..0792571 100644\n--- a/color.c\n+++ b/color.c\n@@ -3,6 +3,9 @@\n \n #define COLOR_RESET \"\\033[m\"\n \n+int git_use_color = -1;\n+int git_use_color_default = -1;\n+\n static int parse_color(const char *name, int len)\n {\n \tstatic const char * const color_names[] = {\n@@ -143,6 +146,22 @@ int git_config_colorbool(const char *var, const char *value, int stdout_is_tty)\n \treturn 0;\n }\n \n+int git_color_default_config(const char *var, const char *value)\n+{\n+\tif (!strcmp(var, \"color.ui\")) {\n+\t\tgit_use_color_default = git_config_colorbool(var, value, -1);\n+\t\treturn 0;\n+\t}\n+\n+\treturn git_default_config(var, value);\n+}\n+\n+void git_color_config()\n+{\n+\tif (git_use_color == -1 && git_use_color_default != -1)\n+\t\tgit_use_color = git_use_color_default;\n+}\n+\n static int color_vfprintf(FILE *fp, const char *color, const char *fmt,\n \t\tva_list args, const char *trail)\n {\ndiff --git a/color.h b/color.h\nindex ff63513..bcb845d 100644\n--- a/color.h\n+++ b/color.h\n@@ -4,7 +4,24 @@\n /* \"\\033[1;38;5;2xx;48;5;2xxm\\0\" is 23 bytes */\n #define COLOR_MAXLEN 24\n \n+/*\n+ * Use this variable to store the colorbool when reading from the config file.\n+ */\n+extern int git_use_color;\n+\n int git_config_colorbool(const char *var, const char *value, int stdout_is_tty);\n+\n+/*\n+ * Use this instead of git_default_config if you need the value of color.ui.\n+ */\n+int git_color_default_config(const char *var, const char *value);\n+\n+/*\n+ * Call this function after git_config(config_fn_t fn) to set git_use_color,\n+ * respecting the value of color.ui.\n+ */\n+void git_color_config();\n+\n void color_parse(const char *var, const char *value, char *dst);\n int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);\n int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);\n-- \n1.5.4.rc2.1104.gec8ae5-dirty\n"},{"id":"64533","messageId":"1199542299-12082-2-git-send-email-mk@spinlock.ch","threadId":"11466","inReplyTo":"1199542299-12082-1-git-send-email-mk@spinlock.ch","subject":"[PATCH 2/4] git branch: Use color configuration infrastructure","fromName":"Matthias Kestenholz","fromEmail":"mk@spinlock.ch","sentAt":"2008-01-05T14:11:37Z","receivedAt":"2008-01-05T14:11:37Z","isPatch":true,"sender":{"key":"matthias@spinlock.ch","avatar":"https://gravatar.com/avatar/bc18f396e70163d09ab458a341b1decb7e8b6ee3aa2c0c954ec20162e67c4d46?d=mp&s=160"},"body":"From: Matthias Kestenholz <matthias@spinlock.ch>\n\nSigned-off-by: Matthias Kestenholz <matthias@spinlock.ch>\n---\n builtin-branch.c |   11 ++++++-----\n 1 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 089cae5..448144f 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -31,7 +31,6 @@ static unsigned char head_sha1[20];\n \n static int branch_track = 1;\n \n-static int branch_use_color;\n static char branch_colors[][COLOR_MAXLEN] = {\n \t\"\\033[m\",\t/* reset */\n \t\"\",\t\t/* PLAIN (normal) */\n@@ -65,7 +64,7 @@ static int parse_branch_color_slot(const char *var, int ofs)\n static int git_branch_config(const char *var, const char *value)\n {\n \tif (!strcmp(var, \"color.branch\")) {\n-\t\tbranch_use_color = git_config_colorbool(var, value, -1);\n+\t\tgit_use_color = git_config_colorbool(var, value, -1);\n \t\treturn 0;\n \t}\n \tif (!prefixcmp(var, \"color.branch.\")) {\n@@ -76,12 +75,12 @@ static int git_branch_config(const char *var, const char *value)\n \tif (!strcmp(var, \"branch.autosetupmerge\"))\n \t\t\tbranch_track = git_config_bool(var, value);\n \n-\treturn git_default_config(var, value);\n+\treturn git_color_default_config(var, value);\n }\n \n static const char *branch_get_color(enum color_branch ix)\n {\n-\tif (branch_use_color)\n+\tif (git_use_color > 0)\n \t\treturn branch_colors[ix];\n \treturn \"\";\n }\n@@ -559,7 +558,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_GROUP(\"Generic options\"),\n \t\tOPT__VERBOSE(&verbose),\n \t\tOPT_BOOLEAN( 0 , \"track\",  &track, \"set up tracking mode (see git-pull(1))\"),\n-\t\tOPT_BOOLEAN( 0 , \"color\",  &branch_use_color, \"use colored output\"),\n+\t\tOPT_BOOLEAN( 0 , \"color\",  &git_use_color, \"use colored output\"),\n \t\tOPT_SET_INT('r', NULL,     &kinds, \"act on remote-tracking branches\",\n \t\t\tREF_REMOTE_BRANCH),\n \t\tOPT_CALLBACK(0, \"contains\", &with_commit, \"commit\",\n@@ -585,6 +584,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t};\n \n \tgit_config(git_branch_config);\n+\tgit_color_config();\n+\n \ttrack = branch_track;\n \targc = parse_options(argc, argv, options, builtin_branch_usage, 0);\n \tif (!!delete + !!rename + !!force_create > 1)\n-- \n1.5.4.rc2.1104.gec8ae5-dirty\n"},{"id":"64531","messageId":"1199542299-12082-3-git-send-email-mk@spinlock.ch","threadId":"11466","inReplyTo":"1199542299-12082-2-git-send-email-mk@spinlock.ch","subject":"[PATCH 3/4] status and commit: Use color configuration infrastructure","fromName":"Matthias Kestenholz","fromEmail":"mk@spinlock.ch","sentAt":"2008-01-05T14:11:38Z","receivedAt":"2008-01-05T14:11:38Z","isPatch":true,"sender":{"key":"matthias@spinlock.ch","avatar":"https://gravatar.com/avatar/bc18f396e70163d09ab458a341b1decb7e8b6ee3aa2c0c954ec20162e67c4d46?d=mp&s=160"},"body":"From: Matthias Kestenholz <matthias@spinlock.ch>\n\nSigned-off-by: Matthias Kestenholz <matthias@spinlock.ch>\n---\n builtin-commit.c |    8 +++++---\n wt-status.c      |    7 +++----\n wt-status.h      |    1 -\n 3 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 73f1e35..e442b5f 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -7,6 +7,7 @@\n \n #include \"cache.h\"\n #include \"cache-tree.h\"\n+#include \"color.h\"\n #include \"dir.h\"\n #include \"builtin.h\"\n #include \"diff.h\"\n@@ -435,10 +436,10 @@ static int prepare_log_message(const char *index_file, const char *prefix)\n \tif (only_include_assumed)\n \t\tfprintf(fp, \"# %s\\n\", only_include_assumed);\n \n-\tsaved_color_setting = wt_status_use_color;\n-\twt_status_use_color = 0;\n+\tsaved_color_setting = git_use_color;\n+\tgit_use_color = 0;\n \tcommitable = run_status(fp, index_file, prefix, 1);\n-\twt_status_use_color = saved_color_setting;\n+\tgit_use_color = saved_color_setting;\n \n \tfclose(fp);\n \n@@ -639,6 +640,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tint commitable;\n \n \tgit_config(git_status_config);\n+\tgit_color_config();\n \n \targc = parse_and_validate_options(argc, argv, builtin_status_usage);\n \ndiff --git a/wt-status.c b/wt-status.c\nindex c0c2472..ebcbe5a 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -9,7 +9,6 @@\n #include \"diffcore.h\"\n \n int wt_status_relative_paths = 1;\n-int wt_status_use_color = 0;\n static char wt_status_colors[][COLOR_MAXLEN] = {\n \t\"\",         /* WT_STATUS_HEADER: normal */\n \t\"\\033[32m\", /* WT_STATUS_UPDATED: green */\n@@ -40,7 +39,7 @@ static int parse_status_slot(const char *var, int offset)\n \n static const char* color(int slot)\n {\n-\treturn wt_status_use_color ? wt_status_colors[slot] : \"\";\n+\treturn git_use_color > 0 ? wt_status_colors[slot] : \"\";\n }\n \n void wt_status_prepare(struct wt_status *s)\n@@ -397,7 +396,7 @@ void wt_status_print(struct wt_status *s)\n int git_status_config(const char *k, const char *v)\n {\n \tif (!strcmp(k, \"status.color\") || !strcmp(k, \"color.status\")) {\n-\t\twt_status_use_color = git_config_colorbool(k, v, -1);\n+\t\tgit_use_color = git_config_colorbool(k, v, -1);\n \t\treturn 0;\n \t}\n \tif (!prefixcmp(k, \"status.color.\") || !prefixcmp(k, \"color.status.\")) {\n@@ -409,5 +408,5 @@ int git_status_config(const char *k, const char *v)\n \t\twt_status_relative_paths = git_config_bool(k, v);\n \t\treturn 0;\n \t}\n-\treturn git_default_config(k, v);\n+\treturn git_color_default_config(k, v);\n }\ndiff --git a/wt-status.h b/wt-status.h\nindex 02afaa6..05b05ba 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -28,7 +28,6 @@ struct wt_status {\n };\n \n int git_status_config(const char *var, const char *value);\n-int wt_status_use_color;\n int wt_status_relative_paths;\n void wt_status_prepare(struct wt_status *s);\n void wt_status_print(struct wt_status *s);\n-- \n1.5.4.rc2.1104.gec8ae5-dirty\n"},{"id":"64530","messageId":"1199542299-12082-4-git-send-email-mk@spinlock.ch","threadId":"11466","inReplyTo":"1199542299-12082-3-git-send-email-mk@spinlock.ch","subject":"[PATCH 4/4] diff and log: Use color configuration infrastructure","fromName":"Matthias Kestenholz","fromEmail":"mk@spinlock.ch","sentAt":"2008-01-05T14:11:39Z","receivedAt":"2008-01-05T14:11:39Z","isPatch":true,"sender":{"key":"matthias@spinlock.ch","avatar":"https://gravatar.com/avatar/bc18f396e70163d09ab458a341b1decb7e8b6ee3aa2c0c954ec20162e67c4d46?d=mp&s=160"},"body":"From: Matthias Kestenholz <matthias@spinlock.ch>\n\nSigned-off-by: Matthias Kestenholz <matthias@spinlock.ch>\n---\n builtin-diff.c |    2 ++\n builtin-log.c  |    9 ++++++++-\n diff.c         |    8 ++++----\n 3 files changed, 14 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-diff.c b/builtin-diff.c\nindex 29365a0..66c5896 100644\n--- a/builtin-diff.c\n+++ b/builtin-diff.c\n@@ -4,6 +4,7 @@\n  * Copyright (c) 2006 Junio C Hamano\n  */\n #include \"cache.h\"\n+#include \"color.h\"\n #include \"commit.h\"\n #include \"blob.h\"\n #include \"tag.h\"\n@@ -229,6 +230,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \n \tprefix = setup_git_directory_gently(&nongit);\n \tgit_config(git_diff_ui_config);\n+\tgit_color_config();\n \tinit_revisions(&rev, prefix);\n \trev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;\n \ndiff --git a/builtin-log.c b/builtin-log.c\nindex dcc9f81..c9a23fb 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -5,6 +5,7 @@\n  *\t\t 2006 Junio Hamano\n  */\n #include \"cache.h\"\n+#include \"color.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\n@@ -235,6 +236,7 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)\n \tstruct rev_info rev;\n \n \tgit_config(git_log_config);\n+\tgit_color_config();\n \tinit_revisions(&rev, prefix);\n \trev.diff = 1;\n \trev.simplify_history = 0;\n@@ -307,6 +309,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \tint i, count, ret = 0;\n \n \tgit_config(git_log_config);\n+\tgit_color_config();\n \tinit_revisions(&rev, prefix);\n \trev.diff = 1;\n \trev.combine_merges = 1;\n@@ -367,6 +370,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)\n \tstruct rev_info rev;\n \n \tgit_config(git_log_config);\n+\tgit_color_config();\n \tinit_revisions(&rev, prefix);\n \tinit_reflog_walk(&rev.reflog_info);\n \trev.abbrev_commit = 1;\n@@ -395,6 +399,7 @@ int cmd_log(int argc, const char **argv, const char *prefix)\n \tstruct rev_info rev;\n \n \tgit_config(git_log_config);\n+\tgit_color_config();\n \tinit_revisions(&rev, prefix);\n \trev.always_show_header = 1;\n \tcmd_log_init(argc, argv, prefix, &rev);\n@@ -436,7 +441,8 @@ static int git_format_config(const char *var, const char *value)\n \t\tfmt_patch_suffix = xstrdup(value);\n \t\treturn 0;\n \t}\n-\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\")) {\n+\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\")\n+\t\t\t|| !strcmp(var, \"color.ui\")) {\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"format.numbered\")) {\n@@ -630,6 +636,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tchar ref_message_id[1024];\n \n \tgit_config(git_format_config);\n+\tgit_color_config();\n \tinit_revisions(&rev, prefix);\n \trev.commit_format = CMIT_FMT_EMAIL;\n \trev.verbose_header = 1;\ndiff --git a/diff.c b/diff.c\nindex 5bdc111..ccc958e 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -19,7 +19,6 @@\n \n static int diff_detect_rename_default;\n static int diff_rename_limit_default = 100;\n-static int diff_use_color_default;\n static const char *external_diff_cmd_cfg;\n int diff_auto_refresh_index = 1;\n \n@@ -64,6 +63,7 @@ static void read_config_if_needed(void)\n \tif (!user_diff_tail) {\n \t\tuser_diff_tail = &user_diff;\n \t\tgit_config(git_diff_ui_config);\n+\t\tgit_color_config();\n \t}\n }\n \n@@ -147,7 +147,7 @@ int git_diff_ui_config(const char *var, const char *value)\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\")) {\n-\t\tdiff_use_color_default = git_config_colorbool(var, value, -1);\n+\t\tgit_use_color = git_config_colorbool(var, value, -1);\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"diff.renames\")) {\n@@ -184,7 +184,7 @@ int git_diff_ui_config(const char *var, const char *value)\n \t\treturn 0;\n \t}\n \n-\treturn git_default_config(var, value);\n+\treturn git_color_default_config(var, value);\n }\n \n static char *quote_two(const char *one, const char *two)\n@@ -2021,7 +2021,7 @@ void diff_setup(struct diff_options *options)\n \n \toptions->change = diff_change;\n \toptions->add_remove = diff_addremove;\n-\tif (diff_use_color_default)\n+\tif (git_use_color > 0)\n \t\tDIFF_OPT_SET(options, COLOR_DIFF);\n \telse\n \t\tDIFF_OPT_CLR(options, COLOR_DIFF);\n-- \n1.5.4.rc2.1104.gec8ae5-dirty\n"},{"id":"64725","messageId":"20080108112328.GA19941@coredump.intra.peff.net","threadId":"11466","inReplyTo":"1199542299-12082-2-git-send-email-mk@spinlock.ch","subject":"Re: [PATCH 2/4] git branch: Use color configuration infrastructure","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-01-08T11:23:28Z","receivedAt":"2008-01-08T11:23:28Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jan 05, 2008 at 03:11:37PM +0100, Matthias Kestenholz wrote:\n\n> --- a/builtin-branch.c\n> +++ b/builtin-branch.c\n> [...]\n> -static int branch_use_color;\n> [...]\n>  \tif (!strcmp(var, \"color.branch\")) {\n> -\t\tbranch_use_color = git_config_colorbool(var, value, -1);\n> +\t\tgit_use_color = git_config_colorbool(var, value, -1);\n>  \t\treturn 0;\n>  \t}\n\nIf I read this right, you are getting rid of the individual \"use color\"\nvariables with a single static git_use_color. This will break if two\ndifferent color \"zones\" get used in the same program (e.g.,\ncolor.branch and color.diff, but only one is supposed to be set). I\ndon't think this is a problem currently, but it seems like a step\nbackwards in terms of libification.\n\n-Peff\n"},{"id":"64733","messageId":"1199796751.19752.23.camel@futex","threadId":"11466","inReplyTo":"20080108112328.GA19941@coredump.intra.peff.net","subject":"Re: [PATCH 2/4] git branch: Use color configuration infrastructure","fromName":"Matthias Kestenholz","fromEmail":"mk@spinlock.ch","sentAt":"2008-01-08T12:52:30Z","receivedAt":"2008-01-08T12:52:30Z","isPatch":true,"sender":{"key":"matthias@spinlock.ch","avatar":"https://gravatar.com/avatar/bc18f396e70163d09ab458a341b1decb7e8b6ee3aa2c0c954ec20162e67c4d46?d=mp&s=160"},"body":"On Tue, 2008-01-08 at 06:23 -0500, Jeff King wrote:\n> On Sat, Jan 05, 2008 at 03:11:37PM +0100, Matthias Kestenholz wrote:\n> \n> > --- a/builtin-branch.c\n> > +++ b/builtin-branch.c\n> > [...]\n> > -static int branch_use_color;\n> > [...]\n> >  \tif (!strcmp(var, \"color.branch\")) {\n> > -\t\tbranch_use_color = git_config_colorbool(var, value, -1);\n> > +\t\tgit_use_color = git_config_colorbool(var, value, -1);\n> >  \t\treturn 0;\n> >  \t}\n> \n> If I read this right, you are getting rid of the individual \"use color\"\n> variables with a single static git_use_color. This will break if two\n> different color \"zones\" get used in the same program (e.g.,\n> color.branch and color.diff, but only one is supposed to be set). I\n> don't think this is a problem currently, but it seems like a step\n> backwards in terms of libification.\n\nYes that's right. I am still not convinced that its worth having\nmultiple color switches, but since they are there now we should probably\npreserve them.\n\nI finally made the application of the default config (color.ui)\nexplicit. It's a little bit more code and I have to export the\ncolorbools, but appart from that it's not too bad (I hope). I am\ninitializing all colorbools to -1 to differentiate between `unset` and\n`false`/`never`.\n\nI have doubts about the change in diff.c. That git_diff_basic_config()\ncalls git_color_default_config() seems not too nice, because color.diff\nis evaluated one layer higher, in git_diff_ui_config. It does not do no\nharm however, because git_color_default_config() has no side effects.\n\nThis is the last complete rewrite of the patch without requests from\noutside, I promise :-)  I am rather happy with the current state of\naffairs. Many thanks for the reviews and comments.\n\n-- 8< --\n\n>From 1ee26ac15628979b480b087f4dba3375ce1efd13 Mon Sep 17 00:00:00 2001\nFrom: Matthias Kestenholz <matthias@spinlock.ch>\nDate: Tue, 8 Jan 2008 13:45:32 +0100\nSubject: [PATCH] Add color.ui variable which globally enables colorization if set\n\nSigned-off-by: Matthias Kestenholz <matthias@spinlock.ch>\n---\n Documentation/config.txt |    7 +++++++\n builtin-branch.c         |   10 +++++++---\n builtin-commit.c         |    4 ++++\n builtin-diff.c           |    5 +++++\n builtin-log.c            |   17 +++++++++++++++++\n color.c                  |   12 ++++++++++++\n color.h                  |   11 +++++++++++\n diff.c                   |    6 +++---\n diff.h                   |    1 +\n wt-status.c              |    6 +++---\n 10 files changed, 70 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 1b6d6d6..b55f3b4 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -439,6 +439,13 @@ color.status.<slot>::\n commit.template::\n \tSpecify a file to use as the template for new commit messages.\n \n+color.ui::\n+\tWhen set to `always`, always use colors in all git commands which\n+\tare capable of colored output. When false (or `never`), never. When\n+\tset to `true` or `auto`, use colors only when the output is to the\n+\tterminal. When more specific variables of color.* are set, they always\n+\ttake precedence over this setting. Defaults to false.\n+\n diff.autorefreshindex::\n \tWhen using `git diff` to compare with work tree\n \tfiles, do not consider stat-only change as changed.\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 089cae5..9a1eb21 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -31,7 +31,7 @@ static unsigned char head_sha1[20];\n \n static int branch_track = 1;\n \n-static int branch_use_color;\n+static int branch_use_color = -1;\n static char branch_colors[][COLOR_MAXLEN] = {\n \t\"\\033[m\",\t/* reset */\n \t\"\",\t\t/* PLAIN (normal) */\n@@ -76,12 +76,12 @@ static int git_branch_config(const char *var, const char *value)\n \tif (!strcmp(var, \"branch.autosetupmerge\"))\n \t\t\tbranch_track = git_config_bool(var, value);\n \n-\treturn git_default_config(var, value);\n+\treturn git_color_default_config(var, value);\n }\n \n static const char *branch_get_color(enum color_branch ix)\n {\n-\tif (branch_use_color)\n+\tif (branch_use_color > 0)\n \t\treturn branch_colors[ix];\n \treturn \"\";\n }\n@@ -585,6 +585,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t};\n \n \tgit_config(git_branch_config);\n+\n+\tif (branch_use_color == -1)\n+\t\tbranch_use_color = git_use_color_default;\n+\n \ttrack = branch_track;\n \targc = parse_options(argc, argv, options, builtin_branch_usage, 0);\n \tif (!!delete + !!rename + !!force_create > 1)\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 73f1e35..ba60cfa 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -7,6 +7,7 @@\n \n #include \"cache.h\"\n #include \"cache-tree.h\"\n+#include \"color.h\"\n #include \"dir.h\"\n #include \"builtin.h\"\n #include \"diff.h\"\n@@ -640,6 +641,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \n \tgit_config(git_status_config);\n \n+\tif (wt_status_use_color == -1)\n+\t\twt_status_use_color = git_use_color_default;\n+\n \targc = parse_and_validate_options(argc, argv, builtin_status_usage);\n \n \tindex_file = prepare_index(argc, argv, prefix);\ndiff --git a/builtin-diff.c b/builtin-diff.c\nindex 29365a0..77a9c9a 100644\n--- a/builtin-diff.c\n+++ b/builtin-diff.c\n@@ -4,6 +4,7 @@\n  * Copyright (c) 2006 Junio C Hamano\n  */\n #include \"cache.h\"\n+#include \"color.h\"\n #include \"commit.h\"\n #include \"blob.h\"\n #include \"tag.h\"\n@@ -229,6 +230,10 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \n \tprefix = setup_git_directory_gently(&nongit);\n \tgit_config(git_diff_ui_config);\n+\n+\tif (diff_use_color_default == -1)\n+\t\tdiff_use_color_default = git_use_color_default;\n+\n \tinit_revisions(&rev, prefix);\n \trev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;\n \ndiff --git a/builtin-log.c b/builtin-log.c\nindex dcc9f81..880da94 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -5,6 +5,7 @@\n  *\t\t 2006 Junio Hamano\n  */\n #include \"cache.h\"\n+#include \"color.h\"\n #include \"commit.h\"\n #include \"diff.h\"\n #include \"revision.h\"\n@@ -235,6 +236,10 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)\n \tstruct rev_info rev;\n \n \tgit_config(git_log_config);\n+\n+\tif (diff_use_color_default == -1)\n+\t\tdiff_use_color_default = git_use_color_default;\n+\n \tinit_revisions(&rev, prefix);\n \trev.diff = 1;\n \trev.simplify_history = 0;\n@@ -307,6 +312,10 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \tint i, count, ret = 0;\n \n \tgit_config(git_log_config);\n+\n+\tif (diff_use_color_default == -1)\n+\t\tdiff_use_color_default = git_use_color_default;\n+\n \tinit_revisions(&rev, prefix);\n \trev.diff = 1;\n \trev.combine_merges = 1;\n@@ -367,6 +376,10 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)\n \tstruct rev_info rev;\n \n \tgit_config(git_log_config);\n+\n+\tif (diff_use_color_default == -1)\n+\t\tdiff_use_color_default = git_use_color_default;\n+\n \tinit_revisions(&rev, prefix);\n \tinit_reflog_walk(&rev.reflog_info);\n \trev.abbrev_commit = 1;\n@@ -395,6 +408,10 @@ int cmd_log(int argc, const char **argv, const char *prefix)\n \tstruct rev_info rev;\n \n \tgit_config(git_log_config);\n+\n+\tif (diff_use_color_default == -1)\n+\t\tdiff_use_color_default = git_use_color_default;\n+\n \tinit_revisions(&rev, prefix);\n \trev.always_show_header = 1;\n \tcmd_log_init(argc, argv, prefix, &rev);\ndiff --git a/color.c b/color.c\nindex 7f66c29..09b81fe 100644\n--- a/color.c\n+++ b/color.c\n@@ -3,6 +3,8 @@\n \n #define COLOR_RESET \"\\033[m\"\n \n+int git_use_color_default = 0;\n+\n static int parse_color(const char *name, int len)\n {\n \tstatic const char * const color_names[] = {\n@@ -143,6 +145,16 @@ int git_config_colorbool(const char *var, const char *value, int stdout_is_tty)\n \treturn 0;\n }\n \n+int git_color_default_config(const char *var, const char *value)\n+{\n+\tif (!strcmp(var, \"color.ui\")) {\n+\t\tgit_use_color_default = git_config_colorbool(var, value, -1);\n+\t\treturn 0;\n+\t}\n+\n+\treturn git_default_config(var, value);\n+}\n+\n static int color_vfprintf(FILE *fp, const char *color, const char *fmt,\n \t\tva_list args, const char *trail)\n {\ndiff --git a/color.h b/color.h\nindex ff63513..ecda556 100644\n--- a/color.h\n+++ b/color.h\n@@ -4,6 +4,17 @@\n /* \"\\033[1;38;5;2xx;48;5;2xxm\\0\" is 23 bytes */\n #define COLOR_MAXLEN 24\n \n+/*\n+ * This variable stores the value of color.ui\n+ */\n+extern int git_use_color_default;\n+\n+\n+/*\n+ * Use this instead of git_default_config if you need the value of color.ui.\n+ */\n+int git_color_default_config(const char *var, const char *value);\n+\n int git_config_colorbool(const char *var, const char *value, int stdout_is_tty);\n void color_parse(const char *var, const char *value, char *dst);\n int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);\ndiff --git a/diff.c b/diff.c\nindex b18c140..d6f23c7 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -20,7 +20,7 @@\n \n static int diff_detect_rename_default;\n static int diff_rename_limit_default = 100;\n-static int diff_use_color_default;\n+int diff_use_color_default = -1;\n static const char *external_diff_cmd_cfg;\n int diff_auto_refresh_index = 1;\n \n@@ -189,7 +189,7 @@ int git_diff_basic_config(const char *var, const char *value)\n \t\t}\n \t}\n \n-\treturn git_default_config(var, value);\n+\treturn git_color_default_config(var, value);\n }\n \n static char *quote_two(const char *one, const char *two)\n@@ -2048,7 +2048,7 @@ void diff_setup(struct diff_options *options)\n \n \toptions->change = diff_change;\n \toptions->add_remove = diff_addremove;\n-\tif (diff_use_color_default)\n+\tif (diff_use_color_default > 0)\n \t\tDIFF_OPT_SET(options, COLOR_DIFF);\n \telse\n \t\tDIFF_OPT_CLR(options, COLOR_DIFF);\ndiff --git a/diff.h b/diff.h\nindex 073d5cb..8e73f07 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -174,6 +174,7 @@ extern void diff_unmerge(struct diff_options *,\n \n extern int git_diff_basic_config(const char *var, const char *value);\n extern int git_diff_ui_config(const char *var, const char *value);\n+extern int diff_use_color_default;\n extern void diff_setup(struct diff_options *);\n extern int diff_opt_parse(struct diff_options *, const char **, int);\n extern int diff_setup_done(struct diff_options *);\ndiff --git a/wt-status.c b/wt-status.c\nindex c0c2472..0dfc909 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -9,7 +9,7 @@\n #include \"diffcore.h\"\n \n int wt_status_relative_paths = 1;\n-int wt_status_use_color = 0;\n+int wt_status_use_color = -1;\n static char wt_status_colors[][COLOR_MAXLEN] = {\n \t\"\",         /* WT_STATUS_HEADER: normal */\n \t\"\\033[32m\", /* WT_STATUS_UPDATED: green */\n@@ -40,7 +40,7 @@ static int parse_status_slot(const char *var, int offset)\n \n static const char* color(int slot)\n {\n-\treturn wt_status_use_color ? wt_status_colors[slot] : \"\";\n+\treturn wt_status_use_color > 0 ? wt_status_colors[slot] : \"\";\n }\n \n void wt_status_prepare(struct wt_status *s)\n@@ -409,5 +409,5 @@ int git_status_config(const char *k, const char *v)\n \t\twt_status_relative_paths = git_config_bool(k, v);\n \t\treturn 0;\n \t}\n-\treturn git_default_config(k, v);\n+\treturn git_color_default_config(k, v);\n }\n-- \n1.5.4.rc2.68.ge708a-dirty\n"}]}