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

Re: [PATCH] notes: Disallow reusing non-blob as a note object

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 14, 2014, 16:19 UTC
Message-ID
<xmqq7g8xk6ov.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAPig+cSQ12Ga4kEnNrspzru2F3p0jWb2i=1GRX84k0am5AA6Bw@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 8 quoted lines
>> +       if (type != OBJ_BLOB) {
>> +               free(buf);
>> +               die(_("Cannot read note data from non-blob object '%s'."), arg);
>
> The way this diagnostic is worded, it sound as if the 'read' failed
> rather than that the user specified an incorrect object type. Perhaps
> "Object is not a blob '%s'" or "Expected blob but '%s' has type '%s'"
> or something along those lines?

Yeah, sounds good. You also need to say what expects a blob, too. Perhaps something like this?

 builtin/notes.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/notes.c b/builtin/notes.c
index c11d6e6..a16bc00 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -272,8 +272,10 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
 		die(_("Failed to read object '%s'."), arg);
 	}
 	if (type != OBJ_BLOB) {
+		struct msg_arg *msg = opt->value;
 		free(buf);
-		die(_("Cannot read note data from non-blob object '%s'."), arg);
+		die(_("The -%c option takes a blob, which '%s' is not.",
+		      msg->use_editor ? 'c' : 'C', arg));
 	}
 	strbuf_add(&(msg->buf), buf, len);
 	free(buf);
Previous: Eric SunshineNext: Joachim Breitner
Message 8 of 11 in “git-note -C changes commit type?”
  1. Joachim BreitnerFeb 11, 2014
  2. Johan HerlandFeb 11, 2014
  3. Junio C HamanoFeb 12, 2014
  4. Kyle J. McKayFeb 12, 2014
  5. Johan HerlandFeb 12, 2014
  6. notes: Disallow reusing non-blob as a note objectJohan Herland, Feb 12, 2014
  7. Eric SunshineFeb 14, 2014
  8. Junio C HamanoFeb 14, 2014
  9. Joachim BreitnerFeb 12, 2014
  10. Johan HerlandFeb 12, 2014
  11. Joachim BreitnerFeb 12, 2014

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.