commit: teach --gpg-sign option

This uses the gpg-interface.[ch] to allow signing the commit, i.e.

    $ git commit --gpg-sign -m foo
    You need a passphrase to unlock the secret key for
    user: "Junio C Hamano <gitster@pobox.com>"
    4096-bit RSA key, ID 96AFE6CB, created 2011-10-03 (main key ID 713660A7)

    [master 8457d13] foo
     1 files changed, 1 insertions(+), 0 deletions(-)

The lines of GPG detached signature are placed in a new multi-line header
field, instead of tucking the signature block at the end of the commit log
message text (similar to how signed tag is done), for multiple reasons:

 - The signature won't clutter output from "git log" and friends if it is
   in the extra header. If we place it at the end of the log message, we
   would need to teach "git log" and friends to strip the signature block
   with an option.

 - Teaching new versions of "git log" and "gitk" to optionally verify and
   show signatures is cleaner if we structurally know where the signature
   block is (instead of scanning in the commit log message).

 - The signature needs to be stripped upon various commit rewriting
   operations, e.g. rebase, filter-branch, etc. They all already ignore
   unknown headers, but if we place signature in the log message, all of
   these tools (and third-party tools) also need to learn how a signature
   block would look like.

 - When we added the optional encoding header, all the tools (both in tree
   and third-party) that acts on the raw commit object should have been
   fixed to ignore headers they do not understand, so it is not like that
   new header would be more likely to break than extra text in the commit.

A commit made with the above sample sequence would look like this:

    $ git cat-file commit HEAD
    tree 3cd71d90e3db4136e5260ab54599791c4f883b9d
    parent b87755351a47b09cb27d6913e6e0e17e6254a4d4
    author Junio C Hamano <gitster@pobox.com> 1317862251 -0700
    committer Junio C Hamano <gitster@pobox.com> 1317862251 -0700
    gpgsig -----BEGIN PGP SIGNATURE-----
     Version: GnuPG v1.4.10 (GNU/Linux)

     iQIcBAABAgAGBQJOjPtrAAoJELC16IaWr+bL4TMP/RSe2Y/jYnCkds9unO5JEnfG
     ...
     =dt98
     -----END PGP SIGNATURE-----

    foo

but "git log" (unless you ask for it with --pretty=raw) output is not
cluttered with the signature information.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 files changed
tree: a0d13cdc7e85835f529afce77e53a67b3ef42a84
  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