The target objects for copying notes was defaulted to HEAD from very early stage of git-notes. However, that default was limited by commit bbb1b8a35a, ("notes: check number of parameters to "git notes copy"", 2010-06-28). Lift that limitation by adjust the check for numbers of arguments. Signed-off-by: Doan Tran Cong Danh <congdanhqx@xxxxxxxxx> --- Documentation/git-notes.txt | 6 +++--- builtin/notes.c | 2 +- t/t3301-notes.sh | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Documentation/git-notes.txt b/Documentation/git-notes.txt index f56a5a9197..ced2e8280e 100644 --- a/Documentation/git-notes.txt +++ b/Documentation/git-notes.txt @@ -10,7 +10,7 @@ SYNOPSIS [verse] 'git notes' [list [<object>]] 'git notes' add [-f] [--allow-empty] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>] -'git notes' copy [-f] ( --stdin | <from-object> <to-object> ) +'git notes' copy [-f] ( --stdin | <from-object> [<to-object>] ) 'git notes' append [--allow-empty] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>] 'git notes' edit [--allow-empty] [<object>] 'git notes' show [<object>] @@ -68,8 +68,8 @@ add:: subcommand). copy:: - Copy the notes for the first object onto the second object. - Abort if the second object already has notes, or if the first + Copy the notes for the first object onto the second object (defaults to + HEAD). Abort if the second object already has notes, or if the first object has none (use -f to overwrite existing notes to the second object). This subcommand is equivalent to: `git notes add [-f] -C $(git notes list <from-object>) <to-object>` diff --git a/builtin/notes.c b/builtin/notes.c index 02e97f55c5..95456f3165 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -513,7 +513,7 @@ static int copy(int argc, const char **argv, const char *prefix) } } - if (argc < 2) { + if (argc < 1) { error(_("too few parameters")); usage_with_options(git_notes_copy_usage, options); } diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh index d3fa298c6a..a8f9a0f36c 100755 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh @@ -908,6 +908,10 @@ test_expect_success 'allow overwrite with "git notes copy -f"' ' git notes copy -f HEAD~2 HEAD && git log -1 >actual && test_cmp expect actual && + test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" && + git notes copy -f HEAD~2 && + git log -1 >actual && + test_cmp expect actual && test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" ' -- 2.23.0