From: Junio C Hamano Date: Fri, 9 Feb 2024 00:22:11 +0000 (-0800) Subject: Merge branch 'jx/sideband-chomp-newline-fix' into maint-2.43 X-Git-Tag: v2.43.1~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5b49c1af03e600c286f63d9d9c9fb01403230b9f;p=thirdparty%2Fgit.git Merge branch 'jx/sideband-chomp-newline-fix' into maint-2.43 Sideband demultiplexer fixes. * jx/sideband-chomp-newline-fix: pkt-line: do not chomp newlines for sideband messages pkt-line: memorize sideband fragment in reader test-pkt-line: add option parser for unpack-sideband --- 5b49c1af03e600c286f63d9d9c9fb01403230b9f diff --cc t/helper/test-pkt-line.c index 77e99c37df,6b306cf5ca..4daa82f00f --- a/t/helper/test-pkt-line.c +++ b/t/helper/test-pkt-line.c @@@ -1,8 -1,8 +1,9 @@@ #include "git-compat-util.h" #include "test-tool.h" #include "pkt-line.h" +#include "sideband.h" #include "write-or-die.h" + #include "parse-options.h" static void pack_line(const char *line) { diff --cc t/t0070-fundamental.sh index 487bc8d905,0d2b7d8d93..f18f9284a5 --- a/t/t0070-fundamental.sh +++ b/t/t0070-fundamental.sh @@@ -50,7 -50,65 +50,65 @@@ test_expect_success 'eof on sideband me test_expect_success 'missing sideband designator is reported' ' printf 0004 >input && test-tool pkt-line receive-sideband err && - test_i18ngrep "missing sideband" err + test_grep "missing sideband" err ' + test_expect_success 'unpack-sideband: --no-chomp-newline' ' + test_when_finished "rm -f expect-out expect-err" && + test-tool pkt-line send-split-sideband >split-sideband && + test-tool pkt-line unpack-sideband \ + --no-chomp-newline out 2>err && + cat >expect-out <<-EOF && + primary: regular output + EOF + cat >expect-err <<-EOF && + Foo. + Bar. + Hello, world! + EOF + test_cmp expect-out out && + test_cmp expect-err err + ' + + test_expect_success 'unpack-sideband: --chomp-newline (default)' ' + test_when_finished "rm -f expect-out expect-err" && + test-tool pkt-line send-split-sideband >split-sideband && + test-tool pkt-line unpack-sideband \ + --chomp-newline out 2>err && + printf "primary: regular output" >expect-out && + printf "Foo.Bar.Hello, world!" >expect-err && + test_cmp expect-out out && + test_cmp expect-err err + ' + + test_expect_success 'unpack-sideband: packet_reader_read() consumes sideband, no chomp payload' ' + test_when_finished "rm -f expect-out expect-err" && + test-tool pkt-line send-split-sideband >split-sideband && + test-tool pkt-line unpack-sideband \ + --reader-use-sideband \ + --no-chomp-newline out 2>err && + cat >expect-out <<-EOF && + primary: regular output + EOF + printf "remote: Foo. \n" >expect-err && + printf "remote: Bar. \n" >>expect-err && + printf "remote: Hello, world! \n" >>expect-err && + test_cmp expect-out out && + test_cmp expect-err err + ' + + test_expect_success 'unpack-sideband: packet_reader_read() consumes sideband, chomp payload' ' + test_when_finished "rm -f expect-out expect-err" && + test-tool pkt-line send-split-sideband >split-sideband && + test-tool pkt-line unpack-sideband \ + --reader-use-sideband \ + --chomp-newline out 2>err && + printf "primary: regular output" >expect-out && + printf "remote: Foo. \n" >expect-err && + printf "remote: Bar. \n" >>expect-err && + printf "remote: Hello, world! \n" >>expect-err && + test_cmp expect-out out && + test_cmp expect-err err + ' + test_done