login
Header Space

 
 

Re: [PATCH v2] Updated status to show 'Not currently on any branch' in red

Previous thread: [PATCH] gitk: Mark some strings for translation by Michele Ballabio on Thursday, May 22, 2008 - 5:41 am. (1 message)

Next thread: [PATCH] log --graph: draw '>' and '<' with --left-right by Johannes Schindelin on Thursday, May 22, 2008 - 7:36 am. (6 messages)
To: <git@...>, Junio C Hamano <gitster@...>
Date: Thursday, May 22, 2008 - 6:19 am

This provides additional warning to users when attempting to
commit to a detached HEAD. It is configurable in color.status.nobranch.

Signed-off-by: Chris Parsons &lt;chris@edendevelopment.co.uk&gt;
---
Updated to incorporate changes suggested by Jeff King.

  Documentation/config.txt |    6 ++++--
  wt-status.c              |   11 ++++++++---
  wt-status.h              |    1 +
  3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 217980f..a073dc1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -523,8 +523,10 @@ color.status.&lt;slot&gt;::
  	one of `header` (the header text of the status message),
  	`added` or `updated` (files which are added but not committed),
  	`changed` (files which are changed but not added in the index),
-	or `untracked` (files which are not tracked by git). The values of
-	these variables may be specified as in color.branch.&lt;slot&gt;.
+	`untracked` (files which are not tracked by git), or
+	`nobranch` (the color the 'no branch' warning is shown in, defaulting
+	to red). The values of these variables may be specified as in
+	color.branch.&lt;slot&gt;.

  commit.template::
  	Specify a file to use as the template for new commit messages.
diff --git a/wt-status.c b/wt-status.c
index a44c543..78bc769 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -18,6 +18,7 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
  	"\033[32m", /* WT_STATUS_UPDATED: green */
  	"\033[31m", /* WT_STATUS_CHANGED: red */
  	"\033[31m", /* WT_STATUS_UNTRACKED: red */
+	"\033[31m", /* WT_STATUS_NOBRANCH: red */
  };

  static const char use_add_msg[] =
@@ -38,6 +39,8 @@ static int parse_status_slot(const char *var, int  
offset)
  		return WT_STATUS_CHANGED;
  	if (!strcasecmp(var+offset, "untracked"))
  		return WT_STATUS_UNTRACKED;
+	if (!strcasecmp(var+offset, "nobranch"))
+		return WT_STATUS_NOBRANCH;
  	die("bad config variable '%s'", var);
  }

@@ -315,7 +318,8 @@ ...
To: Chris Parsons <chris@...>
Cc: <git@...>, Junio C Hamano <gitster@...>
Date: Thursday, May 22, 2008 - 8:50 am

From: Chris Parsons &lt;chris@edendevelopment.co.uk&gt;

This provides additional warning to users when attempting to
commit to a detached HEAD. It is configurable in color.status.nobranch.

Signed-off-by: Chris Parsons &lt;chris@edendevelopment.co.uk&gt;
Acked-by: Jeff King &lt;peff@peff.net&gt;
---

The improvements look good to me.

This patch was severely whitespaced damaged, probably due to:

  Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

in the original, so I am resending an unmangled version for Junio's
convenience. Chris, please make sure to turn off flowed text when
sending future patches.

 Documentation/config.txt |    6 ++++--
 wt-status.c              |    9 +++++++--
 wt-status.h              |    1 +
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 217980f..554977b 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -523,8 +523,10 @@ color.status.&lt;slot&gt;::
 	one of `header` (the header text of the status message),
 	`added` or `updated` (files which are added but not committed),
 	`changed` (files which are changed but not added in the index),
-	or `untracked` (files which are not tracked by git). The values of
-	these variables may be specified as in color.branch.&lt;slot&gt;.
+	`untracked` (files which are not tracked by git), or
+	`nobranch` (the color the 'no branch' warning is shown in, defaulting
+	to red). The values of these variables may be specified as in
+	color.branch.&lt;slot&gt;.
 
 commit.template::
 	Specify a file to use as the template for new commit messages.
diff --git a/wt-status.c b/wt-status.c
index a44c543..7a3223e 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -18,6 +18,7 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
 	"\033[32m", /* WT_STATUS_UPDATED: green */
 	"\033[31m", /* WT_STATUS_CHANGED: red */
 	"\033[31m", /* WT_STATUS_UNTRACKED: red */
+	"\033[31m", /* WT_STATUS_NOBRANCH: red */
 };
 
...
To: Jeff King <peff@...>
Cc: Chris Parsons <chris@...>, <git@...>
Date: Friday, May 23, 2008 - 2:19 am

Thanks, both.
--
To: Jeff King <peff@...>
Cc: <git@...>
Date: Thursday, May 22, 2008 - 9:12 am

Hmph - sorry about that. I did read SubmittingPatches carefully, but I  
guess Apple Mail tripped me up.

Thanks
Chris
--
Previous thread: [PATCH] gitk: Mark some strings for translation by Michele Ballabio on Thursday, May 22, 2008 - 5:41 am. (1 message)

Next thread: [PATCH] log --graph: draw '>' and '<' with --left-right by Johannes Schindelin on Thursday, May 22, 2008 - 7:36 am. (6 messages)
speck-geostationary