From: Junio C Hamano Date: Fri, 14 Mar 2014 21:25:39 +0000 (-0700) Subject: Merge branch 'jh/note-trees-record-blobs' X-Git-Tag: v2.0.0-rc0~122 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b37f81b7b676fe7ede3fa171535593337a8911c8?ds=inline;hp=-c Merge branch 'jh/note-trees-record-blobs' "git notes -C " should not take an object that is not a blob. * jh/note-trees-record-blobs: notes: disallow reusing non-blob as a note object --- b37f81b7b676fe7ede3fa171535593337a8911c8 diff --combined builtin/notes.c index 2b24d059b5,c11d6e6dc8..bb89930373 --- a/builtin/notes.c +++ b/builtin/notes.c @@@ -269,7 -269,11 +269,11 @@@ static int parse_reuse_arg(const struc die(_("Failed to resolve '%s' as a valid ref."), arg); if (!(buf = read_sha1_file(object, &type, &len)) || !len) { free(buf); - die(_("Failed to read object '%s'."), arg);; + die(_("Failed to read object '%s'."), arg); + } + if (type != OBJ_BLOB) { + free(buf); + die(_("Cannot read note data from non-blob object '%s'."), arg); } strbuf_add(&(msg->buf), buf, len); free(buf); @@@ -347,7 -351,7 +351,7 @@@ static struct notes_tree *init_notes_ch init_notes(NULL, NULL, NULL, 0); t = &default_notes_tree; - if (prefixcmp(t->ref, "refs/notes/")) + if (!starts_with(t->ref, "refs/notes/")) die("Refusing to %s notes in %s (outside of refs/notes/)", subcommand, t->ref); return t; @@@ -483,7 -487,7 +487,7 @@@ static int copy(int argc, const char ** const char *rewrite_cmd = NULL; struct option options[] = { OPT__FORCE(&force, N_("replace existing notes")), - OPT_BOOLEAN(0, "stdin", &from_stdin, N_("read objects from stdin")), + OPT_BOOL(0, "stdin", &from_stdin, N_("read objects from stdin")), OPT_STRING(0, "for-rewrite", &rewrite_cmd, N_("command"), N_("load rewriting config for (implies " "--stdin)")), @@@ -739,13 -743,13 +743,13 @@@ static int merge(int argc, const char * N_("resolve notes conflicts using the given strategy " "(manual/ours/theirs/union/cat_sort_uniq)")), OPT_GROUP(N_("Committing unmerged notes")), - { OPTION_BOOLEAN, 0, "commit", &do_commit, NULL, + { OPTION_SET_INT, 0, "commit", &do_commit, NULL, N_("finalize notes merge by committing unmerged notes"), - PARSE_OPT_NOARG | PARSE_OPT_NONEG }, + PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1}, OPT_GROUP(N_("Aborting notes merge resolution")), - { OPTION_BOOLEAN, 0, "abort", &do_abort, NULL, + { OPTION_SET_INT, 0, "abort", &do_abort, NULL, N_("abort notes merge"), - PARSE_OPT_NOARG | PARSE_OPT_NONEG }, + PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1}, OPT_END() }; @@@ -853,7 -857,7 +857,7 @@@ static int remove_cmd(int argc, const c OPT_BIT(0, "ignore-missing", &flag, N_("attempt to remove non-existent note is not an error"), IGNORE_MISSING), - OPT_BOOLEAN(0, "stdin", &from_stdin, + OPT_BOOL(0, "stdin", &from_stdin, N_("read object names from the standard input")), OPT_END() };