MCPcopy Index your code
hub / github.com/git/git / prepare_note_data

Function prepare_note_data

builtin/notes.c:193–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193static 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
230static void write_note_data(struct note_data *d, struct object_id *oid)
231{

Callers 2

addFunction · 0.85
append_editFunction · 0.85

Calls 11

repo_git_pathFunction · 0.85
xopenFunction · 0.85
write_or_dieFunction · 0.85
copy_obj_to_fdFunction · 0.85
strbuf_addchFunction · 0.85
write_commented_objectFunction · 0.85
strbuf_releaseFunction · 0.85
launch_editorFunction · 0.85
strbuf_stripspaceFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected