diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2018-04-10 08:56:07 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-04-11 10:43:02 +0900 |
commit | 3d5df01b5e42416a59e857135e932bbdd8cc3ba0 (patch) | |
tree | 39368eb806a613e4d98876c5d5d3b2b4eef5683e /commit-graph.c | |
parent | 049d51a2bb9a03d2f2c2cce1ae41e57dbbf42244 (diff) | |
download | git-3d5df01b5e42416a59e857135e932bbdd8cc3ba0.tar.gz |
commit-graph: build graph from starting commits
Teach git-commit-graph to read commits from stdin when the
--stdin-commits flag is specified. Commits reachable from these
commits are added to the graph. This is a much faster way to construct
the graph than inspecting all packed objects, but is restricted to
known tips.
For the Linux repository, 700,000+ commits were added to the graph
file starting from 'master' in 7-9 seconds, depending on the number
of packfiles in the repo (1, 24, or 120).
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r-- | commit-graph.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/commit-graph.c b/commit-graph.c index 70472840a3..a59d1e387b 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -551,7 +551,9 @@ static void close_reachable(struct packed_oid_list *oids) void write_commit_graph(const char *obj_dir, const char **pack_indexes, - int nr_packs) + int nr_packs, + const char **commit_hex, + int nr_commits) { struct packed_oid_list oids; struct packed_commit_list commits; @@ -591,7 +593,28 @@ void write_commit_graph(const char *obj_dir, close_pack(p); } strbuf_release(&packname); - } else + } + + if (commit_hex) { + for (i = 0; i < nr_commits; i++) { + const char *end; + struct object_id oid; + struct commit *result; + + if (commit_hex[i] && parse_oid_hex(commit_hex[i], &oid, &end)) + continue; + + result = lookup_commit_reference_gently(&oid, 1); + + if (result) { + ALLOC_GROW(oids.list, oids.nr + 1, oids.alloc); + oidcpy(&oids.list[oids.nr], &(result->object.oid)); + oids.nr++; + } + } + } + + if (!pack_indexes && !commit_hex) for_each_packed_object(add_packed_commits, &oids, 0); close_reachable(&oids); |