--- /dev/null
+sideband.allowControlCharacters::
+ By default, control characters that are delivered via the sideband
+ are masked, to prevent potentially unwanted ANSI escape sequences
+ from being sent to the terminal. Use this config setting to override
+ this behavior.
{ "error", GIT_COLOR_BOLD_RED },
};
+static int allow_control_characters;
+
/* Returns a color setting (GIT_COLOR_NEVER, etc). */
static int use_sideband_colors(void)
{
if (use_sideband_colors_cached >= 0)
return use_sideband_colors_cached;
+ git_config_get_bool("sideband.allowcontrolcharacters",
+ &allow_control_characters);
+
if (!git_config_get_string_tmp(key, &value))
use_sideband_colors_cached = git_config_colorbool(key, value);
else if (!git_config_get_string_tmp("color.ui", &value))
static void strbuf_add_sanitized(struct strbuf *dest, const char *src, int n)
{
+ if (allow_control_characters) {
+ strbuf_add(dest, src, n);
+ return;
+ }
+
strbuf_grow(dest, n);
for (; n && *src; src++, n--) {
if (!iscntrl(*src) || *src == '\t' || *src == '\n')
EOF
test_config_global uploadPack.packObjectsHook ./color-me-surprised &&
test_commit need-at-least-one-commit &&
+
git clone --no-local . throw-away 2>stderr &&
test_decode_color <stderr >decoded &&
- test_grep ! RED decoded
+ test_grep ! RED decoded &&
+
+ rm -rf throw-away &&
+ git -c sideband.allowControlCharacters clone --no-local . throw-away 2>stderr &&
+ test_decode_color <stderr >decoded &&
+ test_grep RED decoded
'
test_done