progress.c: refactor stop_progress{,_msg}() to use helpers
Create two new static helpers for the stop_progress() and stop_progress_msg() functions. As we'll see in the subsequent commit having those two split up doesn't make much sense, and results in a bug in how we log to trace2. This narrow preparatory change makes the diff for that subsequent change smaller. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
1ccad6a1f1
commit
accf1eb1d0
82
progress.c
82
progress.c
@@ -317,44 +317,8 @@ static void finish_if_sparse(struct progress *progress)
|
|||||||
display_progress(progress, progress->total);
|
display_progress(progress, progress->total);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop_progress(struct progress **p_progress)
|
static void force_last_update(struct progress *progress, const char *msg)
|
||||||
{
|
{
|
||||||
struct progress *progress;
|
|
||||||
|
|
||||||
if (!p_progress)
|
|
||||||
BUG("don't provide NULL to stop_progress");
|
|
||||||
progress = *p_progress;
|
|
||||||
|
|
||||||
finish_if_sparse(progress);
|
|
||||||
|
|
||||||
if (progress) {
|
|
||||||
trace2_data_intmax("progress", the_repository, "total_objects",
|
|
||||||
progress->total);
|
|
||||||
|
|
||||||
if (progress->throughput)
|
|
||||||
trace2_data_intmax("progress", the_repository,
|
|
||||||
"total_bytes",
|
|
||||||
progress->throughput->curr_total);
|
|
||||||
|
|
||||||
trace2_region_leave("progress", progress->title, the_repository);
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_progress_msg(p_progress, _("done"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void stop_progress_msg(struct progress **p_progress, const char *msg)
|
|
||||||
{
|
|
||||||
struct progress *progress;
|
|
||||||
|
|
||||||
if (!p_progress)
|
|
||||||
BUG("don't provide NULL to stop_progress_msg");
|
|
||||||
|
|
||||||
progress = *p_progress;
|
|
||||||
if (!progress)
|
|
||||||
return;
|
|
||||||
*p_progress = NULL;
|
|
||||||
if (progress->last_value != -1) {
|
|
||||||
/* Force the last update */
|
|
||||||
char *buf;
|
char *buf;
|
||||||
struct throughput *tp = progress->throughput;
|
struct throughput *tp = progress->throughput;
|
||||||
|
|
||||||
@@ -370,6 +334,50 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
|
|||||||
display(progress, progress->last_value, buf);
|
display(progress, progress->last_value, buf);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void log_trace2(struct progress *progress)
|
||||||
|
{
|
||||||
|
trace2_data_intmax("progress", the_repository, "total_objects",
|
||||||
|
progress->total);
|
||||||
|
|
||||||
|
if (progress->throughput)
|
||||||
|
trace2_data_intmax("progress", the_repository, "total_bytes",
|
||||||
|
progress->throughput->curr_total);
|
||||||
|
|
||||||
|
trace2_region_leave("progress", progress->title, the_repository);
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop_progress(struct progress **p_progress)
|
||||||
|
{
|
||||||
|
struct progress *progress;
|
||||||
|
|
||||||
|
if (!p_progress)
|
||||||
|
BUG("don't provide NULL to stop_progress");
|
||||||
|
progress = *p_progress;
|
||||||
|
|
||||||
|
finish_if_sparse(progress);
|
||||||
|
|
||||||
|
if (progress)
|
||||||
|
log_trace2(*p_progress);
|
||||||
|
|
||||||
|
stop_progress_msg(p_progress, _("done"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop_progress_msg(struct progress **p_progress, const char *msg)
|
||||||
|
{
|
||||||
|
struct progress *progress;
|
||||||
|
|
||||||
|
if (!p_progress)
|
||||||
|
BUG("don't provide NULL to stop_progress_msg");
|
||||||
|
|
||||||
|
progress = *p_progress;
|
||||||
|
if (!progress)
|
||||||
|
return;
|
||||||
|
*p_progress = NULL;
|
||||||
|
|
||||||
|
if (progress->last_value != -1)
|
||||||
|
force_last_update(progress, msg);
|
||||||
|
|
||||||
clear_progress_signal();
|
clear_progress_signal();
|
||||||
strbuf_release(&progress->counters_sb);
|
strbuf_release(&progress->counters_sb);
|
||||||
if (progress->throughput)
|
if (progress->throughput)
|
||||||
|
|||||||
Reference in New Issue
Block a user