*/
#include "cache.h"
+#include "config.h"
#include "builtin.h"
#include "notes.h"
#include "blob.h"
if (rewrite_cmd)
err = copy_note_for_rewrite(c, &from_obj, &to_obj);
else
- err = copy_note(t, from_obj.hash, to_obj.hash, force,
+ err = copy_note(t, &from_obj, &to_obj, force,
combine_notes_overwrite);
if (err) {
} else {
finish_copy_notes_for_rewrite(c, msg);
}
+ strbuf_release(&buf);
return ret;
}
ref = (flags & NOTES_INIT_WRITABLE) ? t->update_ref : t->ref;
if (!starts_with(ref, "refs/notes/"))
- /* TRANSLATORS: the first %s will be replaced by a
- git notes command: 'add', 'merge', 'remove', etc.*/
+ /*
+ * TRANSLATORS: the first %s will be replaced by a git
+ * notes command: 'add', 'merge', 'remove', etc.
+ */
die(_("refusing to %s notes in %s (outside of refs/notes/)"),
subcommand, ref);
return t;
if (argc) {
if (get_oid(argv[0], &object))
die(_("failed to resolve '%s' as a valid ref."), argv[0]);
- note = get_note(t, object.hash);
+ note = get_note(t, &object);
if (note) {
puts(oid_to_hex(note));
retval = 0;
die(_("failed to resolve '%s' as a valid ref."), object_ref);
t = init_notes_check("add", NOTES_INIT_WRITABLE);
- note = get_note(t, object.hash);
+ note = get_note(t, &object);
if (note) {
if (!force) {
oid_to_hex(&object));
}
- prepare_note_data(&object, &d, note->hash);
+ prepare_note_data(&object, &d, note ? note->hash : NULL);
if (d.buf.len || allow_empty) {
write_note_data(&d, new_note.hash);
- if (add_note(t, object.hash, new_note.hash, combine_notes_overwrite))
+ if (add_note(t, &object, &new_note, combine_notes_overwrite))
die("BUG: combine_notes_overwrite failed");
commit_notes(t, "Notes added by 'git notes add'");
} else {
die(_("failed to resolve '%s' as a valid ref."), object_ref);
t = init_notes_check("copy", NOTES_INIT_WRITABLE);
- note = get_note(t, object.hash);
+ note = get_note(t, &object);
if (note) {
if (!force) {
oid_to_hex(&object));
}
- from_note = get_note(t, from_obj.hash);
+ from_note = get_note(t, &from_obj);
if (!from_note) {
retval = error(_("missing notes on source object %s. Cannot "
"copy."), oid_to_hex(&from_obj));
goto out;
}
- if (add_note(t, object.hash, from_note->hash, combine_notes_overwrite))
+ if (add_note(t, &object, from_note, combine_notes_overwrite))
die("BUG: combine_notes_overwrite failed");
commit_notes(t, "Notes added by 'git notes copy'");
out:
die(_("failed to resolve '%s' as a valid ref."), object_ref);
t = init_notes_check(argv[0], NOTES_INIT_WRITABLE);
- note = get_note(t, object.hash);
+ note = get_note(t, &object);
prepare_note_data(&object, &d, edit && note ? note->hash : NULL);
if (d.buf.len || allow_empty) {
write_note_data(&d, new_note.hash);
- if (add_note(t, object.hash, new_note.hash, combine_notes_overwrite))
+ if (add_note(t, &object, &new_note, combine_notes_overwrite))
die("BUG: combine_notes_overwrite failed");
logmsg = xstrfmt("Notes added by 'git notes %s'", argv[0]);
} else {
die(_("failed to resolve '%s' as a valid ref."), object_ref);
t = init_notes_check("show", 0);
- note = get_note(t, object.hash);
+ note = get_note(t, &object);
if (!note)
retval = error(_("no note found for object %s."),
if (!o->local_ref)
die(_("failed to resolve NOTES_MERGE_REF"));
- if (notes_merge_commit(o, t, partial, oid.hash))
+ if (notes_merge_commit(o, t, partial, &oid))
die(_("failed to finalize notes merge"));
/* Reuse existing commit message in reflog message */
remote_ref.buf, default_notes_ref());
strbuf_add(&(o.commit_msg), msg.buf + 7, msg.len - 7); /* skip "notes: " */
- result = notes_merge(&o, t, result_oid.hash);
+ result = notes_merge(&o, t, &result_oid);
- if (result >= 0) /* Merge resulted (trivially) in result_sha1 */
+ if (result >= 0) /* Merge resulted (trivially) in result_oid */
/* Update default notes ref with new commit */
update_ref(msg.buf, default_notes_ref(), result_oid.hash, NULL,
0, UPDATE_REFS_DIE_ON_ERR);
if (create_symref("NOTES_MERGE_REF", default_notes_ref(), NULL))
die(_("failed to store link to current notes ref (%s)"),
default_notes_ref());
- printf(_("Automatic notes merge failed. Fix conflicts in %s and "
- "commit the result with 'git notes merge --commit', or "
- "abort the merge with 'git notes merge --abort'.\n"),
- git_path(NOTES_MERGE_WORKTREE));
+ fprintf(stderr, _("Automatic notes merge failed. Fix conflicts in %s "
+ "and commit the result with 'git notes merge --commit', "
+ "or abort the merge with 'git notes merge --abort'.\n"),
+ git_path(NOTES_MERGE_WORKTREE));
}
free_notes(t);