commit: add repository argument to lookup_commit_reference
[gitweb.git] / builtin / notes.c
index e5bf80eef1d4113ac9c5361f200bb7b162de18a6..c05cd004abcbdcd1e4c3d140f3cf4251c416df36 100644 (file)
@@ -11,6 +11,8 @@
 #include "config.h"
 #include "builtin.h"
 #include "notes.h"
+#include "object-store.h"
+#include "repository.h"
 #include "blob.h"
 #include "pretty.h"
 #include "refs.h"
@@ -461,7 +463,7 @@ static int add(int argc, const char **argv, const char *prefix)
        if (d.buf.len || allow_empty) {
                write_note_data(&d, &new_note);
                if (add_note(t, &object, &new_note, combine_notes_overwrite))
-                       die("BUG: combine_notes_overwrite failed");
+                       BUG("combine_notes_overwrite failed");
                commit_notes(t, "Notes added by 'git notes add'");
        } else {
                fprintf(stderr, _("Removing note for object %s\n"),
@@ -544,7 +546,7 @@ static int copy(int argc, const char **argv, const char *prefix)
        }
 
        if (add_note(t, &object, from_note, combine_notes_overwrite))
-               die("BUG: combine_notes_overwrite failed");
+               BUG("combine_notes_overwrite failed");
        commit_notes(t, "Notes added by 'git notes copy'");
 out:
        free_notes(t);
@@ -621,7 +623,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)
        if (d.buf.len || allow_empty) {
                write_note_data(&d, &new_note);
                if (add_note(t, &object, &new_note, combine_notes_overwrite))
-                       die("BUG: combine_notes_overwrite failed");
+                       BUG("combine_notes_overwrite failed");
                logmsg = xstrfmt("Notes added by 'git notes %s'", argv[0]);
        } else {
                fprintf(stderr, _("Removing note for object %s\n"),
@@ -710,7 +712,7 @@ static int merge_commit(struct notes_merge_options *o)
 
        if (get_oid("NOTES_MERGE_PARTIAL", &oid))
                die(_("failed to read ref NOTES_MERGE_PARTIAL"));
-       else if (!(partial = lookup_commit_reference(&oid)))
+       else if (!(partial = lookup_commit_reference(the_repository, &oid)))
                die(_("could not find commit from NOTES_MERGE_PARTIAL."));
        else if (parse_commit(partial))
                die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
@@ -778,13 +780,13 @@ static int merge(int argc, const char **argv, const char *prefix)
                           N_("resolve notes conflicts using the given strategy "
                              "(manual/ours/theirs/union/cat_sort_uniq)")),
                OPT_GROUP(N_("Committing unmerged notes")),
-               { OPTION_SET_INT, 0, "commit", &do_commit, NULL,
-                       N_("finalize notes merge by committing unmerged notes"),
-                       PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1},
+               OPT_SET_INT_F(0, "commit", &do_commit,
+                             N_("finalize notes merge by committing unmerged notes"),
+                             1, PARSE_OPT_NONEG),
                OPT_GROUP(N_("Aborting notes merge resolution")),
-               { OPTION_SET_INT, 0, "abort", &do_abort, NULL,
-                       N_("abort notes merge"),
-                       PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1},
+               OPT_SET_INT_F(0, "abort", &do_abort,
+                             N_("abort notes merge"),
+                             1, PARSE_OPT_NONEG),
                OPT_END()
        };
 
@@ -831,7 +833,7 @@ static int merge(int argc, const char **argv, const char *prefix)
                const char *short_ref = NULL;
 
                if (!skip_prefix(o.local_ref, "refs/notes/", &short_ref))
-                       die("BUG: local ref %s is outside of refs/notes/",
+                       BUG("local ref %s is outside of refs/notes/",
                            o.local_ref);
 
                strbuf_addf(&merge_key, "notes.%s.mergeStrategy", short_ref);