{"thread":{"id":"28372","subject":"[PATCH/RFCv2 0/2] format-patch: produce non colorized patches when color.ui=always","startedAt":"2011-09-12T17:46:39Z","lastAt":"2011-09-12T18:43:09Z","messageCount":6,"participants":["Pang Yan Han","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"175345","messageId":"1315849601-26497-1-git-send-email-pangyanhan@gmail.com","threadId":"28372","inReplyTo":null,"subject":"[PATCH/RFCv2 0/2] format-patch: produce non colorized patches when color.ui=always","fromName":"Pang Yan Han","fromEmail":"pangyanhan@gmail.com","sentAt":"2011-09-12T17:46:39Z","receivedAt":"2011-09-12T17:46:39Z","isPatch":true,"sender":{"key":"pangyanhan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/539739?v=4"},"body":"Hi list,\n\nThis 2-patch series has been rerolled with Jeff's suggestions.\n\nFor patch 1/2, I've renamed the new test file to t4051-format-patch-config.sh\nand changed the description to \"check that format-patch does not respect\nporcelain config\". In addition, I've slightly reworded the commit message to\ninclude the date of the commit (c9bfb953) which introduces the regression.\n\nFor patch 2/2, as per Jeff's recommendation, teach git_format_config to\nintercept color.ui in the same way as commit f3aafa4 (Disable color detection\nduring format-patch, 2006-07-09). This is inline with the way we avoid passing\ndown diff.color and color.diff to git_log_config and config functions further\ndown the callchain.\n\nPang Yan Han (2):\n  format-patch: demonstrate that color.ui=always produces colorized\n    patches\n  format-patch: produce non colorized patches when ui.color=always\n\n builtin/log.c                  |    3 ++-\n t/t4051-format-patch-config.sh |   23 +++++++++++++++++++++++\n 2 files changed, 25 insertions(+), 1 deletions(-)\n create mode 100755 t/t4051-format-patch-config.sh\n\n-- \n1.7.7.rc0.190.gb47b6\n"},{"id":"175346","messageId":"1315849601-26497-2-git-send-email-pangyanhan@gmail.com","threadId":"28372","inReplyTo":"1315849601-26497-1-git-send-email-pangyanhan@gmail.com","subject":"[PATCH/RFCv2 1/2] format-patch: demonstrate that color.ui=always produces colorized patches","fromName":"Pang Yan Han","fromEmail":"pangyanhan@gmail.com","sentAt":"2011-09-12T17:46:40Z","receivedAt":"2011-09-12T17:46:40Z","isPatch":true,"sender":{"key":"pangyanhan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/539739?v=4"},"body":"commit c9bfb953 (want_color: automatically fallback to color.ui,\n2011-08-17) introduced a regression where format-patch produces colorized\npatches when color.ui is set to \"always\".\n\nDemonstrate this through a new test.\n\nHelped-by: Jeff King <peff@peff.net>\nSigned-off-by: Pang Yan Han <pangyanhan@gmail.com>\n---\n t/t4051-format-patch-config.sh |   23 +++++++++++++++++++++++\n 1 files changed, 23 insertions(+), 0 deletions(-)\n create mode 100755 t/t4051-format-patch-config.sh\n\ndiff --git a/t/t4051-format-patch-config.sh b/t/t4051-format-patch-config.sh\nnew file mode 100755\nindex 0000000..cea9c7d\n--- /dev/null\n+++ b/t/t4051-format-patch-config.sh\n@@ -0,0 +1,23 @@\n+#!/bin/sh\n+\n+test_description='check that format-patch does not respect porcelain config'\n+\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\techo foo >foo &&\n+\tgit add foo &&\n+\tgit commit -m \"commit1\" &&\n+\techo bar >foo &&\n+\tgit add foo &&\n+\tgit commit -m \"commit2\"\n+'\n+\n+test_expect_failure 'format patch with ui.color=always generates non colorized patch' '\n+\tgit config color.ui always &&\n+\tgit format-patch -1 &&\n+\tmv 0001-commit2.patch actual &&\n+\ttest_must_fail grep \"\\[31m-\" actual\n+'\n+\n+test_done\n-- \n1.7.7.rc0.190.gb47b6\n"},{"id":"175347","messageId":"1315849601-26497-3-git-send-email-pangyanhan@gmail.com","threadId":"28372","inReplyTo":"1315849601-26497-1-git-send-email-pangyanhan@gmail.com","subject":"[PATCH/RFCv2 2/2] format-patch: produce non colorized patches when ui.color=always","fromName":"Pang Yan Han","fromEmail":"pangyanhan@gmail.com","sentAt":"2011-09-12T17:46:41Z","receivedAt":"2011-09-12T17:46:41Z","isPatch":true,"sender":{"key":"pangyanhan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/539739?v=4"},"body":"commit c9bfb953 (want_color: automatically fallback to color.ui,\n2011-08-17) introduced a regression where format-patch produces colorized\npatches when color.ui is set to \"always\".\n\nIn f3aafa4 (Disable color detection during format-patch, 2006-07-09),\ngit_format_config was taught to intercept diff.color to avoid passing it\ndown to git_log_config and later, git_diff_ui_config.\n\nTeach git_format_config to intercept color.ui in the same way.\n\nHelped-by: Jeff King <peff@peff.net>\nSigned-off-by: Pang Yan Han <pangyanhan@gmail.com>\n---\n builtin/log.c                  |    3 ++-\n t/t4051-format-patch-config.sh |    2 +-\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d760ee0..99f8c4c 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -608,7 +608,8 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t\tstring_list_append(&extra_cc, value);\n \t\treturn 0;\n \t}\n-\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\")) {\n+\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\") ||\n+\t\t!strcmp(var, \"color.ui\")) {\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"format.numbered\")) {\ndiff --git a/t/t4051-format-patch-config.sh b/t/t4051-format-patch-config.sh\nindex cea9c7d..35b349e 100755\n--- a/t/t4051-format-patch-config.sh\n+++ b/t/t4051-format-patch-config.sh\n@@ -13,7 +13,7 @@ test_expect_success setup '\n \tgit commit -m \"commit2\"\n '\n \n-test_expect_failure 'format patch with ui.color=always generates non colorized patch' '\n+test_expect_success 'format patch with ui.color=always generates non colorized patch' '\n \tgit config color.ui always &&\n \tgit format-patch -1 &&\n \tmv 0001-commit2.patch actual &&\n-- \n1.7.7.rc0.190.gb47b6\n"},{"id":"175350","messageId":"7vwrdd7hyp.fsf@alter.siamese.dyndns.org","threadId":"28372","inReplyTo":"1315849601-26497-2-git-send-email-pangyanhan@gmail.com","subject":"Re: [PATCH/RFCv2 1/2] format-patch: demonstrate that color.ui=always produces colorized patches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-12T18:07:10Z","receivedAt":"2011-09-12T18:07:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pang Yan Han <pangyanhan@gmail.com> writes:\n\n> commit c9bfb953 (want_color: automatically fallback to color.ui,\n> 2011-08-17) introduced a regression where format-patch produces colorized\n> patches when color.ui is set to \"always\".\n\nThanks.\n\nI'd very much prefer this \"one setup, one test\" folded into an existing\ntest script, instead of wasting a new test number. Perhaps in t4014 whose\ntitle reads \"various format-patch tests\"?\n\n> diff --git a/t/t4051-format-patch-config.sh b/t/t4051-format-patch-config.sh\n> new file mode 100755\n> index 0000000..cea9c7d\n> --- /dev/null\n> +++ b/t/t4051-format-patch-config.sh\n> @@ -0,0 +1,23 @@\n> +#!/bin/sh\n> +\n> +test_description='check that format-patch does not respect porcelain config'\n> +\n> +. ./test-lib.sh\n> +\n> +test_expect_success setup '\n> +\techo foo >foo &&\n> +\tgit add foo &&\n> +\tgit commit -m \"commit1\" &&\n> +\techo bar >foo &&\n> +\tgit add foo &&\n> +\tgit commit -m \"commit2\"\n> +'\n> +\n> +test_expect_failure 'format patch with ui.color=always generates non colorized patch' '\n> +\tgit config color.ui always &&\n> +\tgit format-patch -1 &&\n> +\tmv 0001-commit2.patch actual &&\n\nIf you have a concrete output file, there is no point moving it to\n\"actual\", especially when you are not comparing it with \"expect\".\n\n> +\ttest_must_fail grep \"\\[31m-\" actual\n> +'\n\nHmm, is this grep safe?\n\nPerhaps adding something like this near the end of an existing test script\nmight be simpler and sufficient, no?\n\ntest_expect_failure 'format patch ignores color.ui' '\n\ttest_unconfig color.ui &&\n        git format-patch --stdout -1 >expect &&\n\ttest_config color.ui always &&\n\tgit format-patch --stdout -1 >actual &&\n        test_cmp expect actual\n'\n"},{"id":"175351","messageId":"7vsjo17hws.fsf@alter.siamese.dyndns.org","threadId":"28372","inReplyTo":"1315849601-26497-3-git-send-email-pangyanhan@gmail.com","subject":"Re: [PATCH/RFCv2 2/2] format-patch: produce non colorized patches when ui.color=always","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-12T18:08:19Z","receivedAt":"2011-09-12T18:08:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pang Yan Han <pangyanhan@gmail.com> writes:\n\n> commit c9bfb953 (want_color: automatically fallback to color.ui,\n> 2011-08-17) introduced a regression where format-patch produces colorized\n> patches when color.ui is set to \"always\".\n>\n> In f3aafa4 (Disable color detection during format-patch, 2006-07-09),\n> git_format_config was taught to intercept diff.color to avoid passing it\n> down to git_log_config and later, git_diff_ui_config.\n>\n> Teach git_format_config to intercept color.ui in the same way.\n>\n> Helped-by: Jeff King <peff@peff.net>\n> Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>\n> ---\n>  builtin/log.c                  |    3 ++-\n>  t/t4051-format-patch-config.sh |    2 +-\n>  2 files changed, 3 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/log.c b/builtin/log.c\n> index d760ee0..99f8c4c 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -608,7 +608,8 @@ static int git_format_config(const char *var, const char *value, void *cb)\n>  \t\tstring_list_append(&extra_cc, value);\n>  \t\treturn 0;\n>  \t}\n> -\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\")) {\n> +\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\") ||\n> +\t\t!strcmp(var, \"color.ui\")) {\n>  \t\treturn 0;\n\nLooks sensible. Thanks.\n"},{"id":"175353","messageId":"7vobyp7gaq.fsf@alter.siamese.dyndns.org","threadId":"28372","inReplyTo":"7vsjo17hws.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFCv2 2/2] format-patch: produce non colorized patches when ui.color=always","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-12T18:43:09Z","receivedAt":"2011-09-12T18:43:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I've queued this. Thanks.\n\n-- >8 --\nFrom: Pang Yan Han <pangyanhan@gmail.com>\nDate: Tue, 13 Sep 2011 01:46:41 +0800\nSubject: [PATCH] format-patch: ignore ui.color\n\ncommit c9bfb953 (want_color: automatically fallback to color.ui,\n2011-08-17) introduced a regression where format-patch produces colorized\npatches when color.ui is set to \"always\".\n\nIn f3aafa4 (Disable color detection during format-patch, 2006-07-09),\ngit_format_config was taught to intercept diff.color to avoid passing it\ndown to git_log_config and later, git_diff_ui_config.\n\nTeach git_format_config to intercept color.ui in the same way.\n\nHelped-by: Jeff King <peff@peff.net>\nSigned-off-by: Pang Yan Han <pangyanhan@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/log.c           |    3 ++-\n t/t4014-format-patch.sh |    8 ++++++++\n 2 files changed, 10 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d760ee0..f5d4930 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -608,7 +608,8 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t\tstring_list_append(&extra_cc, value);\n \t\treturn 0;\n \t}\n-\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\")) {\n+\tif (!strcmp(var, \"diff.color\") || !strcmp(var, \"color.diff\") ||\n+\t    !strcmp(var, \"color.ui\")) {\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"format.numbered\")) {\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 5cbc066..7e405d7 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -886,4 +886,12 @@ test_expect_success 'empty subject prefix does not have extra space' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'format patch ignores color.ui' '\n+\ttest_unconfig color.ui &&\n+\tgit format-patch --stdout -1 >expect &&\n+\ttest_config color.ui always &&\n+\tgit format-patch --stdout -1 >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n1.7.7.rc1\n"}]}