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

[PATCH] gpg-interface: reflect stderr to stderr

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Sep 6, 2016, 13:13 UTC
Message-ID
<18a7e2984121d988137c135ec560fee56506981b.1473167263.git.git@drmicha.warpmail.net>
In-Reply-To
<ced7502d-0095-bd90-19e3-c14d0e4d4f07@drmicha.warpmail.net>

efee955 ("gpg-interface: check gpg signature creation status", 2016-06-17) used stderr to capture gpg's status output, which is the only reliable way for status checks. As a side effect, stderr was not shown to the user any more.

In case of a gpg error, reflect the whole captured buffer to stderr.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
A full blown approach would use --status-fd=4 or such rather than hijacking stderr.
This would require an extension of pipe_command() etc. to handle yet another fd.
 gpg-interface.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/gpg-interface.c b/gpg-interface.c
index 8672eda..cf35bca 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -173,9 +173,12 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
 	sigchain_pop(SIGPIPE);
 
 	ret |= !strstr(gpg_status.buf, "\n[GNUPG:] SIG_CREATED ");
-	strbuf_release(&gpg_status);
-	if (ret)
+	if (ret) {
+		fputs(gpg_status.buf, stderr);
+		strbuf_release(&gpg_status);
 		return error(_("gpg failed to sign the data"));
+	}
+	strbuf_release(&gpg_status);
 
 	/* Strip CR from the line endings, in case we are on Windows. */
 	for (i = j = bottom; i < signature->len; i++)
-- 
2.10.0.rc2.333.g8ef2d05
Previous: Michael J GruberNext: Johannes Schindelin
Message 3 of 16 in “Unbreak interactive GPG prompt upon signing”
  1. Unbreak interactive GPG prompt upon signingJohannes Schindelin, Sep 6, 2016
  2. Michael J GruberSep 6, 2016
  3. gpg-interface: reflect stderr to stderrMichael J Gruber, Sep 6, 2016
  4. Johannes SchindelinSep 6, 2016
  5. Johannes SchindelinSep 6, 2016
  6. Johannes SchindelinSep 6, 2016
  7. Michael J GruberSep 7, 2016
  8. Jeff KingSep 7, 2016
  9. Michael J GruberSep 7, 2016
  10. Junio C HamanoSep 8, 2016
  11. Jeff KingSep 8, 2016
  12. Junio C HamanoSep 8, 2016
  13. Michael J GruberSep 12, 2016
  14. Johannes SchindelinOct 2, 2018
  15. Johannes SchindelinSep 9, 2016
  16. Johannes SchindelinSep 6, 2016

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.