summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-02 22:58:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-02 22:58:32 (GMT)
commit2d23c64ba2e91029f4ce932117a1772378d63cf3 (patch)
tree3ed1df7f43cbb310aab98f6f57e61011fe1c11c0 /builtin
parentc67e367c50304c5a0701ae2bb8ecb7291f481ffd (diff)
parent84a7e35eea97388ba5ca458808119650818c2fd2 (diff)
downloadgit-2d23c64ba2e91029f4ce932117a1772378d63cf3.zip
git-2d23c64ba2e91029f4ce932117a1772378d63cf3.tar.gz
git-2d23c64ba2e91029f4ce932117a1772378d63cf3.tar.bz2
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
Diffstat (limited to 'builtin')
-rw-r--r--builtin/notes.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/builtin/notes.c b/builtin/notes.c
index d6dcfcb..8685d2b 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -529,6 +529,8 @@ static int list(int argc, const char **argv, const char *prefix)
return retval;
}
+static int append_edit(int argc, const char **argv, const char *prefix);
+
static int add(int argc, const char **argv, const char *prefix)
{
int retval = 0, force = 0;
@@ -556,14 +558,14 @@ static int add(int argc, const char **argv, const char *prefix)
};
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"));
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);
@@ -573,6 +575,18 @@ static int add(int argc, const char **argv, const char *prefix)
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 "
"for object %s. Use '-f' to overwrite "
"existing notes"), sha1_to_hex(object));