From: Hans Jerry Illikainen <hidden> Date: 2017-12-09 09:06:21
Verify the signature of the tip commit when `merge.verifySignatures` is
true. This can be overridden with `--no-verify-signatures`.
Signed-off-by: Hans Jerry Illikainen <redacted>
---
Documentation/merge-config.txt | 7 +++++++
builtin/merge.c | 2 ++
t/t7612-merge-verify-signatures.sh | 43 ++++++++++++++++++++++++++++++++++++--
3 files changed, 50 insertions(+), 2 deletions(-)
@@ -26,6 +26,13 @@ merge.ff:: allowed (equivalent to giving the `--ff-only` option from the command line).+merge.verifySignatures::+ Verify that the tip commit of the side branch being merged is+ signed with a valid key, i.e. a key that has a valid uid: in the+ default trust model, this means the signing key has been signed+ by a trusted key. If the tip commit of the side branch is not+ signed with a valid key, the merge is aborted.+ include::fmt-merge-msg-config.txt[] merge.renameLimit::
@@ -39,23 +39,62 @@ test_expect_success GPG 'merge unsigned commit with verification' 'test_i18ngrep"does not have a GPG signature"mergeerror'+test_expect_successGPG'merge unsigned commit with merge.verifySignatures=true''+test_configmerge.verifySignaturestrue&&+test_must_failgitmerge--ff-onlyside-unsigned2>mergeerror&&+test_i18ngrep"does not have a GPG signature"mergeerror+'+ test_expect_successGPG'merge commit with bad signature with verification''test_must_failgitmerge--ff-only--verify-signatures$(catforged.commit)2>mergeerror&&test_i18ngrep"has a bad GPG signature"mergeerror'+test_expect_successGPG'merge commit with bad signature with merge.verifySignatures=true''+test_configmerge.verifySignaturestrue&&+test_must_failgitmerge--ff-only$(catforged.commit)2>mergeerror&&+test_i18ngrep"has a bad GPG signature"mergeerror+'+ test_expect_successGPG'merge commit with untrusted signature with verification''test_must_failgitmerge--ff-only--verify-signaturesside-untrusted2>mergeerror&&test_i18ngrep"has an untrusted GPG signature"mergeerror'+test_expect_successGPG'merge commit with untrusted signature with merge.verifySignatures=true''+test_configmerge.verifySignaturestrue&&+test_must_failgitmerge--ff-onlyside-untrusted2>mergeerror&&+test_i18ngrep"has an untrusted GPG signature"mergeerror+'+ test_expect_successGPG'merge signed commit with verification''gitmerge--verbose--ff-only--verify-signaturesside-signed>mergeoutput&&-test_i18ngrep"has a good GPG signature"mergeoutput+test_i18ngrep"has a good GPG signature"mergeoutput&&+gitcheckoutinitial+'++test_expect_successGPG'merge signed commit with merge.verifySignatures=true''+test_configmerge.verifySignaturestrue&&+gitmerge--verbose--ff-onlyside-signed>mergeoutput&&+test_i18ngrep"has a good GPG signature"mergeoutput&&+gitcheckoutinitial' test_expect_successGPG'merge commit with bad signature without verification''-gitmerge$(catforged.commit)+gitmerge$(catforged.commit)&&+gitcheckoutinitial+'++test_expect_successGPG'merge commit with bad signature with merge.verifySignatures=false''+test_configmerge.verifySignaturesfalse&&+gitmerge$(catforged.commit)&&+gitcheckoutinitial+'++test_expect_successGPG'merge commit with bad signature with merge.verifySignatures=true and --no-verify-signatures''+test_configmerge.verifySignaturestrue&&+gitmerge--no-verify-signatures$(catforged.commit)&&+gitcheckoutinitial' test_done
From: Hans Jerry Illikainen <hidden> Date: 2017-12-09 09:06:09
Add tests for `pull --verify-signatures` with untrusted, bad and no
signatures. Previously the only test for `--verify-signatures` was to
make sure that `pull --rebase --verify-signatures` result in a warning
(t5520-pull.sh).
Signed-off-by: Hans Jerry Illikainen <redacted>
---
t/t5573-pull-verify-signatures.sh | 78 +++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
create mode 100755 t/t5573-pull-verify-signatures.sh
@@ -0,0 +1,78 @@+#!/bin/sh++test_description='pull signature verification tests'+../test-lib.sh+."$TEST_DIRECTORY/lib-gpg.sh"++test_expect_successGPG'create repositories with signed commits''+echo1>a&&gitadda&&+test_tick&&gitcommit-minitial&&+gittaginitial&&++gitclone.signed&&+(+cdsigned&&+echo2>b&&gitaddb&&+test_tick&&gitcommit-S-m"signed"+)&&++gitclone.unsigned&&+(+cdunsigned&&+echo3>c&&gitaddc&&+test_tick&&gitcommit-m"unsigned"+)&&++gitclone.bad&&+(+cdbad&&+echo4>d&&gitaddd&&+test_tick&&gitcommit-S-m"bad"&&+gitcat-filecommitHEAD>raw&&+sed-e"s/bad/forged bad/"raw>forged&&+githash-object-w-tcommitforged>forged.commit&&+gitcheckout$(catforged.commit)+)&&++gitclone.untrusted&&+(+cduntrusted&&+echo5>e&&gitadde&&+test_tick&&gitcommit-SB7227189-m"untrusted"+)+'++test_expect_successGPG'pull unsigned commit with --verify-signatures''+test_must_failgitpull--ff-only--verify-signaturesunsigned2>pullerror&&+test_i18ngrep"does not have a GPG signature"pullerror+'++test_expect_successGPG'pull commit with bad signature with --verify-signatures''+test_must_failgitpull--ff-only--verify-signaturesbad2>pullerror&&+test_i18ngrep"has a bad GPG signature"pullerror+'++test_expect_successGPG'pull commit with untrusted signature with --verify-signatures''+test_must_failgitpull--ff-only--verify-signaturesuntrusted2>pullerror&&+test_i18ngrep"has an untrusted GPG signature"pullerror+'++test_expect_successGPG'pull signed commit with --verify-signatures''+gitpull--verify-signaturessigned>pulloutput&&+test_i18ngrep"has a good GPG signature"pulloutput&&+gitcheckoutinitial+'++test_expect_successGPG'pull commit with bad signature without verification''+gitpull--ff-onlybad2>pullerror&&+gitcheckoutinitial+'++test_expect_successGPG'pull commit with bad signature with --no-verify-signatures''+test_configmerge.verifySignaturestrue&&+test_configpull.verifySignaturestrue&&+gitpull--ff-only--no-verify-signaturesbad2>pullerror&&+gitcheckoutinitial+'++test_done
From: Hans Jerry Illikainen <hidden> Date: 2017-12-09 09:06:16
Verify the signature of the tip commit when `pull.verifySignatures` is
true. This option overrides `merge.verifySignatures` on pull, and can
be disabled with the option `--no-verify-signatures`.
Signed-off-by: Hans Jerry Illikainen <redacted>
---
Documentation/config.txt | 8 ++++++++
builtin/pull.c | 25 +++++++++++++++++++++++++
t/t5520-pull.sh | 18 ++++++++++++++++++
t/t5573-pull-verify-signatures.sh | 32 ++++++++++++++++++++++++++++++++
4 files changed, 83 insertions(+)
@@ -2596,6 +2596,14 @@ pull.ff:: allowed (equivalent to giving the `--ff-only` option from the command line). This setting overrides `merge.ff` when pulling.+pull.verifySignatures::+ Verify that the tip commit of the side branch being merged is+ signed with a valid key, i.e. a key that has a valid uid: in the+ default trust model, this means the signing key has been signed+ by a trusted key. If the tip commit of the side branch is not+ signed with a valid key, the merge is aborted. This setting+ overrides `merge.verifySignatures` when pulling.+ pull.rebase:: When true, rebase branches on top of the fetched branch, instead of merging the default branch from the default remote when "git
@@ -416,6 +416,15 @@ test_expect_success "pull --rebase warns on --verify-signatures" 'test_i18ngrep"ignoring --verify-signatures for rebase"err'+test_expect_success"pull --rebase warns on pull.verifySignatures=true"'+test_configpull.verifySignaturestrue&&+gitreset--hardbefore-rebase&&+gitpull--rebase.copy2>err&&+test"$(gitrev-parseHEAD^)"="$(gitrev-parsecopy)"&&+testnew="$(gitshowHEAD:file2)"&&+test_i18ngrep"ignoring --verify-signatures for rebase"err+'+ test_expect_success"pull --rebase does not warn on --no-verify-signatures"'gitreset--hardbefore-rebase&&gitpull--rebase--no-verify-signatures.copy2>err&&
@@ -424,6 +433,15 @@ test_expect_success "pull --rebase does not warn on --no-verify-signatures" 'test_i18ngrep!"verify-signatures"err'+test_expect_success"pull --rebase does not warn on pull.verifySignatures=false"'+test_configpull.verifySignaturesfalse&&+gitreset--hardbefore-rebase&&+gitpull--rebase.copy2>err&&+test"$(gitrev-parseHEAD^)"="$(gitrev-parsecopy)"&&+testnew="$(gitshowHEAD:file2)"&&+test_i18ngrep!"verify-signatures"err+'+# add a feature branch, keep-merge, that is merged into master, so the# test can try preserving the merge commit (or not) with various# --rebase flags/pull.rebase settings.
@@ -47,22 +47,54 @@ test_expect_success GPG 'pull unsigned commit with --verify-signatures' 'test_i18ngrep"does not have a GPG signature"pullerror'+test_expect_successGPG'pull unsigned commit with pull.verifySignatures=true''+test_configpull.verifySignaturestrue&&+test_must_failgitpull--ff-onlyunsigned2>pullerror&&+test_i18ngrep"does not have a GPG signature"pullerror+'+ test_expect_successGPG'pull commit with bad signature with --verify-signatures''test_must_failgitpull--ff-only--verify-signaturesbad2>pullerror&&test_i18ngrep"has a bad GPG signature"pullerror'+test_expect_successGPG'pull commit with bad signature with pull.verifySignatures=true''+test_configpull.verifySignaturestrue&&+test_must_failgitpull--ff-onlybad2>pullerror&&+test_i18ngrep"has a bad GPG signature"pullerror+'+ test_expect_successGPG'pull commit with untrusted signature with --verify-signatures''test_must_failgitpull--ff-only--verify-signaturesuntrusted2>pullerror&&test_i18ngrep"has an untrusted GPG signature"pullerror'+test_expect_successGPG'pull commit with untrusted signature with pull.verifySignatures=true''+test_configpull.verifySignaturestrue&&+test_must_failgitpull--ff-onlyuntrusted2>pullerror&&+test_i18ngrep"has an untrusted GPG signature"pullerror+'++test_expect_successGPG'pull commit with untrusted signature with pull.verifySignatures=true and merge.verifySignatures=false''+test_configmerge.verifySignaturesfalse&&+test_configpull.verifySignaturestrue&&+test_must_failgitpull--ff-onlyuntrusted2>pullerror&&+test_i18ngrep"has an untrusted GPG signature"pullerror+'+ test_expect_successGPG'pull signed commit with --verify-signatures''gitpull--verify-signaturessigned>pulloutput&&test_i18ngrep"has a good GPG signature"pulloutput&&gitcheckoutinitial'+test_expect_successGPG'pull signed commit with pull.verifySignatures=true''+test_configpull.verifySignaturestrue&&+gitpullsigned>pulloutput&&+test_i18ngrep"has a good GPG signature"pulloutput&&+gitcheckoutinitial+'+ test_expect_successGPG'pull commit with bad signature without verification''gitpull--ff-onlybad2>pullerror&&gitcheckoutinitial
From: Kevin Daudt <hidden> Date: 2017-12-09 12:05:45
Hello Hans Jerry,
Thank you for your contribution. I have soem remarks below.
On Sat, Dec 09, 2017 at 09:05:28AM +0000, Hans Jerry Illikainen wrote:
Verify the signature of the tip commit when `merge.verifySignatures` is
true. This can be overridden with `--no-verify-signatures`.
Signed-off-by: Hans Jerry Illikainen <redacted>
I miss the motivation in the commit message. I imagine something like:
git merge --verify-signatures can be used to verify that the tip
commit of the branch being merged in is properly signed, but it's
cumbersome to have to specify that every time.
Add a configuration option that enables this behaviour by default,
which can be overridden by --no-verify-signatures.
@@ -26,6 +26,13 @@ merge.ff:: allowed (equivalent to giving the `--ff-only` option from the command line).+merge.verifySignatures::+ Verify that the tip commit of the side branch being merged is+ signed with a valid key, i.e. a key that has a valid uid: in the+ default trust model, this means the signing key has been signed+ by a trusted key. If the tip commit of the side branch is not+ signed with a valid key, the merge is aborted.+
This is a verbatim copy of the explenation of --verify-signatures. Would
it be an idea to refer to the explenation of merge --verify-signatures?
@@ -39,23 +39,62 @@ test_expect_success GPG 'merge unsigned commit with verification' 'test_i18ngrep"does not have a GPG signature"mergeerror'+test_expect_successGPG'merge unsigned commit with merge.verifySignatures=true''+test_configmerge.verifySignaturestrue&&+test_must_failgitmerge--ff-onlyside-unsigned2>mergeerror&&+test_i18ngrep"does not have a GPG signature"mergeerror+'+ test_expect_successGPG'merge commit with bad signature with verification''test_must_failgitmerge--ff-only--verify-signatures$(catforged.commit)2>mergeerror&&test_i18ngrep"has a bad GPG signature"mergeerror'+test_expect_successGPG'merge commit with bad signature with merge.verifySignatures=true''+test_configmerge.verifySignaturestrue&&+test_must_failgitmerge--ff-only$(catforged.commit)2>mergeerror&&+test_i18ngrep"has a bad GPG signature"mergeerror+'+ test_expect_successGPG'merge commit with untrusted signature with verification''test_must_failgitmerge--ff-only--verify-signaturesside-untrusted2>mergeerror&&test_i18ngrep"has an untrusted GPG signature"mergeerror'+test_expect_successGPG'merge commit with untrusted signature with merge.verifySignatures=true''+test_configmerge.verifySignaturestrue&&+test_must_failgitmerge--ff-onlyside-untrusted2>mergeerror&&+test_i18ngrep"has an untrusted GPG signature"mergeerror+'+ test_expect_successGPG'merge signed commit with verification''gitmerge--verbose--ff-only--verify-signaturesside-signed>mergeoutput&&-test_i18ngrep"has a good GPG signature"mergeoutput+test_i18ngrep"has a good GPG signature"mergeoutput&&+gitcheckoutinitial
This looks like a clean up step. If so, it's better to add
`test_when_finished 'git checkout initial'` at the beginning to clearly
mark it as a clean up step and make sure it's run even when the test
fails. Same counts for the other occurances.
+'
+
+test_expect_success GPG 'merge signed commit with merge.verifySignatures=true' '
+ test_config merge.verifySignatures true &&
+ git merge --verbose --ff-only side-signed >mergeoutput &&
+ test_i18ngrep "has a good GPG signature" mergeoutput &&
+ git checkout initial
'
test_expect_success GPG 'merge commit with bad signature without verification' '
- git merge $(cat forged.commit)
+ git merge $(cat forged.commit) &&
+ git checkout initial
+'
+
+test_expect_success GPG 'merge commit with bad signature with merge.verifySignatures=false' '
+ test_config merge.verifySignatures false &&
+ git merge $(cat forged.commit) &&
+ git checkout initial
+'
+
+test_expect_success GPG 'merge commit with bad signature with merge.verifySignatures=true and --no-verify-signatures' '
+ test_config merge.verifySignatures true &&
+ git merge --no-verify-signatures $(cat forged.commit) &&
+ git checkout initial
'
test_done
From: Kevin Daudt <hidden> Date: 2017-12-09 12:06:20
On Sat, Dec 09, 2017 at 09:05:29AM +0000, Hans Jerry Illikainen wrote:
Add tests for `pull --verify-signatures` with untrusted, bad and no
signatures. Previously the only test for `--verify-signatures` was to
make sure that `pull --rebase --verify-signatures` result in a warning
(t5520-pull.sh).
Nice!
Same thing regarding the `git checkout initial` commands counts
here too.
quoted hunk
Signed-off-by: Hans Jerry Illikainen <redacted>
---
t/t5573-pull-verify-signatures.sh | 78 +++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
create mode 100755 t/t5573-pull-verify-signatures.sh
@@ -0,0 +1,78 @@+#!/bin/sh++test_description='pull signature verification tests'+../test-lib.sh+."$TEST_DIRECTORY/lib-gpg.sh"++test_expect_successGPG'create repositories with signed commits''+echo1>a&&gitadda&&+test_tick&&gitcommit-minitial&&+gittaginitial&&++gitclone.signed&&+(+cdsigned&&+echo2>b&&gitaddb&&+test_tick&&gitcommit-S-m"signed"+)&&++gitclone.unsigned&&+(+cdunsigned&&+echo3>c&&gitaddc&&+test_tick&&gitcommit-m"unsigned"+)&&++gitclone.bad&&+(+cdbad&&+echo4>d&&gitaddd&&+test_tick&&gitcommit-S-m"bad"&&+gitcat-filecommitHEAD>raw&&+sed-e"s/bad/forged bad/"raw>forged&&+githash-object-w-tcommitforged>forged.commit&&+gitcheckout$(catforged.commit)+)&&++gitclone.untrusted&&+(+cduntrusted&&+echo5>e&&gitadde&&+test_tick&&gitcommit-SB7227189-m"untrusted"+)+'++test_expect_successGPG'pull unsigned commit with --verify-signatures''+test_must_failgitpull--ff-only--verify-signaturesunsigned2>pullerror&&+test_i18ngrep"does not have a GPG signature"pullerror+'++test_expect_successGPG'pull commit with bad signature with --verify-signatures''+test_must_failgitpull--ff-only--verify-signaturesbad2>pullerror&&+test_i18ngrep"has a bad GPG signature"pullerror+'++test_expect_successGPG'pull commit with untrusted signature with --verify-signatures''+test_must_failgitpull--ff-only--verify-signaturesuntrusted2>pullerror&&+test_i18ngrep"has an untrusted GPG signature"pullerror+'++test_expect_successGPG'pull signed commit with --verify-signatures''+gitpull--verify-signaturessigned>pulloutput&&+test_i18ngrep"has a good GPG signature"pulloutput&&+gitcheckoutinitial+'++test_expect_successGPG'pull commit with bad signature without verification''+gitpull--ff-onlybad2>pullerror&&+gitcheckoutinitial+'++test_expect_successGPG'pull commit with bad signature with --no-verify-signatures''+test_configmerge.verifySignaturestrue&&+test_configpull.verifySignaturestrue&&+gitpull--ff-only--no-verify-signaturesbad2>pullerror&&+gitcheckoutinitial+'++test_done
From: Kevin Daudt <hidden> Date: 2017-12-09 12:06:30
On Sat, Dec 09, 2017 at 09:05:30AM +0000, Hans Jerry Illikainen wrote:
Verify the signature of the tip commit when `pull.verifySignatures` is
true. This option overrides `merge.verifySignatures` on pull, and can
be disabled with the option `--no-verify-signatures`.
Is there a reason why git pull would need a different behaviour from git
merge? Pull itself is just a convenience command for fetch +
merge/rebase.
One precedent for having a separate configuration option for pull
however is 'pull.ff', so there might be a usecase for it.
I guess your commit message could use a motivation on why you want to
set this differently from 'merge.verifySignature'.
@@ -2596,6 +2596,14 @@ pull.ff:: allowed (equivalent to giving the `--ff-only` option from the command line). This setting overrides `merge.ff` when pulling.+pull.verifySignatures::+ Verify that the tip commit of the side branch being merged is+ signed with a valid key, i.e. a key that has a valid uid: in the+ default trust model, this means the signing key has been signed+ by a trusted key. If the tip commit of the side branch is not+ signed with a valid key, the merge is aborted. This setting+ overrides `merge.verifySignatures` when pulling.+ pull.rebase:: When true, rebase branches on top of the fetched branch, instead of merging the default branch from the default remote when "git
@@ -416,6 +416,15 @@ test_expect_success "pull --rebase warns on --verify-signatures" 'test_i18ngrep"ignoring --verify-signatures for rebase"err'+test_expect_success"pull --rebase warns on pull.verifySignatures=true"'+test_configpull.verifySignaturestrue&&+gitreset--hardbefore-rebase&&+gitpull--rebase.copy2>err&&+test"$(gitrev-parseHEAD^)"="$(gitrev-parsecopy)"&&+testnew="$(gitshowHEAD:file2)"&&+test_i18ngrep"ignoring --verify-signatures for rebase"err+'+ test_expect_success"pull --rebase does not warn on --no-verify-signatures"'gitreset--hardbefore-rebase&&gitpull--rebase--no-verify-signatures.copy2>err&&
@@ -424,6 +433,15 @@ test_expect_success "pull --rebase does not warn on --no-verify-signatures" 'test_i18ngrep!"verify-signatures"err'+test_expect_success"pull --rebase does not warn on pull.verifySignatures=false"'+test_configpull.verifySignaturesfalse&&+gitreset--hardbefore-rebase&&+gitpull--rebase.copy2>err&&+test"$(gitrev-parseHEAD^)"="$(gitrev-parsecopy)"&&+testnew="$(gitshowHEAD:file2)"&&+test_i18ngrep!"verify-signatures"err+'+# add a feature branch, keep-merge, that is merged into master, so the# test can try preserving the merge commit (or not) with various# --rebase flags/pull.rebase settings.
@@ -47,22 +47,54 @@ test_expect_success GPG 'pull unsigned commit with --verify-signatures' 'test_i18ngrep"does not have a GPG signature"pullerror'+test_expect_successGPG'pull unsigned commit with pull.verifySignatures=true''+test_configpull.verifySignaturestrue&&+test_must_failgitpull--ff-onlyunsigned2>pullerror&&+test_i18ngrep"does not have a GPG signature"pullerror+'+ test_expect_successGPG'pull commit with bad signature with --verify-signatures''test_must_failgitpull--ff-only--verify-signaturesbad2>pullerror&&test_i18ngrep"has a bad GPG signature"pullerror'+test_expect_successGPG'pull commit with bad signature with pull.verifySignatures=true''+test_configpull.verifySignaturestrue&&+test_must_failgitpull--ff-onlybad2>pullerror&&+test_i18ngrep"has a bad GPG signature"pullerror+'+ test_expect_successGPG'pull commit with untrusted signature with --verify-signatures''test_must_failgitpull--ff-only--verify-signaturesuntrusted2>pullerror&&test_i18ngrep"has an untrusted GPG signature"pullerror'+test_expect_successGPG'pull commit with untrusted signature with pull.verifySignatures=true''+test_configpull.verifySignaturestrue&&+test_must_failgitpull--ff-onlyuntrusted2>pullerror&&+test_i18ngrep"has an untrusted GPG signature"pullerror+'++test_expect_successGPG'pull commit with untrusted signature with pull.verifySignatures=true and merge.verifySignatures=false''+test_configmerge.verifySignaturesfalse&&+test_configpull.verifySignaturestrue&&+test_must_failgitpull--ff-onlyuntrusted2>pullerror&&+test_i18ngrep"has an untrusted GPG signature"pullerror+'+ test_expect_successGPG'pull signed commit with --verify-signatures''gitpull--verify-signaturessigned>pulloutput&&test_i18ngrep"has a good GPG signature"pulloutput&&gitcheckoutinitial'+test_expect_successGPG'pull signed commit with pull.verifySignatures=true''+test_configpull.verifySignaturestrue&&+gitpullsigned>pulloutput&&+test_i18ngrep"has a good GPG signature"pulloutput&&+gitcheckoutinitial+'+ test_expect_successGPG'pull commit with bad signature without verification''gitpull--ff-onlybad2>pullerror&&gitcheckoutinitial
From: Hans Jerry Illikainen <hidden> Date: 2017-12-10 06:53:41
On Sat, Dec 09, 2017 at 01:06:23PM +0100, Kevin Daudt wrote:
On Sat, Dec 09, 2017 at 09:05:30AM +0000, Hans Jerry Illikainen wrote:
quoted
Verify the signature of the tip commit when `pull.verifySignatures` is
true. This option overrides `merge.verifySignatures` on pull, and can
be disabled with the option `--no-verify-signatures`.
Is there a reason why git pull would need a different behaviour from git
merge? Pull itself is just a convenience command for fetch +
merge/rebase.
One precedent for having a separate configuration option for pull
however is 'pull.ff', so there might be a usecase for it.
I guess your commit message could use a motivation on why you want to
set this differently from 'merge.verifySignature'.
Thanks for the review! I wasn't sure whether pull.verifySignatures made
sense -- I included it to be consistent with pull.ff/merge.ff, but it's
scrapped in v2.
--
hji
From: Hans Jerry Illikainen <hidden> Date: 2017-12-10 06:53:44
Add tests for pull --verify-signatures with untrusted, bad and no
signatures. Previously the only test for --verify-signatures was to
make sure that pull --rebase --verify-signatures result in a warning
(t5520-pull.sh).
Signed-off-by: Hans Jerry Illikainen <redacted>
---
t/t5573-pull-verify-signatures.sh | 78 +++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
create mode 100755 t/t5573-pull-verify-signatures.sh
@@ -0,0 +1,78 @@+#!/bin/sh++test_description='pull signature verification tests'+../test-lib.sh+."$TEST_DIRECTORY/lib-gpg.sh"++test_expect_successGPG'create repositories with signed commits''+echo1>a&&gitadda&&+test_tick&&gitcommit-minitial&&+gittaginitial&&++gitclone.signed&&+(+cdsigned&&+echo2>b&&gitaddb&&+test_tick&&gitcommit-S-m"signed"+)&&++gitclone.unsigned&&+(+cdunsigned&&+echo3>c&&gitaddc&&+test_tick&&gitcommit-m"unsigned"+)&&++gitclone.bad&&+(+cdbad&&+echo4>d&&gitaddd&&+test_tick&&gitcommit-S-m"bad"&&+gitcat-filecommitHEAD>raw&&+sed-e"s/bad/forged bad/"raw>forged&&+githash-object-w-tcommitforged>forged.commit&&+gitcheckout$(catforged.commit)+)&&++gitclone.untrusted&&+(+cduntrusted&&+echo5>e&&gitadde&&+test_tick&&gitcommit-SB7227189-m"untrusted"+)+'++test_expect_successGPG'pull unsigned commit with --verify-signatures''+test_must_failgitpull--ff-only--verify-signaturesunsigned2>pullerror&&+test_i18ngrep"does not have a GPG signature"pullerror+'++test_expect_successGPG'pull commit with bad signature with --verify-signatures''+test_must_failgitpull--ff-only--verify-signaturesbad2>pullerror&&+test_i18ngrep"has a bad GPG signature"pullerror+'++test_expect_successGPG'pull commit with untrusted signature with --verify-signatures''+test_must_failgitpull--ff-only--verify-signaturesuntrusted2>pullerror&&+test_i18ngrep"has an untrusted GPG signature"pullerror+'++test_expect_successGPG'pull signed commit with --verify-signatures''+test_when_finished"git checkout initial"&&+gitpull--verify-signaturessigned>pulloutput&&+test_i18ngrep"has a good GPG signature"pulloutput+'++test_expect_successGPG'pull commit with bad signature without verification''+test_when_finished"git checkout initial"&&+gitpull--ff-onlybad2>pullerror+'++test_expect_successGPG'pull commit with bad signature with --no-verify-signatures''+test_when_finished"git checkout initial"&&+test_configmerge.verifySignaturestrue&&+test_configpull.verifySignaturestrue&&+gitpull--ff-only--no-verify-signaturesbad2>pullerror+'++test_done
From: Hans Jerry Illikainen <hidden> Date: 2017-12-10 06:53:52
git merge --verify-signatures can be used to verify that the tip commit
of the branch being merged in is properly signed, but it's cumbersome to
have to specify that every time.
Add a configuration option that enables this behaviour by default, which
can be overridden by --no-verify-signatures.
Signed-off-by: Hans Jerry Illikainen <redacted>
---
Documentation/merge-config.txt | 4 ++++
builtin/merge.c | 2 ++
t/t7612-merge-verify-signatures.sh | 39 ++++++++++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+)
@@ -26,6 +26,10 @@ merge.ff:: allowed (equivalent to giving the `--ff-only` option from the command line).+merge.verifySignatures::+ If true, this is equivalent to the --verify-signatures command+ line option. See linkgit:git-merge[1] for details.+ include::fmt-merge-msg-config.txt[] merge.renameLimit::
@@ -39,23 +39,62 @@ test_expect_success GPG 'merge unsigned commit with verification' 'test_i18ngrep"does not have a GPG signature"mergeerror'+test_expect_successGPG'merge unsigned commit with merge.verifySignatures=true''+test_configmerge.verifySignaturestrue&&+test_must_failgitmerge--ff-onlyside-unsigned2>mergeerror&&+test_i18ngrep"does not have a GPG signature"mergeerror+'+ test_expect_successGPG'merge commit with bad signature with verification''test_must_failgitmerge--ff-only--verify-signatures$(catforged.commit)2>mergeerror&&test_i18ngrep"has a bad GPG signature"mergeerror'+test_expect_successGPG'merge commit with bad signature with merge.verifySignatures=true''+test_configmerge.verifySignaturestrue&&+test_must_failgitmerge--ff-only$(catforged.commit)2>mergeerror&&+test_i18ngrep"has a bad GPG signature"mergeerror+'+ test_expect_successGPG'merge commit with untrusted signature with verification''test_must_failgitmerge--ff-only--verify-signaturesside-untrusted2>mergeerror&&test_i18ngrep"has an untrusted GPG signature"mergeerror'+test_expect_successGPG'merge commit with untrusted signature with merge.verifySignatures=true''+test_configmerge.verifySignaturestrue&&+test_must_failgitmerge--ff-onlyside-untrusted2>mergeerror&&+test_i18ngrep"has an untrusted GPG signature"mergeerror+'+ test_expect_successGPG'merge signed commit with verification''+test_when_finished"git checkout initial"&&gitmerge--verbose--ff-only--verify-signaturesside-signed>mergeoutput&&test_i18ngrep"has a good GPG signature"mergeoutput'+test_expect_successGPG'merge signed commit with merge.verifySignatures=true''+test_when_finished"git checkout initial"&&+test_configmerge.verifySignaturestrue&&+gitmerge--verbose--ff-onlyside-signed>mergeoutput&&+test_i18ngrep"has a good GPG signature"mergeoutput+'+ test_expect_successGPG'merge commit with bad signature without verification''+test_when_finished"git checkout initial"&&+gitmerge$(catforged.commit)+'++test_expect_successGPG'merge commit with bad signature with merge.verifySignatures=false''+test_when_finished"git checkout initial"&&+test_configmerge.verifySignaturesfalse&&gitmerge$(catforged.commit)'+test_expect_successGPG'merge commit with bad signature with merge.verifySignatures=true and --no-verify-signatures''+test_when_finished"git checkout initial"&&+test_configmerge.verifySignaturestrue&&+gitmerge--no-verify-signatures$(catforged.commit)+'+ test_done