{"thread":{"id":"34482","subject":"[PATCH] git add -e: Explicitly specify that patch should have no color","startedAt":"2013-07-18T22:58:04Z","lastAt":"2013-07-19T08:49:41Z","messageCount":2,"participants":["Andrew Wong","Matthieu Moy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"223718","messageId":"1374188284-27638-1-git-send-email-andrew.kw.w@gmail.com","threadId":"34482","inReplyTo":null,"subject":"[PATCH] git add -e: Explicitly specify that patch should have no color","fromName":"Andrew Wong","fromEmail":"andrew.kw.w@gmail.com","sentAt":"2013-07-18T22:58:04Z","receivedAt":"2013-07-18T22:58:04Z","isPatch":true,"sender":{"key":"andrew.kw.w@gmail.com","avatar":"https://avatars.githubusercontent.com/u/489311?v=4"},"body":"After this commit:\n    4c7f1819b3c142ace98269a556bc929c80e7c9fd make color.ui default to 'auto'\nthe patch file for 'git add -e' receives all the color codes.  This is because\ndiffopt.use_color defaults to -1, which causes want_color to now return 'auto'.\n\nBy explicitly setting use_color to 0, we can ensure the diff output has no\ncolor codes in it.\n\nSigned-off-by: Andrew Wong <andrew.kw.w@gmail.com>\n---\n builtin/add.c | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex f45d9d4..8266a9c 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -343,6 +343,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)\n \n \targc = setup_revisions(argc, argv, &rev, NULL);\n \trev.diffopt.output_format = DIFF_FORMAT_PATCH;\n+\trev.diffopt.use_color = 0;\n \tDIFF_OPT_SET(&rev.diffopt, IGNORE_DIRTY_SUBMODULES);\n \tout = open(file, O_CREAT | O_WRONLY, 0666);\n \tif (out < 0)\n-- \n1.8.3.3.755.gbf91598\n"},{"id":"223740","messageId":"vpqehavndcq.fsf@anie.imag.fr","threadId":"34482","inReplyTo":"1374188284-27638-1-git-send-email-andrew.kw.w@gmail.com","subject":"Re: [PATCH] git add -e: Explicitly specify that patch should have no color","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-07-19T08:49:41Z","receivedAt":"2013-07-19T08:49:41Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Andrew Wong <andrew.kw.w@gmail.com> writes:\n\n> After this commit:\n>     4c7f1819b3c142ace98269a556bc929c80e7c9fd make color.ui default to 'auto'\n> the patch file for 'git add -e' receives all the color codes.  This is because\n> diffopt.use_color defaults to -1, which causes want_color to now return 'auto'.\n\nOops, indeed. The code was relying on the user's config not being loaded\n(hence color.ui was previously ignored), and now has to explicitely\ndisable color.\n\nI'm wondering whether there are other instances of this. I checked that\n\"git format-patch\" is not broken, but I hope we did not forget others.\n\n> --- a/builtin/add.c\n> +++ b/builtin/add.c\n> @@ -343,6 +343,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)\n>  \n>  \targc = setup_revisions(argc, argv, &rev, NULL);\n>  \trev.diffopt.output_format = DIFF_FORMAT_PATCH;\n> +\trev.diffopt.use_color = 0;\n>  \tDIFF_OPT_SET(&rev.diffopt, IGNORE_DIRTY_SUBMODULES);\n>  \tout = open(file, O_CREAT | O_WRONLY, 0666);\n>  \tif (out < 0)\n\nAcknowledged-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}