From 25b75cd9bc01896a2b74c748ceef7110ea1b165f Mon Sep 17 00:00:00 2001 From: lhchavez Date: Wed, 10 Mar 2021 07:06:15 -0800 Subject: commit-graph: Create `git_commit_graph` as an abstraction for the file This change does a medium-size refactor of the git_commit_graph_file and the interaction with the ODB. Now instead of the ODB owning a direct reference to the git_commit_graph_file, there will be an intermediate git_commit_graph. The main advantage of that is that now end users can explicitly set a git_commit_graph that is eagerly checked for errors, while still being able to lazily use the commit-graph in a regular ODB, if the file is present. --- fuzzers/commit_graph_fuzzer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'fuzzers') diff --git a/fuzzers/commit_graph_fuzzer.c b/fuzzers/commit_graph_fuzzer.c index eb2c38258..b41816ed9 100644 --- a/fuzzers/commit_graph_fuzzer.c +++ b/fuzzers/commit_graph_fuzzer.c @@ -31,7 +31,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - git_commit_graph_file cgraph = {{0}}; + git_commit_graph_file file = {{0}}; git_commit_graph_entry e; git_buf commit_graph_buf = GIT_BUF_INIT; git_oid oid = {{0}}; @@ -62,19 +62,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) git_buf_attach_notowned(&commit_graph_buf, (char *)data, size); } - if (git_commit_graph_parse( - &cgraph, + if (git_commit_graph_file_parse( + &file, (const unsigned char *)git_buf_cstr(&commit_graph_buf), git_buf_len(&commit_graph_buf)) < 0) goto cleanup; /* Search for any oid, just to exercise that codepath. */ - if (git_commit_graph_entry_find(&e, &cgraph, &oid, GIT_OID_HEXSZ) < 0) + if (git_commit_graph_entry_find(&e, &file, &oid, GIT_OID_HEXSZ) < 0) goto cleanup; cleanup: - git_commit_graph_close(&cgraph); + git_commit_graph_file_close(&file); git_buf_dispose(&commit_graph_buf); return 0; } -- cgit v1.2.1