git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Doan Tran Cong Danh <congdanhqx@gmail.com>
To: git@vger.kernel.org
Cc: Doan Tran Cong Danh <congdanhqx@gmail.com>
Subject: [PATCH 1/1] notes: copy notes to HEAD by default
Date: Tue, 15 Oct 2019 23:36:31 +0700	[thread overview]
Message-ID: <20191015163631.21808-2-congdanhqx@gmail.com> (raw)
In-Reply-To: <20191015163631.21808-1-congdanhqx@gmail.com>

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@gmail.com>
---
 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


  reply	other threads:[~2019-10-15 16:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15 16:36 [PATCH 0/1] Allow default value for target of git-notes copy Doan Tran Cong Danh
2019-10-15 16:36 ` Doan Tran Cong Danh [this message]
2019-10-16  2:01   ` [PATCH 1/1] notes: copy notes to HEAD by default Junio C Hamano
2019-10-16  5:17     ` Danh Doan
2019-10-16  5:18 ` [PATCH 1/2] t3301: test diagnose messages for too few/many paramters Doan Tran Cong Danh
2019-10-16  5:18   ` [PATCH 2/2] notes: fix minimum number of parameters to "copy" subcommand Doan Tran Cong Danh
2019-10-18  0:44     ` Junio C Hamano
2019-10-18  0:38   ` [PATCH 1/2] t3301: test diagnose messages for too few/many paramters Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191015163631.21808-2-congdanhqx@gmail.com \
    --to=congdanhqx@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).