Re: [PATCH v2 2/2] log: add log.showSignature configuration variable
Hi Eric, Thanks for your review. On Sun, Jun 19, 2016 at 12:29 PM, Eric Sunshinewrote: > On Sat, Jun 18, 2016 at 8:25 AM, Mehul Jain wrote: >> diff --git a/t/t4202-log.sh b/t/t4202-log.sh >> @@ -900,6 +900,31 @@ test_expect_success GPG '--no-show-signature overrides >> --show-signature' ' >> +test_expect_success GPG 'log.showsignature=true behaves like >> --show-signature' ' >> + git checkout -b test_sign master && > > It appears that you copied the bulk of this test from the 'log --graph > --show-signature' test and changed it to create a new branch named > 'test_sign' rather than 'signed', however... > >> + echo foo >foo && >> + git add foo && >> + git commit -S -m signed_commit && >> + test_config log.showsignature true && >> + git log -1 signed >actual && > > ... you're incorrectly testing against the 'signed' branch rather than > the 'test_sign' created specifically for this test. Yes, I made a mistake here. >> + 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_when_finished "git reset --hard && git checkout master" && > > So, in the first of these three new tests, you're setting up some > state by creating and checking out a new branch named 'test_sign', and > leaving that branch checked out while these three tests run, and > finally use test_when_finished() in the last of the three tests to > restore sanity (by returning to the 'master' branch) when that test > exits. > > This is ugly and couples these three tests too tightly. It would be > better to make each test more self-contained, not relying upon state > left over from previous tests. > >> + test_config log.showsignature false && >> + git log -1 --show-signature signed >actual && >> + grep "gpg: Signature made" actual && >> + grep "gpg: Good signature" actual >> +' > > In fact, the original 'log --graph --show-signature' test which > created the 'signed' branch, the new --no-show-signature test added in > patch 1/2, and the three new tests here could all just work against > the same 'signed' branch. There is no need to create a new 'test_sign' > branch for these three tests, or a 'nosign' branch for the patch 1/2 > test. > > Therefore, it probably would make more sense to add a new distinct > 'setup signed' test (or just enhance the existing 'setup' test) which > creates the 'signed' branch and update the original 'log --graph > --show-signature' to take advantage of it, as well as each of the new > tests introduced by this patch series. And since each test would > mention 'signed' explicitly in its git-log invocation, there's no need > to leave that branch checked out, so the setup test itself only needs > test_when_finished() to ensure that the current branch is restored to > 'master'. Adding a new test 'setup signed' will work, where I will create a new 'signed' branch and use that branch in new --no-show-signature test introduced in patch 1/2, and the three tests in current patch 2/2. Also by creating a preparatory patch for this series, I will modify the 'log --graph --show-signature' test, so that it can also take advantage of new 'setup signed' test. Though I'm wondering if whether there is a need to create the new 'setup signed' test. In 'log --graph --show-signature' test, we already have the 'signed' branch, which could be used in the test introduced here. But this will couple the tests, 'log --graph ...' and new ones, tightly. Because if in future someone changes the 'log --graph ...' test, then there is a possibility of new tests (introduced in patch 1/2 and 2/2) to fail. So creating a new test for creation of 'signed' branch seems fair. Thanks, Mehul -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/2] log: add log.showSignature configuration variable
On Sat, Jun 18, 2016 at 8:25 AM, Mehul Jainwrote: > 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 > --- > diff --git a/t/t4202-log.sh b/t/t4202-log.sh > @@ -900,6 +900,31 @@ test_expect_success GPG '--no-show-signature overrides > --show-signature' ' > +test_expect_success GPG 'log.showsignature=true behaves like > --show-signature' ' > + git checkout -b test_sign master && It appears that you copied the bulk of this test from the 'log --graph --show-signature' test and changed it to create a new branch named 'test_sign' rather than 'signed', however... > + echo foo >foo && > + git add foo && > + git commit -S -m signed_commit && > + test_config log.showsignature true && > + git log -1 signed >actual && ... you're incorrectly testing against the 'signed' branch rather than the 'test_sign' created specifically for this test. > + 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_when_finished "git reset --hard && git checkout master" && So, in the first of these three new tests, you're setting up some state by creating and checking out a new branch named 'test_sign', and leaving that branch checked out while these three tests run, and finally use test_when_finished() in the last of the three tests to restore sanity (by returning to the 'master' branch) when that test exits. This is ugly and couples these three tests too tightly. It would be better to make each test more self-contained, not relying upon state left over from previous tests. > + test_config log.showsignature false && > + git log -1 --show-signature signed >actual && > + grep "gpg: Signature made" actual && > + grep "gpg: Good signature" actual > +' In fact, the original 'log --graph --show-signature' test which created the 'signed' branch, the new --no-show-signature test added in patch 1/2, and the three new tests here could all just work against the same 'signed' branch. There is no need to create a new 'test_sign' branch for these three tests, or a 'nosign' branch for the patch 1/2 test. Therefore, it probably would make more sense to add a new distinct 'setup signed' test (or just enhance the existing 'setup' test) which creates the 'signed' branch and update the original 'log --graph --show-signature' to take advantage of it, as well as each of the new tests introduced by this patch series. And since each test would mention 'signed' explicitly in its git-log invocation, there's no need to leave that branch checked out, so the setup test itself only needs test_when_finished() to ensure that the current branch is restored to 'master'. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/2] 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--- Documentation/git-log.txt | 4 builtin/log.c | 6 ++ t/t4202-log.sh| 25 + t/t7510-signed-commit.sh | 7 +++ 4 files changed, 42 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(>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 02384a3..63ed863 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -900,6 +900,31 @@ test_expect_success GPG '--no-show-signature overrides --show-signature' ' ! grep "^gpg:" 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 '--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 && + 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html