File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 1212#include "progress.h"
1313#include "error.h"
1414
15- #define PROGRESS_UPDATE_TIME 0.05
15+ /*
16+ * Show updates to the percentage and number of objects received
17+ * separately from the throughput to give an accurate progress while
18+ * avoiding too much noise on the screen.
19+ */
20+ #define PROGRESS_UPDATE_TIME 0.10
21+ #define THROUGHPUT_UPDATE_TIME 1.00
1622
1723#define is_nl (c ) ((c) == '\r' || (c) == '\n')
1824
@@ -200,11 +206,20 @@ static int fetch_receiving(
200206 else
201207 now = git__timer ();
202208
203- recv_len = (double )stats -> received_bytes ;
209+ if (progress -> throughput_update &&
210+ now - progress -> throughput_update < THROUGHPUT_UPDATE_TIME ) {
211+ elapsed = progress -> throughput_update -
212+ progress -> action_start ;
213+ recv_len = progress -> throughput_bytes ;
214+ } else {
215+ elapsed = now - progress -> action_start ;
216+ recv_len = (double )stats -> received_bytes ;
217+
218+ progress -> throughput_update = now ;
219+ progress -> throughput_bytes = recv_len ;
220+ }
204221
205- elapsed = now - progress -> action_start ;
206222 rate = elapsed ? recv_len / elapsed : 0 ;
207- done = (stats -> received_objects == stats -> total_objects );
208223
209224 while (recv_len > 1024 && recv_units [recv_unit_idx + 1 ]) {
210225 recv_len /= 1024 ;
Original file line number Diff line number Diff line change @@ -40,6 +40,10 @@ typedef struct {
4040 git_str sideband ;
4141 git_str onscreen ;
4242 git_str deferred ;
43+
44+ /* Last update about throughput */
45+ double throughput_update ;
46+ double throughput_bytes ;
4347} cli_progress ;
4448
4549#define CLI_PROGRESS_INIT { 0 }
You can’t perform that action at this time.
0 commit comments