odb: introduce odb_write_object()

We do not have a backend-agnostic way to write objects into an object
database. While there is `write_object_file()`, this function is rather
specific to the loose object format.

Introduce `odb_write_object()` to plug this gap. For now, this function
is a simple wrapper around `write_object_file()` and doesn't even use
the passed-in object database yet. This will change in subsequent
commits, where `write_object_file()` is converted so that it works on
top of an `odb_source`. `odb_write_object()` will then become
responsible for deciding which source an object shall be written to.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-07-17 06:56:35 +02:00
committed by Junio C Hamano
parent 0f9b189357
commit ab1c6e1d12
21 changed files with 106 additions and 67 deletions

View File

@@ -246,7 +246,7 @@ static int splice_tree(struct repository *r,
rewrite_with = oid2;
}
hashcpy(rewrite_here, rewrite_with->hash, r->hash_algo);
status = write_object_file(buf, sz, OBJ_TREE, result);
status = odb_write_object(r->objects, buf, sz, OBJ_TREE, result);
free(buf);
return status;
}