Remove third stage from checkout progress reporting Also, now only reporting checkout progress for files that are actually being added or removed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
diff --git a/src/checkout.c b/src/checkout.c
index a20a6f9..35e3d29 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -31,7 +31,6 @@ struct checkout_diff_data
bool can_symlink;
bool found_submodules;
bool create_submodules;
- int num_stages;
int error;
};
@@ -164,7 +163,7 @@ static void report_progress(
struct checkout_diff_data *data,
const char *path)
{
- float per_stage_progress = 1.f/data->num_stages;
+ float per_stage_progress = 0.5;
float overall_progress = (stage-1)*per_stage_progress +
stage_progress*per_stage_progress;
@@ -177,7 +176,8 @@ static void report_progress(
static int checkout_blob(
struct checkout_diff_data *data,
- const git_diff_file *file)
+ const git_diff_file *file,
+ float progress)
{
git_blob *blob;
int error;
@@ -196,6 +196,7 @@ static int checkout_blob(
error = blob_content_to_file(
blob, git_buf_cstr(data->path), file->mode, data->checkout_opts);
+ report_progress(2, progress, data, file->path);
git_blob_free(blob);
return error;
@@ -218,9 +219,9 @@ static int checkout_remove_the_old(
delta->new_file.path,
git_repository_workdir(data->owner),
GIT_DIRREMOVAL_FILES_AND_DIRS);
- }
- report_progress(1, progress, data, delta->new_file.path);
+ report_progress(1, progress, data, delta->new_file.path);
+ }
return data->error;
}
@@ -262,18 +263,14 @@ static int checkout_create_the_new(
if (is_submodule) {
data->found_submodules = true;
- data->num_stages = 3;
}
if (!is_submodule && !data->create_submodules) {
- error = checkout_blob(data, &delta->old_file);
- report_progress(2, progress, data, delta->old_file.path);
-
+ error = checkout_blob(data, &delta->old_file, progress);
}
else if (is_submodule && data->create_submodules) {
error = checkout_submodule(data, &delta->old_file);
- report_progress(3, progress, data, delta->old_file.path);
}
}
@@ -368,7 +365,6 @@ int git_checkout_index(
data.workdir_len = git_buf_len(&workdir);
data.checkout_opts = &checkout_opts;
data.owner = repo;
- data.num_stages = 2;
if ((error = retrieve_symlink_capabilities(repo, &data.can_symlink)) < 0)
goto cleanup;
@@ -396,7 +392,7 @@ int git_checkout_index(
diff, &data, checkout_create_the_new, NULL, NULL);
}
- report_progress(data.num_stages, 1.f, &data, NULL);
+ report_progress(2, 1.f, &data, NULL);
cleanup:
if (error == GIT_EUSER)