Commit 9af3c416 by Edward Thomson

clone example: don't divide by zero

Local transports don't have data about the size, avoid dividing by
zero in the callback.
parent b91f28be
...@@ -18,14 +18,20 @@ typedef struct progress_data { ...@@ -18,14 +18,20 @@ typedef struct progress_data {
static void print_progress(const progress_data *pd) static void print_progress(const progress_data *pd)
{ {
int network_percent = (100*pd->fetch_progress.received_objects) / pd->fetch_progress.total_objects; int network_percent = pd->fetch_progress.total_objects > 0 ?
int index_percent = (100*pd->fetch_progress.indexed_objects) / pd->fetch_progress.total_objects; (100*pd->fetch_progress.received_objects) / pd->fetch_progress.total_objects :
0;
int index_percent = pd->fetch_progress.total_objects > 0 ?
(100*pd->fetch_progress.indexed_objects) / pd->fetch_progress.total_objects :
0;
int checkout_percent = pd->total_steps > 0 int checkout_percent = pd->total_steps > 0
? (100 * pd->completed_steps) / pd->total_steps ? (100 * pd->completed_steps) / pd->total_steps
: 0; : 0;
int kbytes = pd->fetch_progress.received_bytes / 1024; int kbytes = pd->fetch_progress.received_bytes / 1024;
if (pd->fetch_progress.received_objects == pd->fetch_progress.total_objects) { if (pd->fetch_progress.total_objects &&
pd->fetch_progress.received_objects == pd->fetch_progress.total_objects) {
printf("Resolving deltas %d/%d\r", printf("Resolving deltas %d/%d\r",
pd->fetch_progress.indexed_deltas, pd->fetch_progress.indexed_deltas,
pd->fetch_progress.total_deltas); pd->fetch_progress.total_deltas);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment