Merge branch 'js/progress-delay-fix' into maint-2.51

The start_delayed_progress() function in the progress eye-candy API
did not clear its internal state, making an initial delay value
larger than 1 second ineffective, which has been corrected.

* js/progress-delay-fix:
  progress: pay attention to (customized) delay time
maint
Junio C Hamano 2025-10-14 13:40:53 -07:00
commit 5b57e1e926
2 changed files with 8 additions and 6 deletions

View File

@ -685,7 +685,7 @@ other


`GIT_PROGRESS_DELAY`:: `GIT_PROGRESS_DELAY`::
A number controlling how many seconds to delay before showing A number controlling how many seconds to delay before showing
optional progress indicators. Defaults to 2. optional progress indicators. Defaults to 1.


`GIT_EDITOR`:: `GIT_EDITOR`::
This environment variable overrides `$EDITOR` and `$VISUAL`. This environment variable overrides `$EDITOR` and `$VISUAL`.

View File

@ -114,16 +114,19 @@ static void display(struct progress *progress, uint64_t n, const char *done)
const char *tp; const char *tp;
struct strbuf *counters_sb = &progress->counters_sb; struct strbuf *counters_sb = &progress->counters_sb;
int show_update = 0; int show_update = 0;
int update = !!progress_update;
int last_count_len = counters_sb->len; int last_count_len = counters_sb->len;


if (progress->delay && (!progress_update || --progress->delay)) progress_update = 0;

if (progress->delay && (!update || --progress->delay))
return; return;


progress->last_value = n; progress->last_value = n;
tp = (progress->throughput) ? progress->throughput->display.buf : ""; tp = (progress->throughput) ? progress->throughput->display.buf : "";
if (progress->total) { if (progress->total) {
unsigned percent = n * 100 / progress->total; unsigned percent = n * 100 / progress->total;
if (percent != progress->last_percent || progress_update) { if (percent != progress->last_percent || update) {
progress->last_percent = percent; progress->last_percent = percent;


strbuf_reset(counters_sb); strbuf_reset(counters_sb);
@ -133,7 +136,7 @@ static void display(struct progress *progress, uint64_t n, const char *done)
tp); tp);
show_update = 1; show_update = 1;
} }
} else if (progress_update) { } else if (update) {
strbuf_reset(counters_sb); strbuf_reset(counters_sb);
strbuf_addf(counters_sb, "%"PRIuMAX"%s", (uintmax_t)n, tp); strbuf_addf(counters_sb, "%"PRIuMAX"%s", (uintmax_t)n, tp);
show_update = 1; show_update = 1;
@ -166,7 +169,6 @@ static void display(struct progress *progress, uint64_t n, const char *done)
} }
fflush(stderr); fflush(stderr);
} }
progress_update = 0;
} }
} }


@ -281,7 +283,7 @@ static int get_default_delay(void)
static int delay_in_secs = -1; static int delay_in_secs = -1;


if (delay_in_secs < 0) if (delay_in_secs < 0)
delay_in_secs = git_env_ulong("GIT_PROGRESS_DELAY", 2); delay_in_secs = git_env_ulong("GIT_PROGRESS_DELAY", 1);


return delay_in_secs; return delay_in_secs;
} }