log: add log.showSignature configuration variable
authorMehul Jain <mehul.jain2029@gmail.com>
Wed, 22 Jun 2016 16:51:26 +0000 (22:21 +0530)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Jun 2016 20:01:13 +0000 (13:01 -0700)
Users may want to always use "--show-signature" while using git-log and
related commands.

When log.showSignature is set to true, git-log and related commands will
behave as if "--show-signature" was given to them.

Note that this config variable is meant to affect git-log, git-show,
git-whatchanged and git-reflog. Other commands like git-format-patch,
git-rev-list are not to be affected by this config variable.

Signed-off-by: Mehul Jain <mehul.jain2029@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-log.txt
builtin/log.c
t/t4202-log.sh
t/t7510-signed-commit.sh
index dec379b3e2bd58c74dba61a2a5207a38e702278c..3995324024d49b2f79c3f53486d1c420f795e250 100644 (file)
@@ -198,6 +198,10 @@ log.showRoot::
        `git log -p` output would be shown without a diff attached.
        The default is `true`.
 
        `git log -p` output would be shown without a diff attached.
        The default is `true`.
 
+log.showSignature::
+       If `true`, `git log` and related commands will act as if the
+       `--show-signature` option was passed to them.
+
 mailmap.*::
        See linkgit:git-shortlog[1].
 
 mailmap.*::
        See linkgit:git-shortlog[1].
 
index 099f4f7be92c6d4371dcc8cba1322351c6840439..71032175052e41f18f2b184eed9caba306e3466f 100644 (file)
@@ -33,6 +33,7 @@ static const char *default_date_mode = NULL;
 static int default_abbrev_commit;
 static int default_show_root = 1;
 static int default_follow;
 static int default_abbrev_commit;
 static int default_show_root = 1;
 static int default_follow;
+static int default_show_signature;
 static int decoration_style;
 static int decoration_given;
 static int use_mailmap_config;
 static int decoration_style;
 static int decoration_given;
 static int use_mailmap_config;
@@ -119,6 +120,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
        rev->abbrev_commit = default_abbrev_commit;
        rev->show_root_diff = default_show_root;
        rev->subject_prefix = fmt_patch_subject_prefix;
        rev->abbrev_commit = default_abbrev_commit;
        rev->show_root_diff = default_show_root;
        rev->subject_prefix = fmt_patch_subject_prefix;
+       rev->show_signature = default_show_signature;
        DIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);
 
        if (default_date_mode)
        DIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);
 
        if (default_date_mode)
@@ -409,6 +411,10 @@ static int git_log_config(const char *var, const char *value, void *cb)
                use_mailmap_config = git_config_bool(var, value);
                return 0;
        }
                use_mailmap_config = git_config_bool(var, value);
                return 0;
        }
+       if (!strcmp(var, "log.showsignature")) {
+               default_show_signature = git_config_bool(var, value);
+               return 0;
+       }
 
        if (grep_config(var, value, cb) < 0)
                return -1;
 
        if (grep_config(var, value, cb) < 0)
                return -1;
index 449a5275d490fa087fd70f1bda91b14053461d83..803e1e6b8fc5633b4d33c5749226b1aa506a8152 100755 (executable)
@@ -898,6 +898,26 @@ test_expect_success GPG '--no-show-signature overrides --show-signature' '
        ! grep "^gpg:" actual
 '
 
        ! grep "^gpg:" actual
 '
 
+test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
+       test_config log.showsignature true &&
+       git log -1 signed >actual &&
+       grep "gpg: Signature made" actual &&
+       grep "gpg: Good signature" actual
+'
+
+test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
+       test_config log.showsignature true &&
+       git log -1 --no-show-signature signed >actual &&
+       ! grep "^gpg:" actual
+'
+
+test_expect_success GPG '--show-signature overrides log.showsignature=false' '
+       test_config log.showsignature false &&
+       git log -1 --show-signature signed >actual &&
+       grep "gpg: Signature made" actual &&
+       grep "gpg: Good signature" actual
+'
+
 test_expect_success 'log --graph --no-walk is forbidden' '
        test_must_fail git log --graph --no-walk
 '
 test_expect_success 'log --graph --no-walk is forbidden' '
        test_must_fail git log --graph --no-walk
 '
index 4177a8609acac433cbc3f87d9ddec9c02672963c..6e839f5489c5a8e3667d182f6de1873c2d29bd0a 100755 (executable)
@@ -210,4 +210,11 @@ test_expect_success GPG 'show lack of signature with custom format' '
        test_cmp expect actual
 '
 
        test_cmp expect actual
 '
 
+test_expect_success GPG 'log.showsignature behaves like --show-signature' '
+       test_config log.showsignature true &&
+       git show initial >actual &&
+       grep "gpg: Signature made" actual &&
+       grep "gpg: Good signature" actual
+'
+
 test_done
 test_done