summaryrefslogtreecommitdiff
path: root/notes.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-07-17 06:56:35 +0200
committerJunio C Hamano <gitster@pobox.com>2025-07-16 22:16:15 -0700
commitab1c6e1d12e869cbca3ea7f8a4e767e45fd14c49 (patch)
tree32a6815af9b9ec50578da260882e52ab9de8182f /notes.c
parent0f9b18935745fcdebcad613a6e3e52db5b29b1d4 (diff)
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>
Diffstat (limited to 'notes.c')
-rw-r--r--notes.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/notes.c b/notes.c
index 97b995f3f2..7596c0df9a 100644
--- a/notes.c
+++ b/notes.c
@@ -682,7 +682,8 @@ static int tree_write_stack_finish_subtree(struct tree_write_stack *tws)
ret = tree_write_stack_finish_subtree(n);
if (ret)
return ret;
- ret = write_object_file(n->buf.buf, n->buf.len, OBJ_TREE, &s);
+ ret = odb_write_object(the_repository->objects, n->buf.buf,
+ n->buf.len, OBJ_TREE, &s);
if (ret)
return ret;
strbuf_release(&n->buf);
@@ -847,7 +848,8 @@ int combine_notes_concatenate(struct object_id *cur_oid,
free(new_msg);
/* create a new blob object from buf */
- ret = write_object_file(buf, buf_len, OBJ_BLOB, cur_oid);
+ ret = odb_write_object(the_repository->objects, buf,
+ buf_len, OBJ_BLOB, cur_oid);
free(buf);
return ret;
}
@@ -927,7 +929,8 @@ int combine_notes_cat_sort_uniq(struct object_id *cur_oid,
string_list_join_lines_helper, &buf))
goto out;
- ret = write_object_file(buf.buf, buf.len, OBJ_BLOB, cur_oid);
+ ret = odb_write_object(the_repository->objects, buf.buf,
+ buf.len, OBJ_BLOB, cur_oid);
out:
strbuf_release(&buf);
@@ -1215,7 +1218,8 @@ int write_notes_tree(struct notes_tree *t, struct object_id *result)
ret = for_each_note(t, flags, write_each_note, &cb_data) ||
write_each_non_note_until(NULL, &cb_data) ||
tree_write_stack_finish_subtree(&root) ||
- write_object_file(root.buf.buf, root.buf.len, OBJ_TREE, result);
+ odb_write_object(the_repository->objects, root.buf.buf,
+ root.buf.len, OBJ_TREE, result);
strbuf_release(&root.buf);
return ret;
}