commit-graph: introduce repo_find_commit_pos_in_graph()
Low-level callers in systems that are adjacent to the commit-graph (like the changed-path Bloom filter code) could benefit from being able to call a function like `parse_commit_in_graph()` without modifying the corresponding commit slab data. This is useful in contexts where that slab data is being used to prepare for an upcoming commit-graph write, where Git must be careful to avoid clobbering any of that data during a read operation. Introduce a low-level variant of `parse_commit_in_graph()` which returns the graph position of a given commit only, without modifying any of the slab data. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
2dd804cd12
commit
7805360b7a
@ -898,6 +898,14 @@ static int find_commit_pos_in_graph(struct commit *item, struct commit_graph *g,
|
||||
}
|
||||
}
|
||||
|
||||
int repo_find_commit_pos_in_graph(struct repository *r, struct commit *c,
|
||||
uint32_t *pos)
|
||||
{
|
||||
if (!prepare_commit_graph(r))
|
||||
return 0;
|
||||
return find_commit_pos_in_graph(c, r->objects->commit_graph, pos);
|
||||
}
|
||||
|
||||
struct commit *lookup_commit_in_graph(struct repository *repo, const struct object_id *id)
|
||||
{
|
||||
struct commit *commit;
|
||||
@ -955,9 +963,7 @@ int parse_commit_in_graph(struct repository *r, struct commit *item)
|
||||
void load_commit_graph_info(struct repository *r, struct commit *item)
|
||||
{
|
||||
uint32_t pos;
|
||||
if (!prepare_commit_graph(r))
|
||||
return;
|
||||
if (find_commit_pos_in_graph(item, r->objects->commit_graph, &pos))
|
||||
if (repo_find_commit_pos_in_graph(r, item, &pos))
|
||||
fill_commit_graph_info(item, r->objects->commit_graph, pos);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user