]> git.ipfire.org Git - thirdparty/git.git/commit
progress: use term_clear_line()
authorSZEDER Gábor <szeder.dev@gmail.com>
Mon, 24 Jun 2019 18:13:18 +0000 (20:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Jun 2019 19:58:41 +0000 (12:58 -0700)
commit5b12e3123b7b70e3875404a4ffe571ca079364fe
treeeed88958e7b41500d9ad4ff4aaf8da705c1878fd
parentd7d90885e0aeb50eb4acc221ee43301b2a43aa3e
progress: use term_clear_line()

To make sure that the previously displayed progress line is completely
covered up when the new line is shorter, commit 545dc345eb (progress:
break too long progress bar lines, 2019-04-12) added a bunch of
calculations to figure out how many characters it needs to overwrite
with spaces.

Use the just introduced term_clear_line() helper function to, well,
clear the last line, making all these calculations unnecessary, and
thus simplifying the code considerably.

Three tests in 't5541-http-push-smart.sh' 'grep' for specific text
shown in the progress lines at the beginning of the line, but now
those lines begin either with the ANSI escape sequence or with the
terminal width worth of space characters clearing the line.  Relax the
'grep' patterns to match anywhere on the line.  Note that only two of
these three tests fail without relaxing their 'grep' pattern, but the
third looks for the absence of the pattern, so it still succeeds, but
without the adjustment would potentially hide future regressions.

Note also that with this change we no longer need the length of the
previously displayed progress line, so the strbuf added to 'struct
progress' in d53ba841d4 (progress: assemble percentage and counters in
a strbuf before printing, 2019-04-05) is not strictly necessary
anymore.  We still keep it, though, as it avoids allocating and
releasing a strbuf each time the progress is updated.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
progress.c
t/t5541-http-push-smart.sh