* [PATCH 1/2] log: add "log.showsignature" configuration variable
2016-06-05 15:39 [PATCH 0/2] Introduce "log.showSignature" config variable Mehul Jain
@ 2016-06-05 15:39 ` Mehul Jain
2016-06-05 15:39 ` [PATCH 2/2] log: "--no-show-signature" commmand-line option Mehul Jain
1 sibling, 0 replies; 5+ messages in thread
From: Mehul Jain @ 2016-06-05 15:39 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Jeff King, Remi Galan Alfonso, Mehul Jain
People 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.
Signed-off-by: Mehul Jain <mehul.jain2029@gmail.com>
---
Documentation/git-log.txt | 4 ++++
builtin/log.c | 6 ++++++
t/t4202-log.sh | 19 +++++++++++++++++++
t/t7510-signed-commit.sh | 7 +++++++
4 files changed, 36 insertions(+)
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 03f9580..bbb5adc 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -196,6 +196,10 @@ log.showRoot::
`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].
diff --git a/builtin/log.c b/builtin/log.c
index 099f4f7..7103217 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -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_show_signature;
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->show_signature = default_show_signature;
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;
}
+ if (!strcmp(var, "log.showsignature")) {
+ default_show_signature = git_config_bool(var, value);
+ return 0;
+ }
if (grep_config(var, value, cb) < 0)
return -1;
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 128ba93..3e4a4ac 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -890,6 +890,25 @@ test_expect_success GPG 'log --graph --show-signature for merged tag' '
grep "^| | gpg: Good signature" actual
'
+test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
+ git checkout -b test_sign master &&
+ echo foo >foo &&
+ git add foo &&
+ git commit -S -m signed_commit &&
+ test_config log.showsignature true &&
+ git log -1 signed >actual &&
+ grep "gpg: Signature made" actual &&
+ grep "gpg: Good signature" actual
+'
+
+test_expect_success GPG '--show-signature overrides log.showsignature=false' '
+ test_when_finished "git reset --hard && git checkout master" &&
+ 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
'
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 4177a86..6e839f5 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -210,4 +210,11 @@ test_expect_success GPG 'show lack of signature with custom format' '
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
--
2.9.0.rc0.dirty
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] log: "--no-show-signature" commmand-line option
2016-06-05 15:39 [PATCH 0/2] Introduce "log.showSignature" config variable Mehul Jain
2016-06-05 15:39 ` [PATCH 1/2] log: add "log.showsignature" configuration variable Mehul Jain
@ 2016-06-05 15:39 ` Mehul Jain
2016-06-06 18:50 ` Junio C Hamano
1 sibling, 1 reply; 5+ messages in thread
From: Mehul Jain @ 2016-06-05 15:39 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Jeff King, Remi Galan Alfonso, Mehul Jain
If "log.showSignature=true", then there is no way to override it using
command line switch.
Teach git-log and related commands about "--no-showSignature" command
line option.
Note that introduction of "--no-show-signature" is meant to tackle
the above mentioned problem for the following commands: git-log,
git-show, git-whatchanged and git-reflog. It does not suggest that
we need "log.showSignature" config variable to affect other git
commands, as currently "log.showSignature" is only meant to affect
git-log, git-show, git-whatchanged and git-reflog.
Signed-off-by: Mehul Jain <mehul.jain2029@gmail.com>
---
revision.c | 2 ++
t/t4202-log.sh | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/revision.c b/revision.c
index d30d1c4..3546ff9 100644
--- a/revision.c
+++ b/revision.c
@@ -1871,6 +1871,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->notes_opt.use_default_notes = 1;
} else if (!strcmp(arg, "--show-signature")) {
revs->show_signature = 1;
+ } else if (!strcmp(arg, "--no-show-signature")) {
+ revs->show_signature = 0;
} else if (!strcmp(arg, "--show-linear-break") ||
starts_with(arg, "--show-linear-break=")) {
if (starts_with(arg, "--show-linear-break="))
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 3e4a4ac..026808e 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -901,6 +901,12 @@ test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
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_when_finished "git reset --hard && git checkout master" &&
test_config log.showsignature false &&
--
2.9.0.rc0.dirty
^ permalink raw reply related [flat|nested] 5+ messages in thread