gpg-interface: allow use of a custom GPG binary

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Nov 29, 2011 at 12:29 UTC 0c5e70f041bfda8b3899d13694a9093b41fafa19
3 files changed +24 -6
Documentation/config.txt
+11
@@ -1094,6 +1094,17 @@ grep.lineNumber::
1094 grep.extendedRegexp::
1095 If set to true, enable '--extended-regexp' option by default.
1096
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 +
1108 gui.commitmsgwidth::
1109 Defines how wide the commit message window is in the
1110 linkgit:git-gui[1]. "75" is the default.
Documentation/git-tag.txt
+5 -3
@@ -38,7 +38,9 @@ created (i.e. a lightweight tag).
38 A GnuPG signed tag object will be created when `-s` or `-u
39 <key-id>` is used. When `-u <key-id>` is not used, the
40 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 +
44
45 OPTIONS
46 -------
@@ -48,11 +50,11 @@ OPTIONS
50
51 -s::
52 --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.
54
55 -u <key-id>::
56 --local-user=<key-id>::
55 - Make a GPG-signed tag, using the given key
57 + Make a GPG-signed tag, using the given key.
58
59 -f::
60 --force::
gpg-interface.c
+8 -3
@@ -5,6 +5,7 @@
5 #include "sigchain.h"
6
7 static char *configured_signing_key;
8 +static const char *gpg_program = "gpg";
9
10 void set_signing_key(const char *key)
11 {
@@ -15,9 +16,12 @@ void set_signing_key(const char *key)
16 int git_gpg_config(const char *var, const char *value, void *cb)
17 {
18 if (!strcmp(var, "user.signingkey")) {
19 + set_signing_key(value);
20 + }
21 + if (!strcmp(var, "gpg.program")) {
22 if (!value)
23 return config_error_nonbool(var);
20 - set_signing_key(value);
24 + gpg_program = xstrdup(value);
25 }
26 return 0;
27 }
@@ -46,7 +50,7 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
50 gpg.argv = args;
51 gpg.in = -1;
52 gpg.out = -1;
49 - args[0] = "gpg";
53 + args[0] = gpg_program;
54 args[1] = "-bsau";
55 args[2] = signing_key;
56 args[3] = NULL;
@@ -101,10 +105,11 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
105 struct strbuf *gpg_output)
106 {
107 struct child_process gpg;
104 - const char *args_gpg[] = {"gpg", "--verify", "FILE", "-", NULL};
108 + const char *args_gpg[] = {NULL, "--verify", "FILE", "-", NULL};
109 char path[PATH_MAX];
110 int fd, ret;
111
112 + args_gpg[0] = gpg_program;
113 fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXXXXXX");
114 if (fd < 0)
115 return error("could not create temporary file '%s': %s",