Test that %GR output ("Raw" contents of "gpgsig" header) looks like ASCII-armored GPG signature. Test %G+ (Y/N for presence/absence of "gpgsig" header) by adding it to existing format tests for signed commits. Signed-off-by: John Passaro <john.a.passaro@xxxxxxxxx> --- t/t7510-signed-commit.sh | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh index 86d3f93fa2..aff6b1eb3a 100755 --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@ -177,8 +177,9 @@ test_expect_success GPG 'show good signature with custom format' ' C O Mitter <committer@xxxxxxxxxxx> 73D758744BE721698EC54E8713B6F51ECDDE430D 73D758744BE721698EC54E8713B6F51ECDDE430D + Y EOF - git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" sixth-signed >actual && + git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP%n%G+" sixth-signed >actual && test_cmp expect actual ' @@ -189,8 +190,9 @@ test_expect_success GPG 'show bad signature with custom format' ' C O Mitter <committer@xxxxxxxxxxx> + Y EOF - git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" $(cat forged1.commit) >actual && + git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP%n%G+" $(cat forged1.commit) >actual && test_cmp expect actual ' @@ -201,8 +203,9 @@ test_expect_success GPG 'show untrusted signature with custom format' ' Eris Discordia <discord@xxxxxxxxxxx> F8364A59E07FFE9F4D63005A65A0EEA02E30CAD7 D4BE22311AD3131E5EDA29A461092E85B7227189 + Y EOF - git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual && + git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP%n%G+" eighth-signed-alt >actual && test_cmp expect actual ' @@ -213,8 +216,9 @@ test_expect_success GPG 'show unknown signature with custom format' ' + Y EOF - GNUPGHOME="$GNUPGHOME_NOT_USED" git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" eighth-signed-alt >actual && + GNUPGHOME="$GNUPGHOME_NOT_USED" git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP%n%G+" eighth-signed-alt >actual && test_cmp expect actual ' @@ -225,11 +229,27 @@ test_expect_success GPG 'show lack of signature with custom format' ' + N EOF - git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP" seventh-unsigned >actual && + git log -1 --format="%G?%n%GK%n%GS%n%GF%n%GP%n%G+" seventh-unsigned >actual && test_cmp expect actual ' +test_expect_success GPG 'show lack of raw signature with custom format' ' + git log -1 --format=format:"%GR" seventh-unsigned > actual && + test_must_be_empty actual +' + +test_expect_success GPG 'show raw signature with custom format' ' + git log -1 --format=format:"%GR" sixth-signed >output && + cat output && + head -n1 output | grep -q "^---*BEGIN PGP SIGNATURE---*$" && + sed 1d output | grep -q "^$" && + sed "1,/^$/d" output | grep -q "^[a-zA-Z0-9+/][a-zA-Z0-9+/=]*$" && + tail -n2 output | head -n1 | grep -q "^=[a-zA-Z0-9+/][a-zA-Z0-9+/=]*$" && + tail -n1 output | grep -q "^---*END PGP SIGNATURE---*$" +' + test_expect_success GPG 'log.showsignature behaves like --show-signature' ' test_config log.showsignature true && git show initial >actual && -- 2.19.1