{"thread":{"id":"5146","subject":"[PATCH] git-status: support always/auto/never in colorization","startedAt":"2006-08-05T23:57:56Z","lastAt":"2006-08-06T00:38:02Z","messageCount":2,"participants":["Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"24854","messageId":"20060805235756.GA15075@coredump.intra.peff.net","threadId":"5146","inReplyTo":null,"subject":"[PATCH] git-status: support always/auto/never in colorization","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-05T23:57:56Z","receivedAt":"2006-08-05T23:57:56Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Signed-off-by: Jeff King <peff@peff.net>\n---\nThis is on top of the previous two patches:\n    git-status: colorize status output (me)\n    git-status: do not use colors all the time (Matthias)\n\nI was hoping to join the term selection logic with the diff.color logic\nin git_config_termbool or similar (and a git-repo-config --termbool),\nbut unfortunately that doesn't work since git-repo-config can't do an\nisatty test (since we call it as `git-repo-config`). In general, config\nparsing is a little awkward (and inefficient) in sh. Is there any\ninterest in me converting git-commit/git-status to C builtins (I know\nJohannes will be happy...)?\n\n Documentation/config.txt |    4 +++-\n git-commit.sh            |   13 ++++++++-----\n 2 files changed, 11 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 83f4627..43766bd 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -224,7 +224,9 @@ showbranch.default::\n \n status.color::\n \tA boolean to enable/disable color in the output of\n-\tgitlink:git-status[1]. Defaults to false.\n+\tgitlink:git-status[1]. May be set to `true` (or `always`),\n+\t`false` (or `never`) or `auto`, in which case colors are used\n+\tonly when the output is to a terminal. Defaults to false.\n \n status.color.<slot>::\n \tUse customized color for status colorization. `<slot>` is\ndiff --git a/git-commit.sh b/git-commit.sh\nindex ad0cbb1..2ab1974 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -20,11 +20,14 @@ case \"$0\" in\n *status)\n \tstatus_only=t\n \tunmerged_ok_if_status=--unmerged\n-\t[ \"`git-repo-config --bool --get status.color`\" = 'true' ] &&\n-\t\t([ -t 1 ] || (\n-\t\t\t[ -n \"$GIT_PAGER_IN_USE\" ] &&\n-\t\t\t[ \"`git-repo-config --bool --get pager.color`\" != 'false' ]\n-\t\t)) && color=true\n+\tcase \"`git-repo-config --get status.color`\" in\n+\t  always) color=true ;;\n+\t  never ) color=false ;;\n+\t  auto  ) test -t 1 -o \\( -n \"$GIT_PAGER_IN_USE\" -a \\\n+\t\t     \"`git-repo-config --bool --get pager.color`\" != false \\) \\\n+\t\t  && color=true ;;\n+\t  *     ) color=\"`git-repo-config --bool --get status.color`\" ;;\n+\tesac\n \teval `git-repo-config --get-regexp status.color. \\\n \t      | while read k v; do\n \t          echo color_${k#status.color.}=$v\n-- \n1.4.2.rc3.gf3bd-dirty\n"},{"id":"24863","messageId":"7vac6id7h1.fsf@assigned-by-dhcp.cox.net","threadId":"5146","inReplyTo":"20060805235756.GA15075@coredump.intra.peff.net","subject":"Re: [PATCH] git-status: support always/auto/never in colorization","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-06T00:38:02Z","receivedAt":"2006-08-06T00:38:02Z","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> Signed-off-by: Jeff King <peff@peff.net>\n> ---\n> This is on top of the previous two patches:\n>     git-status: colorize status output (me)\n>     git-status: do not use colors all the time (Matthias)\n>\n> I was hoping to join the term selection logic with the diff.color logic\n> in git_config_termbool or similar (and a git-repo-config --termbool),\n> but unfortunately that doesn't work since git-repo-config can't do an\n> isatty test (since we call it as `git-repo-config`). In general, config\n> parsing is a little awkward (and inefficient) in sh. Is there any\n> interest in me converting git-commit/git-status to C builtins (I know\n> Johannes will be happy...)?\n\nI was planning to do only the status part in C anyway.\n"}]}