{"thread":{"id":"53824","subject":"[PATCH] commit-graph: fix progress of reachable commits","startedAt":"2020-07-09T16:54:54Z","lastAt":"2020-07-09T17:27:55Z","messageCount":2,"participants":["SZEDER Gábor","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"401250","messageId":"20200709165432.2688-1-szeder.dev@gmail.com","threadId":"53824","inReplyTo":null,"subject":"[PATCH] commit-graph: fix progress of reachable commits","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2020-07-09T16:54:32Z","receivedAt":"2020-07-09T16:54:54Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"To display a progress line while iterating over all refs,\nd335ce8f24 (commit-graph.c: show progress of finding reachable\ncommits, 2020-05-13) should have added a pair of\nstart_delayed_progress() and stop_progress() calls around a\nfor_each_ref() invocation.  Alas, the stop_progress() call ended up at\nthe wrong place, after write_commit_graph(), which does all the\ncommit-graph computation and writing, and has several progress lines\nof its own.  Consequently, that new\n\n  Collecting referenced commits: 123\n\nprogress line is overwritten by the first progress line shown by\nwrite_commit_graph(), and its final \"done\" line is shown last, after\neverything is finished:\n\n  Expanding reachable commits in commit graph: 344786, done.\n  Computing commit changed paths Bloom filters: 100% (344786/344786), done.\n  Collecting referenced commits: 154, done.\n\nMove that stop_progress() call to the right place.\n\nWhile at it, drop the unnecessary 'if (data.progress)' condition\nprotecting the stop_progress() call, because that function is prepared\nto handle a NULL progress struct.\n\nSigned-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n---\n commit-graph.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 5df3e08718..aaf3327ede 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1354,12 +1354,13 @@ int write_commit_graph_reachable(struct object_directory *odb,\n \t\t\t_(\"Collecting referenced commits\"), 0);\n \n \tfor_each_ref(add_ref_to_set, &data);\n+\n+\tstop_progress(&data.progress);\n+\n \tresult = write_commit_graph(odb, NULL, &commits,\n \t\t\t\t    flags, split_opts);\n \n \toidset_clear(&commits);\n-\tif (data.progress)\n-\t\tstop_progress(&data.progress);\n \treturn result;\n }\n \n-- \n2.27.0.547.g4ba2d26563\n\n"},{"id":"401254","messageId":"xmqq5zawy4x5.fsf@gitster.c.googlers.com","threadId":"53824","inReplyTo":"20200709165432.2688-1-szeder.dev@gmail.com","subject":"Re: [PATCH] commit-graph: fix progress of reachable commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-09T17:27:50Z","receivedAt":"2020-07-09T17:27:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"SZEDER Gábor <szeder.dev@gmail.com> writes:\n\n> To display a progress line while iterating over all refs,\n> d335ce8f24 (commit-graph.c: show progress of finding reachable\n> commits, 2020-05-13) should have added a pair of\n> start_delayed_progress() and stop_progress() calls around a\n> for_each_ref() invocation.  Alas, the stop_progress() call ended up at\n> the wrong place, after write_commit_graph(), which does all the\n> commit-graph computation and writing, and has several progress lines\n> of its own.  Consequently, that new\n>\n>   Collecting referenced commits: 123\n>\n> progress line is overwritten by the first progress line shown by\n> write_commit_graph(), and its final \"done\" line is shown last, after\n> everything is finished:\n>\n>   Expanding reachable commits in commit graph: 344786, done.\n>   Computing commit changed paths Bloom filters: 100% (344786/344786), done.\n>   Collecting referenced commits: 154, done.\n>\n> Move that stop_progress() call to the right place.\n>\n> While at it, drop the unnecessary 'if (data.progress)' condition\n> protecting the stop_progress() call, because that function is prepared\n> to handle a NULL progress struct.\n\nNicely explained.  Will apply.  Thanks.\n\n>\n> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n> ---\n>  commit-graph.c | 5 +++--\n>  1 file changed, 3 insertions(+), 2 deletions(-)\n>\n> diff --git a/commit-graph.c b/commit-graph.c\n> index 5df3e08718..aaf3327ede 100644\n> --- a/commit-graph.c\n> +++ b/commit-graph.c\n> @@ -1354,12 +1354,13 @@ int write_commit_graph_reachable(struct object_directory *odb,\n>  \t\t\t_(\"Collecting referenced commits\"), 0);\n>  \n>  \tfor_each_ref(add_ref_to_set, &data);\n> +\n> +\tstop_progress(&data.progress);\n> +\n>  \tresult = write_commit_graph(odb, NULL, &commits,\n>  \t\t\t\t    flags, split_opts);\n>  \n>  \toidset_clear(&commits);\n> -\tif (data.progress)\n> -\t\tstop_progress(&data.progress);\n>  \treturn result;\n>  }\n"}]}