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

[PATCH 2/2] notes: revert note_data.given behavior with empty notes add

From
David Disseldorp <ddiss@suse.de>
Date
Jul 25, 2024, 14:41 UTC
Message-ID
<20240725144548.3434-3-ddiss@suse.de>
In-Reply-To
<20240725144548.3434-1-ddiss@suse.de>

Prior to 90bc19b3ae, note_data.given was set alongside an -m, -C or -F parameter for add / append. Following 90bc19b3ae, note_data.given is only set if the notes data buffer length is non-zero, which results in GIT_EDITOR invocation if e.g. a zero length blob object is provided.

Revert to pre-90bc19b3ae note_data.given behavior, to fix non-interactive callers.

Fixes: 90bc19b3ae ("notes.c: introduce '--separator=<paragraph-break>' option")
Link: https://github.com/ddiss/icyci/issues/12
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
 builtin/notes.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin/notes.c b/builtin/notes.c
index d9c356e354..3ccb3eb602 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -282,6 +282,7 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)
 	ALLOC_GROW_BY(d->messages, d->msg_nr, 1, d->msg_alloc);
 	d->messages[d->msg_nr - 1] = msg;
 	msg->stripspace = STRIPSPACE;
+	d->given = 1;
 	return 0;
 }
 
@@ -302,6 +303,7 @@ static int parse_file_arg(const struct option *opt, const char *arg, int unset)
 	ALLOC_GROW_BY(d->messages, d->msg_nr, 1, d->msg_alloc);
 	d->messages[d->msg_nr - 1] = msg;
 	msg->stripspace = STRIPSPACE;
+	d->given = 1;
 	return 0;
 }
 
@@ -335,6 +337,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
 	ALLOC_GROW_BY(d->messages, d->msg_nr, 1, d->msg_alloc);
 	d->messages[d->msg_nr - 1] = msg;
 	msg->stripspace = NO_STRIPSPACE;
+	d->given = 1;
 	return 0;
 }
 
@@ -515,7 +518,6 @@ static int add(int argc, const char **argv, const char *prefix)
 
 	if (d.msg_nr)
 		concat_messages(&d);
-	d.given = !!d.buf.len;
 
 	object_ref = argc > 1 ? argv[1] : "HEAD";
 
@@ -692,7 +694,6 @@ static int append_edit(int argc, const char **argv, const char *prefix)
 
 	if (d.msg_nr)
 		concat_messages(&d);
-	d.given = !!d.buf.len;
 
 	if (d.given && edit)
 		fprintf(stderr, _("The -m/-F/-c/-C options have been deprecated "
-- 
2.43.0
Previous: David DisseldorpNext: Junio C Hamano
Message 8 of 11 in “notes: fix editor invocation regression”
  1. 0/2 notes: fix editor invocation regressionDavid Disseldorp, Jul 25, 2024
  2. 1/2 t3301-notes: check editor isn't invoked for empty notes addDavid Disseldorp, Jul 25, 2024
  3. Kristoffer HaugsbakkJul 25, 2024
  4. David DisseldorpJul 25, 2024
  5. Junio C HamanoJul 25, 2024
  6. Junio C HamanoJul 25, 2024
  7. David DisseldorpJul 25, 2024
  8. 2/2 notes: revert note_data.given behavior with empty notes addDavid Disseldorp, Jul 25, 2024
  9. Junio C HamanoJul 25, 2024
  10. Kristoffer HaugsbakkJul 25, 2024
  11. David DisseldorpJul 25, 2024

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.