commit-graph write: add more descriptive progress output

Make the progress output shown when we're searching for commits to include in the graph more descriptive. This amends code I added in 7b0f229222 ("commit-graph write: add progress output", 2018-09-17). Now, on linux.git, we'll emit this sort of output in the various modes we support: $ git commit-graph write Finding commits for commit graph among packed objects: 100% (6529159/6529159), done. [...] # Actually we don't emit this since this takes almost no time at # all. But if we did (s/_delayed//) we'd show: $ git for-each-ref --format='%(objectname)' | git commit-graph write --stdin-commits Finding commits for commit graph from 630 refs: 100% (630/630), done. [...] $ (cd .git/objects/pack/ && ls *idx) | git commit-graph write --stdin-pack Finding commits for commit graph in 3 packs: 6529159, done. [...] The middle on of those is going to be the output users might see in practice, since it'll be emitted when they get the commit graph via gc.writeCommitGraph=true. But as noted above you need a really large number of refs for this message to show. It'll show up on a test repository I have with ~165k refs: Finding commits for commit graph from 165203 refs: 100% (165203/165203), done. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jan 19, 2019 at 21:21 UTC 7c7b8a7fc7c87011d5b3e384122ce8b23ef280e8
1 file changed +18 -7
commit-graph.c
+18 -7
@@ -822,8 +822,12 @@ void write_commit_graph(const char *obj_dir,
822 strbuf_addf(&packname, "%s/pack/", obj_dir);
823 dirlen = packname.len;
824 if (report_progress) {
825 - oids.progress = start_delayed_progress(
826 - _("Finding commits for commit graph"), 0);
825 + strbuf_addf(&progress_title,
826 + Q_("Finding commits for commit graph in %d pack",
827 + "Finding commits for commit graph in %d packs",
828 + pack_indexes->nr),
829 + pack_indexes->nr);
830 + oids.progress = start_delayed_progress(progress_title.buf, 0);
831 oids.progress_done = 0;
832 }
833 for (i = 0; i < pack_indexes->nr; i++) {
@@ -841,14 +845,20 @@ void write_commit_graph(const char *obj_dir,
845 free(p);
846 }
847 stop_progress(&oids.progress);
848 + strbuf_reset(&progress_title);
849 strbuf_release(&packname);
850 }
851
852 if (commit_hex) {
848 - if (report_progress)
849 - progress = start_delayed_progress(
850 - _("Finding commits for commit graph"),
851 - commit_hex->nr);
853 + if (report_progress) {
854 + strbuf_addf(&progress_title,
855 + Q_("Finding commits for commit graph from %d ref",
856 + "Finding commits for commit graph from %d refs",
857 + commit_hex->nr),
858 + commit_hex->nr);
859 + progress = start_delayed_progress(progress_title.buf,
860 + commit_hex->nr);
861 + }
862 for (i = 0; i < commit_hex->nr; i++) {
863 const char *end;
864 struct object_id oid;
@@ -868,12 +878,13 @@ void write_commit_graph(const char *obj_dir,
878 }
879 }
880 stop_progress(&progress);
881 + strbuf_reset(&progress_title);
882 }
883
884 if (!pack_indexes && !commit_hex) {
885 if (report_progress)
886 oids.progress = start_delayed_progress(
876 - _("Finding commits for commit graph"),
887 + _("Finding commits for commit graph among packed objects"),
888 approx_nr_objects);
889 for_each_packed_object(add_packed_commits, &oids,
890 FOR_EACH_OBJECT_PACK_ORDER);