git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/1] Allow default value for target of git-notes copy

From
Doan Tran Cong Danh <congdanhqx@gmail.com>
Date
Oct 15, 2019, 16:36 UTC
Message-ID
<20191015163631.21808-1-congdanhqx@gmail.com>

As an alternate for the incoming patch, this snippet could be used to eliminate some dead code in builtin/notes.c Since `argc' will always be 2 in the removed condition.

Also:
Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>
---
 builtin/notes.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/builtin/notes.c b/builtin/notes.c
index 02e97f55c5..641ae66f75 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -488,7 +488,6 @@ static int copy(int argc, const char **argv, const char *prefix)
 {
 	int retval = 0, force = 0, from_stdin = 0;
 	const struct object_id *from_note, *note;
-	const char *object_ref;
 	struct object_id object, from_obj;
 	struct notes_tree *t;
 	const char *rewrite_cmd = NULL;
@@ -525,10 +524,8 @@ static int copy(int argc, const char **argv, const char *prefix)
 	if (get_oid(argv[0], &from_obj))
 		die(_("failed to resolve '%s' as a valid ref."), argv[0]);
 
-	object_ref = 1 < argc ? argv[1] : "HEAD";
-
-	if (get_oid(object_ref, &object))
-		die(_("failed to resolve '%s' as a valid ref."), object_ref);
+	if (get_oid(argv[1], &object))
+		die(_("failed to resolve '%s' as a valid ref."), argv[1]);
 
 	t = init_notes_check("copy", NOTES_INIT_WRITABLE);
 	note = get_note(t, &object);
-- 
2.23.0
Next: Doan Tran Cong Danh
Message 1 of 8 in “Allow default value for target of git-notes copy”
  1. 0/1 Allow default value for target of git-notes copyDoan Tran Cong Danh, Oct 15, 2019
  2. 1/1 notes: copy notes to HEAD by defaultDoan Tran Cong Danh, Oct 15, 2019
  3. Junio C HamanoOct 16, 2019
  4. Danh DoanOct 16, 2019
  5. 1/2 t3301: test diagnose messages for too few/many paramtersDoan Tran Cong Danh, Oct 16, 2019
  6. 2/2 notes: fix minimum number of parameters to "copy" subcommandDoan Tran Cong Danh, Oct 16, 2019
  7. Junio C HamanoOct 18, 2019
  8. Junio C HamanoOct 18, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.