builtin-notes: Deprecate the -m/-F options for "git notes edit"

The semantics for "git notes edit -m/-F" overlap with those for
"git notes add -f", and the behaviour (i.e. overwriting existing
notes with the given message/file) is more intuitively captured
by (and better documented with) "git notes add -f".

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Johan Herland 2010-02-13 22:28:34 +01:00 committed by Junio C Hamano
parent 2347fae50b
commit aaec9bcf6d
5 changed files with 14 additions and 8 deletions

View File

@ -11,7 +11,7 @@ SYNOPSIS
'git notes' [list [<object>]] 'git notes' [list [<object>]]
'git notes' add [-f] [-F <file> | -m <msg>] [<object>] 'git notes' add [-f] [-F <file> | -m <msg>] [<object>]
'git notes' append [-F <file> | -m <msg>] [<object>] 'git notes' append [-F <file> | -m <msg>] [<object>]
'git notes' edit [-F <file> | -m <msg>] [<object>] 'git notes' edit [<object>]
'git notes' show [<object>] 'git notes' show [<object>]
'git notes' remove [<object>] 'git notes' remove [<object>]
'git notes' prune 'git notes' prune

View File

@ -21,7 +21,7 @@ static const char * const git_notes_usage[] = {
"git notes [list [<object>]]", "git notes [list [<object>]]",
"git notes add [-f] [-m <msg> | -F <file>] [<object>]", "git notes add [-f] [-m <msg> | -F <file>] [<object>]",
"git notes append [-m <msg> | -F <file>] [<object>]", "git notes append [-m <msg> | -F <file>] [<object>]",
"git notes edit [-m <msg> | -F <file>] [<object>]", "git notes edit [<object>]",
"git notes show [<object>]", "git notes show [<object>]",
"git notes remove [<object>]", "git notes remove [<object>]",
"git notes prune", "git notes prune",
@ -233,7 +233,7 @@ int cmd_notes(int argc, const char **argv, const char *prefix)
const char *msgfile = NULL; const char *msgfile = NULL;
struct msg_arg msg = { 0, STRBUF_INIT }; struct msg_arg msg = { 0, STRBUF_INIT };
struct option options[] = { struct option options[] = {
OPT_GROUP("Notes edit options"), OPT_GROUP("Notes options"),
OPT_CALLBACK('m', "message", &msg, "msg", OPT_CALLBACK('m', "message", &msg, "msg",
"note contents as a string", parse_msg_arg), "note contents as a string", parse_msg_arg),
OPT_FILENAME('F', "file", &msgfile, "note contents in a file"), OPT_FILENAME('F', "file", &msgfile, "note contents in a file"),
@ -270,6 +270,12 @@ int cmd_notes(int argc, const char **argv, const char *prefix)
usage_with_options(git_notes_usage, options); usage_with_options(git_notes_usage, options);
} }


if ((msg.given || msgfile) && edit) {
fprintf(stderr, "The -m and -F options has been deprecated for"
" the 'edit' subcommand.\n"
"Please use 'git notes add -f -m/-F' instead.\n");
}

if (msg.given && msgfile) { if (msg.given && msgfile) {
error("mixing -m and -F options is not allowed."); error("mixing -m and -F options is not allowed.");
usage_with_options(git_notes_usage, options); usage_with_options(git_notes_usage, options);

View File

@ -188,7 +188,7 @@ test_expect_success "verify contents of non-notes" '
test_expect_success "git-notes preserves non-notes" ' test_expect_success "git-notes preserves non-notes" '


test_tick && test_tick &&
git notes edit -m "foo bar" git notes add -f -m "foo bar"
' '


test_expect_success "verify contents of non-notes after git-notes" ' test_expect_success "verify contents of non-notes after git-notes" '

View File

@ -14,7 +14,7 @@ test_expect_success 'creating many notes with git-notes' '
echo "file for commit #$i" > file && echo "file for commit #$i" > file &&
git add file && git add file &&
git commit -q -m "commit #$i" && git commit -q -m "commit #$i" &&
git notes edit -m "note #$i" || return 1 git notes add -m "note #$i" || return 1
done done
' '



View File

@ -10,17 +10,17 @@ test_expect_success 'setup: create a few commits with notes' '
git add file1 && git add file1 &&
test_tick && test_tick &&
git commit -m 1st && git commit -m 1st &&
git notes edit -m "Note #1" && git notes add -m "Note #1" &&
: > file2 && : > file2 &&
git add file2 && git add file2 &&
test_tick && test_tick &&
git commit -m 2nd && git commit -m 2nd &&
git notes edit -m "Note #2" && git notes add -m "Note #2" &&
: > file3 && : > file3 &&
git add file3 && git add file3 &&
test_tick && test_tick &&
git commit -m 3rd && git commit -m 3rd &&
git notes edit -m "Note #3" git notes add -m "Note #3"
' '


cat > expect <<END_OF_LOG cat > expect <<END_OF_LOG