aboutsummaryrefslogtreecommitdiffstats
path: root/odb.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-08-11 15:46:42 +0200
committerJunio C Hamano <gitster@pobox.com>2025-08-11 09:22:21 -0700
commit0d61933b8f9a0392310196578e1374283496843c (patch)
treea6b4267a921bb83e9b138211e1ba805e5b3281b6 /odb.c
parent595bef7180b57889a4dec4b675a7fc6084c863ac (diff)
downloadgit-0d61933b8f9a0392310196578e1374283496843c.tar.gz
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>
Diffstat (limited to 'odb.c')
-rw-r--r--odb.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/odb.c b/odb.c
index 1761a50840..4e7f14be4a 100644
--- a/odb.c
+++ b/odb.c
@@ -464,6 +464,12 @@ struct odb_source *odb_find_source(struct object_database *odb, const char *obj_
free(obj_dir_real);
strbuf_release(&odb_path_real);
+ return source;
+}
+
+struct odb_source *odb_find_source_or_die(struct object_database *odb, const char *obj_dir)
+{
+ struct odb_source *source = odb_find_source(odb, obj_dir);
if (!source)
die(_("could not find object directory matching %s"), obj_dir);
return source;