{"thread":{"id":"29044","subject":"support gnupg-2.x in git.","startedAt":"2011-11-29T18:37:34Z","lastAt":"2011-11-29T20:29:29Z","messageCount":2,"participants":["Paweł Sikora","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"180101","messageId":"201111291937.34324.pawel.sikora@agmk.net","threadId":"29044","inReplyTo":null,"subject":"support gnupg-2.x in git.","fromName":"Paweł Sikora","fromEmail":"pawel.sikora@agmk.net","sentAt":"2011-11-29T18:37:34Z","receivedAt":"2011-11-29T18:37:34Z","isPatch":false,"sender":{"key":"pawel.sikora@agmk.net","avatar":null},"body":"Hi,\n\ni'm using a gnupg-2.0.18 and currently i'm not able to use git tag/verify\ndue to hadcoded \"gpg\" literals in builtin/{tag,verifiy-tag}.c.\ncould you please improve git to use global config key with specified path\nto gpg{,2} executable?\n\nBR,\nPaweł.\n\nplease CC me on reply.\n"},{"id":"180110","messageId":"7vborusmdy.fsf@alter.siamese.dyndns.org","threadId":"29044","inReplyTo":"201111291937.34324.pawel.sikora@agmk.net","subject":"Re: support gnupg-2.x in git.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-29T20:29:29Z","receivedAt":"2011-11-29T20:29:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paweł Sikora <pawel.sikora@agmk.net> writes:\n\n> i'm using a gnupg-2.0.18 and currently i'm not able to use git tag/verify\n> due to hadcoded \"gpg\" literals in builtin/{tag,verifiy-tag}.c.\n\nStating the obvious...\n\n  $ ln -s /usr/local/not/on/my/path/bin/gnupg-2.0.18 $HOME/bin/gpg\n  $ PATH=$HOME/bin:$PATH\n\nOr this untested patch, which applies on top of jc/signed-commit, as the\nGnuPG interface is in the process of getting heavily refactored.\n\n-- >8 --\nSubject: gpg-interface: allow use of a custom GPG binary\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/config.txt  |   11 +++++++++++\n Documentation/git-tag.txt |    8 +++++---\n gpg-interface.c           |   11 ++++++++---\n 3 files changed, 24 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex b30c7e6..094c1c9 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1094,6 +1094,17 @@ grep.lineNumber::\n grep.extendedRegexp::\n \tIf set to true, enable '--extended-regexp' option by default.\n \n+gpg.program::\n+\tUse this custom program instead of \"gpg\" found on $PATH when\n+\tmaking or verifying a PGP signature. The program must support the\n+\tsame command line interface as GPG, namely, to verify a detached\n+\tsignature, \"gpg --verify $file - <$signature\" is run, and the\n+\tprogram is expected to signal a good signature by exiting with\n+\tcode 0, and to generate an ascii-armored detached signature, the\n+\tstandard input of \"gpg -bsau $key\" is fed with the contents to be\n+\tsigned, and the program is expected to send the result to its\n+\tstandard output.\n+\n gui.commitmsgwidth::\n \tDefines how wide the commit message window is in the\n \tlinkgit:git-gui[1]. \"75\" is the default.\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex c83cb13..74fc7e0 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -38,7 +38,9 @@ created (i.e. a lightweight tag).\n A GnuPG signed tag object will be created when `-s` or `-u\n <key-id>` is used.  When `-u <key-id>` is not used, the\n committer identity for the current user is used to find the\n-GnuPG key for signing.\n+GnuPG key for signing. \tThe configuration variable `gpg.program`\n+is used to specify custom GnuPG binary.\n+\n \n OPTIONS\n -------\n@@ -48,11 +50,11 @@ OPTIONS\n \n -s::\n --sign::\n-\tMake a GPG-signed tag, using the default e-mail address's key\n+\tMake a GPG-signed tag, using the default e-mail address's key.\n \n -u <key-id>::\n --local-user=<key-id>::\n-\tMake a GPG-signed tag, using the given key\n+\tMake a GPG-signed tag, using the given key.\n \n -f::\n --force::\ndiff --git a/gpg-interface.c b/gpg-interface.c\nindex ff232c8..18630ff 100644\n--- a/gpg-interface.c\n+++ b/gpg-interface.c\n@@ -5,6 +5,7 @@\n #include \"sigchain.h\"\n \n static char *configured_signing_key;\n+static const char *gpg_program = \"gpg\";\n \n void set_signing_key(const char *key)\n {\n@@ -15,9 +16,12 @@ void set_signing_key(const char *key)\n int git_gpg_config(const char *var, const char *value, void *cb)\n {\n \tif (!strcmp(var, \"user.signingkey\")) {\n+\t\tset_signing_key(value);\n+\t}\n+\tif (!strcmp(var, \"gpg.program\")) {\n \t\tif (!value)\n \t\t\treturn config_error_nonbool(var);\n-\t\tset_signing_key(value);\n+\t\tgpg_program = xstrdup(value);\n \t}\n \treturn 0;\n }\n@@ -46,7 +50,7 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig\n \tgpg.argv = args;\n \tgpg.in = -1;\n \tgpg.out = -1;\n-\targs[0] = \"gpg\";\n+\targs[0] = gpg_program;\n \targs[1] = \"-bsau\";\n \targs[2] = signing_key;\n \targs[3] = NULL;\n@@ -101,10 +105,11 @@ int verify_signed_buffer(const char *payload, size_t payload_size,\n \t\t\t struct strbuf *gpg_output)\n {\n \tstruct child_process gpg;\n-\tconst char *args_gpg[] = {\"gpg\", \"--verify\", \"FILE\", \"-\", NULL};\n+\tconst char *args_gpg[] = {NULL, \"--verify\", \"FILE\", \"-\", NULL};\n \tchar path[PATH_MAX];\n \tint fd, ret;\n \n+\targs_gpg[0] = gpg_program;\n \tfd = git_mkstemp(path, PATH_MAX, \".git_vtag_tmpXXXXXX\");\n \tif (fd < 0)\n \t\treturn error(\"could not create temporary file '%s': %s\",\n"}]}