From: Junio C Hamano Date: Mon, 2 May 2011 22:58:32 +0000 (-0700) Subject: Merge branch 'jh/notes-add-ui' X-Git-Tag: v1.7.6-rc0~125 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2d23c64ba2e91029f4ce932117a1772378d63cf3;p=git.git Merge branch 'jh/notes-add-ui' * jh/notes-add-ui: Make "git notes add" more user-friendly when there are existing notes Conflicts: builtin/notes.c --- 2d23c64ba2e91029f4ce932117a1772378d63cf3 diff --cc builtin/notes.c index d6dcfcb01,0d133be49..8685d2bda --- a/builtin/notes.c +++ b/builtin/notes.c @@@ -556,29 -556,41 +558,41 @@@ static int add(int argc, const char **a }; argc = parse_options(argc, argv, prefix, options, git_notes_add_usage, - 0); + PARSE_OPT_KEEP_ARGV0); - if (1 < argc) { + if (2 < argc) { - error("too many parameters"); + error(_("too many parameters")); usage_with_options(git_notes_add_usage, options); } - object_ref = argc ? argv[0] : "HEAD"; + object_ref = argc > 1 ? argv[1] : "HEAD"; if (get_sha1(object_ref, object)) - die("Failed to resolve '%s' as a valid ref.", object_ref); + die(_("Failed to resolve '%s' as a valid ref."), object_ref); t = init_notes_check("add"); note = get_note(t, object); if (note) { if (!force) { + if (!msg.given) { + /* + * Redirect to "edit" subcommand. + * + * We only end up here if none of -m/-F/-c/-C + * or -f are given. The original args are + * therefore still in argv[0-1]. + */ + argv[0] = "edit"; + free_notes(t); + return append_edit(argc, argv, prefix); + } - retval = error("Cannot add notes. Found existing notes " + retval = error(_("Cannot add notes. Found existing notes " "for object %s. Use '-f' to overwrite " - "existing notes", sha1_to_hex(object)); + "existing notes"), sha1_to_hex(object)); goto out; } - fprintf(stderr, "Overwriting existing notes for object %s\n", + fprintf(stderr, _("Overwriting existing notes for object %s\n"), sha1_to_hex(object)); }