[PATCH v4 0/2] progress.c API users: fix bogus counting
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Sep 9, 2021, 01:10 UTC
- Message-ID
- <cover-v4-0.2-00000000000-20210909T010722Z-avarab@gmail.com>
- In-Reply-To
- <cover-v3-0.2-00000000000-20210823T102722Z-avarab@gmail.com>
Fix bad uses of the progress.c API. See https://lore.kernel.org/git/cover-v3-0.2-00000000000-20210823T102722Z-avarab@gmail.com for the v3.
This re-roll is on top of a merge conflict in v3 with 7a132c628e5 (checkout: make delayed checkout respect --quiet and --no-progress, 2021-08-26), i.e. the mt/quiet-with-delayed-checkout topic.
SZEDER Gábor (2):
commit-graph: fix bogus counter in "Scanning merged commits" progress
line
entry: show finer-grained counter in "Filtering content" progress linecommit-graph.c | 2 +- entry.c | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-)
Range-diff against v3:
1: 443374551ad = 1: 4cc3923089d commit-graph: fix bogus counter in "Scanning merged commits" progress line
2: 71c93f624ec ! 2: 54a09b5b883 entry: show finer-grained counter in "Filtering content" progress line
@@ Commit message
straightforward to fix it with the current progress.c library (see [3]
for an attempt), so let's leave it for now.
+ Let's also initialize the *progress to "NULL" while we're at it. Since
+ 7a132c628e5 (checkout: make delayed checkout respect --quiet and
+ --no-progress, 2021-08-26) we have had progress conditional on
+ "show_progress", usually we use the idiom of a "NULL" initialization
+ of the "*progress", rather than the more verbose ternary added in
+ 7a132c628e5.
+
1. https://lore.kernel.org/git/20210620200303.2328957-1-szeder.dev@gmail.com/
2. http://lore.kernel.org/git/20210802214827.GE23408@szeder.dev
3. https://lore.kernel.org/git/20210620200303.2328957-7-szeder.dev@gmail.com/
@@ Commit message
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## entry.c ##
-@@ entry.c: static int remove_available_paths(struct string_list_item *item, void *cb_data)
- int finish_delayed_checkout(struct checkout *state, int *nr_checkouts)
+@@ entry.c: int finish_delayed_checkout(struct checkout *state, int *nr_checkouts,
+ int show_progress)
{
int errs = 0;
- unsigned delayed_object_count;
+ unsigned processed_paths = 0;
off_t filtered_bytes = 0;
struct string_list_item *filter, *path;
- struct progress *progress;
-@@ entry.c: int finish_delayed_checkout(struct checkout *state, int *nr_checkouts)
+- struct progress *progress;
++ struct progress *progress = NULL;
+ struct delayed_checkout *dco = state->delayed_checkout;
+
+ if (!state->delayed_checkout)
return errs;
dco->state = CE_RETRY;
- delayed_object_count = dco->paths.nr;
-- progress = start_delayed_progress(_("Filtering content"), delayed_object_count);
-+ progress = start_delayed_progress(_("Filtering content"), dco->paths.nr);
+- progress = show_progress
+- ? start_delayed_progress(_("Filtering content"), delayed_object_count)
+- : NULL;
++ if (show_progress)
++ progress = start_delayed_progress(_("Filtering content"), dco->paths.nr);
while (dco->filters.nr > 0) {
for_each_string_list_item(filter, &dco->filters) {
struct string_list available_paths = STRING_LIST_INIT_NODUP;
@@ entry.c: int finish_delayed_checkout(struct checkout *state, int *nr_checkouts)
if (!async_query_available_blobs(filter->string, &available_paths)) {
/* Filter reported an error */
-@@ entry.c: int finish_delayed_checkout(struct checkout *state, int *nr_checkouts)
+@@ entry.c: int finish_delayed_checkout(struct checkout *state, int *nr_checkouts,
ce = index_file_exists(state->istate, path->string,
strlen(path->string), 0);
if (ce) {-- 2.33.0.825.gdc3f7a2a6c7