fix pack progress object counter for loose objects Move pack progres object accounting to a single place. This makes it easier to account for the case were only loose objects are packed. A wrong amount of objects was reported before when packing loose ones.
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
diff --git a/lib/pack_create.c b/lib/pack_create.c
index bcd49de..e852bc8 100644
--- a/lib/pack_create.c
+++ b/lib/pack_create.c
@@ -852,7 +852,10 @@ static const int obj_types[] = {
static const struct got_error *
add_object(int want_meta, struct got_object_idset *idset,
struct got_object_id *id, const char *path, int obj_type,
- time_t mtime, int loose_obj_only, struct got_repository *repo)
+ time_t mtime, int loose_obj_only, struct got_repository *repo,
+ int *ncolored, int *nfound, int *ntrees,
+ got_pack_progress_cb progress_cb, void *progress_arg,
+ struct got_ratelimit *rl)
{
const struct got_error *err;
struct got_pack_meta *m = NULL;
@@ -870,6 +873,12 @@ add_object(int want_meta, struct got_object_idset *idset,
err = alloc_meta(&m, id, path, obj_type, mtime);
if (err)
return err;
+
+ (*nfound)++;
+ err = report_progress(progress_cb, progress_arg, rl,
+ *ncolored, *nfound, *ntrees, 0L, 0, 0, 0, 0);
+ if (err)
+ return err;
}
return got_object_idset_add(idset, id, m);
@@ -927,17 +936,11 @@ load_tree_entries(struct got_object_id_queue *ids, int want_meta,
STAILQ_INSERT_TAIL(ids, qid, entry);
} else if (S_ISREG(mode) || S_ISLNK(mode)) {
err = add_object(want_meta, idset, id, p,
- GOT_OBJ_TYPE_BLOB, mtime, loose_obj_only, repo);
+ GOT_OBJ_TYPE_BLOB, mtime, loose_obj_only, repo,
+ ncolored, nfound, ntrees,
+ progress_cb, progress_arg, rl);
if (err)
break;
- if (want_meta) {
- (*nfound)++;
- err = report_progress(progress_cb, progress_arg,
- rl, *ncolored, *nfound, *ntrees,
- 0L, 0, 0, 0, 0);
- if (err)
- break;
- }
}
free(p);
p = NULL;
@@ -986,20 +989,13 @@ load_tree(int want_meta, struct got_object_idset *idset,
}
err = add_object(want_meta, idset, qid->id, dpath,
- GOT_OBJ_TYPE_TREE, mtime, loose_obj_only, repo);
+ GOT_OBJ_TYPE_TREE, mtime, loose_obj_only, repo,
+ ncolored, nfound, ntrees, progress_cb, progress_arg, rl);
if (err) {
got_object_qid_free(qid);
break;
}
- if (want_meta) {
- (*nfound)++;
- err = report_progress(progress_cb, progress_arg, rl,
- *ncolored, *nfound, *ntrees, 0L, 0, 0, 0, 0);
- if (err)
- break;
- }
-
err = load_tree_entries(&tree_ids, want_meta, idset, qid->id,
dpath, mtime, repo, loose_obj_only, ncolored, nfound,
ntrees, progress_cb, progress_arg, rl,
@@ -1041,18 +1037,11 @@ load_commit(int want_meta, struct got_object_idset *idset,
err = add_object(want_meta, idset, id, "", GOT_OBJ_TYPE_COMMIT,
got_object_commit_get_committer_time(commit),
- loose_obj_only, repo);
+ loose_obj_only, repo,
+ ncolored, nfound, ntrees, progress_cb, progress_arg, rl);
if (err)
goto done;
- if (want_meta) {
- (*nfound)++;
- err = report_progress(progress_cb, progress_arg, rl,
- *ncolored, *nfound, *ntrees, 0L, 0, 0, 0, 0);
- if (err)
- goto done;
- }
-
err = load_tree(want_meta, idset, got_object_commit_get_tree_id(commit),
"", got_object_commit_get_committer_time(commit),
repo, loose_obj_only, ncolored, nfound, ntrees,
@@ -1089,19 +1078,11 @@ load_tag(int want_meta, struct got_object_idset *idset,
return err;
err = add_object(want_meta, idset, id, "", GOT_OBJ_TYPE_TAG,
- got_object_tag_get_tagger_time(tag),
- loose_obj_only, repo);
+ got_object_tag_get_tagger_time(tag), loose_obj_only, repo,
+ ncolored, nfound, ntrees, progress_cb, progress_arg, rl);
if (err)
goto done;
- if (want_meta) {
- (*nfound)++;
- err = report_progress(progress_cb, progress_arg, rl,
- *ncolored, *nfound, *ntrees, 0L, 0, 0, 0, 0);
- if (err)
- goto done;
- }
-
switch (got_object_tag_get_object_type(tag)) {
case GOT_OBJ_TYPE_COMMIT:
err = load_commit(want_meta, idset,