{"thread":{"id":"13355","subject":"[PATCH] git-cherry: add color to the output","startedAt":"2008-05-02T18:01:44Z","lastAt":"2008-05-05T05:14:32Z","messageCount":3,"participants":["Richard Quirk","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"75857","messageId":"1209751304-25304-1-git-send-email-richard.quirk@gmail.com","threadId":"13355","inReplyTo":null,"subject":"[PATCH] git-cherry: add color to the output","fromName":"Richard Quirk","fromEmail":"richard.quirk@gmail.com","sentAt":"2008-05-02T18:01:44Z","receivedAt":"2008-05-02T18:01:44Z","isPatch":true,"sender":{"key":"richard.quirk@gmail.com","avatar":null},"body":"If color.diff is set then patches not yet cherry-picked are marked green\nand already picked ones are marked red. This makes it easier to tell at a\nglance which changes have not been cherry-picked.\n\nA possible inconsistency is that the sha1 is marked in red or green here\nwhereas it is yellow elsewhere. The other possibility was to mark only\nthe +/- sign in the appropriate color, but this was more difficult to\ndistinguish between not-picked/picked changes.\n\nSigned-off-by: Richard Quirk <richard.quirk@gmail.com>\n---\n builtin-log.c |   21 ++++++++++++++++-----\n 1 files changed, 16 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 1670d0b..bca6dd7 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -1083,6 +1083,11 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n \tconst char *limit = NULL;\n \tint verbose = 0;\n \n+\tgit_config(git_log_config);\n+\n+\tif (diff_use_color_default == -1)\n+\t\tdiff_use_color_default = git_use_color_default;\n+\n \tif (argc > 1 && !strcmp(argv[1], \"-v\")) {\n \t\tverbose = 1;\n \t\targc--;\n@@ -1136,26 +1141,32 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n \n \t\tcommit_list_insert(commit, &list);\n \t}\n+\tconst char *reset = diff_get_color(diff_use_color_default, DIFF_RESET);\n+\tconst char *old = diff_get_color(diff_use_color_default, DIFF_FILE_OLD);\n+\tconst char *new = diff_get_color(diff_use_color_default, DIFF_FILE_NEW);\n \n \twhile (list) {\n \t\tchar sign = '+';\n+\t\tconst char * line_color = new;\n \n \t\tcommit = list->item;\n-\t\tif (has_commit_patch_id(commit, &ids))\n+\t\tif (has_commit_patch_id(commit, &ids)) {\n \t\t\tsign = '-';\n+\t\t\tline_color = old;\n+\t\t}\n \n+\t\tprintf(\"%s%c %s%s\", line_color, sign,\n+\t\t       sha1_to_hex(commit->object.sha1), reset);\n \t\tif (verbose) {\n \t\t\tstruct strbuf buf;\n \t\t\tstrbuf_init(&buf, 0);\n \t\t\tpretty_print_commit(CMIT_FMT_ONELINE, commit,\n \t\t\t                    &buf, 0, NULL, NULL, 0, 0);\n-\t\t\tprintf(\"%c %s %s\\n\", sign,\n-\t\t\t       sha1_to_hex(commit->object.sha1), buf.buf);\n+\t\t\tprintf(\" %s\\n\", buf.buf);\n \t\t\tstrbuf_release(&buf);\n \t\t}\n \t\telse {\n-\t\t\tprintf(\"%c %s\\n\", sign,\n-\t\t\t       sha1_to_hex(commit->object.sha1));\n+\t\t\tprintf(\"\\n\");\n \t\t}\n \n \t\tlist = list->next;\n-- \n1.5.5.1.116.ge4b9c\n"},{"id":"76061","messageId":"20080505032718.GA15498@sigill.intra.peff.net","threadId":"13355","inReplyTo":"1209751304-25304-1-git-send-email-richard.quirk@gmail.com","subject":"Re: [PATCH] git-cherry: add color to the output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-05-05T03:27:18Z","receivedAt":"2008-05-05T03:27:18Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, May 02, 2008 at 08:01:44PM +0200, Richard Quirk wrote:\n\n> If color.diff is set then patches not yet cherry-picked are marked green\n> and already picked ones are marked red. This makes it easier to tell at a\n> glance which changes have not been cherry-picked.\n\nI don't actually use git-cherry, so I can't say whether this is useful\nor not. But I wonder if it should follow the trend of other color\noptions and get its own color.cherry variable, but also be controlled by\nthe master color.ui.\n\n-Peff\n"},{"id":"76074","messageId":"7vlk2pnxhj.fsf@gitster.siamese.dyndns.org","threadId":"13355","inReplyTo":"20080505032718.GA15498@sigill.intra.peff.net","subject":"Re: [PATCH] git-cherry: add color to the output","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-05-05T05:14:32Z","receivedAt":"2008-05-05T05:14:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Fri, May 02, 2008 at 08:01:44PM +0200, Richard Quirk wrote:\n>\n>> If color.diff is set then patches not yet cherry-picked are marked green\n>> and already picked ones are marked red. This makes it easier to tell at a\n>> glance which changes have not been cherry-picked.\n>\n> I don't actually use git-cherry, so I can't say whether this is useful\n> or not. But I wonder if it should follow the trend of other color\n> options and get its own color.cherry variable, but also be controlled by\n> the master color.ui.\n\nI do not use git-cherry as Porcelain nor did I design it to be used as\nsuch.  \"color.cherry = always\" would worry me but the user is asking for\ntrouble if he did so, so perhaps it is Ok.\n"}]}