Skip to content

Commit d335ce8

Browse files
ttaylorrgitster
authored andcommitted
commit-graph.c: show progress of finding reachable commits
When 'git commit-graph write --reachable' is invoked, the commit-graph machinery calls 'for_each_ref()' to discover the set of reachable commits. Right now the 'add_ref_to_set' callback is not doing anything other than adding an OID to the set of known-reachable OIDs. In a subsequent commit, 'add_ref_to_set' will presumptively peel references. This operation should be fast for repositories with an up-to-date '$GIT_DIR/packed-refs', but may be slow in the general case. So that it doesn't appear that 'git commit-graph write' is idling with '--reachable' in the slow case, add a progress meter to provide some output in the meantime. In general, we don't expect a progress meter to appear at all, since peeling references with a 'packed-refs' file is quick. If it's slow and we do show a progress meter, the subsequent 'fill_oids_from_commits()' will be fast, since all of the calls to 'lookup_commit_reference_gently()' will be no-ops. Both progress meters are delayed, so it is unlikely that more than one will appear. In either case, this intermediate state will go away in a handful of patches, at which point there will be at most one progress meter. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1fe1084 commit d335ce8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

commit-graph.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
13201320

13211321
struct refs_cb_data {
13221322
struct oidset *commits;
1323+
struct progress *progress;
13231324
};
13241325

13251326
static int add_ref_to_set(const char *refname,
@@ -1329,6 +1330,9 @@ static int add_ref_to_set(const char *refname,
13291330
struct refs_cb_data *data = (struct refs_cb_data *)cb_data;
13301331

13311332
oidset_insert(data->commits, oid);
1333+
1334+
display_progress(data->progress, oidset_size(data->commits));
1335+
13321336
return 0;
13331337
}
13341338

@@ -1342,12 +1346,17 @@ int write_commit_graph_reachable(struct object_directory *odb,
13421346

13431347
memset(&data, 0, sizeof(data));
13441348
data.commits = &commits;
1349+
if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
1350+
data.progress = start_delayed_progress(
1351+
_("Collecting referenced commits"), 0);
13451352

13461353
for_each_ref(add_ref_to_set, &data);
13471354
result = write_commit_graph(odb, NULL, &commits,
13481355
flags, split_opts);
13491356

13501357
oidset_clear(&commits);
1358+
if (data.progress)
1359+
stop_progress(&data.progress);
13511360
return result;
13521361
}
13531362

0 commit comments

Comments
 (0)