commit-tree: add the commit.gpgsign option to sign all commits

If you want to GPG sign all your commits, you have to add the -S option all the time. The commit.gpgsign config option allows to sign all commits automatically. Signed-off-by: Nicolas Vigier <boklm@mars-attacks.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Vigier committed Nov 5, 2013 at 00:14 UTC d95bfb12b87a0be9666f806683e198df9738d0e7
4 files changed +21 -1
Documentation/config.txt
+8
@@ -988,6 +988,14 @@ commit.cleanup::
988 have to remove the help lines that begin with `#` in the commit log
989 template yourself, if you do this).
990
991 +commit.gpgsign::
992 +
993 + A boolean to specify whether all commits should be GPG signed.
994 + Use of this option when doing operations such as rebase can
995 + result in a large number of commits being signed. It may be
996 + convenient to use an agent to avoid typing your GPG passphrase
997 + several times.
998 +
999 commit.status::
1000 A boolean to enable/disable inclusion of status information in the
1001 commit message template when using an editor to prepare the commit
builtin/commit-tree.c
+6 -1
@@ -12,6 +12,8 @@
12
13 static const char commit_tree_usage[] = "git commit-tree [(-p <sha1>)...] [-S[<keyid>]] [-m <message>] [-F <file>] <sha1> <changelog";
14
15 +static const char *sign_commit;
16 +
17 static void new_parent(struct commit *parent, struct commit_list **parents_p)
18 {
19 unsigned char *sha1 = parent->object.sha1;
@@ -31,6 +33,10 @@ static int commit_tree_config(const char *var, const char *value, void *cb)
33 int status = git_gpg_config(var, value, NULL);
34 if (status)
35 return status;
36 + if (!strcmp(var, "commit.gpgsign")) {
37 + sign_commit = git_config_bool(var, value) ? "" : NULL;
38 + return 0;
39 + }
40 return git_default_config(var, value, cb);
41 }
42
@@ -41,7 +47,6 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
47 unsigned char tree_sha1[20];
48 unsigned char commit_sha1[20];
49 struct strbuf buffer = STRBUF_INIT;
44 - const char *sign_commit = NULL;
50
51 git_config(commit_tree_config, NULL);
52
builtin/commit.c
+4
@@ -1406,6 +1406,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
1406 }
1407 if (!strcmp(k, "commit.cleanup"))
1408 return git_config_string(&cleanup_arg, k, v);
1409 + if (!strcmp(k, "commit.gpgsign")) {
1410 + sign_commit = git_config_bool(k, v) ? "" : NULL;
1411 + return 0;
1412 + }
1413
1414 status = git_gpg_config(k, v, NULL);
1415 if (status)
builtin/merge.c
+3
@@ -604,6 +604,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)
604 } else if (!strcmp(k, "merge.defaulttoupstream")) {
605 default_to_upstream = git_config_bool(k, v);
606 return 0;
607 + } else if (!strcmp(k, "commit.gpgsign")) {
608 + sign_commit = git_config_bool(k, v) ? "" : NULL;
609 + return 0;
610 }
611
612 status = fmt_merge_msg_config(k, v, cb);