Skip to content

Commit d95bfb1

Browse files
boklmgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f26f72d commit d95bfb1

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

Documentation/config.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,14 @@ commit.cleanup::
988988
have to remove the help lines that begin with `#` in the commit log
989989
template yourself, if you do this).
990990

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+
991999
commit.status::
9921000
A boolean to enable/disable inclusion of status information in the
9931001
commit message template when using an editor to prepare the commit

builtin/commit-tree.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

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

15+
static const char *sign_commit;
16+
1517
static void new_parent(struct commit *parent, struct commit_list **parents_p)
1618
{
1719
unsigned char *sha1 = parent->object.sha1;
@@ -31,6 +33,10 @@ static int commit_tree_config(const char *var, const char *value, void *cb)
3133
int status = git_gpg_config(var, value, NULL);
3234
if (status)
3335
return status;
36+
if (!strcmp(var, "commit.gpgsign")) {
37+
sign_commit = git_config_bool(var, value) ? "" : NULL;
38+
return 0;
39+
}
3440
return git_default_config(var, value, cb);
3541
}
3642

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

4651
git_config(commit_tree_config, NULL);
4752

builtin/commit.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
14061406
}
14071407
if (!strcmp(k, "commit.cleanup"))
14081408
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+
}
14091413

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

builtin/merge.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)
604604
} else if (!strcmp(k, "merge.defaulttoupstream")) {
605605
default_to_upstream = git_config_bool(k, v);
606606
return 0;
607+
} else if (!strcmp(k, "commit.gpgsign")) {
608+
sign_commit = git_config_bool(k, v) ? "" : NULL;
609+
return 0;
607610
}
608611

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

0 commit comments

Comments
 (0)