log: add log.showSignature configuration variable
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>
Mehul Jain committed
Jun 22, 2016 at 22:21 UTC
fce04c3ca695d32c1b3c59e1bfc1fb4019025c72
4 files changed
+37
Documentation/git-log.txt
+4
@@ -198,6 +198,10 @@ log.showRoot::
198
`git log -p` output would be shown without a diff attached.
199
The default is `true`.
200
201
+log.showSignature::
202
+ If `true`, `git log` and related commands will act as if the
203
+ `--show-signature` option was passed to them.
204
+
205
mailmap.*::
206
See linkgit:git-shortlog[1].
207
builtin/log.c
+6
@@ -33,6 +33,7 @@ static const char *default_date_mode = NULL;
33
static int default_abbrev_commit;
34
static int default_show_root = 1;
35
static int default_follow;
36
+static int default_show_signature;
37
static int decoration_style;
38
static int decoration_given;
39
static int use_mailmap_config;
@@ -119,6 +120,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
120
rev->abbrev_commit = default_abbrev_commit;
121
rev->show_root_diff = default_show_root;
122
rev->subject_prefix = fmt_patch_subject_prefix;
123
+ rev->show_signature = default_show_signature;
124
DIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);
125
126
if (default_date_mode)
@@ -409,6 +411,10 @@ static int git_log_config(const char *var, const char *value, void *cb)
411
use_mailmap_config = git_config_bool(var, value);
412
return 0;
413
}
414
+ if (!strcmp(var, "log.showsignature")) {
415
+ default_show_signature = git_config_bool(var, value);
416
+ return 0;
417
+ }
418
419
if (grep_config(var, value, cb) < 0)
420
return -1;
t/t4202-log.sh
+20
@@ -898,6 +898,26 @@ test_expect_success GPG '--no-show-signature overrides --show-signature' '
898
! grep "^gpg:" actual
899
'
900
901
+test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
902
+ test_config log.showsignature true &&
903
+ git log -1 signed >actual &&
904
+ grep "gpg: Signature made" actual &&
905
+ grep "gpg: Good signature" actual
906
+'
907
+
908
+test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
909
+ test_config log.showsignature true &&
910
+ git log -1 --no-show-signature signed >actual &&
911
+ ! grep "^gpg:" actual
912
+'
913
+
914
+test_expect_success GPG '--show-signature overrides log.showsignature=false' '
915
+ test_config log.showsignature false &&
916
+ git log -1 --show-signature signed >actual &&
917
+ grep "gpg: Signature made" actual &&
918
+ grep "gpg: Good signature" actual
919
+'
920
+
921
test_expect_success 'log --graph --no-walk is forbidden' '
922
test_must_fail git log --graph --no-walk
923
'
t/t7510-signed-commit.sh
+7
@@ -210,4 +210,11 @@ test_expect_success GPG 'show lack of signature with custom format' '
210
test_cmp expect actual
211
'
212
213
+test_expect_success GPG 'log.showsignature behaves like --show-signature' '
214
+ test_config log.showsignature true &&
215
+ git show initial >actual &&
216
+ grep "gpg: Signature made" actual &&
217
+ grep "gpg: Good signature" actual
218
+'
219
+
220
test_done