Skip to content

Commit 41dac79

Browse files
committed
Merge branch 'ds/commit-graph-delay-gen-progress'
One kind of progress messages were always given during commit-graph generation, instead of following the "if it takes more than two seconds, show progress" pattern, which has been corrected. * ds/commit-graph-delay-gen-progress: commit-graph: use start_delayed_progress() progress: create GIT_PROGRESS_DELAY
2 parents 5dd1d59 + ecc0869 commit 41dac79

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

Documentation/git.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,10 @@ other
544544
a pager. See also the `core.pager` option in
545545
linkgit:git-config[1].
546546

547+
`GIT_PROGRESS_DELAY`::
548+
A number controlling how many seconds to delay before showing
549+
optional progress indicators. Defaults to 2.
550+
547551
`GIT_EDITOR`::
548552
This environment variable overrides `$EDITOR` and `$VISUAL`.
549553
It is used by several Git commands when, on interactive mode,

commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx)
11001100
struct commit_list *list = NULL;
11011101

11021102
if (ctx->report_progress)
1103-
ctx->progress = start_progress(
1103+
ctx->progress = start_delayed_progress(
11041104
_("Computing commit graph generation numbers"),
11051105
ctx->commits.nr);
11061106
for (i = 0; i < ctx->commits.nr; i++) {

progress.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "strbuf.h"
1515
#include "trace.h"
1616
#include "utf8.h"
17+
#include "config.h"
1718

1819
#define TP_IDX_MAX 8
1920

@@ -267,9 +268,19 @@ static struct progress *start_progress_delay(const char *title, uint64_t total,
267268
return progress;
268269
}
269270

271+
static int get_default_delay(void)
272+
{
273+
static int delay_in_secs = -1;
274+
275+
if (delay_in_secs < 0)
276+
delay_in_secs = git_env_ulong("GIT_PROGRESS_DELAY", 2);
277+
278+
return delay_in_secs;
279+
}
280+
270281
struct progress *start_delayed_progress(const char *title, uint64_t total)
271282
{
272-
return start_progress_delay(title, total, 2, 0);
283+
return start_progress_delay(title, total, get_default_delay(), 0);
273284
}
274285

275286
struct progress *start_progress(const char *title, uint64_t total)
@@ -294,7 +305,7 @@ struct progress *start_sparse_progress(const char *title, uint64_t total)
294305
struct progress *start_delayed_sparse_progress(const char *title,
295306
uint64_t total)
296307
{
297-
return start_progress_delay(title, total, 2, 1);
308+
return start_progress_delay(title, total, get_default_delay(), 1);
298309
}
299310

300311
static void finish_if_sparse(struct progress *progress)

t/t5318-commit-graph.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ test_expect_success 'commit-graph write progress off for redirected stderr' '
132132

133133
test_expect_success 'commit-graph write force progress on for stderr' '
134134
cd "$TRASH_DIRECTORY/full" &&
135-
git commit-graph write --progress 2>err &&
135+
GIT_PROGRESS_DELAY=0 git commit-graph write --progress 2>err &&
136136
test_file_not_empty err
137137
'
138138

@@ -150,7 +150,7 @@ test_expect_success 'commit-graph verify progress off for redirected stderr' '
150150

151151
test_expect_success 'commit-graph verify force progress on for stderr' '
152152
cd "$TRASH_DIRECTORY/full" &&
153-
git commit-graph verify --progress 2>err &&
153+
GIT_PROGRESS_DELAY=0 git commit-graph verify --progress 2>err &&
154154
test_file_not_empty err
155155
'
156156

t/t6500-gc.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ test_expect_success 'auto gc with too many loose objects does not attempt to cre
103103
'
104104

105105
test_expect_success 'gc --no-quiet' '
106-
git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
106+
GIT_PROGRESS_DELAY=0 git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
107107
test_must_be_empty stdout &&
108-
test_line_count = 1 stderr &&
109108
test_i18ngrep "Computing commit graph generation numbers" stderr
110109
'
111110

112111
test_expect_success TTY 'with TTY: gc --no-quiet' '
113-
test_terminal git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
112+
test_terminal env GIT_PROGRESS_DELAY=0 \
113+
git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
114114
test_must_be_empty stdout &&
115115
test_i18ngrep "Enumerating objects" stderr &&
116116
test_i18ngrep "Computing commit graph generation numbers" stderr

0 commit comments

Comments
 (0)