Patrick Steinhardt <ps@xxxxxx> writes: > 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@xxxxxx> > --- > apply.c | 11 +++++++---- > builtin/checkout.c | 2 +- > builtin/merge-file.c | 3 ++- > builtin/mktag.c | 2 +- > builtin/mktree.c | 2 +- > builtin/notes.c | 3 ++- > builtin/receive-pack.c | 4 ++-- > builtin/replace.c | 3 ++- > builtin/tag.c | 4 ++-- > builtin/unpack-objects.c | 12 ++++++------ > cache-tree.c | 5 ++--- > commit.c | 4 ++-- > match-trees.c | 2 +- > merge-ort.c | 7 ++++--- > notes-cache.c | 3 ++- > notes.c | 12 ++++++++---- > object-file.c | 18 +++++++++--------- > object-file.h | 26 +++----------------------- > odb.c | 10 ++++++++++ > odb.h | 38 ++++++++++++++++++++++++++++++++++++++ > read-cache.c | 2 +- > 21 files changed, 106 insertions(+), 67 deletions(-) > [snip] > diff --git a/odb.h b/odb.h > index e922f256802..c96d2c29e9f 100644 > --- a/odb.h > +++ b/odb.h > @@ -437,6 +437,44 @@ enum for_each_object_flags { > FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4), > }; > > +enum { > + /* > + * By default, `odb_write_object()` does not actually write anything > + * into the object store, but only computes the object ID. This flag > + * changes that so that the object will be written as a loose object > + * and persisted. > + */ > + WRITE_OBJECT_PERSIST = (1 << 0), > + > + /* > + * Do not print an error in case something gose wrong. While at it, shall we fix this typo?: s/gose/goes -- Cheers, Toon