{"thread":{"id":"49996","subject":"silent_exec_failure when calling gpg","startedAt":"2018-12-10T22:32:57Z","lastAt":"2018-12-11T09:56:59Z","messageCount":4,"participants":["John Passaro","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"364984","messageId":"CAJdN7Kj5RaAsTstx_G14a_bR5Y92M3rtWAiMNPnQWgmz4JgEOg@mail.gmail.com","threadId":"49996","inReplyTo":null,"subject":"silent_exec_failure when calling gpg","fromName":"John Passaro","fromEmail":"john.a.passaro@gmail.com","sentAt":"2018-12-10T22:32:18Z","receivedAt":"2018-12-10T22:32:57Z","isPatch":false,"sender":{"key":"john.a.passaro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6754005?v=4"},"body":"I've noticed that in v2.19.1, when using git to pretty print\ninformation about the signature, if git cannot find gpg (e.g. \"git\nconfig gpg.program nogpg\"), it prints an error to stderr:\n\n$ git show -s --pretty=%G?\nfatal: cannot run nogpg: No such file or directory\nN\n\nWhen I build from master, that no longer happens:\n\n$ ../git/git show -s --pretty=%G?\nN\n\nIs this intentional behavior, i.e. something I can count on being the\ncase in future releases? Or should I treat this as a bug report? (I\nhave no opinion on whether this should be a feature or a bug, but I'm\nworking on a patch whose implementation may look very different based\non the answer to this question.)\n\nI've dug around the code and come up with the notion that setting\nchild_process.silent_exec_failure = 1 is the usual way of suppressing\nthis message. But \"git log -S silent_exec_failure v2.19.1..master\"\nshows no changes that could have caused this, nor can I find any\nmention of it in release notes. It occurs for just about any\ninteraction with GPG that I can find, whether signing tags or commits,\nor verifying signatures through pretty-print or git verify-commit or\ngit merge --log or git merge --verify-signatures. In all these cases,\nv2.19.1 issues \"fatal: cannot run nogpg: No such file or directory\" to\nstderr, while a binary built from master behaves the same in all\nrespects (including other errors when trying to sign) except that it's\nmissing the \"fatal:\" message.\n\nThis behavior makes sense in a lot of ways. If you're interested in\nverifying commit signatures, it's hard to imagine needing a reminder\nto install the program it depends on (though the error might help you\nidentify bad configuration for \"gpg.program\"). Conversely, if you're\nnot familiar with crypto software and try git log --format=%G? or git\nverify-commit for fun, \"Fatal: cannot run gpg\" may look like a bug. So\nI can definitely imagine justifications for this. Nonetheless, the\nfact that I can't find documentation for the change smells funny.\n\nI'd be very grateful if somebody on this list could tell me whether I\ncan count on this behavior in the future, or whether my code should\naccount for a possibility that this behavior could change in the future.\nI'd also be very very interested to see in what commit(s) this change\noccurred.\n\nThanks in advance!\n\nJohn Passaro\n(917) 678-8293\n"},{"id":"365022","messageId":"xmqqlg4wlocc.fsf@gitster-ct.c.googlers.com","threadId":"49996","inReplyTo":"CAJdN7Kj5RaAsTstx_G14a_bR5Y92M3rtWAiMNPnQWgmz4JgEOg@mail.gmail.com","subject":"Re: silent_exec_failure when calling gpg","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-12-11T03:44:03Z","receivedAt":"2018-12-11T03:44:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"John Passaro <john.a.passaro@gmail.com> writes:\n\n> I've noticed that in v2.19.1, when using git to pretty print\n> information about the signature, if git cannot find gpg (e.g. \"git\n> config gpg.program nogpg\"), it prints an error to stderr:\n>\n> $ git show -s --pretty=%G?\n> fatal: cannot run nogpg: No such file or directory\n> N\n>\n> When I build from master, that no longer happens:\n>\n> $ ../git/git show -s --pretty=%G?\n> N\n>\n> Is this intentional behavior, i.e. something I can count on being the\n> case in future releases? Or should I treat this as a bug report?\n\nIn general, behaviour of Porcelain commands like \"git show\" can and\nwill be changed to match interactive use by humans, and should never\nbe relied on in your scripts.\n\nHaving said that, I think we did not mean to kill the diagnositic\nmessage.\n\n> This behavior makes sense in a lot of ways. If you're interested in\n> verifying commit signatures, it's hard to imagine needing a reminder\n> to install the program it depends on (though the error might help you\n> identify bad configuration for \"gpg.program\").\n\nQuite the contrary, from a single \"N\", you cannot immediately tell\nif the commit is not signed, if your GPG is misconfigured, or if you\nhave a stray gpg.program that points at nowhere.\n\nI think the uninteded behaviour change was in 17809a98 (\"Merge\nbranch 'jk/run-command-notdot'\", 2018-10-30).\n\nThanks for a report.\n"},{"id":"365025","messageId":"xmqqh8fkln5q.fsf@gitster-ct.c.googlers.com","threadId":"49996","inReplyTo":"xmqqlg4wlocc.fsf@gitster-ct.c.googlers.com","subject":"Re: silent_exec_failure when calling gpg","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-12-11T04:09:37Z","receivedAt":"2018-12-11T04:09:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> John Passaro <john.a.passaro@gmail.com> writes:\n>\n>> I've noticed that in v2.19.1, when using git to pretty print\n>> information about the signature, if git cannot find gpg (e.g. \"git\n>> config gpg.program nogpg\"), it prints an error to stderr:\n>>\n>> $ git show -s --pretty=%G?\n>> fatal: cannot run nogpg: No such file or directory\n>> N\n>\n> I think the uninteded behaviour change was in 17809a98 (\"Merge\n> branch 'jk/run-command-notdot'\", 2018-10-30).\n\nPerhaps something like this.  There needs an additional test added\nfor this codepath, which I haven't done yet, though.\n\n run-command.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/run-command.c b/run-command.c\nindex d679cc267c..e2bc18a083 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -728,6 +728,8 @@ int start_command(struct child_process *cmd)\n \tif (prepare_cmd(&argv, cmd) < 0) {\n \t\tfailed_errno = errno;\n \t\tcmd->pid = -1;\n+\t\tif (!cmd->silent_exec_failure)\n+\t\t\terror_errno(\"cannot run %s\", cmd->argv[0]);\n \t\tgoto end_of_spawn;\n \t}\n \n"},{"id":"365049","messageId":"20181211095633.GC31588@sigill.intra.peff.net","threadId":"49996","inReplyTo":"xmqqh8fkln5q.fsf@gitster-ct.c.googlers.com","subject":"Re: silent_exec_failure when calling gpg","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-12-11T09:56:33Z","receivedAt":"2018-12-11T09:56:59Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Dec 11, 2018 at 01:09:37PM +0900, Junio C Hamano wrote:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n> > John Passaro <john.a.passaro@gmail.com> writes:\n> >\n> >> I've noticed that in v2.19.1, when using git to pretty print\n> >> information about the signature, if git cannot find gpg (e.g. \"git\n> >> config gpg.program nogpg\"), it prints an error to stderr:\n> >>\n> >> $ git show -s --pretty=%G?\n> >> fatal: cannot run nogpg: No such file or directory\n> >> N\n> >\n> > I think the uninteded behaviour change was in 17809a98 (\"Merge\n> > branch 'jk/run-command-notdot'\", 2018-10-30).\n> \n> Perhaps something like this.  There needs an additional test added\n> for this codepath, which I haven't done yet, though.\n\nThanks, both, for the report and the patch.\n\n> diff --git a/run-command.c b/run-command.c\n> index d679cc267c..e2bc18a083 100644\n> --- a/run-command.c\n> +++ b/run-command.c\n> @@ -728,6 +728,8 @@ int start_command(struct child_process *cmd)\n>  \tif (prepare_cmd(&argv, cmd) < 0) {\n>  \t\tfailed_errno = errno;\n>  \t\tcmd->pid = -1;\n> +\t\tif (!cmd->silent_exec_failure)\n> +\t\t\terror_errno(\"cannot run %s\", cmd->argv[0]);\n>  \t\tgoto end_of_spawn;\n>  \t}\n\nYes, I think this is the right fix. For a test, I think we could just\ndo:\n\ndiff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh\nindex cf932c8514..866268dfd1 100755\n--- a/t/t0061-run-command.sh\n+++ b/t/t0061-run-command.sh\n@@ -33,7 +33,8 @@ test_expect_success 'run_command is restricted to PATH' '\n \twrite_script should-not-run <<-\\EOF &&\n \techo yikes\n \tEOF\n-\ttest_must_fail test-tool run-command run-command should-not-run\n+\ttest_must_fail test-tool run-command run-command should-not-run 2>err &&\n+\tgrep should-not-run err\n '\n \n test_expect_success !MINGW 'run_command can run a script without a #! line' '\n\n\nI assume you'll wrap that up into a real commit?\n\n-Peff\n"}]}