git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Make --color available to git-status

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
May 5, 2007, 17:37 UTC
Message-ID
<11783866694076-git-send-email-Matthieu.Moy@imag.fr>
Git has a nice colored output for status, using
$ git runstatus --color

However, this --color is not made available to git-status itself. In my understanding, runstatus is plumbing, while status is porcelain, which the average user wants to use.

This patch makes --color available to git-status itself, and documents it.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 Documentation/git-commit.txt |    4 ++++
 Documentation/git-status.txt |    5 ++++-
 git-commit.sh                |   10 ++++++++--
 3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 53a7bb0..2895225 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -118,6 +118,10 @@ but can be used to amend a merge commit.
 -q|--quiet::
 	Suppress commit summary message.
 
+--color::
+	Ignored by git-commit, but present for compatibility with
+	gitlink:git-status[1]. Show colored output for git-status.
+
 \--::
 	Do not interpret any more arguments as options.
 
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index e9e193f..1d6a240 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -23,9 +23,12 @@ If there is no path that is different between the index file and
 the current HEAD commit, the command exits with non-zero
 status.
 
+
+OPTIONS
+-------
 The command takes the same set of options as `git-commit`; it
 shows what would be committed if the same options are given to
-`git-commit`.
+`git-commit`.  If --color is used, show a colored output.
 
 
 OUTPUT
diff --git a/git-commit.sh b/git-commit.sh
index f28fc24..47f006f 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Linus Torvalds
 # Copyright (c) 2006 Junio C Hamano
 
-USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]'
+USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [--color] [[-i | -o] <path>...]'
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
 require_work_tree
@@ -50,7 +50,7 @@ run_status () {
 	fi
 
 	case "$status_only" in
-	t) color= ;;
+	t) ;;
 	*) color=--nocolor ;;
 	esac
 	git-runstatus ${color} \
@@ -87,6 +87,8 @@ signoff=
 force_author=
 only_include_assumed=
 untracked_files=
+color=
+
 while case "$#" in 0) break;; esac
 do
 	case "$1" in
@@ -262,6 +264,10 @@ $1"
 		untracked_files=t
 		shift
 		;;
+	--c|--co|--col|--colo|--color)
+                color=--color
+                shift
+                ;;
 	--)
 		shift
 		break
-- 
1.5.1.3
Next: Johannes Schindelin
Message 1 of 4 in “Make --color available to git-status”
  1. Make --color available to git-statusMatthieu Moy, May 5, 2007
  2. Johannes SchindelinMay 5, 2007
  3. Matthieu MoyMay 6, 2007
  4. Jeff KingMay 6, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.