]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jx/sideband-chomp-newline-fix' into maint-2.43
authorJunio C Hamano <gitster@pobox.com>
Fri, 9 Feb 2024 00:22:11 +0000 (16:22 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Feb 2024 00:22:11 +0000 (16:22 -0800)
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

1  2 
pkt-line.c
pkt-line.h
t/helper/test-pkt-line.c
t/t0070-fundamental.sh

diff --cc pkt-line.c
Simple merge
diff --cc pkt-line.h
Simple merge
index 77e99c37df0cc00579083b53760accbd0888ffd1,6b306cf5ca1da7942ea486d52c68f60ae85942da..4daa82f00fcb5f0b178aa912033c906fe14c7718
@@@ -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)
  {
index 487bc8d9054c908f97bc376005c3fd1eedd107b9,0d2b7d8d93499547ec65d7f2c36632caa8445a3c..f18f9284a5bf3961a3f5373f887b808e55cd9b75
@@@ -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 <input 2>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 <split-sideband >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 <split-sideband >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 <split-sideband >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 <split-sideband >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