diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2018-04-10 14:56:06 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-04-11 03:43:02 +0200 |
commit | 049d51a2bb9a03d2f2c2cce1ae41e57dbbf42244 (patch) | |
tree | d0bfac6465a31845070c4c55d6916dd6997e94c8 /commit-graph.c | |
parent | commit: integrate commit graph with commit parsing (diff) | |
download | git-049d51a2bb9a03d2f2c2cce1ae41e57dbbf42244.tar.xz git-049d51a2bb9a03d2f2c2cce1ae41e57dbbf42244.zip |
commit-graph: read only from specific pack-indexes
Teach git-commit-graph to inspect the objects only in a certain list
of pack-indexes within the given pack directory. This allows updating
the commit graph iteratively.
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 | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/commit-graph.c b/commit-graph.c index f745186e7f..70472840a3 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -549,7 +549,9 @@ static void close_reachable(struct packed_oid_list *oids) } } -void write_commit_graph(const char *obj_dir) +void write_commit_graph(const char *obj_dir, + const char **pack_indexes, + int nr_packs) { struct packed_oid_list oids; struct packed_commit_list commits; @@ -571,7 +573,27 @@ void write_commit_graph(const char *obj_dir) oids.alloc = 1024; ALLOC_ARRAY(oids.list, oids.alloc); - for_each_packed_object(add_packed_commits, &oids, 0); + if (pack_indexes) { + struct strbuf packname = STRBUF_INIT; + int dirlen; + strbuf_addf(&packname, "%s/pack/", obj_dir); + dirlen = packname.len; + for (i = 0; i < nr_packs; i++) { + struct packed_git *p; + strbuf_setlen(&packname, dirlen); + strbuf_addstr(&packname, pack_indexes[i]); + p = add_packed_git(packname.buf, packname.len, 1); + if (!p) + die("error adding pack %s", packname.buf); + if (open_pack_index(p)) + die("error opening index for %s", packname.buf); + for_each_object_in_pack(p, add_packed_commits, &oids); + close_pack(p); + } + strbuf_release(&packname); + } else + for_each_packed_object(add_packed_commits, &oids, 0); + close_reachable(&oids); QSORT(oids.list, oids.nr, commit_compare); |