summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-04-06 18:39:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-04-06 18:39:13 (GMT)
commita2595f05c7d8c9369623cbc19f92f3f1be6fb534 (patch)
tree9112ba6b6e9423a8a84d274f3d90841ce444c643 /builtin
parent01e1d54418a016fb305cb29295f54a86c57dc316 (diff)
parent61c2fe0c2984a7785e2ac803ce33e23663295b24 (diff)
downloadgit-a2595f05c7d8c9369623cbc19f92f3f1be6fb534.zip
git-a2595f05c7d8c9369623cbc19f92f3f1be6fb534.tar.gz
git-a2595f05c7d8c9369623cbc19f92f3f1be6fb534.tar.bz2
Merge branch 'la/tag-force-signing-annotated-tags'
"git tag" can create an annotated tag without explicitly given an "-a" (or "-s") option (i.e. when a tag message is given). A new configuration variable, tag.forceSignAnnotated, can be used to tell the command to create signed tag in such a situation. * la/tag-force-signing-annotated-tags: tag: add the option to force signing of annotated tags
Diffstat (limited to 'builtin')
-rw-r--r--builtin/tag.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/builtin/tag.c b/builtin/tag.c
index 1705c94..528a1ba 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -29,6 +29,7 @@ static const char * const git_tag_usage[] = {
};
static unsigned int colopts;
+static int force_sign_annotate;
static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, const char *format)
{
@@ -166,6 +167,11 @@ static int git_tag_config(const char *var, const char *value, void *cb)
status = git_gpg_config(var, value, cb);
if (status)
return status;
+ if (!strcmp(var, "tag.forcesignannotated")) {
+ force_sign_annotate = git_config_bool(var, value);
+ return 0;
+ }
+
if (starts_with(var, "column."))
return git_column_config(var, value, "tag", &colopts);
return git_default_config(var, value, cb);
@@ -327,7 +333,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
char *cleanup_arg = NULL;
int create_reflog = 0;
int annotate = 0, force = 0;
- int cmdmode = 0;
+ int cmdmode = 0, create_tag_object = 0;
const char *msgfile = NULL, *keyid = NULL;
struct msg_arg msg = { 0, STRBUF_INIT };
struct ref_transaction *transaction;
@@ -385,12 +391,12 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
opt.sign = 1;
set_signing_key(keyid);
}
- if (opt.sign)
- annotate = 1;
+ create_tag_object = (opt.sign || annotate || msg.given || msgfile);
+
if (argc == 0 && !cmdmode)
cmdmode = 'l';
- if ((annotate || msg.given || msgfile || force) && (cmdmode != 0))
+ if ((create_tag_object || force) && (cmdmode != 0))
usage_with_options(git_tag_usage, options);
finalize_colopts(&colopts, -1);
@@ -431,7 +437,6 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
if (msg.given || msgfile) {
if (msg.given && msgfile)
die(_("only one -F or -m option is allowed."));
- annotate = 1;
if (msg.given)
strbuf_addbuf(&buf, &(msg.buf));
else {
@@ -474,8 +479,11 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
else
die(_("Invalid cleanup mode %s"), cleanup_arg);
- if (annotate)
+ if (create_tag_object) {
+ if (force_sign_annotate && !annotate)
+ opt.sign = 1;
create_tag(object, tag, &buf, &opt, prev, object);
+ }
transaction = ref_transaction_begin(&err);
if (!transaction ||