- if (prev && append_only) {
- /* Append buf to previous note contents */
- unsigned long size;
- enum object_type type;
- char *prev_buf = read_sha1_file(prev, &type, &size);
-
- strbuf_grow(&d->buf, size + 1);
- if (d->buf.len && prev_buf && size)
- strbuf_insert(&d->buf, 0, "\n", 1);
- if (prev_buf && size)
- strbuf_insert(&d->buf, 0, prev_buf, size);
- free(prev_buf);
- }
-
- if (!d->buf.len) {
- fprintf(stderr, _("Removing note for object %s\n"),
- sha1_to_hex(object));
- hashclr(result);
- } else {
- if (write_sha1_file(d->buf.buf, d->buf.len, blob_type, result)) {
- error(_("unable to write note object"));
- if (d->edit_path)
- error(_("The note contents have been left in %s"),
- d->edit_path);
- exit(128);
- }
+static void write_note_data(struct note_data *d, unsigned char *sha1)
+{
+ if (write_sha1_file(d->buf.buf, d->buf.len, blob_type, sha1)) {
+ error(_("unable to write note object"));
+ if (d->edit_path)
+ error(_("The note contents have been left in %s"),
+ d->edit_path);
+ exit(128);