Re: silent_exec_failure when calling gpg

Subsystems: the rest

2 messages, 2 authors, 2018-12-11 · open the first message on its own page

Re: silent_exec_failure when calling gpg

From: Junio C Hamano <hidden>
Date: 2018-12-11 04:09:42

Junio C Hamano [off-list ref] writes:
John Passaro [off-list ref] writes:
quoted
I've noticed that in v2.19.1, when using git to pretty print
information about the signature, if git cannot find gpg (e.g. "git
config gpg.program nogpg"), it prints an error to stderr:

$ git show -s --pretty=%G?
fatal: cannot run nogpg: No such file or directory
N
I think the uninteded behaviour change was in 17809a98 ("Merge
branch 'jk/run-command-notdot'", 2018-10-30).
Perhaps something like this.  There needs an additional test added
for this codepath, which I haven't done yet, though.

 run-command.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/run-command.c b/run-command.c
index d679cc267c..e2bc18a083 100644
--- a/run-command.c
+++ b/run-command.c
@@ -728,6 +728,8 @@ int start_command(struct child_process *cmd)
 	if (prepare_cmd(&argv, cmd) < 0) {
 		failed_errno = errno;
 		cmd->pid = -1;
+		if (!cmd->silent_exec_failure)
+			error_errno("cannot run %s", cmd->argv[0]);
 		goto end_of_spawn;
 	}
 

Re: silent_exec_failure when calling gpg

From: Jeff King <hidden>
Date: 2018-12-11 09:56:59

On Tue, Dec 11, 2018 at 01:09:37PM +0900, Junio C Hamano wrote:
Junio C Hamano [off-list ref] writes:
quoted
John Passaro [off-list ref] writes:
quoted
I've noticed that in v2.19.1, when using git to pretty print
information about the signature, if git cannot find gpg (e.g. "git
config gpg.program nogpg"), it prints an error to stderr:

$ git show -s --pretty=%G?
fatal: cannot run nogpg: No such file or directory
N
I think the uninteded behaviour change was in 17809a98 ("Merge
branch 'jk/run-command-notdot'", 2018-10-30).
Perhaps something like this.  There needs an additional test added
for this codepath, which I haven't done yet, though.
Thanks, both, for the report and the patch.
quoted hunk
diff --git a/run-command.c b/run-command.c
index d679cc267c..e2bc18a083 100644
--- a/run-command.c
+++ b/run-command.c
@@ -728,6 +728,8 @@ int start_command(struct child_process *cmd)
 	if (prepare_cmd(&argv, cmd) < 0) {
 		failed_errno = errno;
 		cmd->pid = -1;
+		if (!cmd->silent_exec_failure)
+			error_errno("cannot run %s", cmd->argv[0]);
 		goto end_of_spawn;
 	}
Yes, I think this is the right fix. For a test, I think we could just
do:
diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh
index cf932c8514..866268dfd1 100755
--- a/t/t0061-run-command.sh
+++ b/t/t0061-run-command.sh
@@ -33,7 +33,8 @@ test_expect_success 'run_command is restricted to PATH' '
 	write_script should-not-run <<-\EOF &&
 	echo yikes
 	EOF
-	test_must_fail test-tool run-command run-command should-not-run
+	test_must_fail test-tool run-command run-command should-not-run 2>err &&
+	grep should-not-run err
 '
 
 test_expect_success !MINGW 'run_command can run a script without a #! line' '

I assume you'll wrap that up into a real commit?

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help