Split GPG interface into its own helper library

This mostly moves existing code from builtin/tag.c (for signing)
and builtin/verify-tag.c (for verifying) to a new gpg-interface.c
file to provide a more generic library interface.

 - sign_buffer() takes a payload strbuf, a signature strbuf, and a signing
   key, runs "gpg" to produce a detached signature for the payload, and
   appends it to the signature strbuf. The contents of a signed tag that
   concatenates the payload and the detached signature can be produced by
   giving the same strbuf as payload and signature strbuf.

 - verify_signed_buffer() takes a payload and a detached signature as
   <ptr, len> pairs, and runs "gpg --verify" to see if the payload matches
   the signature. It can optionally capture the output from GPG to allow
   the callers to pretty-print it in a way more suitable for their
   contexts.

"verify-tag" (aka "tag -v") used to save the whole tag contents as if it
is a detached signature, and fed gpg the payload part of the tag. It
relied on gpg to fail when the given tag is not signed but just is
annotated.  The updated run_gpg_verify() function detects the lack of
detached signature in the input, and errors out without bothering "gpg".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 files changed
tree: 6433828b342b5bc1bb5d1d133f9052fd143b82ab
  1. block-sha1/
  2. builtin/
  3. compat/
  4. contrib/
  5. Documentation/
  6. git-gui/
  7. git_remote_helpers/
  8. gitk-git/
  9. gitweb/
  10. mergetools/
  11. perl/
  12. po/
  13. ppc/
  14. t/
  15. templates/
  16. vcs-svn/
  17. xdiff/
  18. .gitattributes
  19. .gitignore
  20. .mailmap
  21. abspath.c
  22. aclocal.m4
  23. advice.c
  24. advice.h
  25. alias.c
  26. alloc.c
  27. archive-tar.c
  28. archive-zip.c
  29. archive.c
  30. archive.h
  31. argv-array.c
  32. argv-array.h
  33. attr.c
  34. attr.h
  35. base85.c
  36. bisect.c
  37. bisect.h
  38. blob.c
  39. blob.h
  40. branch.c
  41. branch.h
  42. builtin.h
  43. bundle.c
  44. bundle.h
  45. cache-tree.c
  46. cache-tree.h
  47. cache.h
  48. check-builtins.sh
  49. check-racy.c
  50. check_bindir
  51. color.c
  52. color.h
  53. combine-diff.c
  54. command-list.txt
  55. commit.c
  56. commit.h
  57. config.c
  58. config.mak.in
  59. configure.ac
  60. connect.c
  61. connected.c
  62. connected.h
  63. convert.c
  64. convert.h
  65. copy.c
  66. COPYING
  67. csum-file.c
  68. csum-file.h
  69. ctype.c
  70. daemon.c
  71. date.c
  72. decorate.c
  73. decorate.h
  74. delta.h
  75. diff-delta.c
  76. diff-lib.c
  77. diff-no-index.c
  78. diff.c
  79. diff.h
  80. diffcore-break.c
  81. diffcore-delta.c
  82. diffcore-order.c
  83. diffcore-pickaxe.c
  84. diffcore-rename.c
  85. diffcore.h
  86. dir.c
  87. dir.h
  88. editor.c
  89. entry.c
  90. environment.c
  91. exec_cmd.c
  92. exec_cmd.h
  93. fast-import.c
  94. fetch-pack.h
  95. fixup-builtins
  96. fsck.c
  97. fsck.h
  98. generate-cmdlist.sh
  99. gettext.c
  100. gettext.h
  101. git-add--interactive.perl
  102. git-am.sh
  103. git-archimport.perl
  104. git-bisect.sh
  105. git-compat-util.h
  106. git-cvsexportcommit.perl
  107. git-cvsimport.perl
  108. git-cvsserver.perl
  109. git-difftool--helper.sh
  110. git-difftool.perl
  111. git-filter-branch.sh
  112. git-instaweb.sh
  113. git-lost-found.sh
  114. git-merge-octopus.sh
  115. git-merge-one-file.sh
  116. git-merge-resolve.sh
  117. git-mergetool--lib.sh
  118. git-mergetool.sh
  119. git-parse-remote.sh
  120. git-pull.sh
  121. git-quiltimport.sh
  122. git-rebase--am.sh
  123. git-rebase--interactive.sh
  124. git-rebase--merge.sh
  125. git-rebase.sh
  126. git-relink.perl
  127. git-remote-testgit.py
  128. git-repack.sh
  129. git-request-pull.sh
  130. git-send-email.perl
  131. git-sh-i18n.sh
  132. git-sh-setup.sh
  133. git-stash.sh
  134. git-submodule.sh
  135. git-svn.perl
  136. GIT-VERSION-GEN
  137. git-web--browse.sh
  138. git.c
  139. git.spec.in
  140. gpg-interface.c
  141. gpg-interface.h
  142. graph.c
  143. graph.h
  144. grep.c
  145. grep.h
  146. hash.c
  147. hash.h
  148. help.c
  149. help.h
  150. hex.c
  151. http-backend.c
  152. http-fetch.c
  153. http-push.c
  154. http-walker.c
  155. http.c
  156. http.h
  157. ident.c
  158. imap-send.c
  159. INSTALL
  160. kwset.c
  161. kwset.h
  162. levenshtein.c
  163. levenshtein.h
  164. LGPL-2.1
  165. list-objects.c
  166. list-objects.h
  167. ll-merge.c
  168. ll-merge.h
  169. lockfile.c
  170. log-tree.c
  171. log-tree.h
  172. mailmap.c
  173. mailmap.h
  174. Makefile
  175. match-trees.c
  176. merge-file.c
  177. merge-file.h
  178. merge-recursive.c
  179. merge-recursive.h
  180. name-hash.c
  181. notes-cache.c
  182. notes-cache.h
  183. notes-merge.c
  184. notes-merge.h
  185. notes.c
  186. notes.h
  187. object.c
  188. object.h
  189. pack-check.c
  190. pack-refs.c
  191. pack-refs.h
  192. pack-revindex.c
  193. pack-revindex.h
  194. pack-write.c
  195. pack.h
  196. pager.c
  197. parse-options-cb.c
  198. parse-options.c
  199. parse-options.h
  200. patch-delta.c
  201. patch-ids.c
  202. patch-ids.h
  203. path.c
  204. pkt-line.c
  205. pkt-line.h
  206. preload-index.c
  207. pretty.c
  208. progress.c
  209. progress.h
  210. quote.c
  211. quote.h
  212. reachable.c
  213. reachable.h
  214. read-cache.c
  215. README
  216. reflog-walk.c
  217. reflog-walk.h
  218. refs.c
  219. refs.h
  220. remote-curl.c
  221. remote.c
  222. remote.h
  223. replace_object.c
  224. rerere.c
  225. rerere.h
  226. resolve-undo.c
  227. resolve-undo.h
  228. revision.c
  229. revision.h
  230. run-command.c
  231. run-command.h
  232. send-pack.h
  233. sequencer.c
  234. sequencer.h
  235. server-info.c
  236. setup.c
  237. sh-i18n--envsubst.c
  238. sha1-array.c
  239. sha1-array.h
  240. sha1-lookup.c
  241. sha1-lookup.h
  242. sha1_file.c
  243. sha1_name.c
  244. shallow.c
  245. shell.c
  246. shortlog.h
  247. show-index.c
  248. sideband.c
  249. sideband.h
  250. sigchain.c
  251. sigchain.h
  252. strbuf.c
  253. strbuf.h
  254. streaming.c
  255. streaming.h
  256. string-list.c
  257. string-list.h
  258. submodule.c
  259. submodule.h
  260. symlinks.c
  261. tag.c
  262. tag.h
  263. tar.h
  264. test-chmtime.c
  265. test-ctype.c
  266. test-date.c
  267. test-delta.c
  268. test-dump-cache-tree.c
  269. test-genrandom.c
  270. test-index-version.c
  271. test-line-buffer.c
  272. test-match-trees.c
  273. test-mktemp.c
  274. test-obj-pool.c
  275. test-parse-options.c
  276. test-path-utils.c
  277. test-run-command.c
  278. test-sha1.c
  279. test-sha1.sh
  280. test-sigchain.c
  281. test-string-pool.c
  282. test-subprocess.c
  283. test-svn-fe.c
  284. test-treap.c
  285. thread-utils.c
  286. thread-utils.h
  287. trace.c
  288. transport-helper.c
  289. transport.c
  290. transport.h
  291. tree-diff.c
  292. tree-walk.c
  293. tree-walk.h
  294. tree.c
  295. tree.h
  296. unimplemented.sh
  297. unpack-trees.c
  298. unpack-trees.h
  299. upload-pack.c
  300. url.c
  301. url.h
  302. usage.c
  303. userdiff.c
  304. userdiff.h
  305. utf8.c
  306. utf8.h
  307. walker.c
  308. walker.h
  309. wrap-for-bin.sh
  310. wrapper.c
  311. write_or_die.c
  312. ws.c
  313. wt-status.c
  314. wt-status.h
  315. xdiff-interface.c
  316. xdiff-interface.h
  317. zlib.c