From: Junio C Hamano Date: Tue, 5 Feb 2019 22:26:10 +0000 (-0800) Subject: Merge branch 'jt/get-reference-with-commit-graph' X-Git-Tag: v2.21.0-rc0~54 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/09b2e40944f297d6cabe0fb0ce2e3a72e610f657?hp=073312b4c7a15d484d2ffdc2eb4a406df9cf9c55 Merge branch 'jt/get-reference-with-commit-graph' Micro-optimize the code that prepares commit objects to be walked by "git rev-list" when the commit-graph is available. * jt/get-reference-with-commit-graph: revision: use commit graph in get_reference() --- diff --git a/revision.c b/revision.c index 119947ced0..8f886fe8c6 100644 --- a/revision.c +++ b/revision.c @@ -213,7 +213,20 @@ static struct object *get_reference(struct rev_info *revs, const char *name, { struct object *object; - object = parse_object(revs->repo, oid); + /* + * If the repository has commit graphs, repo_parse_commit() avoids + * reading the object buffer, so use it whenever possible. + */ + if (oid_object_info(revs->repo, oid, NULL) == OBJ_COMMIT) { + struct commit *c = lookup_commit(revs->repo, oid); + if (!repo_parse_commit(revs->repo, c)) + object = (struct object *) c; + else + object = NULL; + } else { + object = parse_object(revs->repo, oid); + } + if (!object) { if (revs->ignore_missing) return object;