git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/2] Introduce "log.showSignature" config variable
@ 2016-06-05 15:39 Mehul Jain
  2016-06-05 15:39 ` [PATCH 1/2] log: add "log.showsignature" configuration variable Mehul Jain
  2016-06-05 15:39 ` [PATCH 2/2] log: "--no-show-signature" commmand-line option Mehul Jain
  0 siblings, 2 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

Add a new configuratation variable "log.showSignature" for git-log and
related commands. This variable will enable user to see GPG signature
by default.

[Patch 1/2] 
	Introduce the config variable along with some tests.

[Patch 2/2] 
	Tackles the problem: what if user wants to disable the
	setting of "log.showSignature=true" using a command line
	switch.

* Thanks Junio, Jeff and Remi for helping in reference patch.

Previous reference patch: http://thread.gmane.org/gmane.comp.version-control.git/295649

Mehul Jain (2):
  log: add "log.showsignature" configuration variable
  log: "--no-show-signature" commmand-line option

 Documentation/git-log.txt |  4 ++++
 builtin/log.c             |  6 ++++++
 revision.c                |  2 ++
 t/t4202-log.sh            | 25 +++++++++++++++++++++++++
 t/t7510-signed-commit.sh  |  7 +++++++
 5 files changed, 44 insertions(+)

-- 
2.9.0.rc0.dirty

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [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

* Re: [PATCH 2/2] log: "--no-show-signature" commmand-line option
  2016-06-05 15:39 ` [PATCH 2/2] log: "--no-show-signature" commmand-line option Mehul Jain
@ 2016-06-06 18:50   ` Junio C Hamano
  2016-06-08  6:04     ` Mehul Jain
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2016-06-06 18:50 UTC (permalink / raw)
  To: Mehul Jain; +Cc: git, Jeff King, Remi Galan Alfonso

Mehul Jain <mehul.jain2029@gmail.com> writes:

> 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.

Doesn't that suggest that 1/2 alone will cause users problems?  The
users can by mistake set the configuration variable and there is no
way for them to override it from the command line.

If you swap the order of the two patches, the topic makes more
sense.  I.e.

    [1/2] log: add "--no-show-signature" command line option

makes "git log --show-signature --no-show-signature" to run without
GPG checks, which by itself is a worthy change.  And then

    [2/2] log: add log.showSignature configuration variable

makes revs->show_signature default to the configured value, instead
of always initializing it to false.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] log: "--no-show-signature" commmand-line option
  2016-06-06 18:50   ` Junio C Hamano
@ 2016-06-08  6:04     ` Mehul Jain
  0 siblings, 0 replies; 5+ messages in thread
From: Mehul Jain @ 2016-06-08  6:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Jeff King, Remi Galan Alfonso

On Tue, Jun 7, 2016 at 12:20 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Mehul Jain <mehul.jain2029@gmail.com> writes:
>
>> 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.
>
> Doesn't that suggest that 1/2 alone will cause users problems?  The
> users can by mistake set the configuration variable and there is no
> way for them to override it from the command line.
>
> If you swap the order of the two patches, the topic makes more
> sense.  I.e.
>
>     [1/2] log: add "--no-show-signature" command line option
>
> makes "git log --show-signature --no-show-signature" to run without
> GPG checks, which by itself is a worthy change.  And then
>
>     [2/2] log: add log.showSignature configuration variable
>
> makes revs->show_signature default to the configured value, instead
> of always initializing it to false.

Yes, it does make sense to swap the order of the patches.
I will do a re-roll soon.

Thanks,
Mehul

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-08  6:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/2] log: "--no-show-signature" commmand-line option Mehul Jain
2016-06-06 18:50   ` Junio C Hamano
2016-06-08  6:04     ` Mehul Jain

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).