{"thread":{"id":"22229","subject":"[PATCH] git status: display current branch name in color","startedAt":"2010-01-15T02:23:16Z","lastAt":"2010-01-18T02:32:55Z","messageCount":3,"participants":["Michael Wookey","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"131699","messageId":"d2e97e801001141823i7519864dy264488d36fca465c@mail.gmail.com","threadId":"22229","inReplyTo":null,"subject":"[PATCH] git status: display current branch name in color","fromName":"Michael Wookey","fromEmail":"michaelwookey@gmail.com","sentAt":"2010-01-15T02:23:16Z","receivedAt":"2010-01-15T02:23:16Z","isPatch":true,"sender":{"key":"michaelwookey@gmail.com","avatar":"https://avatars.githubusercontent.com/u/19476?v=4"},"body":"There is an existing highlight when the user is not on any branch.\nEnhance this functionality to always provide the name of the current\nbranch in color.\n\nSigned-off-by: Michael Wookey <michaelwookey@gmail.com>\n---\n wt-status.c |   10 ++++++----\n wt-status.h |    3 ++-\n 2 files changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 5d56988..bdaa98b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -17,6 +17,7 @@ static char default_wt_status_colors[][COLOR_MAXLEN] = {\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_BRANCH */\n };\n\n static const char *color(int slot, struct wt_status *s)\n@@ -553,7 +554,7 @@ 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_BRANCH, s);\n\n \tif (s->branch) {\n \t\tconst char *on_what = \"On branch \";\n@@ -561,12 +562,13 @@ void wt_status_print(struct wt_status *s)\n \t\tif (!prefixcmp(branch_name, \"refs/heads/\"))\n \t\t\tbranch_name += 11;\n \t\telse if (!strcmp(branch_name, \"HEAD\")) {\n-\t\t\tbranch_name = \"\";\n+\t\t\tbranch_name = \"Not currently on any branch.\";\n \t\t\tbranch_color = color(WT_STATUS_NOBRANCH, s);\n-\t\t\ton_what = \"Not currently on any branch.\";\n+\t\t\ton_what = \"\";\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, color(WT_STATUS_HEADER, s), \"%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 c60f40a..b0cf235 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -12,6 +12,7 @@ enum color_wt_status {\n \tWT_STATUS_UNTRACKED,\n \tWT_STATUS_NOBRANCH,\n \tWT_STATUS_UNMERGED,\n+\tWT_STATUS_BRANCH,\n };\n\n enum untracked_status_type {\n@@ -40,7 +41,7 @@ struct wt_status {\n \tint relative_paths;\n \tint submodule_summary;\n \tenum untracked_status_type show_untracked_files;\n-\tchar color_palette[WT_STATUS_UNMERGED+1][COLOR_MAXLEN];\n+\tchar color_palette[WT_STATUS_BRANCH+1][COLOR_MAXLEN];\n\n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n-- \n1.6.6.197.gfd7f6\n"},{"id":"131921","messageId":"d2e97e801001162031n1dab2301k5a839846b3cc5d9d@mail.gmail.com","threadId":"22229","inReplyTo":"d2e97e801001141823i7519864dy264488d36fca465c@mail.gmail.com","subject":"Re: [PATCH] git status: display current branch name in color","fromName":"Michael Wookey","fromEmail":"michaelwookey@gmail.com","sentAt":"2010-01-17T04:31:07Z","receivedAt":"2010-01-17T04:31:07Z","isPatch":true,"sender":{"key":"michaelwookey@gmail.com","avatar":"https://avatars.githubusercontent.com/u/19476?v=4"},"body":"> There is an existing highlight when the user is not on any branch.\n> Enhance this functionality to always provide the name of the current\n> branch in color.\n>\n> Signed-off-by: Michael Wookey <michaelwookey@gmail.com>\n> ---\n>  wt-status.c |   10 ++++++----\n>  wt-status.h |    3 ++-\n>  2 files changed, 8 insertions(+), 5 deletions(-)\n\nAny thoughts on this?\n\nI have found this to be a useful feature; especially when using\nmsysGit in a Windows CMD shell. Specifically because a CMD shell\nprovides no ability for any sort of \"git-completion.bash\" prompt. By\nhighlighting the current branch name, the colouring has helped to\nquickly identify what the current branch is.\n"},{"id":"132006","messageId":"20100118023255.GC6831@coredump.intra.peff.net","threadId":"22229","inReplyTo":"d2e97e801001162031n1dab2301k5a839846b3cc5d9d@mail.gmail.com","subject":"Re: [PATCH] git status: display current branch name in color","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-01-18T02:32:55Z","receivedAt":"2010-01-18T02:32:55Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Jan 17, 2010 at 03:31:07PM +1100, Michael Wookey wrote:\n\n> > There is an existing highlight when the user is not on any branch.\n> > Enhance this functionality to always provide the name of the current\n> > branch in color.\n> >\n> > Signed-off-by: Michael Wookey <michaelwookey@gmail.com>\n> > ---\n> >  wt-status.c |   10 ++++++----\n> >  wt-status.h |    3 ++-\n> >  2 files changed, 8 insertions(+), 5 deletions(-)\n> \n> Any thoughts on this?\n\nI don't have an objection to the concept, but for it to be acceptable\nfor inclusion in mainstream git, the color selection needs to be\nconfigurable (see builtin-commit.c:parse_status_slot) and documented\n(see Documentation/config.txt, color.status.<slot>).\n\nAnd then we can decide what the _default_ color should be. Personally, I\nfind it a bit distracting to change the color for something so mundane,\nand would be in favor of leaving it the same as the header color. But I\nwill not argue too hard either way; I have no problem with setting my\nown config to make it invisible if others disagree. :)\n\n-Peff\n"}]}