commit-graph: split up close_reachable() progress output

Amend the progress output added in 7b0f229222 ("commit-graph write: add progress output", 2018-09-17) so that the total numbers it reports aren't higher than the total number of commits anymore. See [1] for a bug report pointing that out. When I added this I wasn't intending to provide an accurate count, but just have some progress output to show the user the command wasn't hanging[2]. But since we are showing numbers, let's make them accurate. The progress descriptions were suggested by Derrick Stolee in [3]. As noted in [2] we are unlikely to show anything except the "Expanding reachable..." message even on fairly large repositories such as linux.git. On a test repository I have with north of 7 million commits all of these are displayed. Two of them don't show up for long, but as noted in [5] future-proofing this for if the loops become more expensive in the future makes sense. 1. https://public-inbox.org/git/20181010203738.GE23446@szeder.dev/ 2. https://public-inbox.org/git/87pnwhea8y.fsf@evledraar.gmail.com/ 3. https://public-inbox.org/git/f7a0cbee-863c-61d3-4959-5cec8b43c705@gmail.com/ 4. https://public-inbox.org/git/20181015160545.GG19800@szeder.dev/ 5. https://public-inbox.org/git/87murle8da.fsf@evledraar.gmail.com/ Reported-by: SZEDER Gábor <szeder.dev@gmail.com> Helped-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Nov 19, 2018 at 20:23 UTC 01ca387774b6e0f9949f3c1cf6a1ffa3a2409865
1 file changed +10 -3
commit-graph.c
+10 -3
@@ -595,26 +595,29 @@ static void add_missing_parents(struct packed_oid_list *oids, struct commit *com
595
596 static void close_reachable(struct packed_oid_list *oids, int report_progress)
597 {
598 - int i;
598 + int i, j;
599 struct commit *commit;
600 struct progress *progress = NULL;
601 - int j = 0;
601
602 if (report_progress)
603 progress = start_delayed_progress(
605 - _("Annotating commits in commit graph"), 0);
604 + _("Loading known commits in commit graph"), j = 0);
605 for (i = 0; i < oids->nr; i++) {
606 display_progress(progress, ++j);
607 commit = lookup_commit(the_repository, &oids->list[i]);
608 if (commit)
609 commit->object.flags |= UNINTERESTING;
610 }
611 + stop_progress(&progress);
612
613 /*
614 * As this loop runs, oids->nr may grow, but not more
615 * than the number of missing commits in the reachable
616 * closure.
617 */
618 + if (report_progress)
619 + progress = start_delayed_progress(
620 + _("Expanding reachable commits in commit graph"), j = 0);
621 for (i = 0; i < oids->nr; i++) {
622 display_progress(progress, ++j);
623 commit = lookup_commit(the_repository, &oids->list[i]);
@@ -622,7 +625,11 @@ static void close_reachable(struct packed_oid_list *oids, int report_progress)
625 if (commit && !parse_commit(commit))
626 add_missing_parents(oids, commit);
627 }
628 + stop_progress(&progress);
629
630 + if (report_progress)
631 + progress = start_delayed_progress(
632 + _("Clearing commit marks in commit graph"), j = 0);
633 for (i = 0; i < oids->nr; i++) {
634 display_progress(progress, ++j);
635 commit = lookup_commit(the_repository, &oids->list[i]);