Skip to content

Commit 0c5e70f

Browse files
committed
gpg-interface: allow use of a custom GPG binary
Signed-off-by: Junio C Hamano <[email protected]>
1 parent f6667c5 commit 0c5e70f

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

Documentation/config.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,17 @@ grep.lineNumber::
10941094
grep.extendedRegexp::
10951095
If set to true, enable '--extended-regexp' option by default.
10961096

1097+
gpg.program::
1098+
Use this custom program instead of "gpg" found on $PATH when
1099+
making or verifying a PGP signature. The program must support the
1100+
same command line interface as GPG, namely, to verify a detached
1101+
signature, "gpg --verify $file - <$signature" is run, and the
1102+
program is expected to signal a good signature by exiting with
1103+
code 0, and to generate an ascii-armored detached signature, the
1104+
standard input of "gpg -bsau $key" is fed with the contents to be
1105+
signed, and the program is expected to send the result to its
1106+
standard output.
1107+
10971108
gui.commitmsgwidth::
10981109
Defines how wide the commit message window is in the
10991110
linkgit:git-gui[1]. "75" is the default.

Documentation/git-tag.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ created (i.e. a lightweight tag).
3838
A GnuPG signed tag object will be created when `-s` or `-u
3939
<key-id>` is used. When `-u <key-id>` is not used, the
4040
committer identity for the current user is used to find the
41-
GnuPG key for signing.
41+
GnuPG key for signing. The configuration variable `gpg.program`
42+
is used to specify custom GnuPG binary.
43+
4244

4345
OPTIONS
4446
-------
@@ -48,11 +50,11 @@ OPTIONS
4850

4951
-s::
5052
--sign::
51-
Make a GPG-signed tag, using the default e-mail address's key
53+
Make a GPG-signed tag, using the default e-mail address's key.
5254

5355
-u <key-id>::
5456
--local-user=<key-id>::
55-
Make a GPG-signed tag, using the given key
57+
Make a GPG-signed tag, using the given key.
5658

5759
-f::
5860
--force::

gpg-interface.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "sigchain.h"
66

77
static char *configured_signing_key;
8+
static const char *gpg_program = "gpg";
89

910
void set_signing_key(const char *key)
1011
{
@@ -15,9 +16,12 @@ void set_signing_key(const char *key)
1516
int git_gpg_config(const char *var, const char *value, void *cb)
1617
{
1718
if (!strcmp(var, "user.signingkey")) {
19+
set_signing_key(value);
20+
}
21+
if (!strcmp(var, "gpg.program")) {
1822
if (!value)
1923
return config_error_nonbool(var);
20-
set_signing_key(value);
24+
gpg_program = xstrdup(value);
2125
}
2226
return 0;
2327
}
@@ -46,7 +50,7 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
4650
gpg.argv = args;
4751
gpg.in = -1;
4852
gpg.out = -1;
49-
args[0] = "gpg";
53+
args[0] = gpg_program;
5054
args[1] = "-bsau";
5155
args[2] = signing_key;
5256
args[3] = NULL;
@@ -101,10 +105,11 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
101105
struct strbuf *gpg_output)
102106
{
103107
struct child_process gpg;
104-
const char *args_gpg[] = {"gpg", "--verify", "FILE", "-", NULL};
108+
const char *args_gpg[] = {NULL, "--verify", "FILE", "-", NULL};
105109
char path[PATH_MAX];
106110
int fd, ret;
107111

112+
args_gpg[0] = gpg_program;
108113
fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXXXXXX");
109114
if (fd < 0)
110115
return error("could not create temporary file '%s': %s",

0 commit comments

Comments
 (0)