{"thread":{"id":"25774","subject":"[PATCH] status: show branchname with a configurable color","startedAt":"2010-11-17T23:40:05Z","lastAt":"2010-12-01T22:06:27Z","messageCount":2,"participants":["aga@iki.fi","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"156072","messageId":"1290037205-19470-1-git-send-email-aga@iki.fi","threadId":"25774","inReplyTo":null,"subject":"[PATCH] status: show branchname with a configurable color","fromName":"","fromEmail":"aga@iki.fi","sentAt":"2010-11-17T23:40:05Z","receivedAt":"2010-11-17T23:40:05Z","isPatch":true,"sender":{"key":"aga@iki.fi","avatar":null},"body":"From: Aleksi Aalto <aga@iki.fi>\n\nThe configuration variable is color.status.branch.\n\nThe default color is magenta.\n\nSigned-off-by: Aleksi Aalto <aga@iki.fi>\n---\n Documentation/config.txt |   15 +++++++--------\n builtin/commit.c         |    2 ++\n t/t7508-status.sh        |    2 +-\n wt-status.c              |   25 ++++++++++++++-----------\n wt-status.h              |    1 +\n 5 files changed, 25 insertions(+), 20 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex ba9639c..1dd3669 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -769,14 +769,13 @@ color.status::\n \tonly when the output is to a terminal. Defaults to false.\n \n color.status.<slot>::\n-\tUse customized color for status colorization. `<slot>` is\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-\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+\tUse customized color for status colorization. `<slot>` is one of\n+\t`header` (the header text of the status message), `added` or `updated`\n+\t(files which are added but not committed), `changed` (files which\n+\tare changed but not added in the index), `untracked` (files which\n+\tare not tracked by git), `branch` (the current branch) or `nobranch`\n+\t(the color the 'no branch' warning is shown in, defaulting to red). The\n+\tvalues of these variables may be specified as in color.branch.<slot>.\n \n color.ui::\n \tWhen set to `always`, always use colors in all git commands which\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 66fdd22..df4d189 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -984,6 +984,8 @@ static int parse_status_slot(const char *var, int offset)\n {\n \tif (!strcasecmp(var+offset, \"header\"))\n \t\treturn WT_STATUS_HEADER;\n+\tif (!strcasecmp(var+offset, \"branch\"))\n+\t\treturn WT_STATUS_ONBRANCH;\n \tif (!strcasecmp(var+offset, \"updated\")\n \t\t|| !strcasecmp(var+offset, \"added\"))\n \t\treturn WT_STATUS_UPDATED;\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex c9300f3..d755e2a 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -386,7 +386,7 @@ test_expect_success 'setup unique colors' '\n '\n \n cat >expect <<\\EOF\n-# On branch master\n+# On branch <MAGENTA>master<RESET>\n # Changes to be committed:\n #   (use \"git reset HEAD <file>...\" to unstage)\n #\ndiff --git a/wt-status.c b/wt-status.c\nindex fc2438f..ffbbb8f 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -13,14 +13,15 @@\n #include \"submodule.h\"\n \n static char default_wt_status_colors[][COLOR_MAXLEN] = {\n-\tGIT_COLOR_NORMAL, /* WT_STATUS_HEADER */\n-\tGIT_COLOR_GREEN,  /* WT_STATUS_UPDATED */\n-\tGIT_COLOR_RED,    /* WT_STATUS_CHANGED */\n-\tGIT_COLOR_RED,    /* WT_STATUS_UNTRACKED */\n-\tGIT_COLOR_RED,    /* WT_STATUS_NOBRANCH */\n-\tGIT_COLOR_RED,    /* WT_STATUS_UNMERGED */\n-\tGIT_COLOR_GREEN,  /* WT_STATUS_LOCAL_BRANCH */\n-\tGIT_COLOR_RED,    /* WT_STATUS_REMOTE_BRANCH */\n+\tGIT_COLOR_NORMAL,  /* WT_STATUS_HEADER */\n+\tGIT_COLOR_MAGENTA, /* WT_STATUS_ONBRANCH */\n+\tGIT_COLOR_GREEN,   /* WT_STATUS_UPDATED */\n+\tGIT_COLOR_RED,     /* WT_STATUS_CHANGED */\n+\tGIT_COLOR_RED,     /* WT_STATUS_UNTRACKED */\n+\tGIT_COLOR_RED,     /* WT_STATUS_NOBRANCH */\n+\tGIT_COLOR_RED,     /* WT_STATUS_UNMERGED */\n+\tGIT_COLOR_GREEN,   /* WT_STATUS_LOCAL_BRANCH */\n+\tGIT_COLOR_RED,     /* WT_STATUS_REMOTE_BRANCH */\n };\n \n static const char *color(int slot, struct wt_status *s)\n@@ -625,7 +626,8 @@ static void wt_status_print_tracking(struct wt_status *s)\n \n void wt_status_print(struct wt_status *s)\n {\n-\tconst char *branch_color = color(WT_STATUS_HEADER, s);\n+\tconst char *branch_color = color(WT_STATUS_ONBRANCH, s);\n+\tconst char *branch_status_color = color(WT_STATUS_HEADER, s);\n \n \tif (s->branch) {\n \t\tconst char *on_what = \"On branch \";\n@@ -634,11 +636,12 @@ 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, s);\n+\t\t\tbranch_status_color = color(WT_STATUS_NOBRANCH, s);\n \t\t\ton_what = \"Not currently on any branch.\";\n \t\t}\n \t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER, s), \"# \");\n-\t\tcolor_fprintf_ln(s->fp, branch_color, \"%s%s\", on_what, branch_name);\n+\t\tcolor_fprintf(s->fp, branch_status_color, \"%s\", on_what);\n+\t\tcolor_fprintf_ln(s->fp, branch_color, \"%s\", branch_name);\n \t\tif (!s->is_initial)\n \t\t\twt_status_print_tracking(s);\n \t}\ndiff --git a/wt-status.h b/wt-status.h\nindex 9df9c9f..2457f20 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -7,6 +7,7 @@\n \n enum color_wt_status {\n \tWT_STATUS_HEADER = 0,\n+\tWT_STATUS_ONBRANCH,\n \tWT_STATUS_UPDATED,\n \tWT_STATUS_CHANGED,\n \tWT_STATUS_UNTRACKED,\n-- \n1.7.3.3.gc2223.dirty\n"},{"id":"157032","messageId":"7vlj49tafw.fsf@alter.siamese.dyndns.org","threadId":"25774","inReplyTo":"1290037205-19470-1-git-send-email-aga@iki.fi","subject":"Re: [PATCH] status: show branchname with a configurable color","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-01T22:06:27Z","receivedAt":"2010-12-01T22:06:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"aga@iki.fi writes:\n\n>  color.status.<slot>::\n> -\tUse customized color for status colorization. `<slot>` is\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> -\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> +\tUse customized color for status colorization. `<slot>` is one of\n> +\t`header` (the header text of the status message), `added` or `updated`\n> +\t(files which are added but not committed), `changed` (files which\n> +\tare changed but not added in the index), `untracked` (files which\n> +\tare not tracked by git), `branch` (the current branch) or `nobranch`\n> +\t(the color the 'no branch' warning is shown in, defaulting to red). The\n> +\tvalues of these variables may be specified as in color.branch.<slot>.\n\nYuck.  Why did you have to re-wrap the paragraph to make diff unreadable?\n\nIt also is customary to make the default plain, so that existing users\nwon't suddenly get a new and funky behaviour.\n\nI'll queue with a slight rearrangement.\n\nThanks.\n"}]}