odb: allow odb_find_source() to fail
When trying to locate a source for an unknown object directory we will die right away. In subsequent patches we will add new callsites though that want to handle this situation gracefully instead. Refactor the function to return a `NULL` pointer if the source could not be found and adapt the callsites to die instead. Introduce a new wrapper `odb_find_source_or_die()` that continues to die in case the source could not be found. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
595bef7180
commit
0d61933b8f
@@ -101,7 +101,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix,
|
||||
if (opts.progress)
|
||||
flags |= COMMIT_GRAPH_WRITE_PROGRESS;
|
||||
|
||||
source = odb_find_source(the_repository->objects, opts.obj_dir);
|
||||
source = odb_find_source_or_die(the_repository->objects, opts.obj_dir);
|
||||
graph_name = get_commit_graph_filename(source);
|
||||
chain_name = get_commit_graph_chain_filename(source);
|
||||
if (open_commit_graph(graph_name, &fd, &st))
|
||||
@@ -289,7 +289,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,
|
||||
git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))
|
||||
flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;
|
||||
|
||||
source = odb_find_source(the_repository->objects, opts.obj_dir);
|
||||
source = odb_find_source_or_die(the_repository->objects, opts.obj_dir);
|
||||
|
||||
if (opts.reachable) {
|
||||
if (write_commit_graph_reachable(source, flags, &write_opts))
|
||||
|
||||
Reference in New Issue
Block a user