diff options
author | SZEDER Gábor <szeder.dev@gmail.com> | 2019-04-12 21:45:14 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-15 12:11:25 +0900 |
commit | 9f1fd84e15a8109f02867e369c747a1cbe766ba1 (patch) | |
tree | e953d5ac1898f40de1ca73495579a9c34ddf4842 /diffcore-pickaxe.c | |
parent | progress: assemble percentage and counters in a strbuf before printing (diff) | |
download | tgif-9f1fd84e15a8109f02867e369c747a1cbe766ba1.tar.xz |
progress: clear previous progress update dynamically
When the progress bar includes throughput, its length can shorten as
the unit of display changes from KiB to MiB. To cover up remnants of
the previous progress bar when such a change of units happens we
always print three spaces at the end of the progress bar.
Alas, covering only three characters is not quite enough: when both
the total and the throughput happen to change units from KiB to MiB in
the same update, then the progress bar's length is shortened by four
characters (or maybe even more!):
Receiving objects: 25% (2901/11603), 772.01 KiB | 733.00 KiB/s
Receiving objects: 27% (3133/11603), 1.43 MiB | 1.16 MiB/s s
and a stray 's' is left behind.
So instead of hard-coding the three characters to cover, let's compare
the length of the current progress bar with the previous one, and
cover up as many characters as needed.
Sure, it would be much simpler to just print more spaces at the end of
the progress bar, but this approach is more future-proof, and it won't
print extra spaces when none are needed, notably when the progress bar
doesn't show throughput and thus never shrinks.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diffcore-pickaxe.c')
0 files changed, 0 insertions, 0 deletions