{"thread":{"id":"5139","subject":"[PATCH] git-status: colorize status output","startedAt":"2006-08-05T03:14:19Z","lastAt":"2006-08-07T17:12:18Z","messageCount":21,"participants":["Jeff King","Greg KH","Junio C Hamano","Matthias Lederhofer","Joel Becker","Sam Ravnborg"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"24788","messageId":"20060805031418.GA11102@coredump.intra.peff.net","threadId":"5139","inReplyTo":null,"subject":"[PATCH] git-status: colorize status output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-05T03:14:19Z","receivedAt":"2006-08-05T03:14:19Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The git-status output can sometimes be very verbose, making it difficult to\nquickly see whether your files are updated in the index. This adds 4 levels\nof colorizing to the status output:\n  - general header (defaults to normal white)\n  - updated but not committed (defaults to green)\n  - changed but not updated (defaults to red)\n  - untracked files (defaults to red)\nThe idea is that red things indicate a potential mistake on the part of the\nuser (e.g., forgetting to update a file, forgetting to git-add a file).\n\nThis patch also has a few minor output related cleanups. Untracked files are\nnow displayed using the 'report' function (marked with the character 'O').\nThe report function now uses a simple hdr_shown variable instead of\nflip-flopping the header and trailer, which was somewhat difficult to read.\n\nColor support is controlled by status.color and status.color.*. There is no\ncommand line option, and the status.color variable is a simple boolean (no\nchecking for tty output).\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n Documentation/config.txt |   12 ++++++\n git-commit.sh            |   99 ++++++++++++++++++++++++++++++----------------\n 2 files changed, 77 insertions(+), 34 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex d89916b..83f4627 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -222,6 +222,18 @@ showbranch.default::\n \tThe default set of branches for gitlink:git-show-branch[1].\n \tSee gitlink:git-show-branch[1].\n \n+status.color::\n+\tA boolean to enable/disable color in the output of\n+\tgitlink:git-status[1]. Defaults to false.\n+\n+status.color.<slot>::\n+\tUse customized color for status colorization. `<slot>` is\n+\tone of `header` (the header text of the status message),\n+\t`updated` (files which are updated but not committed),\n+\t`changed` (files which are changed but not updated in the index),\n+\tor `untracked` (files which are not tracked by git). The values of\n+\tthese variables may be specified as in diff.color.<slot>.\n+\n tar.umask::\n \tBy default, gitlink:git-tar-tree[1] sets file and directories modes\n \tto 0666 or 0777. While this is both useful and acceptable for projects\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 4cf3fab..b7269c2 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -10,15 +10,49 @@ SUBDIRECTORY_OK=Yes\n git-rev-parse --verify HEAD >/dev/null 2>&1 || initial_commit=t\n branch=$(GIT_DIR=\"$GIT_DIR\" git-symbolic-ref HEAD)\n \n+color=false\n+color_header=normal\n+color_updated=green\n+color_changed=red\n+color_untracked=red\n+\n case \"$0\" in\n *status)\n \tstatus_only=t\n-\tunmerged_ok_if_status=--unmerged ;;\n+\tunmerged_ok_if_status=--unmerged\n+\tcolor=`git-repo-config --bool --get status.color`\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+\t        done`\n+\t;;\n *commit)\n \tstatus_only=\n \tunmerged_ok_if_status= ;;\n esac\n \n+color() {\n+\tcase \"$color\" in true) ;; *) return ;; esac\n+\tcase `eval \"echo \\\\$color_$1\"` in\n+\t  normal) ;;\n+\t  bold)    printf '\\033[1m' ;;\n+\t  red)     printf '\\033[31m' ;;\n+\t  green)   printf '\\033[32m' ;;\n+\t  yellow)  printf '\\033[33m' ;;\n+\t  blue)    printf '\\033[34m' ;;\n+\t  magenta) printf '\\033[35m' ;;\n+\t  cyan)    printf '\\033[36m' ;;\n+\tesac\n+}\n+\n+uncolor() {\n+\tcase \"$color\" in true) ;; *) return ;; esac\n+\tcase \"$1\" in\n+\t  normal) ;;\n+\t  *) printf '\\033[m' ;;\n+\tesac\n+}\n+\n refuse_partial () {\n \techo >&2 \"$1\"\n \techo >&2 \"You might have meant to say 'git commit -i paths...', perhaps?\"\n@@ -33,30 +67,32 @@ save_index () {\n }\n \n report () {\n-  header=\"#\n-# $1:\n-#   ($2)\n-#\n-\"\n-  trailer=\"\"\n+  hdr_shown=0\n   while read status name newname\n   do\n-    printf '%s' \"$header\"\n-    header=\"\"\n-    trailer=\"#\n-\"\n+    case \"$hdr_shown\" in\n+      0) color header; echo \"# $2:\"; uncolor header\n+         color header; echo \"#   ($3)\"; uncolor header\n+\t color header; echo \"#\"; uncolor header\n+\t hdr_shown=1\n+\t ;;\n+    esac\n+    color header; printf '#\\t'; uncolor header\n     case \"$status\" in\n-    M ) echo \"#\tmodified: $name\";;\n-    D*) echo \"#\tdeleted:  $name\";;\n-    T ) echo \"#\ttypechange: $name\";;\n-    C*) echo \"#\tcopied: $name -> $newname\";;\n-    R*) echo \"#\trenamed: $name -> $newname\";;\n-    A*) echo \"#\tnew file: $name\";;\n-    U ) echo \"#\tunmerged: $name\";;\n+    M ) color $1; echo \"modified: $name\"; uncolor $1;;\n+    D*) color $1; echo \"deleted:  $name\"; uncolor $1;;\n+    T ) color $1; echo \"1change: $name\"; uncolor $1;;\n+    C*) color $1; echo \"copied: $name -> $newname\"; uncolor $1;;\n+    R*) color $1; echo \"renamed: $name -> $newname\"; uncolor $1;;\n+    A*) color $1; echo \"new file: $name\"; uncolor $1;;\n+    U ) color $1; echo \"unmerged: $name\"; uncolor $1;;\n+    O ) color $1; echo \"$name\"; uncolor $1;;\n     esac\n   done\n-  printf '%s' \"$trailer\"\n-  [ \"$header\" ]\n+  case \"$hdr_shown\" in\n+    1) color header; echo '#'; uncolor header;;\n+  esac\n+  test \"$hdr_shown\" = 0\n }\n \n run_status () {\n@@ -109,7 +145,7 @@ run_status () {\n \t\t    s/\\\\/\\\\\\\\/g\n \t\t    s/ /\\\\ /g\n \t    ' |\n-\t    report \"Updated but not checked in\" \"will commit\"\n+\t    report updated \"Updated but not checked in\" \"will commit\"\n \t    committable=\"$?\"\n \telse\n \t    echo '#\n@@ -121,7 +157,7 @@ #'\n \t\t    s/ /\\\\ /g\n \t\t    s/^/A /\n \t    ' |\n-\t    report \"Updated but not checked in\" \"will commit\"\n+\t    report updated \"Updated but not checked in\" \"will commit\"\n \n \t    committable=\"$?\"\n \tfi\n@@ -131,14 +167,13 @@ #'\n \t\ts/\\\\/\\\\\\\\/g\n \t\ts/ /\\\\ /g\n \t' |\n-\treport \"Changed but not updated\" \\\n+\treport changed \"Changed but not updated\" \\\n \t    \"use git-update-index to mark for commit\"\n \n         option=\"\"\n         if test -z \"$untracked_files\"; then\n             option=\"--directory --no-empty-directory\"\n         fi\n-\thdr_shown=\n \tif test -f \"$GIT_DIR/info/exclude\"\n \tthen\n \t    git-ls-files --others $option \\\n@@ -148,16 +183,12 @@ #'\n \t    git-ls-files --others $option \\\n \t\t--exclude-per-directory=.gitignore\n \tfi |\n-\twhile read line; do\n-\t    if [ -z \"$hdr_shown\" ]; then\n-\t\techo '#'\n-\t\techo '# Untracked files:'\n-\t\techo '#   (use \"git add\" to add to commit)'\n-\t\techo '#'\n-\t\thdr_shown=1\n-\t    fi\n-\t    echo \"#\t$line\"\n-\tdone\n+\tsed -e '\n+\t\ts/\\\\/\\\\\\\\/g\n+\t\ts/ /\\\\ /g\n+\t\ts/^/O /\n+\t' |\n+\treport untracked \"Untracked files\" \"use git add to commit\"\n \n \tif test -n \"$verbose\" -a -z \"$IS_INITIAL\"\n \tthen\n-- \n1.4.2.rc3.g06c3\n"},{"id":"24790","messageId":"20060805032135.GA11244@coredump.intra.peff.net","threadId":"5139","inReplyTo":"20060805031418.GA11102@coredump.intra.peff.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-05T03:21:35Z","receivedAt":"2006-08-05T03:21:35Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Aug 04, 2006 at 11:14:19PM -0400, Jeff King wrote:\n\n> The idea is that red things indicate a potential mistake on the part of the\n> user (e.g., forgetting to update a file, forgetting to git-add a file).\n\nI actually wanted to do this because I started syntax-highlighting the\ngit-commit message in vim. I found myself catching simple mistakes in\ncommits, like the ones I mentioned above, before committing, saving me\nfrom doing an --amend. Then I got so hooked on it I wanted the\ncolorization everytime I ran git-status.\n\nIf anyone is interested in the vim syntax highlighting, it is below.\nCopy the file to $HOME/.vim/syntax/gitcommit.vim and add the following\nline to your .vimrc:\n  autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit\n\n-Peff\n\n-- >8 --\nsyn region gitLine start=/^#/ end=/$/\nsyn region gitCommit start=/^# Updated but not checked in:$/ end=/^#$/ contains=gitHead,gitCommitFile\nsyn region gitHead contained start=/^#   (.*)/ end=/^#$/\nsyn region gitChanged start=/^# Changed but not updated:/ end=/^#$/ contains=gitHead,gitChangedFile\nsyn region gitUntracked start=/^# Untracked files:/ end=/^#$/ contains=gitHead,gitUntrackedFile\n\nsyn match gitCommitFile contained /^#\\t.*/hs=s+2\nsyn match gitChangedFile contained /^#\\t.*/hs=s+2\nsyn match gitUntrackedFile contained /^#\\t.*/hs=s+2\n\nhi def link gitLine Comment\nhi def link gitCommit Comment\nhi def link gitChanged Comment\nhi def link gitHead Comment\nhi def link gitUntracked Comment\nhi def link gitCommitFile Type\nhi def link gitChangedFile Constant\nhi def link gitUntrackedFile Constant\n"},{"id":"24804","messageId":"20060805081621.GA2683@kroah.com","threadId":"5139","inReplyTo":"20060805032135.GA11244@coredump.intra.peff.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Greg KH","fromEmail":"greg@kroah.com","sentAt":"2006-08-05T08:16:21Z","receivedAt":"2006-08-05T08:16:21Z","isPatch":true,"sender":{"key":"greg@kroah.com","avatar":"https://gravatar.com/avatar/5bb5aa0cc2e01c00ec899d11130c07796bc186e465bae57bc34873b13b72c7c8?d=mp&s=160"},"body":"On Fri, Aug 04, 2006 at 11:21:35PM -0400, Jeff King wrote:\n> On Fri, Aug 04, 2006 at 11:14:19PM -0400, Jeff King wrote:\n> \n> > The idea is that red things indicate a potential mistake on the part of the\n> > user (e.g., forgetting to update a file, forgetting to git-add a file).\n> \n> I actually wanted to do this because I started syntax-highlighting the\n> git-commit message in vim. I found myself catching simple mistakes in\n> commits, like the ones I mentioned above, before committing, saving me\n> from doing an --amend. Then I got so hooked on it I wanted the\n> colorization everytime I ran git-status.\n> \n> If anyone is interested in the vim syntax highlighting, it is below.\n> Copy the file to $HOME/.vim/syntax/gitcommit.vim and add the following\n> line to your .vimrc:\n>   autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit\n\nAh, very nice, thanks for this, makes commits much easier to read now.\n\ngreg k-h\n"},{"id":"24806","messageId":"7vpsffedkw.fsf@assigned-by-dhcp.cox.net","threadId":"5139","inReplyTo":"20060805031418.GA11102@coredump.intra.peff.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-05T09:28:31Z","receivedAt":"2006-08-05T09:28:31Z","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> +    M ) color $1; echo \"modified: $name\"; uncolor $1;;\n> +    D*) color $1; echo \"deleted:  $name\"; uncolor $1;;\n> +    T ) color $1; echo \"1change: $name\"; uncolor $1;;\n\nIs \"1\" a typo?\n\n> +    C*) color $1; echo \"copied: $name -> $newname\"; uncolor $1;;\n> +    R*) color $1; echo \"renamed: $name -> $newname\"; uncolor $1;;\n> +    A*) color $1; echo \"new file: $name\"; uncolor $1;;\n> +    U ) color $1; echo \"unmerged: $name\"; uncolor $1;;\n> +    O ) color $1; echo \"$name\"; uncolor $1;;\n"},{"id":"24808","messageId":"20060805102117.GA28348@sigio.intra.peff.net","threadId":"5139","inReplyTo":"7vpsffedkw.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-05T10:21:18Z","receivedAt":"2006-08-05T10:21:18Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 05, 2006 at 02:28:31AM -0700, Junio C Hamano wrote:\n\n> > +    M ) color $1; echo \"modified: $name\"; uncolor $1;;\n> > +    D*) color $1; echo \"deleted:  $name\"; uncolor $1;;\n> > +    T ) color $1; echo \"1change: $name\"; uncolor $1;;\n> Is \"1\" a typo?\n\nOops, yes, not sure how that got in there.\n\n-Peff\n"},{"id":"24809","messageId":"20060805104415.GA31560@sigio.intra.peff.net","threadId":"5139","inReplyTo":"20060805102117.GA28348@sigio.intra.peff.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-05T10:44:15Z","receivedAt":"2006-08-05T10:44:15Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 05, 2006 at 06:21:18AM -0400, Jeff King wrote:\n\n> > > +    T ) color $1; echo \"1change: $name\"; uncolor $1;;\n> > Is \"1\" a typo?\n> Oops, yes, not sure how that got in there.\n\nOh, I see. It should be 'typechange' in case you didn't reference\nagainst the original version.\n\n-Peff\n"},{"id":"24812","messageId":"20060805105953.GA5410@moooo.ath.cx","threadId":"5139","inReplyTo":"20060805031418.GA11102@coredump.intra.peff.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-05T10:59:53Z","receivedAt":"2006-08-05T10:59:53Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Jeff King <peff@peff.net> wrote:\n> The git-status output can sometimes be very verbose, making it difficult to\n> quickly see whether your files are updated in the index. This adds 4 levels\n> of colorizing to the status output:\n>   - general header (defaults to normal white)\n>   - updated but not committed (defaults to green)\n>   - changed but not updated (defaults to red)\n>   - untracked files (defaults to red)\n> The idea is that red things indicate a potential mistake on the part of the\n> user (e.g., forgetting to update a file, forgetting to git-add a file).\nPerhaps the default values should not use the same color twice? I'd\nsuggest yellow for changed but not updated.  But well, it's no problem\nto change this in my config, I just find it a bit confusing to have\nthe same color for different things.\n\n> Color support is controlled by status.color and status.color.*. There is no\n> command line option, and the status.color variable is a simple boolean (no\n> checking for tty output).\nIs there any way to do isatty() from shell scripts?\n"},{"id":"24819","messageId":"7vejvve8ci.fsf@assigned-by-dhcp.cox.net","threadId":"5139","inReplyTo":"20060805105953.GA5410@moooo.ath.cx","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-05T11:21:33Z","receivedAt":"2006-08-05T11:21:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Lederhofer <matled@gmx.net> writes:\n\n> Jeff King <peff@peff.net> wrote:\n>> The git-status output can sometimes be very verbose, making it difficult to\n>> quickly see whether your files are updated in the index. This adds 4 levels\n>> of colorizing to the status output:\n>>   - general header (defaults to normal white)\n>>   - updated but not committed (defaults to green)\n>>   - changed but not updated (defaults to red)\n>>   - untracked files (defaults to red)\n>> The idea is that red things indicate a potential mistake on the part of the\n>> user (e.g., forgetting to update a file, forgetting to git-add a file).\n> Perhaps the default values should not use the same color twice? I'd\n> suggest yellow for changed but not updated.  But well, it's no problem\n> to change this in my config, I just find it a bit confusing to have\n> the same color for different things.\n>\n>> Color support is controlled by status.color and status.color.*. There is no\n>> command line option, and the status.color variable is a simple boolean (no\n>> checking for tty output).\n> Is there any way to do isatty() from shell scripts?\n\nYes.\n"},{"id":"24821","messageId":"7vac6je825.fsf@assigned-by-dhcp.cox.net","threadId":"5139","inReplyTo":"7vejvve8ci.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-05T11:27:46Z","receivedAt":"2006-08-05T11:27:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n>> Is there any way to do isatty() from shell scripts?\n>\n> Yes.\n\nOops -- wrong answer which is too short.\n\n$ git grep -B1 'standard input' -- '*.sh'\n"},{"id":"24822","messageId":"20060805112851.GA20807@moooo.ath.cx","threadId":"5139","inReplyTo":"7vejvve8ci.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-05T11:28:51Z","receivedAt":"2006-08-05T11:28:51Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Matthias Lederhofer <matled@gmx.net> writes:\n> >> Color support is controlled by status.color and status.color.*. There is no\n> >> command line option, and the status.color variable is a simple boolean (no\n> >> checking for tty output).\n> > Is there any way to do isatty() from shell scripts?\n> \n> Yes.\nHow? :) Is there any reason not checking isatty()?\n"},{"id":"24826","messageId":"7v64h7e7dm.fsf@assigned-by-dhcp.cox.net","threadId":"5139","inReplyTo":"20060805112851.GA20807@moooo.ath.cx","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-05T11:42:29Z","receivedAt":"2006-08-05T11:42:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Lederhofer <matled@gmx.net> writes:\n\n> Junio C Hamano <junkio@cox.net> wrote:\n>> Matthias Lederhofer <matled@gmx.net> writes:\n>> >> Color support is controlled by status.color and status.color.*. There is no\n>> >> command line option, and the status.color variable is a simple boolean (no\n>> >> checking for tty output).\n>> > Is there any way to do isatty() from shell scripts?\n>> \n>> Yes.\n> How? :)\n\nArrrrrrrgh!  The message I wanted to send you went to Jeff.\n\nYour Mail-Followup-To: fooled me.  Please do not do this.\n\n$ git grep -B1 'standard input' -- '*.sh'\ngit-commit.sh-\t\ttest -t 0 &&\ngit-commit.sh:\t\techo >&2 \"(reading log message from standard input)\"\n\n> Is there any reason not checking isatty()?\n\nNot that I can think of, but do people really run \"git status\"?\n\nI think Jeff's follow-up \"vim colorizer\" makes a lot more sense\nthan colorizing \"git status\" output -- it gives reminder during\nthe last chance the user has to notice such problems, which is\nwhile composing the commit log message.\n"},{"id":"24827","messageId":"20060805121821.GB20807@moooo.ath.cx","threadId":"5139","inReplyTo":"7v64h7e7dm.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-05T12:18:21Z","receivedAt":"2006-08-05T12:18:21Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Matthias Lederhofer <matled@gmx.net> writes:\n> Arrrrrrrgh!  The message I wanted to send you went to Jeff.\n> \n> Your Mail-Followup-To: fooled me.  Please do not do this.\nSorry.\n\n> > Is there any reason not checking isatty()?\n> \n> Not that I can think of, but do people really run \"git status\"?\nI do :)\n\n> I think Jeff's follow-up \"vim colorizer\" makes a lot more sense\n> than colorizing \"git status\" output -- it gives reminder during\n> the last chance the user has to notice such problems, which is\n> while composing the commit log message.\nI like the colored git status.  Here is a patch to honor isatty(1) and\npager_in_use (exporting GIT_PAGER_IN_USE) with pager.color.\n\n---\nFrom c01b26cd332283d3b3feaeae4a8218bb409aea2c Mon Sep 17 00:00:00 2001\nFrom: Matthias Lederhofer <matled@gmx.net>\nDate: Sat, 5 Aug 2006 14:09:49 +0200\nSubject: [PATCH] git-status: do not use colors all the time\n\nEither [ -t 1 ] has to be true or the pager is used and pager.color is\nnot false.\n\nSigned-off-by: Matthias Lederhofer <matled@gmx.net>\n---\n git-commit.sh |    6 +++++-\n pager.c       |    1 +\n 2 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/git-commit.sh b/git-commit.sh\nindex b7269c2..ad0cbb1 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -20,7 +20,11 @@ case \"$0\" in\n *status)\n \tstatus_only=t\n \tunmerged_ok_if_status=--unmerged\n-\tcolor=`git-repo-config --bool --get status.color`\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 \teval `git-repo-config --get-regexp status.color. \\\n \t      | while read k v; do\n \t          echo color_${k#status.color.}=$v\ndiff --git a/pager.c b/pager.c\nindex dcb398d..3ba4166 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -27,6 +27,7 @@ void setup_pager(void)\n \t\treturn;\n \n \tpager_in_use = 1; /* means we are emitting to terminal */\n+\tsetenv(\"GIT_PAGER_IN_USE\", \"1\", 1);\n \n \tif (pipe(fd) < 0)\n \t\treturn;\n-- \n1.4.2.rc2.gd71a\n"},{"id":"24839","messageId":"20060805194513.GA4836@sigio.intra.peff.net","threadId":"5139","inReplyTo":"20060805105953.GA5410@moooo.ath.cx","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-05T19:45:13Z","receivedAt":"2006-08-05T19:45:13Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 05, 2006 at 12:59:53PM +0200, Matthias Lederhofer wrote:\n\n> Perhaps the default values should not use the same color twice? I'd\n> suggest yellow for changed but not updated.  But well, it's no problem\n> to change this in my config, I just find it a bit confusing to have\n> the same color for different things.\n\nI'm fine with changing the defaults as you suggest. It makes more sense\nto me with only two colors (files is a potential mistake or not), but I\nadded more fine-grained support because it was trivial and I thought\nothers might want to customize it.\n\nWe could, of course, allow even more fine-grained control by matching\nfile type (added, deleted, modified, etc), but I'm not sure anybody\nwould want that.\n\n> Is there any way to do isatty() from shell scripts?\n\nAs Junio said, test -t. :) Is there interest in me adding that feature?\n\n-Peff\n"},{"id":"24840","messageId":"20060805195118.GB4836@sigio.intra.peff.net","threadId":"5139","inReplyTo":"7v64h7e7dm.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-05T19:51:18Z","receivedAt":"2006-08-05T19:51:18Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 05, 2006 at 04:42:29AM -0700, Junio C Hamano wrote:\n\n> Not that I can think of, but do people really run \"git status\"?\n\nI do! :) I actually wrote the vim colorizer first and used it for a\nweek before realizing it was not sufficient, and that I wanted\ngit-status output colorized, too. So please consider including the\npatch.\n\n> I think Jeff's follow-up \"vim colorizer\" makes a lot more sense\n> than colorizing \"git status\" output -- it gives reminder during\n> the last chance the user has to notice such problems, which is\n> while composing the commit log message.\n\nIt looks like we have some similar emacs stuff in contrib/. Should I\nprepare a short patch to create contrib/vim/?\n\n-Peff\n"},{"id":"24841","messageId":"20060805195411.GA4733@sigio.intra.peff.net","threadId":"5139","inReplyTo":"20060805121821.GB20807@moooo.ath.cx","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-05T19:54:11Z","receivedAt":"2006-08-05T19:54:11Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 05, 2006 at 02:18:21PM +0200, Matthias Lederhofer wrote:\n\n> I like the colored git status.  Here is a patch to honor isatty(1) and\n> pager_in_use (exporting GIT_PAGER_IN_USE) with pager.color.\n\nDoesn't this have different behavior when you use 'git-status' rather\nthan 'git status'? Maybe rather than a boolean, we would be better off\nwith a true/false/auto value similar to diff.color.\n\n-Peff\n"},{"id":"24844","messageId":"20060805202759.GA16186@moooo.ath.cx","threadId":"5139","inReplyTo":"20060805194513.GA4836@sigio.intra.peff.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-05T20:27:59Z","receivedAt":"2006-08-05T20:27:59Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Jeff King <peff@peff.net> wrote:\n> > Is there any way to do isatty() from shell scripts?\n> \n> As Junio said, test -t. :) Is there interest in me adding that feature?\nI would suggest that all scripts that use colors have a\nalways/auto/never (with boolean fallback) option and also honor\npager.color if the pager is in use.\n"},{"id":"24845","messageId":"20060805203107.GB16186@moooo.ath.cx","threadId":"5139","inReplyTo":"20060805195411.GA4733@sigio.intra.peff.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-08-05T20:31:07Z","receivedAt":"2006-08-05T20:31:07Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Jeff King <peff@peff.net> wrote:\n> On Sat, Aug 05, 2006 at 02:18:21PM +0200, Matthias Lederhofer wrote:\n> \n> > I like the colored git status.  Here is a patch to honor isatty(1) and\n> > pager_in_use (exporting GIT_PAGER_IN_USE) with pager.color.\n> \n> Doesn't this have different behavior when you use 'git-status' rather\n> than 'git status'? Maybe rather than a boolean, we would be better off\n> with a true/false/auto value similar to diff.color.\nI don't see the case where git-status and git status behave\ndifferently (except for git -p status but git-status does not have an\noption for paging at all).\n"},{"id":"24851","messageId":"20060805234240.GA11545@coredump.intra.peff.net","threadId":"5139","inReplyTo":"20060805203107.GB16186@moooo.ath.cx","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-05T23:42:40Z","receivedAt":"2006-08-05T23:42:40Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 05, 2006 at 10:27:59PM +0200, Matthias Lederhofer wrote:\n\n> I would suggest that all scripts that use colors have a\n> always/auto/never (with boolean fallback) option and also honor\n> pager.color if the pager is in use.\n\nI'll send out a patch in a moment.\n\n> I don't see the case where git-status and git status behave\n> differently (except for git -p status but git-status does not have an\n> option for paging at all).\n\nSorry, I didn't say what I meant at all. My problem was that one\ncannot get color with a pager using git-status (by doing\n'git-status | less'). The output is not a tty, but GIT_PAGER_IN_USE is\nnot set (and of course I cannot use '-p'). However, that is a moot point\nwith always/auto/never, since in such a case I can just use 'always'.\n\n-Peff\n"},{"id":"24876","messageId":"20060806050138.GN23246@ca-server1.us.oracle.com","threadId":"5139","inReplyTo":"20060805031418.GA11102@coredump.intra.peff.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Joel Becker","fromEmail":"joel.becker@oracle.com","sentAt":"2006-08-06T05:01:38Z","receivedAt":"2006-08-06T05:01:38Z","isPatch":true,"sender":{"key":"joel.becker@oracle.com","avatar":null},"body":"On Fri, Aug 04, 2006 at 11:14:19PM -0400, Jeff King wrote:\n> The git-status output can sometimes be very verbose, making it difficult to\n> quickly see whether your files are updated in the index. This adds 4 levels\n> of colorizing to the status output:\n>   - general header (defaults to normal white)\n>   - updated but not committed (defaults to green)\n>   - changed but not updated (defaults to red)\n>   - untracked files (defaults to red)\n\nPlease do one of two things:\n1) Add code to discover a terminal is white-on-black and use bright colors\nor\n2) Default this to off.\n\nI like the idea of colors, but the colors most people use in\nblack-on-white terminals are invisible on my screen.  colorls has the\nsame problem.\n\nJoel\n\n-- \n\n\"What no boss of a programmer can ever understand is that a programmer\n is working when he's staring out of the window\"\n\t- With apologies to Burton Rascoe\n\n\nJoel Becker\nPrincipal Software Developer\nOracle\nE-mail: joel.becker@oracle.com\nPhone: (650) 506-8127\n"},{"id":"24878","messageId":"20060806061633.GA19148@coredump.intra.peff.net","threadId":"5139","inReplyTo":"20060806050138.GN23246@ca-server1.us.oracle.com","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-06T06:16:33Z","receivedAt":"2006-08-06T06:16:33Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 05, 2006 at 10:01:38PM -0700, Joel Becker wrote:\n\n> Please do one of two things:\n> 1) Add code to discover a terminal is white-on-black and use bright colors\n> or\n> 2) Default this to off.\n\nIt defaults to off. The colors are also easily customizable should you\nwant to use it.\n\n-Peff\n"},{"id":"24928","messageId":"20060807171218.GB10918@mars.ravnborg.org","threadId":"5139","inReplyTo":"7v64h7e7dm.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-status: colorize status output","fromName":"Sam Ravnborg","fromEmail":"sam@ravnborg.org","sentAt":"2006-08-07T17:12:18Z","receivedAt":"2006-08-07T17:12:18Z","isPatch":true,"sender":{"key":"sam@ravnborg.org","avatar":"https://gravatar.com/avatar/168a912606ed0742d840bb365e3cc21db390c36531a58341dc7a069cc1f15f62?d=mp&s=160"},"body":"> \n> Not that I can think of, but do people really run \"git status\"?\nAlways (almost) before I run 'git fetch'.\nI do it to check that I have not made any local modifications that I\nneed to get rid of before fetching and that I do not have stale files\naround.\n\nOne example is my copy of Linus' kernel tree. I use it now and then for\nsmall experiments (can I reporoduce this bug etc) and when fetching I\nwant it to be gone.\n\n\tSam\n"}]}