From f9e9c0d1042779fe25917e9f876e884e42df075e Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Sun, 6 Mar 2016 19:10:24 -0500 Subject: [PATCH 1/4] lib-gpg: drop unnecessary "missing GPG" warning When 37d3e85 (t7004: factor out gpg setup, 2011-09-07) pulled gpg detection code out of t7004-tag.sh and turned it into a standard test prerequisite, it added an unconditional "missing GPG" warning when gpg is not detected. However, this is redundant since all tests which require GPG already warn via either 'test_expect_success GPG' ("skipping: missing GPG") on a test-by-test basis, or when skipping all tests in a script ("skipping all foobar tests; missing GPG"). Consequently, the extra warning from lib-gpg.sh is unnecessary, so retire it. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/lib-gpg.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh index db2ef22e8..ec2aa8f68 100755 --- a/t/lib-gpg.sh +++ b/t/lib-gpg.sh @@ -1,9 +1,8 @@ #!/bin/sh gpg_version=$(gpg --version 2>&1) -if test $? = 127; then - say "You do not seem to have gpg installed" -else +if test $? != 127 +then # As said here: http://www.gnupg.org/documentation/faqs.html#q6.19 # the gpg version 1.0.6 didn't parse trust packets correctly, so for # that version, creation of signed tags using the generated key fails. From ef93c7dbcebecfacaf195d02e54b614926e8c135 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Sun, 6 Mar 2016 19:10:25 -0500 Subject: [PATCH 2/4] t6302: normalize names and descriptions of signed tags An upcoming patch will increase test coverage by testing annotated but not signed tags, as well, so normalize names and descriptions of signed tags to make it easy to give the upcoming unsigned tags similarly patterned names and descriptions. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/t6302-for-each-ref-filter.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh index bcf472bf5..54a7387ce 100755 --- a/t/t6302-for-each-ref-filter.sh +++ b/t/t6302-for-each-ref-filter.sh @@ -17,8 +17,8 @@ test_expect_success 'setup some history and refs' ' test_commit three && git checkout -b side && test_commit four && - git tag -s -m "A signed tag message" signed-tag && - git tag -s -m "Annonated doubly" double-tag signed-tag && + git tag -s -m "A signed tag" signed-tag && + git tag -s -m "Signed doubly" doubly-signed-tag signed-tag && git checkout master && git update-ref refs/odd/spot master ' @@ -58,7 +58,7 @@ test_expect_success 'filtering with --merged' ' test_expect_success 'filtering with --no-merged' ' cat >expect <<-\EOF && refs/heads/side - refs/tags/double-tag + refs/tags/doubly-signed-tag refs/tags/four refs/tags/signed-tag EOF @@ -71,7 +71,7 @@ test_expect_success 'filtering with --contains' ' refs/heads/master refs/heads/side refs/odd/spot - refs/tags/double-tag + refs/tags/doubly-signed-tag refs/tags/four refs/tags/signed-tag refs/tags/three @@ -90,7 +90,7 @@ test_expect_success 'left alignment is default' ' refname is refs/heads/master |refs/heads/master refname is refs/heads/side |refs/heads/side refname is refs/odd/spot |refs/odd/spot - refname is refs/tags/double-tag|refs/tags/double-tag + refname is refs/tags/doubly-signed-tag|refs/tags/doubly-signed-tag refname is refs/tags/four |refs/tags/four refname is refs/tags/one |refs/tags/one refname is refs/tags/signed-tag|refs/tags/signed-tag @@ -106,7 +106,7 @@ test_expect_success 'middle alignment' ' | refname is refs/heads/master |refs/heads/master | refname is refs/heads/side |refs/heads/side | refname is refs/odd/spot |refs/odd/spot - |refname is refs/tags/double-tag|refs/tags/double-tag + |refname is refs/tags/doubly-signed-tag|refs/tags/doubly-signed-tag | refname is refs/tags/four |refs/tags/four | refname is refs/tags/one |refs/tags/one |refname is refs/tags/signed-tag|refs/tags/signed-tag @@ -122,7 +122,7 @@ test_expect_success 'right alignment' ' | refname is refs/heads/master|refs/heads/master | refname is refs/heads/side|refs/heads/side | refname is refs/odd/spot|refs/odd/spot - |refname is refs/tags/double-tag|refs/tags/double-tag + |refname is refs/tags/doubly-signed-tag|refs/tags/doubly-signed-tag | refname is refs/tags/four|refs/tags/four | refname is refs/tags/one|refs/tags/one |refname is refs/tags/signed-tag|refs/tags/signed-tag @@ -137,7 +137,7 @@ cat >expect <<-\EOF | refname is refs/heads/master |refs/heads/master | refname is refs/heads/side |refs/heads/side | refname is refs/odd/spot |refs/odd/spot -| refname is refs/tags/double-tag |refs/tags/double-tag +| refname is refs/tags/doubly-signed-tag |refs/tags/doubly-signed-tag | refname is refs/tags/four |refs/tags/four | refname is refs/tags/one |refs/tags/one | refname is refs/tags/signed-tag |refs/tags/signed-tag @@ -182,7 +182,7 @@ test_expect_success 'alignment with format quote' " |' '\''master| A U Thor'\'' '| |' '\''side| A U Thor'\'' '| |' '\''odd/spot| A U Thor'\'' '| - |' '\''double-tag| '\'' '| + |' '\''doubly-signed-tag| '\'' '| |' '\''four| A U Thor'\'' '| |' '\''one| A U Thor'\'' '| |' '\''signed-tag| '\'' '| @@ -198,7 +198,7 @@ test_expect_success 'nested alignment with quote formatting' " |' master '| |' side '| |' odd/spot '| - |' double-tag '| + |'doubly-signed-tag '| |' four '| |' one '| |' signed-tag '| @@ -214,10 +214,10 @@ test_expect_success 'check `%(contents:lines=1)`' ' master |three side |four odd/spot |three - double-tag |Annonated doubly + doubly-signed-tag |Signed doubly four |four one |one - signed-tag |A signed tag message + signed-tag |A signed tag three |three two |two EOF @@ -230,7 +230,7 @@ test_expect_success 'check `%(contents:lines=0)`' ' master | side | odd/spot | - double-tag | + doubly-signed-tag | four | one | signed-tag | @@ -246,10 +246,10 @@ test_expect_success 'check `%(contents:lines=99999)`' ' master |three side |four odd/spot |three - double-tag |Annonated doubly + doubly-signed-tag |Signed doubly four |four one |one - signed-tag |A signed tag message + signed-tag |A signed tag three |three two |two EOF From 7bc734eed2f3cc4cd171aaaac9ffff8b047c3896 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Sun, 6 Mar 2016 19:10:26 -0500 Subject: [PATCH 3/4] t6302: also test annotated in addition to signed tags It is conceivable, if not highly plausible, that a change to the git-for-each-ref code that does the filtering and formatting can become buggy because a payload with GPG signature looks somewhat different from what is in an annotated but not signed tag. Thus, let's test unsigned tags, as well. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/t6302-for-each-ref-filter.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh index 54a7387ce..2e28559c1 100755 --- a/t/t6302-for-each-ref-filter.sh +++ b/t/t6302-for-each-ref-filter.sh @@ -17,6 +17,8 @@ test_expect_success 'setup some history and refs' ' test_commit three && git checkout -b side && test_commit four && + git tag -m "An annotated tag" annotated-tag && + git tag -m "Annonated doubly" doubly-annotated-tag annotated-tag && git tag -s -m "A signed tag" signed-tag && git tag -s -m "Signed doubly" doubly-signed-tag signed-tag && git checkout master && @@ -36,6 +38,7 @@ test_expect_success 'filtering with --points-at' ' test_expect_success 'check signed tags with --points-at' ' sed -e "s/Z$//" >expect <<-\EOF && refs/heads/side Z + refs/tags/annotated-tag four refs/tags/four Z refs/tags/signed-tag four EOF @@ -58,6 +61,8 @@ test_expect_success 'filtering with --merged' ' test_expect_success 'filtering with --no-merged' ' cat >expect <<-\EOF && refs/heads/side + refs/tags/annotated-tag + refs/tags/doubly-annotated-tag refs/tags/doubly-signed-tag refs/tags/four refs/tags/signed-tag @@ -71,6 +76,8 @@ test_expect_success 'filtering with --contains' ' refs/heads/master refs/heads/side refs/odd/spot + refs/tags/annotated-tag + refs/tags/doubly-annotated-tag refs/tags/doubly-signed-tag refs/tags/four refs/tags/signed-tag @@ -90,6 +97,8 @@ test_expect_success 'left alignment is default' ' refname is refs/heads/master |refs/heads/master refname is refs/heads/side |refs/heads/side refname is refs/odd/spot |refs/odd/spot + refname is refs/tags/annotated-tag|refs/tags/annotated-tag + refname is refs/tags/doubly-annotated-tag|refs/tags/doubly-annotated-tag refname is refs/tags/doubly-signed-tag|refs/tags/doubly-signed-tag refname is refs/tags/four |refs/tags/four refname is refs/tags/one |refs/tags/one @@ -106,6 +115,8 @@ test_expect_success 'middle alignment' ' | refname is refs/heads/master |refs/heads/master | refname is refs/heads/side |refs/heads/side | refname is refs/odd/spot |refs/odd/spot + |refname is refs/tags/annotated-tag|refs/tags/annotated-tag + |refname is refs/tags/doubly-annotated-tag|refs/tags/doubly-annotated-tag |refname is refs/tags/doubly-signed-tag|refs/tags/doubly-signed-tag | refname is refs/tags/four |refs/tags/four | refname is refs/tags/one |refs/tags/one @@ -122,6 +133,8 @@ test_expect_success 'right alignment' ' | refname is refs/heads/master|refs/heads/master | refname is refs/heads/side|refs/heads/side | refname is refs/odd/spot|refs/odd/spot + |refname is refs/tags/annotated-tag|refs/tags/annotated-tag + |refname is refs/tags/doubly-annotated-tag|refs/tags/doubly-annotated-tag |refname is refs/tags/doubly-signed-tag|refs/tags/doubly-signed-tag | refname is refs/tags/four|refs/tags/four | refname is refs/tags/one|refs/tags/one @@ -137,6 +150,8 @@ cat >expect <<-\EOF | refname is refs/heads/master |refs/heads/master | refname is refs/heads/side |refs/heads/side | refname is refs/odd/spot |refs/odd/spot +| refname is refs/tags/annotated-tag |refs/tags/annotated-tag +|refname is refs/tags/doubly-annotated-tag |refs/tags/doubly-annotated-tag | refname is refs/tags/doubly-signed-tag |refs/tags/doubly-signed-tag | refname is refs/tags/four |refs/tags/four | refname is refs/tags/one |refs/tags/one @@ -182,6 +197,8 @@ test_expect_success 'alignment with format quote' " |' '\''master| A U Thor'\'' '| |' '\''side| A U Thor'\'' '| |' '\''odd/spot| A U Thor'\'' '| + |' '\''annotated-tag| '\'' '| + |' '\''doubly-annotated-tag| '\'' '| |' '\''doubly-signed-tag| '\'' '| |' '\''four| A U Thor'\'' '| |' '\''one| A U Thor'\'' '| @@ -198,6 +215,8 @@ test_expect_success 'nested alignment with quote formatting' " |' master '| |' side '| |' odd/spot '| + |' annotated-tag '| + |'doubly-annotated-tag '| |'doubly-signed-tag '| |' four '| |' one '| @@ -214,6 +233,8 @@ test_expect_success 'check `%(contents:lines=1)`' ' master |three side |four odd/spot |three + annotated-tag |An annotated tag + doubly-annotated-tag |Annonated doubly doubly-signed-tag |Signed doubly four |four one |one @@ -230,6 +251,8 @@ test_expect_success 'check `%(contents:lines=0)`' ' master | side | odd/spot | + annotated-tag | + doubly-annotated-tag | doubly-signed-tag | four | one | @@ -246,6 +269,8 @@ test_expect_success 'check `%(contents:lines=99999)`' ' master |three side |four odd/spot |three + annotated-tag |An annotated tag + doubly-annotated-tag |Annonated doubly doubly-signed-tag |Signed doubly four |four one |one From 618310a3df8ddcbb33114c56b659056843c06626 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Sun, 6 Mar 2016 19:10:27 -0500 Subject: [PATCH 4/4] t6302: skip only signed tags rather than all tests when GPG is missing The primary purpose of these tests is to check filtering, sorting, and formatting behavior of git-for-each-ref, so it is unfortunate that the entire test script is skipped when GPG is not present. Rather than skipping all tests, let's instead just skip testing against signed tags when GPG is missing. Helped-by: Junio C Hamano Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/t6302-for-each-ref-filter.sh | 44 +++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh index 2e28559c1..70afb4427 100755 --- a/t/t6302-for-each-ref-filter.sh +++ b/t/t6302-for-each-ref-filter.sh @@ -5,11 +5,14 @@ test_description='test for-each-refs usage of ref-filter APIs' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh -if ! test_have_prereq GPG -then - skip_all="skipping for-each-ref tests, GPG not available" - test_done -fi +test_prepare_expect () { + if test_have_prereq GPG + then + cat + else + sed '/signed/d' + fi +} test_expect_success 'setup some history and refs' ' test_commit one && @@ -19,8 +22,11 @@ test_expect_success 'setup some history and refs' ' test_commit four && git tag -m "An annotated tag" annotated-tag && git tag -m "Annonated doubly" doubly-annotated-tag annotated-tag && - git tag -s -m "A signed tag" signed-tag && - git tag -s -m "Signed doubly" doubly-signed-tag signed-tag && + if test_have_prereq GPG + then + git tag -s -m "A signed tag" signed-tag && + git tag -s -m "Signed doubly" doubly-signed-tag signed-tag + fi && git checkout master && git update-ref refs/odd/spot master ' @@ -36,7 +42,7 @@ test_expect_success 'filtering with --points-at' ' ' test_expect_success 'check signed tags with --points-at' ' - sed -e "s/Z$//" >expect <<-\EOF && + test_prepare_expect <<-\EOF | sed -e "s/Z$//" >expect && refs/heads/side Z refs/tags/annotated-tag four refs/tags/four Z @@ -59,7 +65,7 @@ test_expect_success 'filtering with --merged' ' ' test_expect_success 'filtering with --no-merged' ' - cat >expect <<-\EOF && + test_prepare_expect >expect <<-\EOF && refs/heads/side refs/tags/annotated-tag refs/tags/doubly-annotated-tag @@ -72,7 +78,7 @@ test_expect_success 'filtering with --no-merged' ' ' test_expect_success 'filtering with --contains' ' - cat >expect <<-\EOF && + test_prepare_expect >expect <<-\EOF && refs/heads/master refs/heads/side refs/odd/spot @@ -93,7 +99,7 @@ test_expect_success '%(color) must fail' ' ' test_expect_success 'left alignment is default' ' - cat >expect <<-\EOF && + test_prepare_expect >expect <<-\EOF && refname is refs/heads/master |refs/heads/master refname is refs/heads/side |refs/heads/side refname is refs/odd/spot |refs/odd/spot @@ -111,7 +117,7 @@ test_expect_success 'left alignment is default' ' ' test_expect_success 'middle alignment' ' - cat >expect <<-\EOF && + test_prepare_expect >expect <<-\EOF && | refname is refs/heads/master |refs/heads/master | refname is refs/heads/side |refs/heads/side | refname is refs/odd/spot |refs/odd/spot @@ -129,7 +135,7 @@ test_expect_success 'middle alignment' ' ' test_expect_success 'right alignment' ' - cat >expect <<-\EOF && + test_prepare_expect >expect <<-\EOF && | refname is refs/heads/master|refs/heads/master | refname is refs/heads/side|refs/heads/side | refname is refs/odd/spot|refs/odd/spot @@ -146,7 +152,7 @@ test_expect_success 'right alignment' ' test_cmp expect actual ' -cat >expect <<-\EOF +test_prepare_expect >expect <<-\EOF | refname is refs/heads/master |refs/heads/master | refname is refs/heads/side |refs/heads/side | refname is refs/odd/spot |refs/odd/spot @@ -193,7 +199,7 @@ EOF # Individual atoms inside %(align:...) and %(end) must not be quoted. test_expect_success 'alignment with format quote' " - cat >expect <<-\EOF && + test_prepare_expect >expect <<-\EOF && |' '\''master| A U Thor'\'' '| |' '\''side| A U Thor'\'' '| |' '\''odd/spot| A U Thor'\'' '| @@ -211,7 +217,7 @@ test_expect_success 'alignment with format quote' " " test_expect_success 'nested alignment with quote formatting' " - cat >expect <<-\EOF && + test_prepare_expect >expect <<-\EOF && |' master '| |' side '| |' odd/spot '| @@ -229,7 +235,7 @@ test_expect_success 'nested alignment with quote formatting' " " test_expect_success 'check `%(contents:lines=1)`' ' - cat >expect <<-\EOF && + test_prepare_expect >expect <<-\EOF && master |three side |four odd/spot |three @@ -247,7 +253,7 @@ test_expect_success 'check `%(contents:lines=1)`' ' ' test_expect_success 'check `%(contents:lines=0)`' ' - cat >expect <<-\EOF && + test_prepare_expect >expect <<-\EOF && master | side | odd/spot | @@ -265,7 +271,7 @@ test_expect_success 'check `%(contents:lines=0)`' ' ' test_expect_success 'check `%(contents:lines=99999)`' ' - cat >expect <<-\EOF && + test_prepare_expect >expect <<-\EOF && master |three side |four odd/spot |three