Skip to content

Commit 630cd51

Browse files
ttaylorrgitster
authored andcommitted
commit-graph.c: peel refs in 'add_ref_to_set'
While iterating references (to discover the set of commits to write to the commit-graph with 'git commit-graph write --reachable'), 'add_ref_to_set' can save 'fill_oids_from_commits()' some time by peeling the references beforehand. Move peeling out of 'fill_oids_from_commits()' and into 'add_ref_to_set()' to use 'peel_ref()' instead of 'deref_tag()'. Doing so allows the commit-graph machinery to use the peeled value from '$GIT_DIR/packed-refs' instead of having to load and parse tags. While we're at it, discard non-commit objects reachable from ref tips. This would be done automatically by 'fill_oids_from_commits()', but such functionality will be removed in a subsequent patch after the call to 'lookup_commit_reference_gently' is dropped (at which point a non-commit object in the commits oidset will become an error). Suggested-by: Jeff King <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d335ce8 commit 630cd51

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

commit-graph.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,9 +1327,13 @@ static int add_ref_to_set(const char *refname,
13271327
const struct object_id *oid,
13281328
int flags, void *cb_data)
13291329
{
1330+
struct object_id peeled;
13301331
struct refs_cb_data *data = (struct refs_cb_data *)cb_data;
13311332

1332-
oidset_insert(data->commits, oid);
1333+
if (!peel_ref(refname, &peeled))
1334+
oid = &peeled;
1335+
if (oid_object_info(the_repository, oid, NULL) == OBJ_COMMIT)
1336+
oidset_insert(data->commits, oid);
13331337

13341338
display_progress(data->progress, oidset_size(data->commits));
13351339

0 commit comments

Comments
 (0)