threads / patch / 41633

v2, 4 partst6302: normalize names and descriptions of signed tags

Subject: [PATCH v2 2/4] t6302: normalize names and descriptions of signed tags

## tl;dr

9 messages between Mar 7, 2016 and Mar 17, 2016. Diffs are folded; open one to read it.

replies: 8people: 2as markdown or json

Eric Sunshine· Mar 7, 2016, 00:10 UTC · lore

[PATCH v2 0/4] make t6302 usable even without GPG installed

This is a re-roll of [1] which aims to allow t6302 to be run even without GPG installed. Changes since v1:

* rather than converting existing signed tags to unsigned, make testing
  of unsigned tags a normal part of the script and just suppress testing
  of signed tags when GPG is missing (Junio)
* new patch: silence redundant warning about missing GPG
[1]: http://thread.gmane.org/gmane.comp.version-control.git/285170
Eric Sunshine (4):
  lib-gpg: drop unnecessary "missing GPG" warning
  t6302: normalize names and descriptions of signed tags
  t6302: also test annotated in addition to signed tags
  t6302: skip only signed tags rather than all tests when GPG is missing
 t/lib-gpg.sh                   |  5 +--
 t/t6302-for-each-ref-filter.sh | 95 ++++++++++++++++++++++++++++--------------
 2 files changed, 65 insertions(+), 35 deletions(-)
-- 
2.8.0.rc1.175.g19dcece
Eric Sunshine· Mar 7, 2016, 00:10 UTC · re: Eric Sunshine · lore

[PATCH v2 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 <sunshine@sunshineco.com>
---

At first I found this warning alarming and then annoying when changing t6302 to skip only signed tag testing (rather than skipping all tests entirely). It does seem like a redundant warning, hence this patch...

I also sneaked in a minor style cleanup.
 t/lib-gpg.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Show changes to t/lib-gpg.sh +2 −3
diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index db2ef22..ec2aa8f 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.
-- 
2.8.0.rc1.175.g19dcece
Eric Sunshine· Mar 15, 2016, 19:50 UTC · re: Johannes Schindelin · lore

Re: [PATCH v2 1/4] lib-gpg: drop unnecessary "missing GPG" warning

On Tue, Mar 15, 2016 at 3:33 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

> On Sun, 6 Mar 2016, Eric Sunshine wrote:
>> I also sneaked in a minor style cleanup.
>
> Isn't this "snuck"?

I'm no grammarian, but [1] says either would be fine (and we know that the Internet never lies).

[1]: http://grammarist.com/usage/sneaked-snuck/
Eric Sunshine· Mar 7, 2016, 00:10 UTC · re: Eric Sunshine · lore

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 <sunshine@sunshineco.com>
---
 t/t6302-for-each-ref-filter.sh | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
Show changes to t/t6302-for-each-ref-filter.sh +15 −15
diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh
index bcf472b..54a7387 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
-- 
2.8.0.rc1.175.g19dcece
Eric Sunshine· Mar 7, 2016, 00:10 UTC · re: Eric Sunshine · lore

[PATCH v2 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 <sunshine@sunshineco.com>
---

Due either to pragmatism or laziness, I plagiarized Junio's v1 review comment[1] for the commit message.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/285170
 t/t6302-for-each-ref-filter.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
Show changes to t/t6302-for-each-ref-filter.sh +25 −0
diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh
index 54a7387..2e28559 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
-- 
2.8.0.rc1.175.g19dcece
Eric Sunshine· Mar 7, 2016, 00:10 UTC · re: Eric Sunshine · lore

[PATCH v2 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 <gitster@pobox.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/t6302-for-each-ref-filter.sh | 44 ++++++++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 19 deletions(-)
Show changes to t/t6302-for-each-ref-filter.sh +25 −19
diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh
index 2e28559..70afb44 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
-- 
2.8.0.rc1.175.g19dcece
Johannes Schindelin· Mar 15, 2016, 19:38 UTC · re: Eric Sunshine · lore

Re: [PATCH v2 0/4] make t6302 usable even without GPG installed

Hi Eric,
On Sun, 6 Mar 2016, Eric Sunshine wrote:
> This is a re-roll of [1] which aims to allow t6302 to be run even
> without GPG installed.

What a beautiful story this patch series tells. Truly a pleasure to review.

Thanks! Dscho

Eric Sunshine· Mar 17, 2016, 07:31 UTC · re: Johannes Schindelin · lore

Re: [PATCH v2 0/4] make t6302 usable even without GPG installed

On Tue, Mar 15, 2016 at 3:38 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 6 quoted lines
> On Sun, 6 Mar 2016, Eric Sunshine wrote:
>> This is a re-roll of [1] which aims to allow t6302 to be run even
>> without GPG installed.
>
> What a beautiful story this patch series tells. Truly a pleasure to
> review.
Thank you for the kind words; I appreciate it.

← back to recent threads