Skip to content

Commit b42ca35

Browse files
SantiagoTorresgitster
authored andcommitted
t7004, t7030: fix here-doc syntax errors
Jan Palus noticed that some here-doc are spelled incorrectly, resulting the entire remainder of the test snippet being slurped into the "expect" file as if it were data, e.g. in this sequence cat >expect <<EOF && ... expectation ... EOF git $cmd_being_tested >actual && test_cmp expect actual the last command of the test is "cat" that sends everything to 'expect' and succeeds. Fixing these issues in t7004 and t7030 reveals that "git tag -v" and "git verify-tag" with their --format option do not work as the test was expecting originally. Instead of showing both valid tags and tags with incorrect signatures on their output, tags that do not pass verification are omitted from the output. Another breakage that is uncovered is that these tests must be restricted to environment where gpg is available. Arguably, that is a safer behaviour, and because the format specifiers like %(tag) do not have a way to show if the signature verifies correctly, the command with the --format option cannot be used to get a list of tags annotated with their signature validity anyway. For now, let's fix the here-doc syntax, update the expectation to match the reality, and update the test prerequisite. Maybe later when we extend the --format language available to "git tag -v" and "git verify-tag" to include things like "%(gpg:status)", we may want to change the behaviour so that piping a list of tag names into xargs git verify-tag --format='%(gpg:status) %(tag)' becomes a good way to produce such a list, but that is a separate topic. Noticed-by: Jan Palus <[email protected]> Helped-by: Jeff King <[email protected]> Signed-off-by: Santiago Torres <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4fea72f commit b42ca35

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

t/t7004-tag.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -847,18 +847,16 @@ test_expect_success GPG 'verifying a forged tag should fail' '
847847
test_must_fail git tag -v forged-tag
848848
'
849849

850-
test_expect_success 'verifying a proper tag with --format pass and format accordingly' '
851-
cat >expect <<-\EOF
850+
test_expect_success GPG 'verifying a proper tag with --format pass and format accordingly' '
851+
cat >expect <<-\EOF &&
852852
tagname : signed-tag
853-
EOF &&
853+
EOF
854854
git tag -v --format="tagname : %(tag)" "signed-tag" >actual &&
855855
test_cmp expect actual
856856
'
857857

858-
test_expect_success 'verifying a forged tag with --format fail and format accordingly' '
859-
cat >expect <<-\EOF
860-
tagname : forged-tag
861-
EOF &&
858+
test_expect_success GPG 'verifying a forged tag with --format should fail silently' '
859+
>expect &&
862860
test_must_fail git tag -v --format="tagname : %(tag)" "forged-tag" >actual &&
863861
test_cmp expect actual
864862
'

t/t7030-verify-tag.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,16 @@ test_expect_success GPG 'verify multiple tags' '
125125
test_cmp expect.stderr actual.stderr
126126
'
127127

128-
test_expect_success 'verifying tag with --format' '
129-
cat >expect <<-\EOF
128+
test_expect_success GPG 'verifying tag with --format' '
129+
cat >expect <<-\EOF &&
130130
tagname : fourth-signed
131-
EOF &&
131+
EOF
132132
git verify-tag --format="tagname : %(tag)" "fourth-signed" >actual &&
133133
test_cmp expect actual
134134
'
135135

136-
test_expect_success 'verifying a forged tag with --format fail and format accordingly' '
137-
cat >expect <<-\EOF
138-
tagname : 7th forged-signed
139-
EOF &&
136+
test_expect_success GPG 'verifying a forged tag with --format should fail silently' '
137+
>expect &&
140138
test_must_fail git verify-tag --format="tagname : %(tag)" $(cat forged1.tag) >actual-forged &&
141139
test_cmp expect actual-forged
142140
'

0 commit comments

Comments
 (0)