int given_object = 0, i = 1, retval = 0;
struct msg_arg msg = { 0, 0, STRBUF_INIT };
const char *rewrite_cmd = NULL;
+ const char *override_notes_ref = NULL;
struct option options[] = {
OPT_GROUP("Notes options"),
OPT_CALLBACK('m', "message", &msg, "MSG",
"reuse specified note object", parse_reuse_arg),
OPT_BOOLEAN('f', "force", &force, "replace existing notes"),
OPT_BOOLEAN(0, "stdin", &from_stdin, "read objects from stdin"),
+ OPT_STRING(0, "ref", &override_notes_ref, "notes_ref",
+ "use notes from <notes_ref>"),
OPT_STRING(0, "for-rewrite", &rewrite_cmd, "command",
"load rewriting config for <command> (implies --stdin)"),
OPT_END()
argc = parse_options(argc, argv, prefix, options, git_notes_usage, 0);
+ if (override_notes_ref) {
+ struct strbuf sb = STRBUF_INIT;
+ if (!prefixcmp(override_notes_ref, "refs/notes/"))
+ /* we're happy */;
+ else if (!prefixcmp(override_notes_ref, "notes/"))
+ strbuf_addstr(&sb, "refs/");
+ else
+ strbuf_addstr(&sb, "refs/notes/");
+ strbuf_addstr(&sb, override_notes_ref);
+ setenv("GIT_NOTES_REF", sb.buf, 1);
+ strbuf_release(&sb);
+ }
+
if (argc && !strcmp(argv[0], "list"))
list = 1;
else if (argc && !strcmp(argv[0], "add"))