diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-08-11 04:52:34 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-08-11 04:52:35 (GMT) |
commit | 042159a5093db5da1be2a90b7c1b88441ece6029 (patch) | |
tree | 2c196e8915418ee521839e6f8d932467d60eb905 /commit-graph.c | |
parent | 4f049a16bf47c97639cb78b3ede3c6888fe91987 (diff) | |
parent | 9550f6c16a8be18bd4868909d4d5e29d05bd9733 (diff) | |
download | git-042159a5093db5da1be2a90b7c1b88441ece6029.zip git-042159a5093db5da1be2a90b7c1b88441ece6029.tar.gz git-042159a5093db5da1be2a90b7c1b88441ece6029.tar.bz2 |
Merge branch 'tb/commit-graph-genv2-upgrade-fix' into maint
There was a bug in the codepath to upgrade generation information
in commit-graph from v1 to v2 format, which has been corrected.
source: <cover.1657667404.git.me@ttaylorr.com>
* tb/commit-graph-genv2-upgrade-fix:
commit-graph: fix corrupt upgrade from generation v1 to v2
commit-graph: introduce `repo_find_commit_pos_in_graph()`
t5318: demonstrate commit-graph generation v2 corruption
Diffstat (limited to 'commit-graph.c')
-rw-r--r-- | commit-graph.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/commit-graph.c b/commit-graph.c index 2b04ef0..a487d49 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -889,6 +889,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; @@ -946,9 +954,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); } |