{"thread":{"id":"66555","subject":"[PATCH] sideband: skip unrecognized allowControlCharacters keywords","startedAt":"2026-10-16T12:39:34Z","lastAt":"2026-11-07T02:20:36Z","messageCount":6,"participants":["Thomas Bachem via GitGitGadget","Tuomas Ahola","Thomas Bachem","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"555235","messageId":"pull.2261.git.1792154374653.gitgitgadget@gmail.com","threadId":"66555","inReplyTo":null,"subject":"[PATCH] sideband: skip unrecognized allowControlCharacters keywords","fromName":"Thomas Bachem via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-10-16T12:39:34Z","receivedAt":"2026-10-16T12:39:34Z","isPatch":true,"sender":{"key":"mail@thomasbachem.com","avatar":"https://gravatar.com/avatar/e9bc28172fe03ca6777b6d330a8503511d84bde14ce0e84c962d2b3b39ed3db1?d=mp&s=160"},"body":"From: Thomas Bachem <mail@thomasbachem.com>\n\nSince 128914438a (sideband: add options to allow more control\nsequences to be passed through, 2026-03-05), the value of\nsideband.allowControlCharacters is a comma-separated list of\nkeywords. When the parser meets a keyword it does not know, it warns\nbut stays on that keyword, so the warning repeats forever.\n\nAs the setting is read whenever a transport is set up, a typo like\n\"colour\", a list written as \"color, cursor\" with a space, or a\nkeyword that only a newer version of Git knows is enough to make\nevery fetch, push, clone and ls-remote hang this way.\n\nMove on to the next keyword after the warning, and name only the\nunrecognized keyword in it, not the rest of the list.\n\nAssisted-by: Claude Opus 5.5\nSigned-off-by: Thomas Bachem <mail@thomasbachem.com>\n---\n    sideband: skip unrecognized allowControlCharacters keywords\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2261%2Fthomasbachem%2Fsideband-control-characters-loop-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2261/thomasbachem/sideband-control-characters-loop-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/2261\n\n sideband.c                          | 19 ++++++++++++-------\n t/t5409-colorize-remote-messages.sh | 25 +++++++++++++++++++++++++\n 2 files changed, 37 insertions(+), 7 deletions(-)\n\ndiff --git a/sideband.c b/sideband.c\nindex 374187402e..ed6840bf89 100644\n--- a/sideband.c\n+++ b/sideband.c\n@@ -62,18 +62,23 @@ int sideband_allow_control_characters_config(const char *var, const char *value)\n \n \tallow_control_characters = ALLOW_NO_CONTROL_CHARACTERS;\n \twhile (*value) {\n-\t\tif (skip_prefix_in_csv(value, \"color\", &value))\n+\t\tif (skip_prefix_in_csv(value, \"color\", &value)) {\n \t\t\tallow_control_characters |= ALLOW_ANSI_COLOR_SEQUENCES;\n-\t\telse if (skip_prefix_in_csv(value, \"cursor\", &value))\n+\t\t} else if (skip_prefix_in_csv(value, \"cursor\", &value)) {\n \t\t\tallow_control_characters |= ALLOW_ANSI_CURSOR_MOVEMENTS;\n-\t\telse if (skip_prefix_in_csv(value, \"erase\", &value))\n+\t\t} else if (skip_prefix_in_csv(value, \"erase\", &value)) {\n \t\t\tallow_control_characters |= ALLOW_ANSI_ERASE;\n-\t\telse if (skip_prefix_in_csv(value, \"true\", &value))\n+\t\t} else if (skip_prefix_in_csv(value, \"true\", &value)) {\n \t\t\tallow_control_characters = ALLOW_ALL_CONTROL_CHARACTERS;\n-\t\telse if (skip_prefix_in_csv(value, \"false\", &value))\n+\t\t} else if (skip_prefix_in_csv(value, \"false\", &value)) {\n \t\t\tallow_control_characters = ALLOW_NO_CONTROL_CHARACTERS;\n-\t\telse\n-\t\t\twarning(_(\"unrecognized value for '%s': '%s'\"), var, value);\n+\t\t} else {\n+\t\t\tconst char *end = strchrnul(value, ',');\n+\n+\t\t\twarning(_(\"unrecognized value for '%s': '%.*s'\"),\n+\t\t\t\tvar, (int)(end - value), value);\n+\t\t\tvalue = end + !!*end;\n+\t\t}\n \t}\n \treturn 0;\n }\ndiff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh\nindex 5da8b0ad64..6117579eb1 100755\n--- a/t/t5409-colorize-remote-messages.sh\n+++ b/t/t5409-colorize-remote-messages.sh\n@@ -190,4 +190,29 @@ test_expect_success 'allow all control sequences for a specific URL' '\n \ttest_grep ! \"\\\\^\\\\[\\\\[K\" decoded\n '\n \n+test_expect_success 'unrecognized keywords in allowControlCharacters are skipped' '\n+\twrite_script .git/eraser <<-\\EOF &&\n+\tprintf \"error: Ohai!\\\\r\\\\033[K\" >&2\n+\texec \"$@\"\n+\tEOF\n+\ttest_config_global uploadPack.packObjectsHook ./eraser &&\n+\ttest_commit unrecognized-keyword &&\n+\n+\t# Cap the output, so that a parser stuck on the unrecognized\n+\t# keyword fails the test instead of warning forever.\n+\tgit -c sideband.allowControlCharacters=bogus,erase \\\n+\t\tls-remote . 2>&1 >/dev/null |\n+\thead -n 2 >warnings &&\n+\ttest_line_count = 1 warnings &&\n+\ttest_grep \"allowcontrolcharacters.: .bogus.$\" warnings &&\n+\n+\trm -rf throw-away &&\n+\tgit -c sideband.allowControlCharacters=bogus,erase \\\n+\t\tclone --no-local . throw-away 2>stderr &&\n+\ttest_decode_color <stderr >color-decoded &&\n+\ttest_decode_csi <color-decoded >decoded &&\n+\ttest_grep \"CSI \\\\[K\" decoded &&\n+\ttest_grep ! \"\\\\^\\\\[\\\\[K\" decoded\n+'\n+\n test_done\n\nbase-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd\n-- \ngitgitgadget\n\n"},{"id":"555239","messageId":"20261016142515.T1gr4%taahol@utu.fi","threadId":"66555","inReplyTo":"pull.2261.git.1792154374653.gitgitgadget@gmail.com","subject":"Re: [PATCH] sideband: skip unrecognized allowControlCharacters keywords","fromName":"Tuomas Ahola","fromEmail":"taahol@utu.fi","sentAt":"2026-10-16T14:25:15Z","receivedAt":"2026-10-16T14:25:15Z","isPatch":true,"sender":{"key":"taahol@utu.fi","avatar":"https://avatars.githubusercontent.com/u/114303477?v=4"},"body":"\"Thomas Bachem via GitGitGadget\" <gitgitgadget@gmail.com> wrote:\n\n> +\t\t\twarning(_(\"unrecognized value for '%s': '%.*s'\"),\n> +\t\t\t\tvar, (int)(end - value), value);\n> +\t\t\tvalue = end + !!*end;\n> +\t\t}\n\nReading CodingGuidelines, it seems that `!!` is a construct we would\nlike to avoid:\n\n - Some clever tricks, like using the !! operator with arithmetic\n   constructs, can be extremely confusing to others.  Avoid them,\n   unless there is a compelling reason to use them.\n\n--Tuomas\n\n"},{"id":"555249","messageId":"CAA0xjtoyCjzjzNnoGdoA_o-TK9=nKK98mXEpE0y_jWJfah_Xow@mail.gmail.com","threadId":"66555","inReplyTo":"20261016142515.T1gr4%taahol@utu.fi","subject":"Re: [PATCH] sideband: skip unrecognized allowControlCharacters keywords","fromName":"Thomas Bachem","fromEmail":"mail@thomasbachem.com","sentAt":"2026-10-16T16:28:48Z","receivedAt":"2026-10-16T16:28:48Z","isPatch":true,"sender":{"key":"mail@thomasbachem.com","avatar":"https://gravatar.com/avatar/e9bc28172fe03ca6777b6d330a8503511d84bde14ce0e84c962d2b3b39ed3db1?d=mp&s=160"},"body":"Tuomas Ahola <taahol@utu.fi> wrote:\n>> + value = end + !!*end;\n>\n> Reading CodingGuidelines, it seems that `!!` is a construct we would\n> like to avoid:\n\nI wrote it this way to match skip_prefix_in_csv() a few lines above,\nwhich steps past the comma the same way:\n\n*out = value + !!*value;\n\nso the two places in this parser read alike. Happy to spell it out as a\nconditional in a v2 if that's preferred, though.\n\nThomas\n\n"},{"id":"555251","messageId":"xmqq8q3xh98n.fsf@gitster.g","threadId":"66555","inReplyTo":"20261016142515.T1gr4%taahol@utu.fi","subject":"Re: [PATCH] sideband: skip unrecognized allowControlCharacters keywords","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-16T16:59:36Z","receivedAt":"2026-10-16T16:59:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tuomas Ahola <taahol@utu.fi> writes:\n\n> \"Thomas Bachem via GitGitGadget\" <gitgitgadget@gmail.com> wrote:\n>\n>> +\t\t\twarning(_(\"unrecognized value for '%s': '%.*s'\"),\n>> +\t\t\t\tvar, (int)(end - value), value);\n>> +\t\t\tvalue = end + !!*end;\n>> +\t\t}\n>\n> Reading CodingGuidelines, it seems that `!!` is a construct we would\n> like to avoid:\n>\n>  - Some clever tricks, like using the !! operator with arithmetic\n>    constructs, can be extremely confusing to others.  Avoid them,\n>    unless there is a compelling reason to use them.\n>\n> --Tuomas\n\nBut here it is compelling.  You want to normalize random byte into 0\nor 1, depending on \"is it 0 or non-zero?\" criteria, and it certainly\nis easier to read than (*end ? 1 : 0).\n\nQuite honestly, I do not think !! qualifies as \"clever trick that is\nconfusing\" anymore.  Perhaps putting the rule there is misguided.\n\nThanks.\n\n\n"},{"id":"555272","messageId":"20261016193430.JZhfl%taahol@utu.fi","threadId":"66555","inReplyTo":"xmqq8q3xh98n.fsf@gitster.g","subject":"Re: [PATCH] sideband: skip unrecognized allowControlCharacters keywords","fromName":"Tuomas Ahola","fromEmail":"taahol@utu.fi","sentAt":"2026-10-16T19:34:30Z","receivedAt":"2026-10-16T19:34:30Z","isPatch":true,"sender":{"key":"taahol@utu.fi","avatar":"https://avatars.githubusercontent.com/u/114303477?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n\n> Tuomas Ahola <taahol@utu.fi> writes:\n> \n> > \"Thomas Bachem via GitGitGadget\" <gitgitgadget@gmail.com> wrote:\n> >\n> >> +\t\t\twarning(_(\"unrecognized value for '%s': '%.*s'\"),\n> >> +\t\t\t\tvar, (int)(end - value), value);\n> >> +\t\t\tvalue = end + !!*end;\n> >> +\t\t}\n> >\n> > Reading CodingGuidelines, it seems that `!!` is a construct we would\n> > like to avoid:\n> >\n> >  - Some clever tricks, like using the !! operator with arithmetic\n> >    constructs, can be extremely confusing to others.  Avoid them,\n> >    unless there is a compelling reason to use them.\n> >\n> > --Tuomas\n> \n> But here it is compelling.  You want to normalize random byte into 0\n> or 1, depending on \"is it 0 or non-zero?\" criteria, and it certainly\n> is easier to read than (*end ? 1 : 0).\n> \n\nUh, of course.  Sorry for my mental short-circuit.\n\n> Quite honestly, I do not think !! qualifies as \"clever trick that is\n> confusing\" anymore.  Perhaps putting the rule there is misguided.\n> \n> Thanks.\n\nOkay.  I'll consider writing a patch to drop that from CodingGuidelines.\n\n"},{"id":"557753","messageId":"xmqqbj81bcwb.fsf@gitster.g","threadId":"66555","inReplyTo":"pull.2261.git.1792154374653.gitgitgadget@gmail.com","subject":"Re: [PATCH] sideband: skip unrecognized allowControlCharacters keywords","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-07T02:20:36Z","receivedAt":"2026-11-07T02:20:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Thomas Bachem via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Thomas Bachem <mail@thomasbachem.com>\n>\n> Since 128914438a (sideband: add options to allow more control\n> sequences to be passed through, 2026-03-05), the value of\n> sideband.allowControlCharacters is a comma-separated list of\n> keywords. When the parser meets a keyword it does not know, it warns\n> but stays on that keyword, so the warning repeats forever.\n>\n> As the setting is read whenever a transport is set up, a typo like\n> \"colour\", a list written as \"color, cursor\" with a space, or a\n> keyword that only a newer version of Git knows is enough to make\n> every fetch, push, clone and ls-remote hang this way.\n>\n> Move on to the next keyword after the warning, and name only the\n> unrecognized keyword in it, not the rest of the list.\n>\n> Assisted-by: Claude Opus 5.5\n> Signed-off-by: Thomas Bachem <mail@thomasbachem.com>\n> ---\n>     sideband: skip unrecognized allowControlCharacters keywords\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2261%2Fthomasbachem%2Fsideband-control-characters-loop-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2261/thomasbachem/sideband-control-characters-loop-v1\n> Pull-Request: https://github.com/gitgitgadget/git/pull/2261\n>\n>  sideband.c                          | 19 ++++++++++++-------\n>  t/t5409-colorize-remote-messages.sh | 25 +++++++++++++++++++++++++\n>  2 files changed, 37 insertions(+), 7 deletions(-)\n>\n> diff --git a/sideband.c b/sideband.c\n> index 374187402e..ed6840bf89 100644\n> --- a/sideband.c\n> +++ b/sideband.c\n> @@ -62,18 +62,23 @@ int sideband_allow_control_characters_config(const char *var, const char *value)\n>  \n>  \tallow_control_characters = ALLOW_NO_CONTROL_CHARACTERS;\n>  \twhile (*value) {\n> +\t\tif (skip_prefix_in_csv(value, \"color\", &value)) {\n>  \t\t\tallow_control_characters |= ALLOW_ANSI_COLOR_SEQUENCES;\n> +\t\t} else if (skip_prefix_in_csv(value, \"cursor\", &value)) {\n>  \t\t\tallow_control_characters |= ALLOW_ANSI_CURSOR_MOVEMENTS;\n> +\t\t} else if (skip_prefix_in_csv(value, \"erase\", &value)) {\n>  \t\t\tallow_control_characters |= ALLOW_ANSI_ERASE;\n> +\t\t} else if (skip_prefix_in_csv(value, \"true\", &value)) {\n>  \t\t\tallow_control_characters = ALLOW_ALL_CONTROL_CHARACTERS;\n> +\t\t} else if (skip_prefix_in_csv(value, \"false\", &value)) {\n>  \t\t\tallow_control_characters = ALLOW_NO_CONTROL_CHARACTERS;\n> +\t\t} else {\n> +\t\t\tconst char *end = strchrnul(value, ',');\n> +\n> +\t\t\twarning(_(\"unrecognized value for '%s': '%.*s'\"),\n> +\t\t\t\tvar, (int)(end - value), value);\n> +\t\t\tvalue = end + !!*end;\n\nOK, so this assignment to \"value\" is the only thing that is new.\n\n> +\t\t}\n\nSomehow the review thread seems to have been sidetracked and left\nthe topic in \"needs review' state.  The above looks reasonable to\nme.\n\nIt might even make sense to allow whitespaces after the comma, but\nthat would fall into \"enhancement\" category, and I would prefer to\nkeep the change required to fix things to the minimum.\n\n>  \t}\n>  \treturn 0;\n>  }\n> diff --git a/t/t5409-colorize-remote-messages.sh b/t/t5409-colorize-remote-messages.sh\n> index 5da8b0ad64..6117579eb1 100755\n> --- a/t/t5409-colorize-remote-messages.sh\n> +++ b/t/t5409-colorize-remote-messages.sh\n> @@ -190,4 +190,29 @@ test_expect_success 'allow all control sequences for a specific URL' '\n>  \ttest_grep ! \"\\\\^\\\\[\\\\[K\" decoded\n>  '\n>  \n> +test_expect_success 'unrecognized keywords in allowControlCharacters are skipped' '\n> +\twrite_script .git/eraser <<-\\EOF &&\n> +\tprintf \"error: Ohai!\\\\r\\\\033[K\" >&2\n> +\texec \"$@\"\n> +\tEOF\n> +\ttest_config_global uploadPack.packObjectsHook ./eraser &&\n> +\ttest_commit unrecognized-keyword &&\n> +\n> +\t# Cap the output, so that a parser stuck on the unrecognized\n> +\t# keyword fails the test instead of warning forever.\n> +\tgit -c sideband.allowControlCharacters=bogus,erase \\\n> +\t\tls-remote . 2>&1 >/dev/null |\n> +\thead -n 2 >warnings &&\n\nA well thought out testing method.  I like it.\n\n> +\ttest_line_count = 1 warnings &&\n> +\ttest_grep \"allowcontrolcharacters.: .bogus.$\" warnings &&\n> +\n> +\trm -rf throw-away &&\n> +\tgit -c sideband.allowControlCharacters=bogus,erase \\\n> +\t\tclone --no-local . throw-away 2>stderr &&\n> +\ttest_decode_color <stderr >color-decoded &&\n> +\ttest_decode_csi <color-decoded >decoded &&\n> +\ttest_grep \"CSI \\\\[K\" decoded &&\n> +\ttest_grep ! \"\\\\^\\\\[\\\\[K\" decoded\n> +'\n> +\n>  test_done\n\nThanks.  Let's mark the topic as ready for 'next'.\n\n"}]}