Merge branch 'mg/verify-commit'
authorJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2015 20:11:51 +0000 (13:11 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2015 20:11:51 +0000 (13:11 -0700)
Workarounds for certain build of GPG that triggered false breakage
in a test.

* mg/verify-commit:
t7510: do not fail when gpg warns about insecure memory

1  2 
t/t7510-signed-commit.sh
diff --combined t/t7510-signed-commit.sh
index 474dab381aef027207026cb938df7a09cc7a9056,c24d38248aa54ecdfcc90d747ff0abd47e9cb72b..3cef18cfdaa587d12aafec5fe32742f0356fc501
@@@ -43,20 -43,17 +43,20 @@@ test_expect_success GPG 'create signed 
  
        test_tick && git rebase -f HEAD^^ && git tag sixth-signed HEAD^ &&
        git tag seventh-signed
 +
 +      echo 8 >file && test_tick && git commit -a -m eighth -SB7227189 &&
 +      git tag eighth-signed-alt
  '
  
  test_expect_success GPG 'verify and show signatures' '
        (
 -              for commit in initial second merge fourth-signed fifth-signed sixth-signed master
 +              for commit in initial second merge fourth-signed fifth-signed sixth-signed seventh-signed
                do
                        git verify-commit $commit &&
                        git show --pretty=short --show-signature $commit >actual &&
                        grep "Good signature from" actual &&
 -                      ! grep "BAD signature from" actual || exit 1
 -                      echo $commit OK
 +                      ! grep "BAD signature from" actual &&
 +                      echo $commit OK || exit 1
                done
        ) &&
        (
                        test_must_fail git verify-commit $commit &&
                        git show --pretty=short --show-signature $commit >actual &&
                        ! grep "Good signature from" actual &&
 -                      ! grep "BAD signature from" actual || exit 1
 -                      echo $commit OK
 +                      ! grep "BAD signature from" actual &&
 +                      echo $commit OK || exit 1
 +              done
 +      ) &&
 +      (
 +              for commit in eighth-signed-alt
 +              do
 +                      git show --pretty=short --show-signature $commit >actual &&
 +                      grep "Good signature from" actual &&
 +                      ! grep "BAD signature from" actual &&
 +                      grep "not certified" actual &&
 +                      echo $commit OK || exit 1
                done
        )
  '
@@@ -86,8 -73,8 +86,8 @@@ test_expect_success GPG 'show signed co
        git show -s --show-signature initial >show &&
        git verify-commit -v initial >verify.1 2>verify.2 &&
        git cat-file commit initial >cat &&
-       grep -v "gpg: " show >show.commit &&
-       grep "gpg: " show >show.gpg &&
+       grep -v -e "gpg: " -e "Warning: " show >show.commit &&
+       grep -e "gpg: " -e "Warning: " show >show.gpg &&
        grep -v "^ " cat | grep -v "^gpgsig " >cat.commit &&
        test_cmp show.commit commit &&
        test_cmp show.gpg verify.2 &&
@@@ -95,7 -82,7 +95,7 @@@
  '
  
  test_expect_success GPG 'detect fudged signature' '
 -      git cat-file commit master >raw &&
 +      git cat-file commit seventh-signed >raw &&
  
        sed -e "s/seventh/7th forged/" raw >forged1 &&
        git hash-object -w -t commit forged1 >forged1.commit &&
  '
  
  test_expect_success GPG 'detect fudged signature with NUL' '
 -      git cat-file commit master >raw &&
 +      git cat-file commit seventh-signed >raw &&
        cat raw >forged2 &&
        echo Qwik | tr "Q" "\000" >>forged2 &&
        git hash-object -w -t commit forged2 >forged2.commit &&
@@@ -125,44 -112,4 +125,44 @@@ test_expect_success GPG 'amending alrea
        ! grep "BAD signature from" actual
  '
  
 +test_expect_success GPG 'show good signature with custom format' '
 +      cat >expect <<-\EOF &&
 +      G
 +      13B6F51ECDDE430D
 +      C O Mitter <committer@example.com>
 +      EOF
 +      git log -1 --format="%G?%n%GK%n%GS" sixth-signed >actual &&
 +      test_cmp expect actual
 +'
 +
 +test_expect_success GPG 'show bad signature with custom format' '
 +      cat >expect <<-\EOF &&
 +      B
 +      13B6F51ECDDE430D
 +      C O Mitter <committer@example.com>
 +      EOF
 +      git log -1 --format="%G?%n%GK%n%GS" $(cat forged1.commit) >actual &&
 +      test_cmp expect actual
 +'
 +
 +test_expect_success GPG 'show unknown signature with custom format' '
 +      cat >expect <<-\EOF &&
 +      U
 +      61092E85B7227189
 +      Eris Discordia <discord@example.net>
 +      EOF
 +      git log -1 --format="%G?%n%GK%n%GS" eighth-signed-alt >actual &&
 +      test_cmp expect actual
 +'
 +
 +test_expect_success GPG 'show lack of signature with custom format' '
 +      cat >expect <<-\EOF &&
 +      N
 +
 +
 +      EOF
 +      git log -1 --format="%G?%n%GK%n%GS" seventh-unsigned >actual &&
 +      test_cmp expect actual
 +'
 +
  test_done