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
7
odb.h
7
odb.h
@@ -186,11 +186,14 @@ struct object_database *odb_new(struct repository *repo);
|
||||
void odb_clear(struct object_database *o);
|
||||
|
||||
/*
|
||||
* Find source by its object directory path. Dies in case the source couldn't
|
||||
* be found.
|
||||
* Find source by its object directory path. Returns a `NULL` pointer in case
|
||||
* the source could not be found.
|
||||
*/
|
||||
struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir);
|
||||
|
||||
/* Same as `odb_find_source()`, but dies in case the source doesn't exist. */
|
||||
struct odb_source *odb_find_source_or_die(struct object_database *odb, const char *obj_dir);
|
||||
|
||||
/*
|
||||
* Replace the current writable object directory with the specified temporary
|
||||
* object directory; returns the former primary source.
|
||||
|
||||
Reference in New Issue
Block a user