commit-graph write: more descriptive "writing out" output

Make the "Writing out" part of the progress output more descriptive. Depending on the shape of the graph we either make 3 or 4 passes over it. Let's present this information to the user in case they're wondering what this number, which is much larger than their number of commits, has to do with writing out the commit graph. Now e.g. on linux.git we emit: $ ~/g/git/git --exec-path=$HOME/g/git -C ~/g/linux commit-graph write Finding commits for commit graph: 6529159, done. Expanding reachable commits in commit graph: 815990, done. Computing commit graph generation numbers: 100% (815983/815983), done. Writing out commit graph in 4 passes: 100% (3263932/3263932), done. A note on i18n: Why are we using the Q_() function and passing a number & English text for a singular which'll never be used? Because the plural rules of translated languages may not match those of English, and to use the plural function we need to use this format. 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 289447397c311d7f8b3c7ed2e54e11b6e57a1d89
1 file changed +10 -2
commit-graph.c
+10 -2
@@ -784,6 +784,7 @@ void write_commit_graph(const char *obj_dir,
784 struct commit_list *parent;
785 struct progress *progress = NULL;
786 uint64_t progress_cnt = 0;
787 + struct strbuf progress_title = STRBUF_INIT;
788
789 if (!commit_graph_compatible(the_repository))
790 return;
@@ -959,16 +960,23 @@ void write_commit_graph(const char *obj_dir,
960 hashwrite(f, chunk_write, 12);
961 }
962
962 - if (report_progress)
963 + if (report_progress) {
964 + strbuf_addf(&progress_title,
965 + Q_("Writing out commit graph in %d pass",
966 + "Writing out commit graph in %d passes",
967 + num_chunks),
968 + num_chunks);
969 progress = start_delayed_progress(
964 - _("Writing out commit graph"),
970 + progress_title.buf,
971 num_chunks * commits.nr);
972 + }
973 write_graph_chunk_fanout(f, commits.list, commits.nr, progress, &progress_cnt);
974 write_graph_chunk_oids(f, GRAPH_OID_LEN, commits.list, commits.nr, progress, &progress_cnt);
975 write_graph_chunk_data(f, GRAPH_OID_LEN, commits.list, commits.nr, progress, &progress_cnt);
976 if (num_extra_edges)
977 write_graph_chunk_extra_edges(f, commits.list, commits.nr, progress, &progress_cnt);
978 stop_progress(&progress);
979 + strbuf_release(&progress_title);
980
981 close_commit_graph(the_repository);
982 finalize_hashfile(f, NULL, CSUM_HASH_IN_STREAM | CSUM_FSYNC);