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

Re: [PATCH] tag: fix sign_buffer() call to create a signed tag

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 8, 2024, 05:29 UTC
Message-ID
<xmqqv86zplr7.fsf@gitster.g>
In-Reply-To
<xmqq5xyzr6tm.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 5 quoted lines
> We could do belt and suspenders by tightening the other callers to
> only expect negative for errors (but then what should they do when
> they receive non-zero positive?  Should they BUG() out???) while
> teaching sign_buffer_ssh() that our convention is to return negative
> for an error, of course, but I am not sure if it that is worth it.

Actually, we could loosen the caller(s) while tightening the callee(s), which is the more usual approach we would take in a situation like this. Here is what I am tempted to pile on top of the patch.

----- >8 --------- >8 --------- >8 --------- >8 --------- >8 -----
Subject: [PATCH] ssh signing: signal an error with a negative return value

The other backend for the sign_buffer() function followed our usual "an error is signalled with a negative return" convention, but the SSH signer did not. Even though we already fixed the caller that assumed only a negative return value is an error, tighten the callee to signal an error with a negative return as well. This way, the callees will be strict on what they produce, while the callers will be lenient in what they accept.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 gpg-interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gpg-interface.c b/gpg-interface.c
index 48f43c5a21..e19a69c400 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -1088,7 +1088,7 @@ static int sign_buffer_ssh(struct strbuf *buffer, struct strbuf *signature,
 		if (strstr(signer_stderr.buf, "usage:"))
 			error(_("ssh-keygen -Y sign is needed for ssh signing (available in openssh version 8.2p1+)"));
 
-		error("%s", signer_stderr.buf);
+		ret = error("%s", signer_stderr.buf);
 		goto out;
 	}
 
-- 
2.43.0-561-g235986be82
Previous: Junio C HamanoNext: Jeff King
Message 4 of 6 in “tag: fix sign_buffer() call to create a signed tag”
  1. tag: fix sign_buffer() call to create a signed tagJunio C Hamano, Feb 7, 2024
  2. Jeff KingFeb 8, 2024
  3. Junio C HamanoFeb 8, 2024
  4. Junio C HamanoFeb 8, 2024
  5. Jeff KingFeb 8, 2024
  6. Jeff KingFeb 8, 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.