Change the "Annotating commit graph" progress output to show a
completion percentage. I added this in 7b0f229222 ("commit-graph
write: add progress output", 2018-09-17) and evidently didn't notice
how easy it was to add a completion percentage.

Now for e.g. linux.git we'll emit:

    ~/g/git/git --exec-path=$HOME/g/git commit-graph write
    Finding commits for commit graph among packed objects: 100% 
(6365442/6365442), done.
    Annotating commit graph: 100% (2391666/2391666), done.
    Computing commit graph generation numbers: 100% (797222/797222), done.
    Writing out commit graph in 4 passes: 100% (3188888/3188888), done.

Signed-off-by: Ævar Arnfjörð Bjarmason <ava...@gmail.com>
---
 commit-graph.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/commit-graph.c b/commit-graph.c
index 80f201adf4..6c6edc679b 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -660,10 +660,17 @@ static void close_reachable(struct packed_oid_list *oids, 
int report_progress)
        struct commit *commit;
        struct progress *progress = NULL;
        int j = 0;
+       /*
+        * We loop over the OIDs N times to close the graph
+        * below. This number must be kept in sync with the number of
+        * passes.
+        */
+       const int oid_passes = 3;
 
        if (report_progress)
                progress = start_delayed_progress(
-                       _("Annotating commit graph"), 0);
+                       _("Annotating commit graph"),
+                       oid_passes * oids->nr);
        for (i = 0; i < oids->nr; i++) {
                display_progress(progress, ++j);
                commit = lookup_commit(the_repository, &oids->list[i]);
-- 
2.20.0.rc0.387.gc7a69e6b6c

Reply via email to