diff options
author | Taylor Blau <me@ttaylorr.com> | 2023-11-10 01:34:14 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-11-10 03:31:32 +0300 |
commit | c1c449c2a6dfd9f042b75dde7c4fb202a3e71e30 (patch) | |
tree | a42d3e0688db2d6caa5624b1d6667f5b143435e2 /commit-graph.c | |
parent | 641a54ccc6f97c7f16e8c536b641b451d77dab11 (diff) |
commit-graph: read `OIDL` chunk with `pair_chunk_expect()`
The `OIDL` chunk can benefit from the new chunk-format API function
described in the previous commit. Convert it to `pair_chunk_expect()`
accordingly.
While here, clean up some of the duplicate error messages to simplify
the output when we are missing or have a corrupt OIDL chunk.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r-- | commit-graph.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/commit-graph.c b/commit-graph.c index acac9bf6e1..c2adffe810 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -299,16 +299,6 @@ static int graph_read_oid_fanout(const unsigned char *chunk_start, return 0; } -static int graph_read_oid_lookup(const unsigned char *chunk_start, - size_t chunk_size, void *data) -{ - struct commit_graph *g = data; - g->chunk_oid_lookup = chunk_start; - if (chunk_size / g->hash_len != g->num_commits) - return error(_("commit-graph OID lookup chunk is the wrong size")); - return 0; -} - static int graph_read_commit_data(const unsigned char *chunk_start, size_t chunk_size, void *data) { @@ -435,8 +425,10 @@ struct commit_graph *parse_commit_graph(struct repo_settings *s, error(_("commit-graph required OID fanout chunk missing or corrupted")); goto free_and_return; } - if (read_chunk(cf, GRAPH_CHUNKID_OIDLOOKUP, graph_read_oid_lookup, graph)) { - error(_("commit-graph required OID lookup chunk missing or corrupted")); + if (pair_chunk_expect(cf, GRAPH_CHUNKID_OIDLOOKUP, + &graph->chunk_oid_lookup, graph->hash_len, + graph->num_commits)) { + error(_("commit-graph OID lookup chunk is the wrong size")); goto free_and_return; } if (read_chunk(cf, GRAPH_CHUNKID_DATA, graph_read_commit_data, graph)) { |