Skip to content

Commit 787570c

Browse files
yanhangitster
authored andcommitted
format-patch: ignore ui.color
commit c9bfb95 (want_color: automatically fallback to color.ui, 2011-08-17) introduced a regression where format-patch produces colorized patches when color.ui is set to "always". In f3aafa4 (Disable color detection during format-patch, 2006-07-09), git_format_config was taught to intercept diff.color to avoid passing it down to git_log_config and later, git_diff_ui_config. Teach git_format_config to intercept color.ui in the same way. Helped-by: Jeff King <[email protected]> Signed-off-by: Pang Yan Han <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c9bfb95 commit 787570c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

builtin/log.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,8 @@ static int git_format_config(const char *var, const char *value, void *cb)
608608
string_list_append(&extra_cc, value);
609609
return 0;
610610
}
611-
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
611+
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff") ||
612+
!strcmp(var, "color.ui")) {
612613
return 0;
613614
}
614615
if (!strcmp(var, "format.numbered")) {

t/t4014-format-patch.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,4 +869,12 @@ test_expect_success 'empty subject prefix does not have extra space' '
869869
test_cmp expect actual
870870
'
871871

872+
test_expect_success 'format patch ignores color.ui' '
873+
test_unconfig color.ui &&
874+
git format-patch --stdout -1 >expect &&
875+
test_config color.ui always &&
876+
git format-patch --stdout -1 >actual &&
877+
test_cmp expect actual
878+
'
879+
872880
test_done

0 commit comments

Comments
 (0)