{"thread":{"id":"21870","subject":"[PATCH 0/2] Refactor status producers and make status -s use color","startedAt":"2009-12-05T15:04:36Z","lastAt":"2009-12-07T08:33:27Z","messageCount":7,"participants":["Michael J Gruber","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"129270","messageId":"cover.1260025135.git.git@drmicha.warpmail.net","threadId":"21870","inReplyTo":null,"subject":"[PATCH 0/2] Refactor status producers and make status -s use color","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-12-05T15:04:36Z","receivedAt":"2009-12-05T15:04:36Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"This is is the refactoring as suggested by Junio, and rebased on top is\nthe patch which makes status -s obey color.status. I also adjusted the\nlatter to not color the space separating the (colored) status letters\nfrom the (uncolored) file name.\n\nThis mini series is directly on top of 91691ec (Merge branch\n'jk/1.7.0-status' into next, 2009-11-27).\n\nMichael J Gruber (2):\n  builtin-commit: refactor short-status code into wt-status.c\n  status -s: obey color.status\n\n builtin-commit.c |  105 ++++-------------------------------------------------\n wt-status.c      |   96 +++++++++++++++++++++++++++++++++++++++++++++++++\n wt-status.h      |    2 +\n 3 files changed, 106 insertions(+), 97 deletions(-)\n"},{"id":"129271","messageId":"c42e3f38816a08aba4610cb808f09067a07ad097.1260025135.git.git@drmicha.warpmail.net","threadId":"21870","inReplyTo":"cover.1260025135.git.git@drmicha.warpmail.net","subject":"[PATCH 1/2] builtin-commit: refactor short-status code into wt-status.c","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-12-05T15:04:37Z","receivedAt":"2009-12-05T15:04:37Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Currently, builtin-commit.c contains most code producing the\nshort-status output, whereas wt-status.c contains most of the code for\nthe long format.\n\nRefactor so that most of the long and short format producing code\nresides in wt-status.c and is named analogously.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n builtin-commit.c |  101 ++---------------------------------------------------\n wt-status.c      |   89 +++++++++++++++++++++++++++++++++++++++++++++++\n wt-status.h      |    2 +\n 3 files changed, 95 insertions(+), 97 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex c103beb..548bbf5 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -79,8 +79,6 @@ static enum {\n \tSTATUS_FORMAT_PORCELAIN,\n } status_format = STATUS_FORMAT_LONG;\n \n-static void short_print(struct wt_status *s, int null_termination);\n-\n static int opt_parse_m(const struct option *opt, const char *arg, int unset)\n {\n \tstruct strbuf *buf = opt->value;\n@@ -387,10 +385,10 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \n \tswitch (status_format) {\n \tcase STATUS_FORMAT_SHORT:\n-\t\tshort_print(s, null_termination);\n+\t\twt_shortstatus_print(s, null_termination);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\n-\t\tshort_print(s, null_termination);\n+\t\twt_shortstatus_print(s, null_termination);\n \t\tbreak;\n \tcase STATUS_FORMAT_LONG:\n \t\twt_status_print(s);\n@@ -982,97 +980,6 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \treturn git_diff_ui_config(k, v, NULL);\n }\n \n-#define quote_path quote_path_relative\n-\n-static void short_unmerged(int null_termination, struct string_list_item *it,\n-\t\t\t   struct wt_status *s)\n-{\n-\tstruct wt_status_change_data *d = it->util;\n-\tconst char *how = \"??\";\n-\n-\tswitch (d->stagemask) {\n-\tcase 1: how = \"DD\"; break; /* both deleted */\n-\tcase 2: how = \"AU\"; break; /* added by us */\n-\tcase 3: how = \"UD\"; break; /* deleted by them */\n-\tcase 4: how = \"UA\"; break; /* added by them */\n-\tcase 5: how = \"DU\"; break; /* deleted by us */\n-\tcase 6: how = \"AA\"; break; /* both added */\n-\tcase 7: how = \"UU\"; break; /* both modified */\n-\t}\n-\tprintf(\"%s \", how);\n-\tif (null_termination) {\n-\t\tfprintf(stdout, \"%s%c\", it->string, 0);\n-\t} else {\n-\t\tstruct strbuf onebuf = STRBUF_INIT;\n-\t\tconst char *one;\n-\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n-\t\tprintf(\"%s\\n\", one);\n-\t\tstrbuf_release(&onebuf);\n-\t}\n-}\n-\n-static void short_status(int null_termination, struct string_list_item *it,\n-\t\t\t struct wt_status *s)\n-{\n-\tstruct wt_status_change_data *d = it->util;\n-\n-\tprintf(\"%c%c \",\n-\t       !d->index_status ? ' ' : d->index_status,\n-\t       !d->worktree_status ? ' ' : d->worktree_status);\n-\tif (null_termination) {\n-\t\tfprintf(stdout, \"%s%c\", it->string, 0);\n-\t\tif (d->head_path)\n-\t\t\tfprintf(stdout, \"%s%c\", d->head_path, 0);\n-\t} else {\n-\t\tstruct strbuf onebuf = STRBUF_INIT;\n-\t\tconst char *one;\n-\t\tif (d->head_path) {\n-\t\t\tone = quote_path(d->head_path, -1, &onebuf, s->prefix);\n-\t\t\tprintf(\"%s -> \", one);\n-\t\t\tstrbuf_release(&onebuf);\n-\t\t}\n-\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n-\t\tprintf(\"%s\\n\", one);\n-\t\tstrbuf_release(&onebuf);\n-\t}\n-}\n-\n-static void short_untracked(int null_termination, struct string_list_item *it,\n-\t\t\t    struct wt_status *s)\n-{\n-\tif (null_termination) {\n-\t\tfprintf(stdout, \"?? %s%c\", it->string, 0);\n-\t} else {\n-\t\tstruct strbuf onebuf = STRBUF_INIT;\n-\t\tconst char *one;\n-\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n-\t\tprintf(\"?? %s\\n\", one);\n-\t\tstrbuf_release(&onebuf);\n-\t}\n-}\n-\n-static void short_print(struct wt_status *s, int null_termination)\n-{\n-\tint i;\n-\tfor (i = 0; i < s->change.nr; i++) {\n-\t\tstruct wt_status_change_data *d;\n-\t\tstruct string_list_item *it;\n-\n-\t\tit = &(s->change.items[i]);\n-\t\td = it->util;\n-\t\tif (d->stagemask)\n-\t\t\tshort_unmerged(null_termination, it, s);\n-\t\telse\n-\t\t\tshort_status(null_termination, it, s);\n-\t}\n-\tfor (i = 0; i < s->untracked.nr; i++) {\n-\t\tstruct string_list_item *it;\n-\n-\t\tit = &(s->untracked.items[i]);\n-\t\tshort_untracked(null_termination, it, s);\n-\t}\n-}\n-\n int cmd_status(int argc, const char **argv, const char *prefix)\n {\n \tstruct wt_status s;\n@@ -1115,10 +1022,10 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tcase STATUS_FORMAT_SHORT:\n \t\tif (s.relative_paths)\n \t\t\ts.prefix = prefix;\n-\t\tshort_print(&s, null_termination);\n+\t\twt_shortstatus_print(&s, null_termination);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\n-\t\tshort_print(&s, null_termination);\n+\t\twt_shortstatus_print(&s, null_termination);\n \t\tbreak;\n \tcase STATUS_FORMAT_LONG:\n \t\ts.verbose = verbose;\ndiff --git a/wt-status.c b/wt-status.c\nindex 3c2f580..93af994 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -600,3 +600,92 @@ void wt_status_print(struct wt_status *s)\n \t\t\tprintf(\"nothing to commit (working directory clean)\\n\");\n \t}\n }\n+\n+static void wt_shortstatus_unmerged(int null_termination, struct string_list_item *it,\n+\t\t\t   struct wt_status *s)\n+{\n+\tstruct wt_status_change_data *d = it->util;\n+\tconst char *how = \"??\";\n+\n+\tswitch (d->stagemask) {\n+\tcase 1: how = \"DD\"; break; /* both deleted */\n+\tcase 2: how = \"AU\"; break; /* added by us */\n+\tcase 3: how = \"UD\"; break; /* deleted by them */\n+\tcase 4: how = \"UA\"; break; /* added by them */\n+\tcase 5: how = \"DU\"; break; /* deleted by us */\n+\tcase 6: how = \"AA\"; break; /* both added */\n+\tcase 7: how = \"UU\"; break; /* both modified */\n+\t}\n+\tprintf(\"%s \", how);\n+\tif (null_termination) {\n+\t\tfprintf(stdout, \"%s%c\", it->string, 0);\n+\t} else {\n+\t\tstruct strbuf onebuf = STRBUF_INIT;\n+\t\tconst char *one;\n+\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n+\t\tprintf(\"%s\\n\", one);\n+\t\tstrbuf_release(&onebuf);\n+\t}\n+}\n+\n+static void wt_shortstatus_status(int null_termination, struct string_list_item *it,\n+\t\t\t struct wt_status *s)\n+{\n+\tstruct wt_status_change_data *d = it->util;\n+\n+\tprintf(\"%c%c \",\n+\t\t!d->index_status ? ' ' : d->index_status,\n+\t\t!d->worktree_status ? ' ' : d->worktree_status);\n+\tif (null_termination) {\n+\t\tfprintf(stdout, \"%s%c\", it->string, 0);\n+\t\tif (d->head_path)\n+\t\t\tfprintf(stdout, \"%s%c\", d->head_path, 0);\n+\t} else {\n+\t\tstruct strbuf onebuf = STRBUF_INIT;\n+\t\tconst char *one;\n+\t\tif (d->head_path) {\n+\t\t\tone = quote_path(d->head_path, -1, &onebuf, s->prefix);\n+\t\t\tprintf(\"%s -> \", one);\n+\t\t\tstrbuf_release(&onebuf);\n+\t\t}\n+\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n+\t\tprintf(\"%s\\n\", one);\n+\t\tstrbuf_release(&onebuf);\n+\t}\n+}\n+\n+static void wt_shortstatus_untracked(int null_termination, struct string_list_item *it,\n+\t\t\t    struct wt_status *s)\n+{\n+\tif (null_termination) {\n+\t\tfprintf(stdout, \"?? %s%c\", it->string, 0);\n+\t} else {\n+\t\tstruct strbuf onebuf = STRBUF_INIT;\n+\t\tconst char *one;\n+\t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n+\t\tprintf(\"?? %s\\n\", one);\n+\t\tstrbuf_release(&onebuf);\n+\t}\n+}\n+\n+void wt_shortstatus_print(struct wt_status *s, int null_termination)\n+{\n+\tint i;\n+\tfor (i = 0; i < s->change.nr; i++) {\n+\t\tstruct wt_status_change_data *d;\n+\t\tstruct string_list_item *it;\n+\n+\t\tit = &(s->change.items[i]);\n+\t\td = it->util;\n+\t\tif (d->stagemask)\n+\t\t\twt_shortstatus_unmerged(null_termination, it, s);\n+\t\telse\n+\t\t\twt_shortstatus_status(null_termination, it, s);\n+\t}\n+\tfor (i = 0; i < s->untracked.nr; i++) {\n+\t\tstruct string_list_item *it;\n+\n+\t\tit = &(s->untracked.items[i]);\n+\t\twt_shortstatus_untracked(null_termination, it, s);\n+\t}\n+}\ndiff --git a/wt-status.h b/wt-status.h\nindex 09fd9f1..39c9aef 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -56,4 +56,6 @@ void wt_status_prepare(struct wt_status *s);\n void wt_status_print(struct wt_status *s);\n void wt_status_collect(struct wt_status *s);\n \n+void wt_shortstatus_print(struct wt_status *s, int null_termination);\n+\n #endif /* STATUS_H */\n-- \n1.6.6.rc1.282.ge6667\n"},{"id":"129272","messageId":"2b987524f57a0ac04e219f82e20e806741ce4eca.1260025135.git.git@drmicha.warpmail.net","threadId":"21870","inReplyTo":"cover.1260025135.git.git@drmicha.warpmail.net","subject":"[PATCH 2/2] status -s: obey color.status","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-12-05T15:04:38Z","receivedAt":"2009-12-05T15:04:38Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Make the short version of status obey the color.status boolean. We color\nthe status letters only, because they carry the state information and are\npotentially colored differently, such as for a file with staged changes\nas well as changes in the worktree against the index.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n builtin-commit.c |    4 ++++\n wt-status.c      |   21 ++++++++++++++-------\n 2 files changed, 18 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 548bbf5..ddcfffb 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -1022,6 +1022,10 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tcase STATUS_FORMAT_SHORT:\n \t\tif (s.relative_paths)\n \t\t\ts.prefix = prefix;\n+\t\tif (s.use_color == -1)\n+\t\t\ts.use_color = git_use_color_default;\n+\t\tif (diff_use_color_default == -1)\n+\t\t\tdiff_use_color_default = git_use_color_default;\n \t\twt_shortstatus_print(&s, null_termination);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\ndiff --git a/wt-status.c b/wt-status.c\nindex 93af994..a8b6d05 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -616,14 +616,14 @@ static void wt_shortstatus_unmerged(int null_termination, struct string_list_ite\n \tcase 6: how = \"AA\"; break; /* both added */\n \tcase 7: how = \"UU\"; break; /* both modified */\n \t}\n-\tprintf(\"%s \", how);\n+\tcolor_fprintf(s->fp, color(WT_STATUS_UNMERGED, s), \"%s\", how);\n \tif (null_termination) {\n-\t\tfprintf(stdout, \"%s%c\", it->string, 0);\n+\t\tfprintf(stdout, \" %s%c\", it->string, 0);\n \t} else {\n \t\tstruct strbuf onebuf = STRBUF_INIT;\n \t\tconst char *one;\n \t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n-\t\tprintf(\"%s\\n\", one);\n+\t\tprintf(\" %s\\n\", one);\n \t\tstrbuf_release(&onebuf);\n \t}\n }\n@@ -633,9 +633,15 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item\n {\n \tstruct wt_status_change_data *d = it->util;\n \n-\tprintf(\"%c%c \",\n-\t\t!d->index_status ? ' ' : d->index_status,\n-\t\t!d->worktree_status ? ' ' : d->worktree_status);\n+\tif (d->index_status)\n+\t\tcolor_fprintf(s->fp, color(WT_STATUS_UPDATED, s), \"%c\", d->index_status);\n+\telse\n+\t\tputchar(' ');\n+\tif (d->worktree_status)\n+\t\tcolor_fprintf(s->fp, color(WT_STATUS_CHANGED, s), \"%c\", d->worktree_status);\n+\telse\n+\t\tputchar(' ');\n+\tputchar(' ');\n \tif (null_termination) {\n \t\tfprintf(stdout, \"%s%c\", it->string, 0);\n \t\tif (d->head_path)\n@@ -663,7 +669,8 @@ static void wt_shortstatus_untracked(int null_termination, struct string_list_it\n \t\tstruct strbuf onebuf = STRBUF_INIT;\n \t\tconst char *one;\n \t\tone = quote_path(it->string, -1, &onebuf, s->prefix);\n-\t\tprintf(\"?? %s\\n\", one);\n+\t\tcolor_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), \"??\");\n+\t\tprintf(\" %s\\n\", one);\n \t\tstrbuf_release(&onebuf);\n \t}\n }\n-- \n1.6.6.rc1.282.ge6667\n"},{"id":"129365","messageId":"7v638jd3sj.fsf@alter.siamese.dyndns.org","threadId":"21870","inReplyTo":"c42e3f38816a08aba4610cb808f09067a07ad097.1260025135.git.git@drmicha.warpmail.net","subject":"Re: [PATCH 1/2] builtin-commit: refactor short-status code into wt-status.c","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-07T00:30:04Z","receivedAt":"2009-12-07T00:30:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Currently, builtin-commit.c contains most code producing the\n> short-status output, whereas wt-status.c contains most of the code for\n> the long format.\n>\n> Refactor so that most of the long and short format producing code\n> resides in wt-status.c and is named analogously.\n>\n> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n> ---\n>  builtin-commit.c |  101 ++---------------------------------------------------\n>  wt-status.c      |   89 +++++++++++++++++++++++++++++++++++++++++++++++\n>  wt-status.h      |    2 +\n>  3 files changed, 95 insertions(+), 97 deletions(-)\n\nNice.\n\nThanks.\n"},{"id":"129377","messageId":"20091207051715.GA17521@coredump.intra.peff.net","threadId":"21870","inReplyTo":"2b987524f57a0ac04e219f82e20e806741ce4eca.1260025135.git.git@drmicha.warpmail.net","subject":"Re: [PATCH 2/2] status -s: obey color.status","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-12-07T05:17:15Z","receivedAt":"2009-12-07T05:17:15Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Dec 05, 2009 at 04:04:38PM +0100, Michael J Gruber wrote:\n\n> Make the short version of status obey the color.status boolean. We color\n> the status letters only, because they carry the state information and are\n> potentially colored differently, such as for a file with staged changes\n> as well as changes in the worktree against the index.\n\nThis seems to also turn on color for --porcelain in some cases, because\ngit_status_config unconditionally sets s->use_color if you are using\ncolor.status instead of color.ui. I think we are probably best just\nexplicitly disabling options for the \"porcelain\" format rather than\ntrying to come up with some trickery to make sure they never get set.\nLike:\n\n-- >8 --\nSubject: [PATCH] status: disable color for porcelain format\n\nThe porcelain format is identical to the shortstatus format,\nexcept that it should not respect any user configuration,\nincluding color.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin-commit.c |    4 ++--\n wt-status.c      |    6 ++++++\n wt-status.h      |    1 +\n 3 files changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex ddcfffb..88b25aa 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -388,7 +388,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int\n \t\twt_shortstatus_print(s, null_termination);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\n-\t\twt_shortstatus_print(s, null_termination);\n+\t\twt_porcelain_print(s, null_termination);\n \t\tbreak;\n \tcase STATUS_FORMAT_LONG:\n \t\twt_status_print(s);\n@@ -1029,7 +1029,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\twt_shortstatus_print(&s, null_termination);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\n-\t\twt_shortstatus_print(&s, null_termination);\n+\t\twt_porcelain_print(&s, null_termination);\n \t\tbreak;\n \tcase STATUS_FORMAT_LONG:\n \t\ts.verbose = verbose;\ndiff --git a/wt-status.c b/wt-status.c\nindex a8b6d05..e9bbfbc 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -696,3 +696,9 @@ void wt_shortstatus_print(struct wt_status *s, int null_termination)\n \t\twt_shortstatus_untracked(null_termination, it, s);\n \t}\n }\n+\n+void wt_porcelain_print(struct wt_status *s, int null_termination)\n+{\n+\ts->use_color = 0;\n+\twt_shortstatus_print(s, null_termination);\n+}\ndiff --git a/wt-status.h b/wt-status.h\nindex 39c9aef..a4bddcf 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -57,5 +57,6 @@ void wt_status_print(struct wt_status *s);\n void wt_status_collect(struct wt_status *s);\n \n void wt_shortstatus_print(struct wt_status *s, int null_termination);\n+void wt_porcelain_print(struct wt_status *s, int null_termination);\n \n #endif /* STATUS_H */\n-- \n1.6.6.rc1.292.gd8fe.dirty\n"},{"id":"129378","messageId":"20091207052625.GB17521@coredump.intra.peff.net","threadId":"21870","inReplyTo":"20091207051715.GA17521@coredump.intra.peff.net","subject":"Re: [PATCH 2/2] status -s: obey color.status","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-12-07T05:26:25Z","receivedAt":"2009-12-07T05:26:25Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Dec 07, 2009 at 12:17:15AM -0500, Jeff King wrote:\n\n> This seems to also turn on color for --porcelain in some cases, because\n> git_status_config unconditionally sets s->use_color if you are using\n> color.status instead of color.ui. I think we are probably best just\n> explicitly disabling options for the \"porcelain\" format rather than\n> trying to come up with some trickery to make sure they never get set.\n\nAlso, this means we can hoist repeated code out of the switch statement,\nlike this:\n\n-- >8 --\nSubject: [PATCH] status: reduce duplicated setup code\n\nWe have three output formats: short, porcelain, and long.\nThe short and long formats respect user-config, and the\nporcelain one does not. This led to us repeating\nconfig-related setup code for the short and long formats.\n\nSince the last commit, color config is explicitly cleared\nwhen showing the porcelain format. Let's do the same with\nrelative-path configuration, which enables us to hoist the\nduplicated code from the switch statement in cmd_status.\n\nAs a bonus, this fixes \"commit --dry-run --porcelain\", which\nwas unconditionally setting up that configuration, anyway.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin-commit.c |   19 +++++++------------\n wt-status.c      |    2 ++\n 2 files changed, 9 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 88b25aa..a11e585 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -1018,14 +1018,15 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \ts.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;\n \twt_status_collect(&s);\n \n+\tif (s.relative_paths)\n+\t\ts.prefix = prefix;\n+\tif (s.use_color == -1)\n+\t\ts.use_color = git_use_color_default;\n+\tif (diff_use_color_default == -1)\n+\t\tdiff_use_color_default = git_use_color_default;\n+\n \tswitch (status_format) {\n \tcase STATUS_FORMAT_SHORT:\n-\t\tif (s.relative_paths)\n-\t\t\ts.prefix = prefix;\n-\t\tif (s.use_color == -1)\n-\t\t\ts.use_color = git_use_color_default;\n-\t\tif (diff_use_color_default == -1)\n-\t\t\tdiff_use_color_default = git_use_color_default;\n \t\twt_shortstatus_print(&s, null_termination);\n \t\tbreak;\n \tcase STATUS_FORMAT_PORCELAIN:\n@@ -1033,12 +1034,6 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \t\tbreak;\n \tcase STATUS_FORMAT_LONG:\n \t\ts.verbose = verbose;\n-\t\tif (s.relative_paths)\n-\t\t\ts.prefix = prefix;\n-\t\tif (s.use_color == -1)\n-\t\t\ts.use_color = git_use_color_default;\n-\t\tif (diff_use_color_default == -1)\n-\t\t\tdiff_use_color_default = git_use_color_default;\n \t\twt_status_print(&s);\n \t\tbreak;\n \t}\ndiff --git a/wt-status.c b/wt-status.c\nindex e9bbfbc..55b6696 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -700,5 +700,7 @@ void wt_shortstatus_print(struct wt_status *s, int null_termination)\n void wt_porcelain_print(struct wt_status *s, int null_termination)\n {\n \ts->use_color = 0;\n+\ts->relative_paths = 0;\n+\ts->prefix = NULL;\n \twt_shortstatus_print(s, null_termination);\n }\n-- \n1.6.6.rc1.292.gd8fe.dirty\n"},{"id":"129390","messageId":"4B1CBDD7.2070906@drmicha.warpmail.net","threadId":"21870","inReplyTo":"20091207051715.GA17521@coredump.intra.peff.net","subject":"Re: [PATCH 2/2] status -s: obey color.status","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-12-07T08:33:27Z","receivedAt":"2009-12-07T08:33:27Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jeff King venit, vidit, dixit 07.12.2009 06:17:\n> On Sat, Dec 05, 2009 at 04:04:38PM +0100, Michael J Gruber wrote:\n> \n>> Make the short version of status obey the color.status boolean. We color\n>> the status letters only, because they carry the state information and are\n>> potentially colored differently, such as for a file with staged changes\n>> as well as changes in the worktree against the index.\n> \n> This seems to also turn on color for --porcelain in some cases, because\n> git_status_config unconditionally sets s->use_color if you are using\n> color.status instead of color.ui. I think we are probably best just\n> explicitly disabling options for the \"porcelain\" format rather than\n> trying to come up with some trickery to make sure they never get set.\n> Like:\n\nThanks. I let myself get fooled by the apparent option handling within\nthe switch statement (which is OK for relativePaths) (and some\nsubconscious link between null_termination and porcelain, which goes one\nway only).\n\nI guess this shows (again) that one needs tests for everything... If I\nget around to I'll amend t$(relevantoneicantrecallrightnow) with tests\nfor long and short status with color and porcelain with the various options.\n\nMichael\n"}]}