{"thread":{"id":"13611","subject":"[PATCH v2] Updated status to show 'Not currently on any branch' in red","startedAt":"2008-05-22T10:19:18Z","lastAt":"2008-05-23T06:19:33Z","messageCount":4,"participants":["Chris Parsons","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"77452","messageId":"056F10DF-524A-48F3-9D53-A8676335B6C3@edendevelopment.co.uk","threadId":"13611","inReplyTo":null,"subject":"[PATCH v2] Updated status to show 'Not currently on any branch' in red","fromName":"Chris Parsons","fromEmail":"chris@edendevelopment.co.uk","sentAt":"2008-05-22T10:19:18Z","receivedAt":"2008-05-22T10:19:18Z","isPatch":true,"sender":{"key":"chris@edendevelopment.co.uk","avatar":null},"body":"This provides additional warning to users when attempting to\ncommit to a detached HEAD. It is configurable in color.status.nobranch.\n\nSigned-off-by: Chris Parsons <chris@edendevelopment.co.uk>\n---\nUpdated to incorporate changes suggested by Jeff King.\n\n  Documentation/config.txt |    6 ++++--\n  wt-status.c              |   11 ++++++++---\n  wt-status.h              |    1 +\n  3 files changed, 13 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 217980f..a073dc1 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -523,8 +523,10 @@ color.status.<slot>::\n  \tone of `header` (the header text of the status message),\n  \t`added` or `updated` (files which are added but not committed),\n  \t`changed` (files which are changed but not added in the index),\n-\tor `untracked` (files which are not tracked by git). The values of\n-\tthese variables may be specified as in color.branch.<slot>.\n+\t`untracked` (files which are not tracked by git), or\n+\t`nobranch` (the color the 'no branch' warning is shown in, defaulting\n+\tto red). The values of these variables may be specified as in\n+\tcolor.branch.<slot>.\n\n  commit.template::\n  \tSpecify a file to use as the template for new commit messages.\ndiff --git a/wt-status.c b/wt-status.c\nindex a44c543..78bc769 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -18,6 +18,7 @@ static char wt_status_colors[][COLOR_MAXLEN] = {\n  \t\"\\033[32m\", /* WT_STATUS_UPDATED: green */\n  \t\"\\033[31m\", /* WT_STATUS_CHANGED: red */\n  \t\"\\033[31m\", /* WT_STATUS_UNTRACKED: red */\n+\t\"\\033[31m\", /* WT_STATUS_NOBRANCH: red */\n  };\n\n  static const char use_add_msg[] =\n@@ -38,6 +39,8 @@ static int parse_status_slot(const char *var, int  \noffset)\n  \t\treturn WT_STATUS_CHANGED;\n  \tif (!strcasecmp(var+offset, \"untracked\"))\n  \t\treturn WT_STATUS_UNTRACKED;\n+\tif (!strcasecmp(var+offset, \"nobranch\"))\n+\t\treturn WT_STATUS_NOBRANCH;\n  \tdie(\"bad config variable '%s'\", var);\n  }\n\n@@ -315,7 +318,8 @@ void wt_status_print(struct wt_status *s)\n  {\n  \tunsigned char sha1[20];\n  \ts->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;\n-\n+\tconst char* branch_color = color(WT_STATUS_HEADER);\n+\n  \tif (s->branch) {\n  \t\tconst char *on_what = \"On branch \";\n  \t\tconst char *branch_name = s->branch;\n@@ -323,10 +327,11 @@ void wt_status_print(struct wt_status *s)\n  \t\t\tbranch_name += 11;\n  \t\telse if (!strcmp(branch_name, \"HEAD\")) {\n  \t\t\tbranch_name = \"\";\n+\t\t\tbranch_color = color(WT_STATUS_NOBRANCH);\n  \t\t\ton_what = \"Not currently on any branch.\";\n  \t\t}\n-\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER),\n-\t\t\t\"# %s%s\", on_what, branch_name);\n+\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"# \");\n+\t\tcolor_fprintf_ln(s->fp, branch_color, \"%s%s\", on_what, branch_name);\n  \t}\n\n  \tif (s->is_initial) {\ndiff --git a/wt-status.h b/wt-status.h\nindex 7d61410..f0675fd 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -8,6 +8,7 @@ enum color_wt_status {\n  \tWT_STATUS_UPDATED,\n  \tWT_STATUS_CHANGED,\n  \tWT_STATUS_UNTRACKED,\n+\tWT_STATUS_NOBRANCH,\n  };\n\n  struct wt_status {\n-- \n1.5.5.1.249.g3fdb.dirty\n"},{"id":"77464","messageId":"20080522125002.GA23889@sigill.intra.peff.net","threadId":"13611","inReplyTo":"056F10DF-524A-48F3-9D53-A8676335B6C3@edendevelopment.co.uk","subject":"Re: [PATCH v2] Updated status to show 'Not currently on any branch' in red","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-05-22T12:50:02Z","receivedAt":"2008-05-22T12:50:02Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"From: Chris Parsons <chris@edendevelopment.co.uk>\n\nThis provides additional warning to users when attempting to\ncommit to a detached HEAD. It is configurable in color.status.nobranch.\n\nSigned-off-by: Chris Parsons <chris@edendevelopment.co.uk>\nAcked-by: Jeff King <peff@peff.net>\n---\nOn Thu, May 22, 2008 at 11:19:18AM +0100, Chris Parsons wrote:\n\n> Updated to incorporate changes suggested by Jeff King.\n\nThe improvements look good to me.\n\nThis patch was severely whitespaced damaged, probably due to:\n\n  Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes\n\nin the original, so I am resending an unmangled version for Junio's\nconvenience. Chris, please make sure to turn off flowed text when\nsending future patches.\n\n Documentation/config.txt |    6 ++++--\n wt-status.c              |    9 +++++++--\n wt-status.h              |    1 +\n 3 files changed, 12 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 217980f..554977b 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -523,8 +523,10 @@ color.status.<slot>::\n \tone of `header` (the header text of the status message),\n \t`added` or `updated` (files which are added but not committed),\n \t`changed` (files which are changed but not added in the index),\n-\tor `untracked` (files which are not tracked by git). The values of\n-\tthese variables may be specified as in color.branch.<slot>.\n+\t`untracked` (files which are not tracked by git), or\n+\t`nobranch` (the color the 'no branch' warning is shown in, defaulting\n+\tto red). The values of these variables may be specified as in\n+\tcolor.branch.<slot>.\n \n commit.template::\n \tSpecify a file to use as the template for new commit messages.\ndiff --git a/wt-status.c b/wt-status.c\nindex a44c543..7a3223e 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -18,6 +18,7 @@ static char wt_status_colors[][COLOR_MAXLEN] = {\n \t\"\\033[32m\", /* WT_STATUS_UPDATED: green */\n \t\"\\033[31m\", /* WT_STATUS_CHANGED: red */\n \t\"\\033[31m\", /* WT_STATUS_UNTRACKED: red */\n+\t\"\\033[31m\", /* WT_STATUS_NOBRANCH: red */\n };\n \n static const char use_add_msg[] =\n@@ -38,6 +39,8 @@ static int parse_status_slot(const char *var, int offset)\n \t\treturn WT_STATUS_CHANGED;\n \tif (!strcasecmp(var+offset, \"untracked\"))\n \t\treturn WT_STATUS_UNTRACKED;\n+\tif (!strcasecmp(var+offset, \"nobranch\"))\n+\t\treturn WT_STATUS_NOBRANCH;\n \tdie(\"bad config variable '%s'\", var);\n }\n \n@@ -315,6 +318,7 @@ void wt_status_print(struct wt_status *s)\n {\n \tunsigned char sha1[20];\n \ts->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;\n+\tconst char* branch_color = color(WT_STATUS_HEADER);\n \n \tif (s->branch) {\n \t\tconst char *on_what = \"On branch \";\n@@ -323,10 +327,11 @@ void wt_status_print(struct wt_status *s)\n \t\t\tbranch_name += 11;\n \t\telse if (!strcmp(branch_name, \"HEAD\")) {\n \t\t\tbranch_name = \"\";\n+\t\t\tbranch_color = color(WT_STATUS_NOBRANCH);\n \t\t\ton_what = \"Not currently on any branch.\";\n \t\t}\n-\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER),\n-\t\t\t\"# %s%s\", on_what, branch_name);\n+\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"# \");\n+\t\tcolor_fprintf_ln(s->fp, branch_color, \"%s%s\", on_what, branch_name);\n \t}\n \n \tif (s->is_initial) {\ndiff --git a/wt-status.h b/wt-status.h\nindex 7d61410..f0675fd 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -8,6 +8,7 @@ enum color_wt_status {\n \tWT_STATUS_UPDATED,\n \tWT_STATUS_CHANGED,\n \tWT_STATUS_UNTRACKED,\n+\tWT_STATUS_NOBRANCH,\n };\n \n struct wt_status {\n-- \n1.5.5.1.450.gdbd2d\n"},{"id":"77470","messageId":"F2379E8F-ACB9-4920-B014-56DA616898A6@edendevelopment.co.uk","threadId":"13611","inReplyTo":"20080522125002.GA23889@sigill.intra.peff.net","subject":"Re: [PATCH v2] Updated status to show 'Not currently on any branch' in red","fromName":"Chris Parsons","fromEmail":"chris@edendevelopment.co.uk","sentAt":"2008-05-22T13:12:54Z","receivedAt":"2008-05-22T13:12:54Z","isPatch":true,"sender":{"key":"chris@edendevelopment.co.uk","avatar":null},"body":"\nOn 22 May 2008, at 13:50, Jeff King wrote:\n\n> in the original, so I am resending an unmangled version for Junio's\n> convenience. Chris, please make sure to turn off flowed text when\n> sending future patches.\n\nHmph - sorry about that. I did read SubmittingPatches carefully, but I  \nguess Apple Mail tripped me up.\n\nThanks\nChris\n"},{"id":"77526","messageId":"7vtzgpsft6.fsf@gitster.siamese.dyndns.org","threadId":"13611","inReplyTo":"20080522125002.GA23889@sigill.intra.peff.net","subject":"Re: [PATCH v2] Updated status to show 'Not currently on any branch' in red","fromName":"Junio C Hamano","fromEmail":"junio@pobox.com","sentAt":"2008-05-23T06:19:33Z","receivedAt":"2008-05-23T06:19:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks, both.\n"}]}