summaryrefslogtreecommitdiff
path: root/sideband.c
diff options
context:
space:
mode:
authorLibravatar Jiang Xin <worldhello.net@gmail.com>2021-08-03 17:03:35 +0800
committerLibravatar Jiang Xin <worldhello.net@gmail.com>2021-08-03 17:03:35 +0800
commit972c9cf6aed660f3b4189a8f2adda505e67110ff (patch)
tree350bb2a29eb3360cdf36a30d8c8e7c76c3e61851 /sideband.c
parentl10n: fixed typos of mismatched constant strings (diff)
parentGit 2.33-rc0 (diff)
downloadtgif-972c9cf6aed660f3b4189a8f2adda505e67110ff.tar.xz
Merge branch 'master' of github.com:git/git
* 'master' of github.com:git/git: (397 commits) Git 2.33-rc0 The seventh batch ci/install-dependencies: handle "sparse" job package installs ci: run "apt-get update" before "apt-get install" cache-tree: prefetch in partial clone read-tree unpack-trees: refactor prefetching code pack-bitmap: check pack validity when opening bitmap bundle tests: use test_cmp instead of grep bundle tests: use ">file" not ": >file" The sixth batch doc: pull: fix rebase=false documentation pack-bitmap: clarify comment in filter_bitmap_exclude_type() doc: clarify description of 'submodule.recurse' doc/git-config: simplify "override" advice for FILES section doc/git-config: clarify GIT_CONFIG environment variable doc/git-config: explain --file instead of referring to GIT_CONFIG t0000: fix test if run with TEST_OUTPUT_DIRECTORY multi-pack-index: fix potential segfault without sub-command refs/debug: quote prefix t0000: clear GIT_SKIP_TESTS before running sub-tests ...
Diffstat (limited to 'sideband.c')
-rw-r--r--sideband.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/sideband.c b/sideband.c
index 6f9e026732..85bddfdcd4 100644
--- a/sideband.c
+++ b/sideband.c
@@ -183,8 +183,31 @@ int demultiplex_sideband(const char *me, int status,
while ((brk = strpbrk(b, "\n\r"))) {
int linelen = brk - b;
+ /*
+ * For message accross packet boundary, there would have
+ * a nonempty "scratch" buffer from last call of this
+ * function, and there may have a leading CR/LF in "buf".
+ * For this case we should add a clear-to-eol suffix to
+ * clean leftover letters we previously have written on
+ * the same line.
+ */
+ if (scratch->len && !linelen)
+ strbuf_addstr(scratch, suffix);
+
if (!scratch->len)
strbuf_addstr(scratch, DISPLAY_PREFIX);
+
+ /*
+ * A use case that we should not add clear-to-eol suffix
+ * to empty lines:
+ *
+ * For progress reporting we may receive a bunch of
+ * percentage updates followed by '\r' to remain on the
+ * same line, and at the end receive a single '\n' to
+ * move to the next line. We should preserve the final
+ * status report line by not appending clear-to-eol
+ * suffix to this single line break.
+ */
if (linelen > 0) {
maybe_colorize_sideband(scratch, b, linelen);
strbuf_addstr(scratch, suffix);