From: Maarten Bosmans <mkbosmans@xxxxxxxxx> From: Maarten Bosmans <maarten.bosmans@xxxxxxxxxx> Use functionality from streaming.c and remove the copy_obj_to_fd() function local to notes.c. Streaming the blob to stdout instead of copying through an intermediate buffer might also be more efficient, but at the size a typical note is, this is unlikely to matter a lot. Signed-off-by: Maarten Bosmans <maarten.bosmans@xxxxxxxxxx> --- builtin/notes.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/builtin/notes.c b/builtin/notes.c index 2a31da6c97..184a92d0c1 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -22,6 +22,7 @@ #include "refs.h" #include "pager.h" #include "log.h" +#include "streaming.h" #include "run-command.h" #include "parse-options.h" #include "string-list.h" @@ -149,18 +150,6 @@ static int list_each_note(const struct object_id *object_oid, return 0; } -static void copy_obj_to_fd(int fd, const struct object_id *oid) -{ - unsigned long size; - enum object_type type; - char *buf = repo_read_object_file(the_repository, oid, &type, &size); - if (buf) { - if (size) - write_or_die(fd, buf, size); - free(buf); - } -} - static void write_commented_object(int fd, const struct object_id *object) { struct child_process show = CHILD_PROCESS_INIT; @@ -205,7 +194,7 @@ static void prepare_note_data(const struct object_id *object, struct note_data * if (d->given) write_or_die(fd, d->buf.buf, d->buf.len); else if (old_note) - copy_obj_to_fd(fd, old_note); + stream_blob_to_fd(fd, old_note, NULL, 0); strbuf_addch(&buf, '\n'); strbuf_add_commented_lines(&buf, "\n", strlen("\n"), comment_line_char); -- 2.35.3