gpg-interface: add new config to select how to sign a commit

Add "gpg.format" where the user can specify which type of signature to use for commits. At the moment only "openpgp" is supported and the value is not even used. This commit prepares for a new types of signatures. Signed-off-by: Henning Schild <henning.schild@siemens.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Henning Schild committed Jul 17, 2018 at 14:50 UTC 57a8dd75df4e1d716d60fc95bd0acaab45465d68
2 files changed +14
Documentation/config.txt
+4
@@ -1828,6 +1828,10 @@ gpg.program::
1828 signed, and the program is expected to send the result to its
1829 standard output.
1830
1831 +gpg.format::
1832 + Specifies which key format to use when signing with `--gpg-sign`.
1833 + Default is "openpgp", that is also the only supported value.
1834 +
1835 gui.commitMsgWidth::
1836 Defines how wide the commit message window is in the
1837 linkgit:git-gui[1]. "75" is the default.
gpg-interface.c
+10
@@ -7,6 +7,7 @@
7 #include "tempfile.h"
8
9 static char *configured_signing_key;
10 +static const char *gpg_format = "openpgp";
11 static const char *gpg_program = "gpg";
12
13 #define PGP_SIGNATURE "-----BEGIN PGP SIGNATURE-----"
@@ -138,6 +139,15 @@ int git_gpg_config(const char *var, const char *value, void *cb)
139 return 0;
140 }
141
142 + if (!strcmp(var, "gpg.format")) {
143 + if (!value)
144 + return config_error_nonbool(var);
145 + if (strcmp(value, "openpgp"))
146 + return error("unsupported value for %s: %s",
147 + var, value);
148 + return git_config_string(&gpg_format, var, value);
149 + }
150 +
151 if (!strcmp(var, "gpg.program")) {
152 if (!value)
153 return config_error_nonbool(var);