| 191 | } |
| 192 | |
| 193 | static void prepare_note_data(const struct object_id *object, struct note_data *d, |
| 194 | const struct object_id *old_note) |
| 195 | { |
| 196 | if (d->use_editor || !d->msg_nr) { |
| 197 | int fd; |
| 198 | struct strbuf buf = STRBUF_INIT; |
| 199 | |
| 200 | /* write the template message before editing: */ |
| 201 | d->edit_path = repo_git_path(the_repository, "NOTES_EDITMSG"); |
| 202 | fd = xopen(d->edit_path, O_CREAT | O_TRUNC | O_WRONLY, 0600); |
| 203 | |
| 204 | if (d->msg_nr) |
| 205 | write_or_die(fd, d->buf.buf, d->buf.len); |
| 206 | else if (old_note) |
| 207 | copy_obj_to_fd(fd, old_note); |
| 208 | |
| 209 | strbuf_addch(&buf, '\n'); |
| 210 | strbuf_add_commented_lines(&buf, "\n", strlen("\n"), comment_line_str); |
| 211 | strbuf_add_commented_lines(&buf, _(note_template), strlen(_(note_template)), |
| 212 | comment_line_str); |
| 213 | strbuf_add_commented_lines(&buf, "\n", strlen("\n"), comment_line_str); |
| 214 | write_or_die(fd, buf.buf, buf.len); |
| 215 | |
| 216 | write_commented_object(fd, object); |
| 217 | |
| 218 | close(fd); |
| 219 | strbuf_release(&buf); |
| 220 | strbuf_reset(&d->buf); |
| 221 | |
| 222 | if (launch_editor(d->edit_path, &d->buf, NULL)) { |
| 223 | die(_("please supply the note contents using either -m or -F option")); |
| 224 | } |
| 225 | if (d->stripspace) |
| 226 | strbuf_stripspace(&d->buf, comment_line_str); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | static void write_note_data(struct note_data *d, struct object_id *oid) |
| 231 | { |
no test coverage detected