summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-02-27 22:01:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-02-27 22:01:03 (GMT)
commit810273bc33b1f50191f90deef74277ee84174efd (patch)
treec6295f6cd956f71be4044032f077e75f0d9b7237 /builtin
parent5f95c9f850b19b368c43ae399cc831b17a26a5ac (diff)
parent4b8d14b4c5d73dd4adb354d9689022d1b87828d5 (diff)
downloadgit-810273bc33b1f50191f90deef74277ee84174efd.zip
git-810273bc33b1f50191f90deef74277ee84174efd.tar.gz
git-810273bc33b1f50191f90deef74277ee84174efd.tar.bz2
Merge branch 'nv/commit-gpgsign-config'
Introduce commit.gpgsign configuration variable to force every commit to be GPG signed. The variable cannot be overriden from the command line of some of the commands that create commits except for "git commit" and "git commit-tree", but I am not convinced that it is a good idea to sprinkle support for --no-gpg-sign everywhere, which in turn means that this configuration variable may not be such a good idea. * nv/commit-gpgsign-config: test the commit.gpgsign config option commit-tree: add and document --no-gpg-sign commit-tree: add the commit.gpgsign option to sign all commits
Diffstat (limited to 'builtin')
-rw-r--r--builtin/commit-tree.c12
-rw-r--r--builtin/commit.c4
-rw-r--r--builtin/merge.c3
3 files changed, 18 insertions, 1 deletions
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index f641ff2..987a4c3 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -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 *sign_commit;
+
static void new_parent(struct commit *parent, struct commit_list **parents_p)
{
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);
if (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);
}
@@ -41,7 +47,6 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
unsigned char tree_sha1[20];
unsigned char commit_sha1[20];
struct strbuf buffer = STRBUF_INIT;
- const char *sign_commit = NULL;
git_config(commit_tree_config, NULL);
@@ -66,6 +71,11 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
continue;
}
+ if (!strcmp(arg, "--no-gpg-sign")) {
+ sign_commit = NULL;
+ continue;
+ }
+
if (!strcmp(arg, "-m")) {
if (argc <= ++i)
usage(commit_tree_usage);
diff --git a/builtin/commit.c b/builtin/commit.c
index 3767478..9c51b12 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1406,6 +1406,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
}
if (!strcmp(k, "commit.cleanup"))
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);
if (status)
diff --git a/builtin/merge.c b/builtin/merge.c
index e576a7f..f0cf120 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -597,6 +597,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)
} else if (!strcmp(k, "merge.defaulttoupstream")) {
default_to_upstream = git_config_bool(k, v);
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);