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>
maint
Nicolas Vigier 2013-11-05 00:14:41 +01:00 committed by Junio C Hamano
parent f26f72de15
commit d95bfb12b8
4 changed files with 21 additions and 1 deletions

View File

@ -988,6 +988,14 @@ commit.cleanup::
have to remove the help lines that begin with `#` in the commit log have to remove the help lines that begin with `#` in the commit log
template yourself, if you do this). template yourself, if you do this).


commit.gpgsign::

A boolean to specify whether all commits should be GPG signed.
Use of this option when doing operations such as rebase can
result in a large number of commits being signed. It may be
convenient to use an agent to avoid typing your GPG passphrase
several times.

commit.status:: commit.status::
A boolean to enable/disable inclusion of status information in the A boolean to enable/disable inclusion of status information in the
commit message template when using an editor to prepare the commit commit message template when using an editor to prepare the commit

View File

@ -12,6 +12,8 @@


static const char commit_tree_usage[] = "git commit-tree [(-p <sha1>)...] [-S[<keyid>]] [-m <message>] [-F <file>] <sha1> <changelog"; static const char commit_tree_usage[] = "git commit-tree [(-p <sha1>)...] [-S[<keyid>]] [-m <message>] [-F <file>] <sha1> <changelog";


static const char *sign_commit;

static void new_parent(struct commit *parent, struct commit_list **parents_p) static void new_parent(struct commit *parent, struct commit_list **parents_p)
{ {
unsigned char *sha1 = parent->object.sha1; unsigned char *sha1 = parent->object.sha1;
@ -31,6 +33,10 @@ static int commit_tree_config(const char *var, const char *value, void *cb)
int status = git_gpg_config(var, value, NULL); int status = git_gpg_config(var, value, NULL);
if (status) if (status)
return status; return status;
if (!strcmp(var, "commit.gpgsign")) {
sign_commit = git_config_bool(var, value) ? "" : NULL;
return 0;
}
return git_default_config(var, value, cb); return git_default_config(var, value, cb);
} }


@ -41,7 +47,6 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
unsigned char tree_sha1[20]; unsigned char tree_sha1[20];
unsigned char commit_sha1[20]; unsigned char commit_sha1[20];
struct strbuf buffer = STRBUF_INIT; struct strbuf buffer = STRBUF_INIT;
const char *sign_commit = NULL;


git_config(commit_tree_config, NULL); git_config(commit_tree_config, NULL);



View File

@ -1406,6 +1406,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
} }
if (!strcmp(k, "commit.cleanup")) if (!strcmp(k, "commit.cleanup"))
return git_config_string(&cleanup_arg, k, v); return git_config_string(&cleanup_arg, k, v);
if (!strcmp(k, "commit.gpgsign")) {
sign_commit = git_config_bool(k, v) ? "" : NULL;
return 0;
}


status = git_gpg_config(k, v, NULL); status = git_gpg_config(k, v, NULL);
if (status) if (status)

View File

@ -604,6 +604,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)
} else if (!strcmp(k, "merge.defaulttoupstream")) { } else if (!strcmp(k, "merge.defaulttoupstream")) {
default_to_upstream = git_config_bool(k, v); default_to_upstream = git_config_bool(k, v);
return 0; return 0;
} else if (!strcmp(k, "commit.gpgsign")) {
sign_commit = git_config_bool(k, v) ? "" : NULL;
return 0;
} }


status = fmt_merge_msg_config(k, v, cb); status = fmt_merge_msg_config(k, v, cb);