Commit 2dae54a9419aaeb9d3d6a8eb6a28e13edb41bd58

Ben Straub 2012-10-19T20:24:15

Improve clone sample's formatting

diff --git a/examples/network/clone.c b/examples/network/clone.c
index 19bf0cc..6f98192 100644
--- a/examples/network/clone.c
+++ b/examples/network/clone.c
@@ -19,17 +19,14 @@ static void print_progress(const progress_data *pd)
 	int network_percent = (100*pd->fetch_progress.received) / pd->fetch_progress.total;
 	int index_percent = (100*pd->fetch_progress.processed) / pd->fetch_progress.total;
 	int checkout_percent = pd->total_steps > 0
-		? (100.f * pd->completed_steps) / pd->total_steps
+		? (100 * pd->completed_steps) / pd->total_steps
 		: 0.f;
 	int kbytes = pd->fetch_progress.bytes / 1024;
-	printf("net %3d%% (%6d kb)  /  idx %3d%%  /  chk %3d%%  %50s\n",
-			network_percent, kbytes, index_percent, checkout_percent, pd->path);
-	/*
-	printf("net %5d /%5d  –  idx %5d /%5d  –  chk %.04f   %20s\n",
-			pd->fetch_progress.received, pd->fetch_progress.total,
-			pd->fetch_progress.processed, pd->fetch_progress.total,
-			pd->checkout_progress, pd->path);
-			*/
+	printf("net %3d%% (%4d kb, %5d/%5d)  /  idx %3d%% (%5d/%5d)  /  chk %3d%% (%4lu/%4lu) %s\n",
+			network_percent, kbytes, pd->fetch_progress.received, pd->fetch_progress.total,
+			index_percent, pd->fetch_progress.processed, pd->fetch_progress.total,
+			checkout_percent, pd->completed_steps, pd->total_steps,
+			pd->path);
 }
 
 static void fetch_progress(const git_indexer_stats *stats, void *payload)
diff --git a/src/checkout.c b/src/checkout.c
index 8ab3da8..b7bfa40 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -192,7 +192,6 @@ static int checkout_blob(
 		error = blob_content_to_file(
 			blob, git_buf_cstr(data->path), file->mode, data->checkout_opts);
 
-	report_progress(data, file->path);
 	git_blob_free(blob);
 
 	return error;
@@ -265,11 +264,13 @@ static int checkout_create_the_new(
 		if (!is_submodule && !data->create_submodules) {
 			error = checkout_blob(data, &delta->old_file);
 			data->completed_steps++;
+			report_progress(data, delta->old_file.path);
 		}
 
 		else if (is_submodule && data->create_submodules) {
 			error = checkout_submodule(data, &delta->old_file);
 			data->completed_steps++;
+			report_progress(data, delta->old_file.path);
 		}
 
 	}