summaryrefslogtreecommitdiff
path: root/progress.c
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2019-05-19 14:45:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-05-28 17:21:11 (GMT)
commit1aed1a5f25ad300dbdc48f0943ca5c3bed952e6a (patch)
treed416894c9362c4f71fa4630b9bfd48eddf7eaf36 /progress.c
parent545dc345ebd00adbd96229e8e46b2e8c0b2f1b37 (diff)
downloadgit-1aed1a5f25ad300dbdc48f0943ca5c3bed952e6a.zip
git-1aed1a5f25ad300dbdc48f0943ca5c3bed952e6a.tar.gz
git-1aed1a5f25ad300dbdc48f0943ca5c3bed952e6a.tar.bz2
progress: avoid empty line when breaking the progress line
Since commit 545dc345eb (progress: break too long progress bar lines, 2019-04-12) when splitting a too long progress line, sometimes it looks as if a superfluous empty line were added between the title line and the counters. To make sure that the previously displayed progress line is completely covered up when writing the new, shorter title line, we calculate how many characters need to be overwritten with spaces. Alas, this calculation doesn't account for the newline character at the end of the new title line, and resulted in printing one more space than strictly necessary. This extra space character doesn't matter, if the length of the previous progress line was shorter than the width of the terminal. However, if the previous line matched the terminal width, then this extra space made the new line longer, effectively adding that empty line after the title line. Fix this off-by-one to avoid that spurious empty line. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'progress.c')
-rw-r--r--progress.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/progress.c b/progress.c
index 2d8022a..a4da26c 100644
--- a/progress.c
+++ b/progress.c
@@ -127,7 +127,7 @@ static void display(struct progress *progress, uint64_t n, const char *done)
(int) clear_len, eol);
} else if (!done && cols < progress_line_len) {
clear_len = progress->title_len + 1 < cols ?
- cols - progress->title_len : 0;
+ cols - progress->title_len - 1 : 0;
fprintf(stderr, "%s:%*s\n %s%s",
progress->title, (int) clear_len, "",
counters_sb->buf, eol);