Skip to content

Commit c7757b2

Browse files
committed
Merge branch 'as/ssh-signing-improve-key-missing-error'
Improve the error message given when private key is not loaded in the ssh agent in the codepath to sign with an ssh key. * as/ssh-signing-improve-key-missing-error: ssh signing: better error message when key not in agent
2 parents 86cca75 + dce7b31 commit c7757b2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

gpg-interface.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,13 +998,15 @@ static int sign_buffer_ssh(struct strbuf *buffer, struct strbuf *signature,
998998
char *ssh_signing_key_file = NULL;
999999
struct strbuf ssh_signature_filename = STRBUF_INIT;
10001000
const char *literal_key = NULL;
1001+
int literal_ssh_key = 0;
10011002

10021003
if (!signing_key || signing_key[0] == '\0')
10031004
return error(
10041005
_("user.signingKey needs to be set for ssh signing"));
10051006

10061007
if (is_literal_ssh_key(signing_key, &literal_key)) {
10071008
/* A literal ssh key */
1009+
literal_ssh_key = 1;
10081010
key_file = mks_tempfile_t(".git_signing_key_tmpXXXXXX");
10091011
if (!key_file)
10101012
return error_errno(
@@ -1039,8 +1041,10 @@ static int sign_buffer_ssh(struct strbuf *buffer, struct strbuf *signature,
10391041
"-Y", "sign",
10401042
"-n", "git",
10411043
"-f", ssh_signing_key_file,
1042-
buffer_file->filename.buf,
10431044
NULL);
1045+
if (literal_ssh_key)
1046+
strvec_push(&signer.args, "-U");
1047+
strvec_push(&signer.args, buffer_file->filename.buf);
10441048

10451049
sigchain_push(SIGPIPE, SIG_IGN);
10461050
ret = pipe_command(&signer, NULL, 0, NULL, 0, &signer_stderr, 0);

0 commit comments

Comments
 (0)