* [PATCH v4 0/8] t7004: Modernize the style
@ 2024-08-05 23:59 AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 1/8] [Newcomer] t7004: Remove space after redirect operators AbdAlRahman Gad
` (8 more replies)
0 siblings, 9 replies; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-05 23:59 UTC (permalink / raw)
To: git; +Cc: AbdAlRahman Gad
- Remove whitespace after the redirect operators.
- Move number of expect files prepared outside of
test_expect_success to be inside the tests that use it.
- Split some lines that have two commands into two lines
one command each.
- Turn some "<<\EOF" into "<<-\EOF" and indent their body.
- Avoid using pipes in the output from "test-tool ref-store"
and write the output to a file.
- Change test_expect_success that are seperated from its name
to be on the same line.
- Avoid separating test Description and test body with backslash
- Use single quotes instead of double quotes for test description and
body.
AbdAlRahman Gad (8):
[Newcomer] t7004: Remove space after redirect operators
[Newcomer] t7004: Do not lose exit status to pipe
[Newcomer] t7004: One command per line
[Newcomer] t7004: Do not prepare things outside test_expect_success
[Newcomer] t7004: Use indented here-doc
[Newcomer] t7004: Description on the same line as test_expect_success
[Newcomer] t7004: Description and test body seperated with backslash
[Newcomer] t7004: Use single quotes instead of double quotes
t/t7004-tag.sh | 1154 +++++++++++++++++++++++-------------------------
1 file changed, 557 insertions(+), 597 deletions(-)
base-commit: 406f326d271e0bacecdb00425422c5fa3f314930
--
2.43.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 1/8] [Newcomer] t7004: Remove space after redirect operators
2024-08-05 23:59 [PATCH v4 0/8] t7004: Modernize the style AbdAlRahman Gad
@ 2024-08-05 23:59 ` AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 2/8] [Newcomer] t7004: Do not lose exit status to pipe AbdAlRahman Gad
` (7 subsequent siblings)
8 siblings, 0 replies; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-05 23:59 UTC (permalink / raw)
To: git; +Cc: AbdAlRahman Gad
Modernize 't7004' by removing whitespace after redirect operators.
Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
---
t/t7004-tag.sh | 50 +++++++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index fa6336edf9..3100a4c219 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -213,9 +213,9 @@ mytag
EOF
test_expect_success \
'trying to delete tags without params should succeed and do nothing' '
- git tag -l > actual && test_cmp expect actual &&
+ git tag -l >actual && test_cmp expect actual &&
git tag -d &&
- git tag -l > actual && test_cmp expect actual
+ git tag -l >actual && test_cmp expect actual
'
test_expect_success \
@@ -269,9 +269,9 @@ test_expect_success 'listing all tags should print them ordered' '
git tag a1 &&
git tag v1.0 &&
git tag t210 &&
- git tag -l > actual &&
+ git tag -l >actual &&
test_cmp expect actual &&
- git tag > actual &&
+ git tag >actual &&
test_cmp expect actual
'
@@ -283,7 +283,7 @@ EOF
test_expect_success \
'listing tags with substring as pattern must print those matching' '
rm *a* &&
- git tag -l "*a*" > current &&
+ git tag -l "*a*" >current &&
test_cmp expect current
'
@@ -293,7 +293,7 @@ v1.0.1
EOF
test_expect_success \
'listing tags with a suffix as pattern must print those matching' '
- git tag -l "*.1" > actual &&
+ git tag -l "*.1" >actual &&
test_cmp expect actual
'
@@ -303,7 +303,7 @@ t211
EOF
test_expect_success \
'listing tags with a prefix as pattern must print those matching' '
- git tag -l "t21*" > actual &&
+ git tag -l "t21*" >actual &&
test_cmp expect actual
'
@@ -312,7 +312,7 @@ a1
EOF
test_expect_success \
'listing tags using a name as pattern must print that one matching' '
- git tag -l a1 > actual &&
+ git tag -l a1 >actual &&
test_cmp expect actual
'
@@ -321,7 +321,7 @@ v1.0
EOF
test_expect_success \
'listing tags using a name as pattern must print that one matching' '
- git tag -l v1.0 > actual &&
+ git tag -l v1.0 >actual &&
test_cmp expect actual
'
@@ -331,13 +331,13 @@ v1.1.3
EOF
test_expect_success \
'listing tags with ? in the pattern should print those matching' '
- git tag -l "v1.?.?" > actual &&
+ git tag -l "v1.?.?" >actual &&
test_cmp expect actual
'
test_expect_success \
'listing tags using v.* should print nothing because none have v.' '
- git tag -l "v.*" > actual &&
+ git tag -l "v.*" >actual &&
test_must_be_empty actual
'
@@ -349,7 +349,7 @@ v1.1.3
EOF
test_expect_success \
'listing tags using v* should print only those having v' '
- git tag -l "v*" > actual &&
+ git tag -l "v*" >actual &&
test_cmp expect actual
'
@@ -1171,7 +1171,7 @@ test_expect_success GPG \
git tag -v emptyfile-signed-tag
'
-printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile
+printf '\n\n \n\t\nLeading blank lines\n' >sigblanksfile
printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile
printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile
printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
@@ -1569,7 +1569,7 @@ test_expect_success \
test_expect_success \
'message in editor has initial comment' '
- ! (GIT_EDITOR=cat git tag -a initial-comment > actual)
+ ! (GIT_EDITOR=cat git tag -a initial-comment >actual)
'
test_expect_success 'message in editor has initial comment: first line' '
@@ -1587,7 +1587,7 @@ test_expect_success \
'
get_tag_header reuse $commit commit $time >expect
-echo "An annotation to be reused" >> expect
+echo "An annotation to be reused" >>expect
test_expect_success \
'overwriting an annotated tag should use its previous body' '
git tag -a -m "An annotation to be reused" reuse &&
@@ -1639,7 +1639,7 @@ hash3=$(git rev-parse HEAD)
# simple linear checks of --continue
-cat > expected <<EOF
+cat >expected <<EOF
v0.2.1
v1.0
v1.0.1
@@ -1679,7 +1679,7 @@ test_expect_success 'checking that first commit is in all tags (relative)' "
test_must_be_empty actual
"
-cat > expected <<EOF
+cat >expected <<EOF
v2.0
EOF
@@ -1688,7 +1688,7 @@ test_expect_success 'checking that second commit only has one tag' "
test_cmp expected actual
"
-cat > expected <<EOF
+cat >expected <<EOF
v0.2.1
v1.0
v1.0.1
@@ -1705,7 +1705,7 @@ test_expect_success 'checking that third commit has no tags' "
test_must_be_empty actual
"
-cat > expected <<EOF
+cat >expected <<EOF
v0.2.1
v1.0
v1.0.1
@@ -1723,14 +1723,14 @@ test_expect_success 'conversely --no-contains on the third commit lists all tags
test_expect_success 'creating simple branch' '
git branch stable v2.0 &&
git checkout stable &&
- echo foo-3.0 > foo &&
+ echo foo-3.0 >foo &&
git commit foo -m fourth &&
git tag v3.0
'
hash4=$(git rev-parse HEAD)
-cat > expected <<EOF
+cat >expected <<EOF
v3.0
EOF
@@ -1739,7 +1739,7 @@ test_expect_success 'checking that branch head only has one tag' "
test_cmp expected actual
"
-cat > expected <<EOF
+cat >expected <<EOF
v0.2.1
v1.0
v1.0.1
@@ -1757,7 +1757,7 @@ test_expect_success 'merging original branch into this branch' '
git tag v4.0
'
-cat > expected <<EOF
+cat >expected <<EOF
v4.0
EOF
@@ -1766,7 +1766,7 @@ test_expect_success 'checking that original branch head has one tag now' "
test_cmp expected actual
"
-cat > expected <<EOF
+cat >expected <<EOF
v0.2.1
v1.0
v1.0.1
@@ -1780,7 +1780,7 @@ test_expect_success 'checking that original branch head with --no-contains lists
test_cmp expected actual
"
-cat > expected <<EOF
+cat >expected <<EOF
v0.2.1
v1.0
v1.0.1
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v4 2/8] [Newcomer] t7004: Do not lose exit status to pipe
2024-08-05 23:59 [PATCH v4 0/8] t7004: Modernize the style AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 1/8] [Newcomer] t7004: Remove space after redirect operators AbdAlRahman Gad
@ 2024-08-05 23:59 ` AbdAlRahman Gad
2024-08-06 3:13 ` Eric Sunshine
2024-08-05 23:59 ` [PATCH v4 3/8] [Newcomer] t7004: One command per line AbdAlRahman Gad
` (6 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-05 23:59 UTC (permalink / raw)
To: git; +Cc: AbdAlRahman Gad
Split "test-tool ... | sed" pipeline into two commands to avoid losing
exit status from test-tool.
Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
---
t/t7004-tag.sh | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 3100a4c219..1e31f39646 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -97,7 +97,8 @@ test_expect_success 'creating a tag with --create-reflog should create reflog' '
test_when_finished "git tag -d tag_with_reflog1" &&
git tag --create-reflog tag_with_reflog1 &&
git reflog exists refs/tags/tag_with_reflog1 &&
- test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 | sed -e "s/^.* //" >actual &&
+ test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 >actual.body &&
+ sed -e "s/^.* //" actual.body >actual &&
test_cmp expected actual
'
@@ -108,7 +109,8 @@ test_expect_success 'annotated tag with --create-reflog has correct message' '
test_when_finished "git tag -d tag_with_reflog2" &&
git tag -m "annotated tag" --create-reflog tag_with_reflog2 &&
git reflog exists refs/tags/tag_with_reflog2 &&
- test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog2 | sed -e "s/^.* //" >actual &&
+ test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog2 >actual.body &&
+ sed -e "s/^.* //" actual.body >actual &&
test_cmp expected actual
'
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v4 3/8] [Newcomer] t7004: One command per line
2024-08-05 23:59 [PATCH v4 0/8] t7004: Modernize the style AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 1/8] [Newcomer] t7004: Remove space after redirect operators AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 2/8] [Newcomer] t7004: Do not lose exit status to pipe AbdAlRahman Gad
@ 2024-08-05 23:59 ` AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 4/8] [Newcomer] t7004: Do not prepare things outside test_expect_success AbdAlRahman Gad
` (5 subsequent siblings)
8 siblings, 0 replies; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-05 23:59 UTC (permalink / raw)
To: git; +Cc: AbdAlRahman Gad
One of the tests in t7004 has multiple commands on a single line,
which is discouraged. Adapt these by splitting up these into one
line per command.
Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
---
t/t7004-tag.sh | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 1e31f39646..cfe7653317 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -215,9 +215,11 @@ mytag
EOF
test_expect_success \
'trying to delete tags without params should succeed and do nothing' '
- git tag -l >actual && test_cmp expect actual &&
+ git tag -l >actual &&
+ test_cmp expect actual &&
git tag -d &&
- git tag -l >actual && test_cmp expect actual
+ git tag -l >actual &&
+ test_cmp expect actual
'
test_expect_success \
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v4 4/8] [Newcomer] t7004: Do not prepare things outside test_expect_success
2024-08-05 23:59 [PATCH v4 0/8] t7004: Modernize the style AbdAlRahman Gad
` (2 preceding siblings ...)
2024-08-05 23:59 ` [PATCH v4 3/8] [Newcomer] t7004: One command per line AbdAlRahman Gad
@ 2024-08-05 23:59 ` AbdAlRahman Gad
2024-08-06 3:29 ` Eric Sunshine
2024-08-05 23:59 ` [PATCH v4 5/8] [Newcomer] t7004: Use indented here-doc AbdAlRahman Gad
` (4 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-05 23:59 UTC (permalink / raw)
To: git; +Cc: AbdAlRahman Gad
Do not prepare expect and other things outside test_expect_success.
Also add '\' before EOF to avoid shell interpolation and '-' to allow
indentation of the body.
Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
---
t/t7004-tag.sh | 698 +++++++++++++++++++++++++------------------------
1 file changed, 360 insertions(+), 338 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index cfe7653317..b9fe58fbee 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -131,10 +131,10 @@ test_expect_success 'listing all tags if one exists should succeed' '
git tag
'
-cat >expect <<EOF
-mytag
-EOF
test_expect_success 'Multiple -l or --list options are equivalent to one -l option' '
+ cat >expect <<-\EOF &&
+ mytag
+ EOF
git tag -l -l >actual &&
test_cmp expect actual &&
git tag --list --list >actual &&
@@ -209,12 +209,12 @@ test_expect_success 'trying to delete an unknown tag should fail' '
test_must_fail git tag -d unknown-tag
'
-cat >expect <<EOF
-myhead
-mytag
-EOF
test_expect_success \
'trying to delete tags without params should succeed and do nothing' '
+ cat >expect <<-\EOF &&
+ myhead
+ mytag
+ EOF
git tag -l >actual &&
test_cmp expect actual &&
git tag -d &&
@@ -252,18 +252,18 @@ test_expect_success 'trying to delete an already deleted tag should fail' \
# listing various tags with pattern matching:
-cat >expect <<EOF
-a1
-aa1
-cba
-t210
-t211
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-EOF
test_expect_success 'listing all tags should print them ordered' '
+ cat >expect <<-\EOF &&
+ a1
+ aa1
+ cba
+ t210
+ t211
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ EOF
git tag v1.0.1 &&
git tag t211 &&
git tag aa1 &&
@@ -279,62 +279,62 @@ test_expect_success 'listing all tags should print them ordered' '
test_cmp expect actual
'
-cat >expect <<EOF
-a1
-aa1
-cba
-EOF
test_expect_success \
'listing tags with substring as pattern must print those matching' '
+ cat >expect <<-\EOF &&
+ a1
+ aa1
+ cba
+ EOF
rm *a* &&
git tag -l "*a*" >current &&
test_cmp expect current
'
-cat >expect <<EOF
-v0.2.1
-v1.0.1
-EOF
test_expect_success \
'listing tags with a suffix as pattern must print those matching' '
+ cat >expect <<-\EOF &&
+ v0.2.1
+ v1.0.1
+ EOF
git tag -l "*.1" >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-t210
-t211
-EOF
test_expect_success \
'listing tags with a prefix as pattern must print those matching' '
+ cat >expect <<-\EOF &&
+ t210
+ t211
+ EOF
git tag -l "t21*" >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-a1
-EOF
test_expect_success \
'listing tags using a name as pattern must print that one matching' '
+ cat >expect <<-\EOF &&
+ a1
+ EOF
git tag -l a1 >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-v1.0
-EOF
test_expect_success \
'listing tags using a name as pattern must print that one matching' '
+ cat >expect <<-\EOF &&
+ v1.0
+ EOF
git tag -l v1.0 >actual &&
test_cmp expect actual
'
-cat >expect <<EOF
-v1.0.1
-v1.1.3
-EOF
test_expect_success \
'listing tags with ? in the pattern should print those matching' '
+ cat >expect <<-\EOF &&
+ v1.0.1
+ v1.1.3
+ EOF
git tag -l "v1.?.?" >actual &&
test_cmp expect actual
'
@@ -345,19 +345,25 @@ test_expect_success \
test_must_be_empty actual
'
-cat >expect <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-EOF
test_expect_success \
'listing tags using v* should print only those having v' '
+ cat >expect <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ EOF
git tag -l "v*" >actual &&
test_cmp expect actual
'
test_expect_success 'tag -l can accept multiple patterns' '
+ cat >expect <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ EOF
git tag -l "v1*" "v0*" >actual &&
test_cmp expect actual
'
@@ -371,6 +377,12 @@ test_expect_success 'tag -l can accept multiple patterns' '
# out if we're going to break this long-documented form of taking
# multiple patterns.
test_expect_success 'tag -l <pattern> -l <pattern> works, as our buggy documentation previously suggested' '
+ cat >expect <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ EOF
git tag -l "v1*" -l "v0*" >actual &&
test_cmp expect actual
'
@@ -453,68 +465,69 @@ tagger C O Mitter <committer@example.com> $4 -0700
EOF
}
-commit=$(git rev-parse HEAD)
-time=$test_tick
-
-get_tag_header annotated-tag $commit commit $time >expect
-echo "A message" >>expect
test_expect_success \
'creating an annotated tag with -m message should succeed' '
+ commit=$(git rev-parse HEAD) &&
+ time=$test_tick &&
+ get_tag_header annotated-tag $commit commit $time >expect &&
+ echo "A message" >>expect &&
git tag -m "A message" annotated-tag &&
get_tag_msg annotated-tag >actual &&
test_cmp expect actual
'
-get_tag_header annotated-tag-edit $commit commit $time >expect
-echo "An edited message" >>expect
test_expect_success 'set up editor' '
write_script fakeeditor <<-\EOF
sed -e "s/A message/An edited message/g" <"$1" >"$1-"
mv "$1-" "$1"
EOF
'
+
test_expect_success \
'creating an annotated tag with -m message --edit should succeed' '
+ get_tag_header annotated-tag-edit $commit commit $time >expect &&
+ echo "An edited message" >>expect &&
GIT_EDITOR=./fakeeditor git tag -m "A message" --edit annotated-tag-edit &&
get_tag_msg annotated-tag-edit >actual &&
test_cmp expect actual
'
-cat >msgfile <<EOF
-Another message
-in a file.
-EOF
-get_tag_header file-annotated-tag $commit commit $time >expect
-cat msgfile >>expect
test_expect_success \
'creating an annotated tag with -F messagefile should succeed' '
+ cat >msgfile <<-\EOF &&
+ Another message
+ in a file.
+ EOF
+ get_tag_header file-annotated-tag $commit commit $time >expect &&
+ cat msgfile >>expect &&
git tag -F msgfile file-annotated-tag &&
get_tag_msg file-annotated-tag >actual &&
test_cmp expect actual
'
-get_tag_header file-annotated-tag-edit $commit commit $time >expect
-sed -e "s/Another message/Another edited message/g" msgfile >>expect
test_expect_success 'set up editor' '
write_script fakeeditor <<-\EOF
sed -e "s/Another message/Another edited message/g" <"$1" >"$1-"
mv "$1-" "$1"
EOF
'
+
test_expect_success \
'creating an annotated tag with -F messagefile --edit should succeed' '
+ get_tag_header file-annotated-tag-edit $commit commit $time >expect &&
+ sed -e "s/Another message/Another edited message/g" msgfile >>expect &&
GIT_EDITOR=./fakeeditor git tag -F msgfile --edit file-annotated-tag-edit &&
get_tag_msg file-annotated-tag-edit >actual &&
test_cmp expect actual
'
-cat >inputmsg <<EOF
-A message from the
-standard input
-EOF
-get_tag_header stdin-annotated-tag $commit commit $time >expect
-cat inputmsg >>expect
test_expect_success 'creating an annotated tag with -F - should succeed' '
+ cat >inputmsg <<-\EOF &&
+ A message from the
+ standard input
+ EOF
+ get_tag_header stdin-annotated-tag $commit commit $time >expect &&
+ cat inputmsg >>expect &&
git tag -F - stdin-annotated-tag <inputmsg &&
get_tag_msg stdin-annotated-tag >actual &&
test_cmp expect actual
@@ -543,67 +556,67 @@ test_expect_success \
# blank and empty messages:
-get_tag_header empty-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with an empty -m message should succeed' '
+ get_tag_header empty-annotated-tag $commit commit $time >expect &&
git tag -m "" empty-annotated-tag &&
get_tag_msg empty-annotated-tag >actual &&
test_cmp expect actual
'
->emptyfile
-get_tag_header emptyfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with an empty -F messagefile should succeed' '
+ >emptyfile &&
+ get_tag_header emptyfile-annotated-tag $commit commit $time >expect &&
git tag -F emptyfile emptyfile-annotated-tag &&
get_tag_msg emptyfile-annotated-tag >actual &&
test_cmp expect actual
'
-printf '\n\n \n\t\nLeading blank lines\n' >blanksfile
-printf '\n\t \t \nRepeated blank lines\n' >>blanksfile
-printf '\n\n\nTrailing spaces \t \n' >>blanksfile
-printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile
-get_tag_header blanks-annotated-tag $commit commit $time >expect
-cat >>expect <<EOF
-Leading blank lines
+test_expect_success \
+ 'extra blanks in the message for an annotated tag should be removed' '
+ printf "\n\n \n\t\nLeading blank lines\n" >blanksfile &&
+ printf "\n\t \t \nRepeated blank lines\n" >>blanksfile &&
+ printf "\n\n\nTrailing spaces \t \n" >>blanksfile &&
+ printf "\nTrailing blank lines\n\n\t \n\n" >>blanksfile &&
+ get_tag_header blanks-annotated-tag $commit commit $time >expect &&
+ cat >>expect <<-\EOF &&
+ Leading blank lines
-Repeated blank lines
+ Repeated blank lines
-Trailing spaces
+ Trailing spaces
-Trailing blank lines
-EOF
-test_expect_success \
- 'extra blanks in the message for an annotated tag should be removed' '
+ Trailing blank lines
+ EOF
git tag -F blanksfile blanks-annotated-tag &&
get_tag_msg blanks-annotated-tag >actual &&
test_cmp expect actual
'
-get_tag_header blank-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with blank -m message with spaces should succeed' '
+ get_tag_header blank-annotated-tag $commit commit $time >expect &&
git tag -m " " blank-annotated-tag &&
get_tag_msg blank-annotated-tag >actual &&
test_cmp expect actual
'
-echo ' ' >blankfile
-echo '' >>blankfile
-echo ' ' >>blankfile
-get_tag_header blankfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with blank -F messagefile with spaces should succeed' '
+ echo " " >blankfile &&
+ echo "" >>blankfile &&
+ echo " " >>blankfile &&
+ get_tag_header blankfile-annotated-tag $commit commit $time >expect &&
git tag -F blankfile blankfile-annotated-tag &&
get_tag_msg blankfile-annotated-tag >actual &&
test_cmp expect actual
'
-printf ' ' >blanknonlfile
-get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with -F file of spaces and no newline should succeed' '
+ printf " " >blanknonlfile &&
+ get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect &&
git tag -F blanknonlfile blanknonlfile-annotated-tag &&
get_tag_msg blanknonlfile-annotated-tag >actual &&
test_cmp expect actual
@@ -611,62 +624,62 @@ test_expect_success \
# messages with commented lines:
-cat >commentsfile <<EOF
-# A comment
+test_expect_success \
+ 'creating a tag using a -F messagefile with #comments should succeed' '
+ cat >commentsfile <<-\EOF &&
+ # A comment
-############
-The message.
-############
-One line.
+ ############
+ The message.
+ ############
+ One line.
-# commented lines
-# commented lines
+ # commented lines
+ # commented lines
-Another line.
-# comments
+ Another line.
+ # comments
-Last line.
-EOF
-get_tag_header comments-annotated-tag $commit commit $time >expect
-cat >>expect <<EOF
-The message.
-One line.
+ Last line.
+ EOF
+ get_tag_header comments-annotated-tag $commit commit $time >expect &&
+ cat >>expect <<-\EOF &&
+ The message.
+ One line.
-Another line.
+ Another line.
-Last line.
-EOF
-test_expect_success \
- 'creating a tag using a -F messagefile with #comments should succeed' '
+ Last line.
+ EOF
git tag -F commentsfile comments-annotated-tag &&
get_tag_msg comments-annotated-tag >actual &&
test_cmp expect actual
'
-get_tag_header comment-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with a #comment in the -m message should succeed' '
+ get_tag_header comment-annotated-tag $commit commit $time >expect &&
git tag -m "#comment" comment-annotated-tag &&
get_tag_msg comment-annotated-tag >actual &&
test_cmp expect actual
'
-echo '#comment' >commentfile
-echo '' >>commentfile
-echo '####' >>commentfile
-get_tag_header commentfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with #comments in the -F messagefile should succeed' '
+ echo "#comment" >commentfile &&
+ echo "" >>commentfile &&
+ echo "####" >>commentfile &&
+ get_tag_header commentfile-annotated-tag $commit commit $time >expect &&
git tag -F commentfile commentfile-annotated-tag &&
get_tag_msg commentfile-annotated-tag >actual &&
test_cmp expect actual
'
-printf '#comment' >commentnonlfile
-get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect
test_expect_success \
'creating a tag with a file of #comment and no newline should succeed' '
+ printf "#comment" >commentnonlfile &&
+ get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect &&
git tag -F commentnonlfile commentnonlfile-annotated-tag &&
get_tag_msg commentnonlfile-annotated-tag >actual &&
test_cmp expect actual
@@ -848,11 +861,11 @@ test_expect_success \
test_cmp expect actual
'
-echo 'tag line one' >annotagmsg
-echo 'tag line two' >>annotagmsg
-echo 'tag line three' >>annotagmsg
test_expect_success \
'listing many message lines of a non-signed tag should succeed' '
+ echo "tag line one" >annotagmsg &&
+ echo "tag line two" >>annotagmsg &&
+ echo "tag line three" >>annotagmsg &&
git tag -F annotagmsg tag-lines &&
echo "tag-lines" >expect &&
@@ -960,20 +973,20 @@ test_expect_success GPG \
# creating and verifying signed tags:
-get_tag_header signed-tag $commit commit $time >expect
-echo 'A signed tag message' >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG 'creating a signed tag with -m message should succeed' '
+ get_tag_header signed-tag $commit commit $time >expect &&
+ echo "A signed tag message" >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -m "A signed tag message" signed-tag &&
get_tag_msg signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header u-signed-tag $commit commit $time >expect
-echo 'Another message' >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG 'sign with a given key id' '
+ get_tag_header u-signed-tag $commit commit $time >expect &&
+ echo "Another message" >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -u committer@example.com -m "Another message" u-signed-tag &&
get_tag_msg u-signed-tag >actual &&
test_cmp expect actual
@@ -993,65 +1006,65 @@ test_expect_success GPG 'sign with an unknown id (2)' '
'
-cat >fakeeditor <<'EOF'
-#!/bin/sh
-test -n "$1" && exec >"$1"
-echo A signed tag message
-echo from a fake editor.
-EOF
-chmod +x fakeeditor
-
-get_tag_header implied-sign $commit commit $time >expect
-./fakeeditor >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG '-u implies signed tag' '
+ cat >fakeeditor <<-\EOF &&
+ #!/bin/sh
+ test -n "$1" && exec >"$1"
+ echo A signed tag message
+ echo from a fake editor.
+ EOF
+ chmod +x fakeeditor &&
+
+ get_tag_header implied-sign $commit commit $time >expect &&
+ ./fakeeditor >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
GIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&
get_tag_msg implied-sign >actual &&
test_cmp expect actual
'
-cat >sigmsgfile <<EOF
-Another signed tag
-message in a file.
-EOF
-get_tag_header file-signed-tag $commit commit $time >expect
-cat sigmsgfile >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with -F messagefile should succeed' '
+ cat >sigmsgfile <<-\EOF &&
+ Another signed tag
+ message in a file.
+ EOF
+ get_tag_header file-signed-tag $commit commit $time >expect &&
+ cat sigmsgfile >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -F sigmsgfile file-signed-tag &&
get_tag_msg file-signed-tag >actual &&
test_cmp expect actual
'
-cat >siginputmsg <<EOF
-A signed tag message from
-the standard input
-EOF
-get_tag_header stdin-signed-tag $commit commit $time >expect
-cat siginputmsg >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG 'creating a signed tag with -F - should succeed' '
+ cat >siginputmsg <<-\EOF &&
+ A signed tag message from
+ the standard input
+ EOF
+ get_tag_header stdin-signed-tag $commit commit $time >expect &&
+ cat siginputmsg >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -F - stdin-signed-tag <siginputmsg &&
get_tag_msg stdin-signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header implied-annotate $commit commit $time >expect
-./fakeeditor >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG '-s implies annotated tag' '
+ get_tag_header implied-annotate $commit commit $time >expect &&
+ ./fakeeditor >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
GIT_EDITOR=./fakeeditor git tag -s implied-annotate &&
get_tag_msg implied-annotate >actual &&
test_cmp expect actual
'
-get_tag_header forcesignannotated-implied-sign $commit commit $time >expect
-echo "A message" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'git tag -s implied if configured with tag.forcesignannotated' \
- 'test_config tag.forcesignannotated true &&
+ 'get_tag_header forcesignannotated-implied-sign $commit commit $time >expect &&
+ echo "A message" >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
+ test_config tag.forcesignannotated true &&
git tag -m "A message" forcesignannotated-implied-sign &&
get_tag_msg forcesignannotated-implied-sign >actual &&
test_cmp expect actual
@@ -1065,44 +1078,44 @@ test_expect_success GPG \
test_must_fail git tag -v forcesignannotated-no-message
'
-get_tag_header forcesignannotated-annotate $commit commit $time >expect
-echo "A message" >>expect
test_expect_success GPG \
'git tag -a disable configured tag.forcesignannotated' \
- 'test_config tag.forcesignannotated true &&
+ 'get_tag_header forcesignannotated-annotate $commit commit $time >expect &&
+ echo "A message" >>expect &&
+ test_config tag.forcesignannotated true &&
git tag -a -m "A message" forcesignannotated-annotate &&
get_tag_msg forcesignannotated-annotate >actual &&
test_cmp expect actual &&
test_must_fail git tag -v forcesignannotated-annotate
'
-get_tag_header forcesignannotated-disabled $commit commit $time >expect
-echo "A message" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'git tag --sign enable GPG sign' \
- 'test_config tag.forcesignannotated false &&
+ 'get_tag_header forcesignannotated-disabled $commit commit $time >expect &&
+ echo "A message" >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
+ test_config tag.forcesignannotated false &&
git tag --sign -m "A message" forcesignannotated-disabled &&
get_tag_msg forcesignannotated-disabled >actual &&
test_cmp expect actual
'
-get_tag_header gpgsign-enabled $commit commit $time >expect
-echo "A message" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'git tag configured tag.gpgsign enables GPG sign' \
- 'test_config tag.gpgsign true &&
+ 'get_tag_header gpgsign-enabled $commit commit $time >expect &&
+ echo "A message" >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
+ test_config tag.gpgsign true &&
git tag -m "A message" gpgsign-enabled &&
get_tag_msg gpgsign-enabled>actual &&
test_cmp expect actual
'
-get_tag_header no-sign $commit commit $time >expect
-echo "A message" >>expect
test_expect_success GPG \
'git tag --no-sign configured tag.gpgsign skip GPG sign' \
- 'test_config tag.gpgsign true &&
+ 'get_tag_header no-sign $commit commit $time >expect &&
+ echo "A message" >>expect &&
+ test_config tag.gpgsign true &&
git tag -a --no-sign -m "A message" no-sign &&
get_tag_msg no-sign>actual &&
test_cmp expect actual
@@ -1154,78 +1167,78 @@ test_expect_success GPG 'verifying a forged tag with --format should fail silent
# blank and empty messages for signed tags:
-get_tag_header empty-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with an empty -m message should succeed' '
+ get_tag_header empty-signed-tag $commit commit $time >expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -m "" empty-signed-tag &&
get_tag_msg empty-signed-tag >actual &&
test_cmp expect actual &&
git tag -v empty-signed-tag
'
->sigemptyfile
-get_tag_header emptyfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with an empty -F messagefile should succeed' '
+ >sigemptyfile &&
+ get_tag_header emptyfile-signed-tag $commit commit $time >expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -F sigemptyfile emptyfile-signed-tag &&
get_tag_msg emptyfile-signed-tag >actual &&
test_cmp expect actual &&
git tag -v emptyfile-signed-tag
'
-printf '\n\n \n\t\nLeading blank lines\n' >sigblanksfile
-printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile
-printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile
-printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
-get_tag_header blanks-signed-tag $commit commit $time >expect
-cat >>expect <<EOF
-Leading blank lines
+test_expect_success GPG \
+ 'extra blanks in the message for a signed tag should be removed' '
+ printf "\n\n \n\t\nLeading blank lines\n" >sigblanksfile &&
+ printf "\n\t \t \nRepeated blank lines\n" >>sigblanksfile &&
+ printf "\n\n\nTrailing spaces \t \n" >>sigblanksfile &&
+ printf "\nTrailing blank lines\n\n\t \n\n" >>sigblanksfile &&
+ get_tag_header blanks-signed-tag $commit commit $time >expect &&
+ cat >>expect <<-\EOF &&
+ Leading blank lines
-Repeated blank lines
+ Repeated blank lines
-Trailing spaces
+ Trailing spaces
-Trailing blank lines
-EOF
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'extra blanks in the message for a signed tag should be removed' '
+ Trailing blank lines
+ EOF
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -F sigblanksfile blanks-signed-tag &&
get_tag_msg blanks-signed-tag >actual &&
test_cmp expect actual &&
git tag -v blanks-signed-tag
'
-get_tag_header blank-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with a blank -m message should succeed' '
+ get_tag_header blank-signed-tag $commit commit $time >expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -m " " blank-signed-tag &&
get_tag_msg blank-signed-tag >actual &&
test_cmp expect actual &&
git tag -v blank-signed-tag
'
-echo ' ' >sigblankfile
-echo '' >>sigblankfile
-echo ' ' >>sigblankfile
-get_tag_header blankfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with blank -F file with spaces should succeed' '
+ echo " " >sigblankfile &&
+ echo "" >>sigblankfile &&
+ echo " " >>sigblankfile &&
+ get_tag_header blankfile-signed-tag $commit commit $time >expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -F sigblankfile blankfile-signed-tag &&
get_tag_msg blankfile-signed-tag >actual &&
test_cmp expect actual &&
git tag -v blankfile-signed-tag
'
-printf ' ' >sigblanknonlfile
-get_tag_header blanknonlfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with spaces and no newline should succeed' '
+ printf " " >sigblanknonlfile &&
+ get_tag_header blanknonlfile-signed-tag $commit commit $time >expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
get_tag_msg blanknonlfile-signed-tag >actual &&
test_cmp expect actual &&
@@ -1245,69 +1258,69 @@ test_expect_success GPG 'signed tag with embedded PGP message' '
# messages with commented lines for signed tags:
-cat >sigcommentsfile <<EOF
-# A comment
+test_expect_success GPG \
+ 'creating a signed tag with a -F file with #comments should succeed' '
+ cat >sigcommentsfile <<-\EOF &&
+ # A comment
-############
-The message.
-############
-One line.
+ ############
+ The message.
+ ############
+ One line.
-# commented lines
-# commented lines
+ # commented lines
+ # commented lines
-Another line.
-# comments
+ Another line.
+ # comments
-Last line.
-EOF
-get_tag_header comments-signed-tag $commit commit $time >expect
-cat >>expect <<EOF
-The message.
-One line.
+ Last line.
+ EOF
+ get_tag_header comments-signed-tag $commit commit $time >expect &&
+ cat >>expect <<-\EOF &&
+ The message.
+ One line.
-Another line.
+ Another line.
-Last line.
-EOF
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
-test_expect_success GPG \
- 'creating a signed tag with a -F file with #comments should succeed' '
+ Last line.
+ EOF
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -F sigcommentsfile comments-signed-tag &&
get_tag_msg comments-signed-tag >actual &&
test_cmp expect actual &&
git tag -v comments-signed-tag
'
-get_tag_header comment-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with #commented -m message should succeed' '
+ get_tag_header comment-signed-tag $commit commit $time >expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -m "#comment" comment-signed-tag &&
get_tag_msg comment-signed-tag >actual &&
test_cmp expect actual &&
git tag -v comment-signed-tag
'
-echo '#comment' >sigcommentfile
-echo '' >>sigcommentfile
-echo '####' >>sigcommentfile
-get_tag_header commentfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with #commented -F messagefile should succeed' '
+ echo "#comment" >sigcommentfile &&
+ echo "" >>sigcommentfile &&
+ echo "####" >>sigcommentfile &&
+ get_tag_header commentfile-signed-tag $commit commit $time >expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -F sigcommentfile commentfile-signed-tag &&
get_tag_msg commentfile-signed-tag >actual &&
test_cmp expect actual &&
git tag -v commentfile-signed-tag
'
-printf '#comment' >sigcommentnonlfile
-get_tag_header commentnonlfile-signed-tag $commit commit $time >expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag with a #comment and no newline should succeed' '
+ printf "#comment" >sigcommentnonlfile &&
+ get_tag_header commentnonlfile-signed-tag $commit commit $time >expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
get_tag_msg commentnonlfile-signed-tag >actual &&
test_cmp expect actual &&
@@ -1366,11 +1379,11 @@ test_expect_success GPG \
test_cmp expect actual
'
-echo 'stag line one' >sigtagmsg
-echo 'stag line two' >>sigtagmsg
-echo 'stag line three' >>sigtagmsg
test_expect_success GPG \
'listing many message lines of a signed tag should succeed' '
+ echo "stag line one" >sigtagmsg &&
+ echo "stag line two" >>sigtagmsg &&
+ echo "stag line three" >>sigtagmsg &&
git tag -s -F sigtagmsg stag-lines &&
echo "stag-lines" >expect &&
@@ -1412,60 +1425,59 @@ test_expect_success GPG \
# tags pointing to objects different from commits:
-tree=$(git rev-parse HEAD^{tree})
-blob=$(git rev-parse HEAD:foo)
-tag=$(git rev-parse signed-tag 2>/dev/null)
-
-get_tag_header tree-signed-tag $tree tree $time >expect
-echo "A message for a tree" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag pointing to a tree should succeed' '
+ tree=$(git rev-parse HEAD^{tree}) &&
+ get_tag_header tree-signed-tag $tree tree $time >expect &&
+ echo "A message for a tree" >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
get_tag_msg tree-signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header blob-signed-tag $blob blob $time >expect
-echo "A message for a blob" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag pointing to a blob should succeed' '
+ blob=$(git rev-parse HEAD:foo) &&
+ get_tag_header blob-signed-tag $blob blob $time >expect &&
+ echo "A message for a blob" >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
get_tag_msg blob-signed-tag >actual &&
test_cmp expect actual
'
-get_tag_header tag-signed-tag $tag tag $time >expect
-echo "A message for another tag" >>expect
-echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success GPG \
'creating a signed tag pointing to another tag should succeed' '
+ tag=$(git rev-parse signed-tag 2>/dev/null) &&
+ get_tag_header tag-signed-tag $tag tag $time >expect &&
+ echo "A message for another tag" >>expect &&
+ echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
get_tag_msg tag-signed-tag >actual &&
test_cmp expect actual
'
# usage with rfc1991 signatures
-get_tag_header rfc1991-signed-tag $commit commit $time >expect
-echo "RFC1991 signed tag" >>expect
-echo '-----BEGIN PGP MESSAGE-----' >>expect
+
test_expect_success GPG,RFC1991 \
'creating a signed tag with rfc1991' '
+ get_tag_header rfc1991-signed-tag $commit commit $time >expect &&
+ echo "RFC1991 signed tag" >>expect &&
+ echo "-----BEGIN PGP MESSAGE-----" >>expect &&
echo "rfc1991" >gpghome/gpg.conf &&
git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
get_tag_msg rfc1991-signed-tag >actual &&
test_cmp expect actual
'
-cat >fakeeditor <<'EOF'
-#!/bin/sh
-cp "$1" actual
-EOF
-chmod +x fakeeditor
-
test_expect_success GPG,RFC1991 \
'reediting a signed tag body omits signature' '
+ cat >fakeeditor <<-\EOF &&
+ #!/bin/sh
+ cp "$1" actual
+ EOF
+ chmod +x fakeeditor &&
echo "rfc1991" >gpghome/gpg.conf &&
echo "RFC1991 signed tag" >expect &&
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
@@ -1490,10 +1502,9 @@ test_expect_success GPG,RFC1991 \
test_cmp expect actual
'
-rm -f gpghome/gpg.conf
-
test_expect_success GPG,RFC1991 \
'verifying rfc1991 signature without --rfc1991' '
+ rm -f gpghome/gpg.conf &&
git tag -v rfc1991-signed-tag
'
@@ -1561,10 +1572,11 @@ test_expect_success GPGSM \
# try to verify without gpg:
-rm -rf gpghome
test_expect_success GPG \
'verify signed tag fails when public key is not present' \
- 'test_must_fail git tag -v signed-tag'
+ 'rm -rf gpghome &&
+ test_must_fail git tag -v signed-tag
+'
test_expect_success \
'git tag -a fails if tag annotation is empty' '
@@ -1590,10 +1602,10 @@ test_expect_success \
test_must_be_empty rest.actual
'
-get_tag_header reuse $commit commit $time >expect
-echo "An annotation to be reused" >>expect
test_expect_success \
'overwriting an annotated tag should use its previous body' '
+ get_tag_header reuse $commit commit $time >expect &&
+ echo "An annotation to be reused" >>expect &&
git tag -a -m "An annotation to be reused" reuse &&
GIT_EDITOR=true git tag -f -a reuse &&
get_tag_msg reuse >actual &&
@@ -1622,47 +1634,57 @@ test_expect_success 'filename for the message is relative to cwd' '
# create a few more commits to test --contains
-hash1=$(git rev-parse HEAD)
-
test_expect_success 'creating second commit and tag' '
+ hash1=$(git rev-parse HEAD) &&
echo foo-2.0 >foo &&
git add foo &&
git commit -m second &&
git tag v2.0
'
-hash2=$(git rev-parse HEAD)
-
test_expect_success 'creating third commit without tag' '
+ hash2=$(git rev-parse HEAD) &&
echo foo-dev >foo &&
git add foo &&
git commit -m third
'
-hash3=$(git rev-parse HEAD)
-
# simple linear checks of --continue
-cat >expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-EOF
-
test_expect_success 'checking that first commit is in all tags (hash)' "
+ hash3=$(git rev-parse HEAD) &&
+ cat >expected <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ EOF
git tag -l --contains $hash1 v* >actual &&
test_cmp expected actual
"
# other ways of specifying the commit
test_expect_success 'checking that first commit is in all tags (tag)' "
+ cat >expected <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ EOF
git tag -l --contains v1.0 v* >actual &&
test_cmp expected actual
"
test_expect_success 'checking that first commit is in all tags (relative)' "
+ cat >expected <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ EOF
git tag -l --contains HEAD~2 v* >actual &&
test_cmp expected actual
"
@@ -1683,23 +1705,21 @@ test_expect_success 'checking that first commit is in all tags (relative)' "
test_must_be_empty actual
"
-cat >expected <<EOF
-v2.0
-EOF
-
test_expect_success 'checking that second commit only has one tag' "
+ cat >expected <<-\EOF &&
+ v2.0
+ EOF
git tag -l --contains $hash2 v* >actual &&
test_cmp expected actual
"
-cat >expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-EOF
-
test_expect_success 'inverse of the last test, with --no-contains' "
+ cat >expected <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ EOF
git tag -l --no-contains $hash2 v* >actual &&
test_cmp expected actual
"
@@ -1709,15 +1729,14 @@ test_expect_success 'checking that third commit has no tags' "
test_must_be_empty actual
"
-cat >expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-EOF
-
test_expect_success 'conversely --no-contains on the third commit lists all tags' "
+ cat >expected <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ EOF
git tag -l --no-contains $hash3 v* >actual &&
test_cmp expected actual
"
@@ -1732,26 +1751,23 @@ test_expect_success 'creating simple branch' '
git tag v3.0
'
-hash4=$(git rev-parse HEAD)
-
-cat >expected <<EOF
-v3.0
-EOF
-
-test_expect_success 'checking that branch head only has one tag' "
+test_expect_success 'checking that branch head only has one tag' '
+ hash4=$(git rev-parse HEAD) &&
+ cat >expected <<-\EOF &&
+ v3.0
+ EOF
git tag -l --contains $hash4 v* >actual &&
test_cmp expected actual
-"
-
-cat >expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-EOF
+'
test_expect_success 'checking that branch head with --no-contains lists all but one tag' "
+ cat >expected <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ EOF
git tag -l --no-contains $hash4 v* >actual &&
test_cmp expected actual
"
@@ -1761,45 +1777,51 @@ test_expect_success 'merging original branch into this branch' '
git tag v4.0
'
-cat >expected <<EOF
-v4.0
-EOF
-
test_expect_success 'checking that original branch head has one tag now' "
+ cat >expected <<-\EOF &&
+ v4.0
+ EOF
git tag -l --contains $hash3 v* >actual &&
test_cmp expected actual
"
-cat >expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-v3.0
-EOF
-
test_expect_success 'checking that original branch head with --no-contains lists all but one tag now' "
+ cat >expected <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ v3.0
+ EOF
git tag -l --no-contains $hash3 v* >actual &&
test_cmp expected actual
"
-cat >expected <<EOF
-v0.2.1
-v1.0
-v1.0.1
-v1.1.3
-v2.0
-v3.0
-v4.0
-EOF
-
test_expect_success 'checking that initial commit is in all tags' "
+ cat >expected <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ v3.0
+ v4.0
+ EOF
git tag -l --contains $hash1 v* >actual &&
test_cmp expected actual
"
test_expect_success 'checking that --contains can be used in non-list mode' '
+ cat >expected <<-\EOF &&
+ v0.2.1
+ v1.0
+ v1.0.1
+ v1.1.3
+ v2.0
+ v3.0
+ v4.0
+ EOF
git tag --contains $hash1 v* >actual &&
test_cmp expected actual
'
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v4 5/8] [Newcomer] t7004: Use indented here-doc
2024-08-05 23:59 [PATCH v4 0/8] t7004: Modernize the style AbdAlRahman Gad
` (3 preceding siblings ...)
2024-08-05 23:59 ` [PATCH v4 4/8] [Newcomer] t7004: Do not prepare things outside test_expect_success AbdAlRahman Gad
@ 2024-08-05 23:59 ` AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 6/8] [Newcomer] t7004: Description on the same line as test_expect_success AbdAlRahman Gad
` (3 subsequent siblings)
8 siblings, 0 replies; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-05 23:59 UTC (permalink / raw)
To: git; +Cc: AbdAlRahman Gad
Use <<-\EOF instead of <<\EOF where the latter allows us to indent
the body of the here-doc.
Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
---
t/t7004-tag.sh | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index b9fe58fbee..242e38887b 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -389,10 +389,10 @@ test_expect_success 'tag -l <pattern> -l <pattern> works, as our buggy documenta
test_expect_success 'listing tags in column' '
COLUMNS=41 git tag -l --column=row >actual &&
- cat >expected <<\EOF &&
-a1 aa1 cba t210 t211
-v0.2.1 v1.0 v1.0.1 v1.1.3
-EOF
+ cat >expected <<-\EOF &&
+ a1 aa1 cba t210 t211
+ v0.2.1 v1.0 v1.0.1 v1.1.3
+ EOF
test_cmp expected actual
'
@@ -400,10 +400,10 @@ test_expect_success 'listing tags in column with column.*' '
test_config column.tag row &&
test_config column.ui dense &&
COLUMNS=40 git tag -l >actual &&
- cat >expected <<\EOF &&
-a1 aa1 cba t210 t211
-v0.2.1 v1.0 v1.0.1 v1.1.3
-EOF
+ cat >expected <<-\EOF &&
+ a1 aa1 cba t210 t211
+ v0.2.1 v1.0 v1.0.1 v1.1.3
+ EOF
test_cmp expected actual
'
@@ -414,17 +414,17 @@ test_expect_success 'listing tag with -n --column should fail' '
test_expect_success 'listing tags -n in column with column.ui ignored' '
test_config column.ui "row dense" &&
COLUMNS=40 git tag -l -n >actual &&
- cat >expected <<\EOF &&
-a1 Foo
-aa1 Foo
-cba Foo
-t210 Foo
-t211 Foo
-v0.2.1 Foo
-v1.0 Foo
-v1.0.1 Foo
-v1.1.3 Foo
-EOF
+ cat >expected <<-\EOF &&
+ a1 Foo
+ aa1 Foo
+ cba Foo
+ t210 Foo
+ t211 Foo
+ v0.2.1 Foo
+ v1.0 Foo
+ v1.0.1 Foo
+ v1.1.3 Foo
+ EOF
test_cmp expected actual
'
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v4 6/8] [Newcomer] t7004: Description on the same line as test_expect_success
2024-08-05 23:59 [PATCH v4 0/8] t7004: Modernize the style AbdAlRahman Gad
` (4 preceding siblings ...)
2024-08-05 23:59 ` [PATCH v4 5/8] [Newcomer] t7004: Use indented here-doc AbdAlRahman Gad
@ 2024-08-05 23:59 ` AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 7/8] [Newcomer] t7004: test Description and test body seperated with backslash AbdAlRahman Gad
` (2 subsequent siblings)
8 siblings, 0 replies; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-05 23:59 UTC (permalink / raw)
To: git; +Cc: AbdAlRahman Gad
There are several tests in t7004 where the test description that
follows `test_expect_success` is on a separate line, violating our
coding style. Adapt these to be on the same line.
Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
---
t/t7004-tag.sh | 249 +++++++++++++++++--------------------------------
1 file changed, 83 insertions(+), 166 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 242e38887b..6c93192d5d 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -156,26 +156,21 @@ test_expect_success 'listing a tag using a matching pattern should succeed' \
test_expect_success 'listing a tag with --ignore-case' \
'test $(git tag -l --ignore-case MYTAG) = mytag'
-test_expect_success \
- 'listing a tag using a matching pattern should output that tag' \
+test_expect_success 'listing a tag using a matching pattern should output that tag' \
'test $(git tag -l mytag) = mytag'
-test_expect_success \
- 'listing tags using a non-matching pattern should succeed' \
+test_expect_success 'listing tags using a non-matching pattern should succeed' \
'git tag -l xxx'
-test_expect_success \
- 'listing tags using a non-matching pattern should output nothing' \
+test_expect_success 'listing tags using a non-matching pattern should output nothing' \
'test $(git tag -l xxx | wc -l) -eq 0'
# special cases for creating tags:
-test_expect_success \
- 'trying to create a tag with the name of one existing should fail' \
+test_expect_success 'trying to create a tag with the name of one existing should fail' \
'test_must_fail git tag mytag'
-test_expect_success \
- 'trying to create a tag with a non-valid name should fail' '
+test_expect_success 'trying to create a tag with a non-valid name should fail' '
test $(git tag -l | wc -l) -eq 1 &&
test_must_fail git tag "" &&
test_must_fail git tag .othertag &&
@@ -209,8 +204,7 @@ test_expect_success 'trying to delete an unknown tag should fail' '
test_must_fail git tag -d unknown-tag
'
-test_expect_success \
- 'trying to delete tags without params should succeed and do nothing' '
+test_expect_success 'trying to delete tags without params should succeed and do nothing' '
cat >expect <<-\EOF &&
myhead
mytag
@@ -222,8 +216,7 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'deleting two existing tags in one command should succeed' '
+test_expect_success 'deleting two existing tags in one command should succeed' '
tag_exists mytag &&
tag_exists myhead &&
git tag -d mytag myhead &&
@@ -231,15 +224,13 @@ test_expect_success \
! tag_exists myhead
'
-test_expect_success \
- 'creating a tag with the name of another deleted one should succeed' '
+test_expect_success 'creating a tag with the name of another deleted one should succeed' '
! tag_exists mytag &&
git tag mytag &&
tag_exists mytag
'
-test_expect_success \
- 'trying to delete two tags, existing and not, should fail in the 2nd' '
+test_expect_success 'trying to delete two tags, existing and not, should fail in the 2nd' '
tag_exists mytag &&
! tag_exists nonexistingtag &&
test_must_fail git tag -d mytag nonexistingtag &&
@@ -279,8 +270,7 @@ test_expect_success 'listing all tags should print them ordered' '
test_cmp expect actual
'
-test_expect_success \
- 'listing tags with substring as pattern must print those matching' '
+test_expect_success 'listing tags with substring as pattern must print those matching' '
cat >expect <<-\EOF &&
a1
aa1
@@ -291,8 +281,7 @@ test_expect_success \
test_cmp expect current
'
-test_expect_success \
- 'listing tags with a suffix as pattern must print those matching' '
+test_expect_success 'listing tags with a suffix as pattern must print those matching' '
cat >expect <<-\EOF &&
v0.2.1
v1.0.1
@@ -301,8 +290,7 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'listing tags with a prefix as pattern must print those matching' '
+test_expect_success 'listing tags with a prefix as pattern must print those matching' '
cat >expect <<-\EOF &&
t210
t211
@@ -311,8 +299,7 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'listing tags using a name as pattern must print that one matching' '
+test_expect_success 'listing tags using a name as pattern must print that one matching' '
cat >expect <<-\EOF &&
a1
EOF
@@ -320,8 +307,7 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'listing tags using a name as pattern must print that one matching' '
+test_expect_success 'listing tags using a name as pattern must print that one matching' '
cat >expect <<-\EOF &&
v1.0
EOF
@@ -329,8 +315,7 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'listing tags with ? in the pattern should print those matching' '
+test_expect_success 'listing tags with ? in the pattern should print those matching' '
cat >expect <<-\EOF &&
v1.0.1
v1.1.3
@@ -339,14 +324,12 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'listing tags using v.* should print nothing because none have v.' '
+test_expect_success 'listing tags using v.* should print nothing because none have v.' '
git tag -l "v.*" >actual &&
test_must_be_empty actual
'
-test_expect_success \
- 'listing tags using v* should print only those having v' '
+test_expect_success 'listing tags using v* should print only those having v' '
cat >expect <<-\EOF &&
v0.2.1
v1.0
@@ -430,8 +413,7 @@ test_expect_success 'listing tags -n in column with column.ui ignored' '
# creating and verifying lightweight tags:
-test_expect_success \
- 'a non-annotated tag created without parameters should point to HEAD' '
+test_expect_success 'a non-annotated tag created without parameters should point to HEAD' '
git tag non-annotated-tag &&
test $(git cat-file -t non-annotated-tag) = commit &&
test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
@@ -440,12 +422,10 @@ test_expect_success \
test_expect_success 'trying to verify an unknown tag should fail' \
'test_must_fail git tag -v unknown-tag'
-test_expect_success \
- 'trying to verify a non-annotated and non-signed tag should fail' \
+test_expect_success 'trying to verify a non-annotated and non-signed tag should fail' \
'test_must_fail git tag -v non-annotated-tag'
-test_expect_success \
- 'trying to verify many non-annotated or unknown tags, should fail' \
+test_expect_success 'trying to verify many non-annotated or unknown tags, should fail' \
'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'
# creating annotated tags:
@@ -465,8 +445,7 @@ tagger C O Mitter <committer@example.com> $4 -0700
EOF
}
-test_expect_success \
- 'creating an annotated tag with -m message should succeed' '
+test_expect_success 'creating an annotated tag with -m message should succeed' '
commit=$(git rev-parse HEAD) &&
time=$test_tick &&
get_tag_header annotated-tag $commit commit $time >expect &&
@@ -483,8 +462,7 @@ test_expect_success 'set up editor' '
EOF
'
-test_expect_success \
- 'creating an annotated tag with -m message --edit should succeed' '
+test_expect_success 'creating an annotated tag with -m message --edit should succeed' '
get_tag_header annotated-tag-edit $commit commit $time >expect &&
echo "An edited message" >>expect &&
GIT_EDITOR=./fakeeditor git tag -m "A message" --edit annotated-tag-edit &&
@@ -492,8 +470,7 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'creating an annotated tag with -F messagefile should succeed' '
+test_expect_success 'creating an annotated tag with -F messagefile should succeed' '
cat >msgfile <<-\EOF &&
Another message
in a file.
@@ -512,8 +489,7 @@ test_expect_success 'set up editor' '
EOF
'
-test_expect_success \
- 'creating an annotated tag with -F messagefile --edit should succeed' '
+test_expect_success 'creating an annotated tag with -F messagefile --edit should succeed' '
get_tag_header file-annotated-tag-edit $commit commit $time >expect &&
sed -e "s/Another message/Another edited message/g" msgfile >>expect &&
GIT_EDITOR=./fakeeditor git tag -F msgfile --edit file-annotated-tag-edit &&
@@ -533,16 +509,14 @@ test_expect_success 'creating an annotated tag with -F - should succeed' '
test_cmp expect actual
'
-test_expect_success \
- 'trying to create a tag with a non-existing -F file should fail' '
+test_expect_success 'trying to create a tag with a non-existing -F file should fail' '
! test -f nonexistingfile &&
! tag_exists notag &&
test_must_fail git tag -F nonexistingfile notag &&
! tag_exists notag
'
-test_expect_success \
- 'trying to create tags giving both -m or -F options should fail' '
+test_expect_success 'trying to create tags giving both -m or -F options should fail' '
echo "message file 1" >msgfile1 &&
! tag_exists msgtag &&
test_must_fail git tag -m "message 1" -F msgfile1 msgtag &&
@@ -556,16 +530,14 @@ test_expect_success \
# blank and empty messages:
-test_expect_success \
- 'creating a tag with an empty -m message should succeed' '
+test_expect_success 'creating a tag with an empty -m message should succeed' '
get_tag_header empty-annotated-tag $commit commit $time >expect &&
git tag -m "" empty-annotated-tag &&
get_tag_msg empty-annotated-tag >actual &&
test_cmp expect actual
'
-test_expect_success \
- 'creating a tag with an empty -F messagefile should succeed' '
+test_expect_success 'creating a tag with an empty -F messagefile should succeed' '
>emptyfile &&
get_tag_header emptyfile-annotated-tag $commit commit $time >expect &&
git tag -F emptyfile emptyfile-annotated-tag &&
@@ -573,8 +545,7 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'extra blanks in the message for an annotated tag should be removed' '
+test_expect_success 'extra blanks in the message for an annotated tag should be removed' '
printf "\n\n \n\t\nLeading blank lines\n" >blanksfile &&
printf "\n\t \t \nRepeated blank lines\n" >>blanksfile &&
printf "\n\n\nTrailing spaces \t \n" >>blanksfile &&
@@ -594,16 +565,14 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'creating a tag with blank -m message with spaces should succeed' '
+test_expect_success 'creating a tag with blank -m message with spaces should succeed' '
get_tag_header blank-annotated-tag $commit commit $time >expect &&
git tag -m " " blank-annotated-tag &&
get_tag_msg blank-annotated-tag >actual &&
test_cmp expect actual
'
-test_expect_success \
- 'creating a tag with blank -F messagefile with spaces should succeed' '
+test_expect_success 'creating a tag with blank -F messagefile with spaces should succeed' '
echo " " >blankfile &&
echo "" >>blankfile &&
echo " " >>blankfile &&
@@ -613,8 +582,7 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'creating a tag with -F file of spaces and no newline should succeed' '
+test_expect_success 'creating a tag with -F file of spaces and no newline should succeed' '
printf " " >blanknonlfile &&
get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect &&
git tag -F blanknonlfile blanknonlfile-annotated-tag &&
@@ -624,8 +592,7 @@ test_expect_success \
# messages with commented lines:
-test_expect_success \
- 'creating a tag using a -F messagefile with #comments should succeed' '
+test_expect_success 'creating a tag using a -F messagefile with #comments should succeed' '
cat >commentsfile <<-\EOF &&
# A comment
@@ -657,16 +624,14 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'creating a tag with a #comment in the -m message should succeed' '
+test_expect_success 'creating a tag with a #comment in the -m message should succeed' '
get_tag_header comment-annotated-tag $commit commit $time >expect &&
git tag -m "#comment" comment-annotated-tag &&
get_tag_msg comment-annotated-tag >actual &&
test_cmp expect actual
'
-test_expect_success \
- 'creating a tag with #comments in the -F messagefile should succeed' '
+test_expect_success 'creating a tag with #comments in the -F messagefile should succeed' '
echo "#comment" >commentfile &&
echo "" >>commentfile &&
echo "####" >>commentfile &&
@@ -676,8 +641,7 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'creating a tag with a file of #comment and no newline should succeed' '
+test_expect_success 'creating a tag with a file of #comment and no newline should succeed' '
printf "#comment" >commentnonlfile &&
get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect &&
git tag -F commentnonlfile commentnonlfile-annotated-tag &&
@@ -796,8 +760,7 @@ test_expect_success 'bad editor causes panic when only --trailer is given' '
# listing messages for annotated non-signed tags:
-test_expect_success \
- 'listing the one-line message of a non-signed tag should succeed' '
+test_expect_success 'listing the one-line message of a non-signed tag should succeed' '
git tag -m "A msg" tag-one-line &&
echo "tag-one-line" >expect &&
@@ -836,8 +799,7 @@ test_expect_success 'The -n 100 invocation means -n --list 100, not -n100' '
test_cmp expect actual
'
-test_expect_success \
- 'listing the zero-lines message of a non-signed tag should succeed' '
+test_expect_success 'listing the zero-lines message of a non-signed tag should succeed' '
git tag -m "" tag-zero-lines &&
echo "tag-zero-lines" >expect &&
@@ -861,8 +823,7 @@ test_expect_success \
test_cmp expect actual
'
-test_expect_success \
- 'listing many message lines of a non-signed tag should succeed' '
+test_expect_success 'listing many message lines of a non-signed tag should succeed' '
echo "tag line one" >annotagmsg &&
echo "tag line two" >>annotagmsg &&
echo "tag line three" >>annotagmsg &&
@@ -953,20 +914,17 @@ test_expect_success 'git tag --format with ahead-behind' '
# trying to verify annotated non-signed tags:
-test_expect_success GPG \
- 'trying to verify an annotated non-signed tag should fail' '
+test_expect_success GPG 'trying to verify an annotated non-signed tag should fail' '
tag_exists annotated-tag &&
test_must_fail git tag -v annotated-tag
'
-test_expect_success GPG \
- 'trying to verify a file-annotated non-signed tag should fail' '
+test_expect_success GPG 'trying to verify a file-annotated non-signed tag should fail' '
tag_exists file-annotated-tag &&
test_must_fail git tag -v file-annotated-tag
'
-test_expect_success GPG \
- 'trying to verify two annotated non-signed tags should fail' '
+test_expect_success GPG 'trying to verify two annotated non-signed tags should fail' '
tag_exists annotated-tag file-annotated-tag &&
test_must_fail git tag -v annotated-tag file-annotated-tag
'
@@ -1023,8 +981,7 @@ test_expect_success GPG '-u implies signed tag' '
test_cmp expect actual
'
-test_expect_success GPG \
- 'creating a signed tag with -F messagefile should succeed' '
+test_expect_success GPG 'creating a signed tag with -F messagefile should succeed' '
cat >sigmsgfile <<-\EOF &&
Another signed tag
message in a file.
@@ -1059,8 +1016,7 @@ test_expect_success GPG '-s implies annotated tag' '
test_cmp expect actual
'
-test_expect_success GPG \
- 'git tag -s implied if configured with tag.forcesignannotated' \
+test_expect_success GPG 'git tag -s implied if configured with tag.forcesignannotated' \
'get_tag_header forcesignannotated-implied-sign $commit commit $time >expect &&
echo "A message" >>expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
@@ -1070,16 +1026,14 @@ test_expect_success GPG \
test_cmp expect actual
'
-test_expect_success GPG \
- 'lightweight with no message when configured with tag.forcesignannotated' \
+test_expect_success GPG 'lightweight with no message when configured with tag.forcesignannotated' \
'test_config tag.forcesignannotated true &&
git tag forcesignannotated-lightweight &&
tag_exists forcesignannotated-lightweight &&
test_must_fail git tag -v forcesignannotated-no-message
'
-test_expect_success GPG \
- 'git tag -a disable configured tag.forcesignannotated' \
+test_expect_success GPG 'git tag -a disable configured tag.forcesignannotated' \
'get_tag_header forcesignannotated-annotate $commit commit $time >expect &&
echo "A message" >>expect &&
test_config tag.forcesignannotated true &&
@@ -1089,8 +1043,7 @@ test_expect_success GPG \
test_must_fail git tag -v forcesignannotated-annotate
'
-test_expect_success GPG \
- 'git tag --sign enable GPG sign' \
+test_expect_success GPG 'git tag --sign enable GPG sign' \
'get_tag_header forcesignannotated-disabled $commit commit $time >expect &&
echo "A message" >>expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
@@ -1100,8 +1053,7 @@ test_expect_success GPG \
test_cmp expect actual
'
-test_expect_success GPG \
- 'git tag configured tag.gpgsign enables GPG sign' \
+test_expect_success GPG 'git tag configured tag.gpgsign enables GPG sign' \
'get_tag_header gpgsign-enabled $commit commit $time >expect &&
echo "A message" >>expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
@@ -1111,8 +1063,7 @@ test_expect_success GPG \
test_cmp expect actual
'
-test_expect_success GPG \
- 'git tag --no-sign configured tag.gpgsign skip GPG sign' \
+test_expect_success GPG 'git tag --no-sign configured tag.gpgsign skip GPG sign' \
'get_tag_header no-sign $commit commit $time >expect &&
echo "A message" >>expect &&
test_config tag.gpgsign true &&
@@ -1121,8 +1072,7 @@ test_expect_success GPG \
test_cmp expect actual
'
-test_expect_success GPG \
- 'trying to create a signed tag with non-existing -F file should fail' '
+test_expect_success GPG 'trying to create a signed tag with non-existing -F file should fail' '
! test -f nonexistingfile &&
! tag_exists nosigtag &&
test_must_fail git tag -s -F nonexistingfile nosigtag &&
@@ -1135,8 +1085,7 @@ test_expect_success GPG 'verifying a signed tag should succeed' \
test_expect_success GPG 'verifying two signed tags in one command should succeed' \
'git tag -v signed-tag file-signed-tag'
-test_expect_success GPG \
- 'verifying many signed and non-signed tags should fail' '
+test_expect_success GPG 'verifying many signed and non-signed tags should fail' '
test_must_fail git tag -v signed-tag annotated-tag &&
test_must_fail git tag -v file-annotated-tag file-signed-tag &&
test_must_fail git tag -v annotated-tag \
@@ -1167,8 +1116,7 @@ test_expect_success GPG 'verifying a forged tag with --format should fail silent
# blank and empty messages for signed tags:
-test_expect_success GPG \
- 'creating a signed tag with an empty -m message should succeed' '
+test_expect_success GPG 'creating a signed tag with an empty -m message should succeed' '
get_tag_header empty-signed-tag $commit commit $time >expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -m "" empty-signed-tag &&
@@ -1177,8 +1125,7 @@ test_expect_success GPG \
git tag -v empty-signed-tag
'
-test_expect_success GPG \
- 'creating a signed tag with an empty -F messagefile should succeed' '
+test_expect_success GPG 'creating a signed tag with an empty -F messagefile should succeed' '
>sigemptyfile &&
get_tag_header emptyfile-signed-tag $commit commit $time >expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
@@ -1188,8 +1135,7 @@ test_expect_success GPG \
git tag -v emptyfile-signed-tag
'
-test_expect_success GPG \
- 'extra blanks in the message for a signed tag should be removed' '
+test_expect_success GPG 'extra blanks in the message for a signed tag should be removed' '
printf "\n\n \n\t\nLeading blank lines\n" >sigblanksfile &&
printf "\n\t \t \nRepeated blank lines\n" >>sigblanksfile &&
printf "\n\n\nTrailing spaces \t \n" >>sigblanksfile &&
@@ -1211,8 +1157,7 @@ test_expect_success GPG \
git tag -v blanks-signed-tag
'
-test_expect_success GPG \
- 'creating a signed tag with a blank -m message should succeed' '
+test_expect_success GPG 'creating a signed tag with a blank -m message should succeed' '
get_tag_header blank-signed-tag $commit commit $time >expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -m " " blank-signed-tag &&
@@ -1221,8 +1166,7 @@ test_expect_success GPG \
git tag -v blank-signed-tag
'
-test_expect_success GPG \
- 'creating a signed tag with blank -F file with spaces should succeed' '
+test_expect_success GPG 'creating a signed tag with blank -F file with spaces should succeed' '
echo " " >sigblankfile &&
echo "" >>sigblankfile &&
echo " " >>sigblankfile &&
@@ -1234,8 +1178,7 @@ test_expect_success GPG \
git tag -v blankfile-signed-tag
'
-test_expect_success GPG \
- 'creating a signed tag with spaces and no newline should succeed' '
+test_expect_success GPG 'creating a signed tag with spaces and no newline should succeed' '
printf " " >sigblanknonlfile &&
get_tag_header blanknonlfile-signed-tag $commit commit $time >expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
@@ -1258,8 +1201,7 @@ test_expect_success GPG 'signed tag with embedded PGP message' '
# messages with commented lines for signed tags:
-test_expect_success GPG \
- 'creating a signed tag with a -F file with #comments should succeed' '
+test_expect_success GPG 'creating a signed tag with a -F file with #comments should succeed' '
cat >sigcommentsfile <<-\EOF &&
# A comment
@@ -1293,8 +1235,7 @@ test_expect_success GPG \
git tag -v comments-signed-tag
'
-test_expect_success GPG \
- 'creating a signed tag with #commented -m message should succeed' '
+test_expect_success GPG 'creating a signed tag with #commented -m message should succeed' '
get_tag_header comment-signed-tag $commit commit $time >expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
git tag -s -m "#comment" comment-signed-tag &&
@@ -1303,8 +1244,7 @@ test_expect_success GPG \
git tag -v comment-signed-tag
'
-test_expect_success GPG \
- 'creating a signed tag with #commented -F messagefile should succeed' '
+test_expect_success GPG 'creating a signed tag with #commented -F messagefile should succeed' '
echo "#comment" >sigcommentfile &&
echo "" >>sigcommentfile &&
echo "####" >>sigcommentfile &&
@@ -1316,8 +1256,7 @@ test_expect_success GPG \
git tag -v commentfile-signed-tag
'
-test_expect_success GPG \
- 'creating a signed tag with a #comment and no newline should succeed' '
+test_expect_success GPG 'creating a signed tag with a #comment and no newline should succeed' '
printf "#comment" >sigcommentnonlfile &&
get_tag_header commentnonlfile-signed-tag $commit commit $time >expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
@@ -1329,8 +1268,7 @@ test_expect_success GPG \
# listing messages for signed tags:
-test_expect_success GPG \
- 'listing the one-line message of a signed tag should succeed' '
+test_expect_success GPG 'listing the one-line message of a signed tag should succeed' '
git tag -s -m "A message line signed" stag-one-line &&
echo "stag-one-line" >expect &&
@@ -1354,8 +1292,7 @@ test_expect_success GPG \
test_cmp expect actual
'
-test_expect_success GPG \
- 'listing the zero-lines message of a signed tag should succeed' '
+test_expect_success GPG 'listing the zero-lines message of a signed tag should succeed' '
git tag -s -m "" stag-zero-lines &&
echo "stag-zero-lines" >expect &&
@@ -1379,8 +1316,7 @@ test_expect_success GPG \
test_cmp expect actual
'
-test_expect_success GPG \
- 'listing many message lines of a signed tag should succeed' '
+test_expect_success GPG 'listing many message lines of a signed tag should succeed' '
echo "stag line one" >sigtagmsg &&
echo "stag line two" >>sigtagmsg &&
echo "stag line three" >>sigtagmsg &&
@@ -1425,8 +1361,7 @@ test_expect_success GPG \
# tags pointing to objects different from commits:
-test_expect_success GPG \
- 'creating a signed tag pointing to a tree should succeed' '
+test_expect_success GPG 'creating a signed tag pointing to a tree should succeed' '
tree=$(git rev-parse HEAD^{tree}) &&
get_tag_header tree-signed-tag $tree tree $time >expect &&
echo "A message for a tree" >>expect &&
@@ -1436,8 +1371,7 @@ test_expect_success GPG \
test_cmp expect actual
'
-test_expect_success GPG \
- 'creating a signed tag pointing to a blob should succeed' '
+test_expect_success GPG 'creating a signed tag pointing to a blob should succeed' '
blob=$(git rev-parse HEAD:foo) &&
get_tag_header blob-signed-tag $blob blob $time >expect &&
echo "A message for a blob" >>expect &&
@@ -1447,8 +1381,7 @@ test_expect_success GPG \
test_cmp expect actual
'
-test_expect_success GPG \
- 'creating a signed tag pointing to another tag should succeed' '
+test_expect_success GPG 'creating a signed tag pointing to another tag should succeed' '
tag=$(git rev-parse signed-tag 2>/dev/null) &&
get_tag_header tag-signed-tag $tag tag $time >expect &&
echo "A message for another tag" >>expect &&
@@ -1460,8 +1393,7 @@ test_expect_success GPG \
# usage with rfc1991 signatures
-test_expect_success GPG,RFC1991 \
- 'creating a signed tag with rfc1991' '
+test_expect_success GPG,RFC1991 'creating a signed tag with rfc1991' '
get_tag_header rfc1991-signed-tag $commit commit $time >expect &&
echo "RFC1991 signed tag" >>expect &&
echo "-----BEGIN PGP MESSAGE-----" >>expect &&
@@ -1471,8 +1403,7 @@ test_expect_success GPG,RFC1991 \
test_cmp expect actual
'
-test_expect_success GPG,RFC1991 \
- 'reediting a signed tag body omits signature' '
+test_expect_success GPG,RFC1991 'reediting a signed tag body omits signature' '
cat >fakeeditor <<-\EOF &&
#!/bin/sh
cp "$1" actual
@@ -1484,14 +1415,12 @@ test_expect_success GPG,RFC1991 \
test_cmp expect actual
'
-test_expect_success GPG,RFC1991 \
- 'verifying rfc1991 signature' '
+test_expect_success GPG,RFC1991 'verifying rfc1991 signature' '
echo "rfc1991" >gpghome/gpg.conf &&
git tag -v rfc1991-signed-tag
'
-test_expect_success GPG,RFC1991 \
- 'list tag with rfc1991 signature' '
+test_expect_success GPG,RFC1991 'list tag with rfc1991 signature' '
echo "rfc1991" >gpghome/gpg.conf &&
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
git tag -l -n1 rfc1991-signed-tag >actual &&
@@ -1502,14 +1431,12 @@ test_expect_success GPG,RFC1991 \
test_cmp expect actual
'
-test_expect_success GPG,RFC1991 \
- 'verifying rfc1991 signature without --rfc1991' '
+test_expect_success GPG,RFC1991 'verifying rfc1991 signature without --rfc1991' '
rm -f gpghome/gpg.conf &&
git tag -v rfc1991-signed-tag
'
-test_expect_success GPG,RFC1991 \
- 'list tag with rfc1991 signature without --rfc1991' '
+test_expect_success GPG,RFC1991 'list tag with rfc1991 signature without --rfc1991' '
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
git tag -l -n1 rfc1991-signed-tag >actual &&
test_cmp expect actual &&
@@ -1519,22 +1446,19 @@ test_expect_success GPG,RFC1991 \
test_cmp expect actual
'
-test_expect_success GPG,RFC1991 \
- 'reediting a signed tag body omits signature' '
+test_expect_success GPG,RFC1991 'reediting a signed tag body omits signature' '
echo "RFC1991 signed tag" >expect &&
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
test_cmp expect actual
'
# try to sign with bad user.signingkey
-test_expect_success GPG \
- 'git tag -s fails if gpg is misconfigured (bad key)' \
+test_expect_success GPG 'git tag -s fails if gpg is misconfigured (bad key)' \
'test_config user.signingkey BobTheMouse &&
test_must_fail git tag -s -m tail tag-gpg-failure'
# try to produce invalid signature
-test_expect_success GPG \
- 'git tag -s fails if gpg is misconfigured (bad signature format)' \
+test_expect_success GPG 'git tag -s fails if gpg is misconfigured (bad signature format)' \
'test_config gpg.program echo &&
test_must_fail git tag -s -m tail tag-gpg-failure'
@@ -1557,34 +1481,29 @@ test_expect_success GPG 'git verifies tag is valid with double signature' '
'
# try to sign with bad user.signingkey
-test_expect_success GPGSM \
- 'git tag -s fails if gpgsm is misconfigured (bad key)' \
+test_expect_success GPGSM 'git tag -s fails if gpgsm is misconfigured (bad key)' \
'test_config user.signingkey BobTheMouse &&
test_config gpg.format x509 &&
test_must_fail git tag -s -m tail tag-gpg-failure'
# try to produce invalid signature
-test_expect_success GPGSM \
- 'git tag -s fails if gpgsm is misconfigured (bad signature format)' \
+test_expect_success GPGSM 'git tag -s fails if gpgsm is misconfigured (bad signature format)' \
'test_config gpg.x509.program echo &&
test_config gpg.format x509 &&
test_must_fail git tag -s -m tail tag-gpg-failure'
# try to verify without gpg:
-test_expect_success GPG \
- 'verify signed tag fails when public key is not present' \
+test_expect_success GPG 'verify signed tag fails when public key is not present' \
'rm -rf gpghome &&
test_must_fail git tag -v signed-tag
'
-test_expect_success \
- 'git tag -a fails if tag annotation is empty' '
+test_expect_success 'git tag -a fails if tag annotation is empty' '
! (GIT_EDITOR=cat git tag -a initial-comment)
'
-test_expect_success \
- 'message in editor has initial comment' '
+test_expect_success 'message in editor has initial comment' '
! (GIT_EDITOR=cat git tag -a initial-comment >actual)
'
@@ -1595,15 +1514,13 @@ test_expect_success 'message in editor has initial comment: first line' '
test_cmp first.expect first.actual
'
-test_expect_success \
- 'message in editor has initial comment: remainder' '
+test_expect_success 'message in editor has initial comment: remainder' '
# remove commented lines from the remainder -- should be empty
sed -e 1d -e "/^#/d" <actual >rest.actual &&
test_must_be_empty rest.actual
'
-test_expect_success \
- 'overwriting an annotated tag should use its previous body' '
+test_expect_success 'overwriting an annotated tag should use its previous body' '
get_tag_header reuse $commit commit $time >expect &&
echo "An annotation to be reused" >>expect &&
git tag -a -m "An annotation to be reused" reuse &&
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v4 7/8] [Newcomer] t7004: test Description and test body seperated with backslash
2024-08-05 23:59 [PATCH v4 0/8] t7004: Modernize the style AbdAlRahman Gad
` (5 preceding siblings ...)
2024-08-05 23:59 ` [PATCH v4 6/8] [Newcomer] t7004: Description on the same line as test_expect_success AbdAlRahman Gad
@ 2024-08-05 23:59 ` AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 8/8] [Newcomer] t7004: Use single quotes instead of double quotes AbdAlRahman Gad
2024-08-06 0:45 ` [PATCH v4 0/8] t7004: Modernize the style Junio C Hamano
8 siblings, 0 replies; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-05 23:59 UTC (permalink / raw)
To: git; +Cc: AbdAlRahman Gad
Test body should begin with a single quote right after the test
description instead of backslash followed by new line.
Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
---
t/t7004-tag.sh | 125 ++++++++++++++++++++++++++++---------------------
1 file changed, 71 insertions(+), 54 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 6c93192d5d..a46f8141d4 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -61,8 +61,9 @@ test_expect_success 'sort tags, ignore case' '
)
'
-test_expect_success 'looking for a tag in an empty tree should fail' \
- '! (tag_exists mytag)'
+test_expect_success 'looking for a tag in an empty tree should fail' '
+ ! (tag_exists mytag)
+'
test_expect_success 'creating a tag in an empty tree should fail' '
test_must_fail git tag mynotag &&
@@ -150,25 +151,31 @@ test_expect_success 'listing all tags if one exists should output that tag' '
# pattern matching:
-test_expect_success 'listing a tag using a matching pattern should succeed' \
- 'git tag -l mytag'
+test_expect_success 'listing a tag using a matching pattern should succeed' '
+ git tag -l mytag
+'
-test_expect_success 'listing a tag with --ignore-case' \
- 'test $(git tag -l --ignore-case MYTAG) = mytag'
+test_expect_success 'listing a tag with --ignore-case' '
+ test $(git tag -l --ignore-case MYTAG) = mytag
+'
-test_expect_success 'listing a tag using a matching pattern should output that tag' \
- 'test $(git tag -l mytag) = mytag'
+test_expect_success 'listing a tag using a matching pattern should output that tag' '
+ test $(git tag -l mytag) = mytag
+'
-test_expect_success 'listing tags using a non-matching pattern should succeed' \
- 'git tag -l xxx'
+test_expect_success 'listing tags using a non-matching pattern should succeed' '
+ git tag -l xxx
+'
-test_expect_success 'listing tags using a non-matching pattern should output nothing' \
- 'test $(git tag -l xxx | wc -l) -eq 0'
+test_expect_success 'listing tags using a non-matching pattern should output nothing' '
+ test $(git tag -l xxx | wc -l) -eq 0
+'
# special cases for creating tags:
-test_expect_success 'trying to create a tag with the name of one existing should fail' \
- 'test_must_fail git tag mytag'
+test_expect_success 'trying to create a tag with the name of one existing should fail' '
+ test_must_fail git tag mytag
+'
test_expect_success 'trying to create a tag with a non-valid name should fail' '
test $(git tag -l | wc -l) -eq 1 &&
@@ -238,8 +245,9 @@ test_expect_success 'trying to delete two tags, existing and not, should fail in
! tag_exists nonexistingtag
'
-test_expect_success 'trying to delete an already deleted tag should fail' \
- 'test_must_fail git tag -d mytag'
+test_expect_success 'trying to delete an already deleted tag should fail' '
+ test_must_fail git tag -d mytag
+'
# listing various tags with pattern matching:
@@ -419,14 +427,17 @@ test_expect_success 'a non-annotated tag created without parameters should point
test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
'
-test_expect_success 'trying to verify an unknown tag should fail' \
- 'test_must_fail git tag -v unknown-tag'
+test_expect_success 'trying to verify an unknown tag should fail' '
+ test_must_fail git tag -v unknown-tag
+'
-test_expect_success 'trying to verify a non-annotated and non-signed tag should fail' \
- 'test_must_fail git tag -v non-annotated-tag'
+test_expect_success 'trying to verify a non-annotated and non-signed tag should fail' '
+ test_must_fail git tag -v non-annotated-tag
+'
-test_expect_success 'trying to verify many non-annotated or unknown tags, should fail' \
- 'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'
+test_expect_success 'trying to verify many non-annotated or unknown tags, should fail' '
+ test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2
+'
# creating annotated tags:
@@ -1016,8 +1027,8 @@ test_expect_success GPG '-s implies annotated tag' '
test_cmp expect actual
'
-test_expect_success GPG 'git tag -s implied if configured with tag.forcesignannotated' \
- 'get_tag_header forcesignannotated-implied-sign $commit commit $time >expect &&
+test_expect_success GPG 'git tag -s implied if configured with tag.forcesignannotated' '
+ get_tag_header forcesignannotated-implied-sign $commit commit $time >expect &&
echo "A message" >>expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
test_config tag.forcesignannotated true &&
@@ -1026,15 +1037,15 @@ test_expect_success GPG 'git tag -s implied if configured with tag.forcesignanno
test_cmp expect actual
'
-test_expect_success GPG 'lightweight with no message when configured with tag.forcesignannotated' \
- 'test_config tag.forcesignannotated true &&
+test_expect_success GPG 'lightweight with no message when configured with tag.forcesignannotated' '
+ test_config tag.forcesignannotated true &&
git tag forcesignannotated-lightweight &&
tag_exists forcesignannotated-lightweight &&
test_must_fail git tag -v forcesignannotated-no-message
'
-test_expect_success GPG 'git tag -a disable configured tag.forcesignannotated' \
- 'get_tag_header forcesignannotated-annotate $commit commit $time >expect &&
+test_expect_success GPG 'git tag -a disable configured tag.forcesignannotated' '
+ get_tag_header forcesignannotated-annotate $commit commit $time >expect &&
echo "A message" >>expect &&
test_config tag.forcesignannotated true &&
git tag -a -m "A message" forcesignannotated-annotate &&
@@ -1043,8 +1054,8 @@ test_expect_success GPG 'git tag -a disable configured tag.forcesignannotated' \
test_must_fail git tag -v forcesignannotated-annotate
'
-test_expect_success GPG 'git tag --sign enable GPG sign' \
- 'get_tag_header forcesignannotated-disabled $commit commit $time >expect &&
+test_expect_success GPG 'git tag --sign enable GPG sign' '
+ get_tag_header forcesignannotated-disabled $commit commit $time >expect &&
echo "A message" >>expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
test_config tag.forcesignannotated false &&
@@ -1053,8 +1064,8 @@ test_expect_success GPG 'git tag --sign enable GPG sign' \
test_cmp expect actual
'
-test_expect_success GPG 'git tag configured tag.gpgsign enables GPG sign' \
- 'get_tag_header gpgsign-enabled $commit commit $time >expect &&
+test_expect_success GPG 'git tag configured tag.gpgsign enables GPG sign' '
+ get_tag_header gpgsign-enabled $commit commit $time >expect &&
echo "A message" >>expect &&
echo "-----BEGIN PGP SIGNATURE-----" >>expect &&
test_config tag.gpgsign true &&
@@ -1063,8 +1074,8 @@ test_expect_success GPG 'git tag configured tag.gpgsign enables GPG sign' \
test_cmp expect actual
'
-test_expect_success GPG 'git tag --no-sign configured tag.gpgsign skip GPG sign' \
- 'get_tag_header no-sign $commit commit $time >expect &&
+test_expect_success GPG 'git tag --no-sign configured tag.gpgsign skip GPG sign' '
+ get_tag_header no-sign $commit commit $time >expect &&
echo "A message" >>expect &&
test_config tag.gpgsign true &&
git tag -a --no-sign -m "A message" no-sign &&
@@ -1079,11 +1090,13 @@ test_expect_success GPG 'trying to create a signed tag with non-existing -F file
! tag_exists nosigtag
'
-test_expect_success GPG 'verifying a signed tag should succeed' \
- 'git tag -v signed-tag'
+test_expect_success GPG 'verifying a signed tag should succeed' '
+ git tag -v signed-tag
+'
-test_expect_success GPG 'verifying two signed tags in one command should succeed' \
- 'git tag -v signed-tag file-signed-tag'
+test_expect_success GPG 'verifying two signed tags in one command should succeed' '
+ git tag -v signed-tag file-signed-tag
+'
test_expect_success GPG 'verifying many signed and non-signed tags should fail' '
test_must_fail git tag -v signed-tag annotated-tag &&
@@ -1453,14 +1466,16 @@ test_expect_success GPG,RFC1991 'reediting a signed tag body omits signature' '
'
# try to sign with bad user.signingkey
-test_expect_success GPG 'git tag -s fails if gpg is misconfigured (bad key)' \
- 'test_config user.signingkey BobTheMouse &&
- test_must_fail git tag -s -m tail tag-gpg-failure'
+test_expect_success GPG 'git tag -s fails if gpg is misconfigured (bad key)' '
+ test_config user.signingkey BobTheMouse &&
+ test_must_fail git tag -s -m tail tag-gpg-failure
+'
# try to produce invalid signature
-test_expect_success GPG 'git tag -s fails if gpg is misconfigured (bad signature format)' \
- 'test_config gpg.program echo &&
- test_must_fail git tag -s -m tail tag-gpg-failure'
+test_expect_success GPG 'git tag -s fails if gpg is misconfigured (bad signature format)' '
+ test_config gpg.program echo &&
+ test_must_fail git tag -s -m tail tag-gpg-failure
+'
# try to produce invalid signature
test_expect_success GPG 'git verifies tag is valid with double signature' '
@@ -1481,21 +1496,23 @@ test_expect_success GPG 'git verifies tag is valid with double signature' '
'
# try to sign with bad user.signingkey
-test_expect_success GPGSM 'git tag -s fails if gpgsm is misconfigured (bad key)' \
- 'test_config user.signingkey BobTheMouse &&
- test_config gpg.format x509 &&
- test_must_fail git tag -s -m tail tag-gpg-failure'
+test_expect_success GPGSM 'git tag -s fails if gpgsm is misconfigured (bad key)' '
+ test_config user.signingkey BobTheMouse &&
+ test_config gpg.format x509 &&
+ test_must_fail git tag -s -m tail tag-gpg-failure
+'
# try to produce invalid signature
-test_expect_success GPGSM 'git tag -s fails if gpgsm is misconfigured (bad signature format)' \
- 'test_config gpg.x509.program echo &&
- test_config gpg.format x509 &&
- test_must_fail git tag -s -m tail tag-gpg-failure'
+test_expect_success GPGSM 'git tag -s fails if gpgsm is misconfigured (bad signature format)' '
+ test_config gpg.x509.program echo &&
+ test_config gpg.format x509 &&
+ test_must_fail git tag -s -m tail tag-gpg-failure
+'
# try to verify without gpg:
-test_expect_success GPG 'verify signed tag fails when public key is not present' \
- 'rm -rf gpghome &&
+test_expect_success GPG 'verify signed tag fails when public key is not present' '
+ rm -rf gpghome &&
test_must_fail git tag -v signed-tag
'
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v4 8/8] [Newcomer] t7004: Use single quotes instead of double quotes
2024-08-05 23:59 [PATCH v4 0/8] t7004: Modernize the style AbdAlRahman Gad
` (6 preceding siblings ...)
2024-08-05 23:59 ` [PATCH v4 7/8] [Newcomer] t7004: test Description and test body seperated with backslash AbdAlRahman Gad
@ 2024-08-05 23:59 ` AbdAlRahman Gad
2024-08-06 3:02 ` Eric Sunshine
2024-08-06 0:45 ` [PATCH v4 0/8] t7004: Modernize the style Junio C Hamano
8 siblings, 1 reply; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-05 23:59 UTC (permalink / raw)
To: git; +Cc: AbdAlRahman Gad
Some test bodies and test description are surrounded with double
quotes instead of single quotes, violating our coding style.
Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
---
t/t7004-tag.sh | 70 +++++++++++++++++++++++++-------------------------
1 file changed, 35 insertions(+), 35 deletions(-)
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index a46f8141d4..06f07b5524 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1585,7 +1585,7 @@ test_expect_success 'creating third commit without tag' '
# simple linear checks of --continue
-test_expect_success 'checking that first commit is in all tags (hash)' "
+test_expect_success 'checking that first commit is in all tags (hash)' '
hash3=$(git rev-parse HEAD) &&
cat >expected <<-\EOF &&
v0.2.1
@@ -1596,10 +1596,10 @@ test_expect_success 'checking that first commit is in all tags (hash)' "
EOF
git tag -l --contains $hash1 v* >actual &&
test_cmp expected actual
-"
+'
# other ways of specifying the commit
-test_expect_success 'checking that first commit is in all tags (tag)' "
+test_expect_success 'checking that first commit is in all tags (tag)' '
cat >expected <<-\EOF &&
v0.2.1
v1.0
@@ -1609,9 +1609,9 @@ test_expect_success 'checking that first commit is in all tags (tag)' "
EOF
git tag -l --contains v1.0 v* >actual &&
test_cmp expected actual
-"
+'
-test_expect_success 'checking that first commit is in all tags (relative)' "
+test_expect_success 'checking that first commit is in all tags (relative)' '
cat >expected <<-\EOF &&
v0.2.1
v1.0
@@ -1621,33 +1621,33 @@ test_expect_success 'checking that first commit is in all tags (relative)' "
EOF
git tag -l --contains HEAD~2 v* >actual &&
test_cmp expected actual
-"
+'
# All the --contains tests above, but with --no-contains
-test_expect_success 'checking that first commit is not listed in any tag with --no-contains (hash)' "
+test_expect_success 'checking that first commit is not listed in any tag with --no-contains (hash)' '
git tag -l --no-contains $hash1 v* >actual &&
test_must_be_empty actual
-"
+'
-test_expect_success 'checking that first commit is in all tags (tag)' "
+test_expect_success 'checking that first commit is in all tags (tag)' '
git tag -l --no-contains v1.0 v* >actual &&
test_must_be_empty actual
-"
+'
-test_expect_success 'checking that first commit is in all tags (relative)' "
+test_expect_success 'checking that first commit is in all tags (relative)' '
git tag -l --no-contains HEAD~2 v* >actual &&
test_must_be_empty actual
-"
+'
-test_expect_success 'checking that second commit only has one tag' "
+test_expect_success 'checking that second commit only has one tag' '
cat >expected <<-\EOF &&
v2.0
EOF
git tag -l --contains $hash2 v* >actual &&
test_cmp expected actual
-"
+'
-test_expect_success 'inverse of the last test, with --no-contains' "
+test_expect_success 'inverse of the last test, with --no-contains' '
cat >expected <<-\EOF &&
v0.2.1
v1.0
@@ -1656,14 +1656,14 @@ test_expect_success 'inverse of the last test, with --no-contains' "
EOF
git tag -l --no-contains $hash2 v* >actual &&
test_cmp expected actual
-"
+'
-test_expect_success 'checking that third commit has no tags' "
+test_expect_success 'checking that third commit has no tags' '
git tag -l --contains $hash3 v* >actual &&
test_must_be_empty actual
-"
+'
-test_expect_success 'conversely --no-contains on the third commit lists all tags' "
+test_expect_success 'conversely --no-contains on the third commit lists all tags' '
cat >expected <<-\EOF &&
v0.2.1
v1.0
@@ -1673,7 +1673,7 @@ test_expect_success 'conversely --no-contains on the third commit lists all tags
EOF
git tag -l --no-contains $hash3 v* >actual &&
test_cmp expected actual
-"
+'
# how about a simple merge?
@@ -1694,7 +1694,7 @@ test_expect_success 'checking that branch head only has one tag' '
test_cmp expected actual
'
-test_expect_success 'checking that branch head with --no-contains lists all but one tag' "
+test_expect_success 'checking that branch head with --no-contains lists all but one tag' '
cat >expected <<-\EOF &&
v0.2.1
v1.0
@@ -1704,22 +1704,22 @@ test_expect_success 'checking that branch head with --no-contains lists all but
EOF
git tag -l --no-contains $hash4 v* >actual &&
test_cmp expected actual
-"
+'
test_expect_success 'merging original branch into this branch' '
git merge --strategy=ours main &&
git tag v4.0
'
-test_expect_success 'checking that original branch head has one tag now' "
+test_expect_success 'checking that original branch head has one tag now' '
cat >expected <<-\EOF &&
v4.0
EOF
git tag -l --contains $hash3 v* >actual &&
test_cmp expected actual
-"
+'
-test_expect_success 'checking that original branch head with --no-contains lists all but one tag now' "
+test_expect_success 'checking that original branch head with --no-contains lists all but one tag now' '
cat >expected <<-\EOF &&
v0.2.1
v1.0
@@ -1730,9 +1730,9 @@ test_expect_success 'checking that original branch head with --no-contains lists
EOF
git tag -l --no-contains $hash3 v* >actual &&
test_cmp expected actual
-"
+'
-test_expect_success 'checking that initial commit is in all tags' "
+test_expect_success 'checking that initial commit is in all tags' '
cat >expected <<-\EOF &&
v0.2.1
v1.0
@@ -1744,7 +1744,7 @@ test_expect_success 'checking that initial commit is in all tags' "
EOF
git tag -l --contains $hash1 v* >actual &&
test_cmp expected actual
-"
+'
test_expect_success 'checking that --contains can be used in non-list mode' '
cat >expected <<-\EOF &&
@@ -1760,10 +1760,10 @@ test_expect_success 'checking that --contains can be used in non-list mode' '
test_cmp expected actual
'
-test_expect_success 'checking that initial commit is in all tags with --no-contains' "
+test_expect_success 'checking that initial commit is in all tags with --no-contains' '
git tag -l --no-contains $hash1 v* >actual &&
test_must_be_empty actual
-"
+'
# mixing modes and options:
@@ -1800,16 +1800,16 @@ test_expect_success 'mixing incompatibles modes and options is forbidden' '
for option in --contains --with --no-contains --without --merged --no-merged --points-at
do
- test_expect_success "mixing incompatible modes with $option is forbidden" "
+ test_expect_success 'mixing incompatible modes with $option is forbidden' '
test_must_fail git tag -d $option HEAD &&
test_must_fail git tag -d $option HEAD some-tag &&
test_must_fail git tag -v $option HEAD
- "
- test_expect_success "Doing 'git tag --list-like $option <commit> <pattern> is permitted" "
+ '
+ test_expect_success 'Doing "git tag --list-like $option <commit> <pattern> is permitted' '
git tag -n $option HEAD HEAD &&
git tag $option HEAD HEAD &&
git tag $option
- "
+ '
done
# check points-at
@@ -2185,7 +2185,7 @@ test_expect_success 'git tag -l with --format="%(rest)" must fail' '
test_must_fail git tag -l --format="%(rest)" "v1*"
'
-test_expect_success "set up color tests" '
+test_expect_success 'set up color tests' '
echo "<RED>v1.0<RESET>" >expect.color &&
echo "v1.0" >expect.bare &&
color_args="--format=%(color:red)%(refname:short) --list v1.0"
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v4 0/8] t7004: Modernize the style
2024-08-05 23:59 [PATCH v4 0/8] t7004: Modernize the style AbdAlRahman Gad
` (7 preceding siblings ...)
2024-08-05 23:59 ` [PATCH v4 8/8] [Newcomer] t7004: Use single quotes instead of double quotes AbdAlRahman Gad
@ 2024-08-06 0:45 ` Junio C Hamano
2024-08-06 8:44 ` AbdAlRahman Gad
8 siblings, 1 reply; 21+ messages in thread
From: Junio C Hamano @ 2024-08-06 0:45 UTC (permalink / raw)
To: AbdAlRahman Gad; +Cc: git
AbdAlRahman Gad <abdobngad@gmail.com> writes:
> AbdAlRahman Gad (8):
> [Newcomer] t7004: Remove space after redirect operators
> [Newcomer] t7004: Do not lose exit status to pipe
> [Newcomer] t7004: One command per line
> [Newcomer] t7004: Do not prepare things outside test_expect_success
> [Newcomer] t7004: Use indented here-doc
> [Newcomer] t7004: Description on the same line as test_expect_success
> [Newcomer] t7004: Description and test body seperated with backslash
> [Newcomer] t7004: Use single quotes instead of double quotes
As you can see from "git shortlog --no-merges --since=6.months", we
do not capitalize the first word of the title description of each
patch.
Also, I haven't looked at the individual patches, it seems the patch
is somewhoat whitespace damaged.
$ git am -s ./+ag8-v4
Applying: t7004: remove space after redirect operators
.git/rebase-apply/patch:169: indent with spaces.
git checkout stable &&
.git/rebase-apply/patch:193: indent with spaces.
git tag v4.0
warning: 2 lines add whitespace errors.
Applying: t7004: do not lose exit status to pipe
Applying: t7004: one command per line
Applying: t7004: do not prepare things outside test_expect_success
.git/rebase-apply/patch:1188: indent with spaces.
git tag v4.0
warning: 1 line adds whitespace errors.
Applying: t7004: use indented here-doc
Applying: t7004: description on the same line as test_expect_success
Applying: t7004: test description and test body seperated with backslash
Applying: t7004: use single quotes instead of double quotes
.git/rebase-apply/patch:133: indent with spaces.
git tag v4.0
warning: 1 line adds whitespace errors.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 8/8] [Newcomer] t7004: Use single quotes instead of double quotes
2024-08-05 23:59 ` [PATCH v4 8/8] [Newcomer] t7004: Use single quotes instead of double quotes AbdAlRahman Gad
@ 2024-08-06 3:02 ` Eric Sunshine
2024-08-06 10:10 ` AbdAlRahman Gad
2024-08-06 16:35 ` Junio C Hamano
0 siblings, 2 replies; 21+ messages in thread
From: Eric Sunshine @ 2024-08-06 3:02 UTC (permalink / raw)
To: AbdAlRahman Gad; +Cc: git
On Mon, Aug 5, 2024 at 8:00 PM AbdAlRahman Gad <abdobngad@gmail.com> wrote:
> Some test bodies and test description are surrounded with double
> quotes instead of single quotes, violating our coding style.
>
> Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
> ---
> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
> @@ -1585,7 +1585,7 @@ test_expect_success 'creating third commit without tag' '
> -test_expect_success 'checking that first commit is in all tags (hash)' "
> +test_expect_success 'checking that first commit is in all tags (hash)' '
> hash3=$(git rev-parse HEAD) &&
> ...
> git tag -l --contains $hash1 v* >actual &&
> test_cmp expected actual
> -"
> +'
We need to exercise a bit of caution when making this sort of change
because a "..." string differs from a '...' string in shell. For
instance, in a "..." string, interpolation occurs as the string is
scanned by the shell, whereas a '...' string is taken as a literal.
Thus, in the above, when it was using a double-quoted string,
expressions such as `$(git rev-parse HEAD)` and `$hash1` were being
evaluated and interpolated into the string _before_ the
test_expect_success() function is even called. On the other hand, with
a single-quoted string, those expression do not get evaluated when the
string is scanned, thus remain as-is when passed to
test_expect_success() as an argument, and they are evaluated only
later when test_expect_success() invokes `eval` on that argument.
Depending upon the situation, this difference in evaluation context
may have a significant impact.
As a practical example, consider a test with a body like this:
echo nothing >nothing &&
git add nothing &&
git commit -m nothing &&
hash=$(git rev-parse HEAD) &&
...
If this body is inside a double-quoted string, then `$(git rev-parse
HEAD)` will be evaluated and its value assigned to `hash` _before_
test_expect_success() is called, thus also before the `git commit`
command inside the test body (which is almost certainly not what the
author intended). On the other hand, inside a single-quoted string,
`$(git rev-parse HEAD)` will be evaluated only once
test_expect_success() runs the test body, meaning `$(git rev-parse
HEAD)` will correctly be evaluated _after_ `git commit`. Hence, `hash`
will have a different value depending upon whether single- or
double-quotes are used.
Having said all that, in this case, you seem to have lucked out and
nothing broke by changing the double-quotes to single-quotes around
the test bodies.
However...
> @@ -1800,16 +1800,16 @@ test_expect_success 'mixing incompatibles modes and options is forbidden' '
> for option in --contains --with --no-contains --without --merged --no-merged --points-at
> do
> - test_expect_success "mixing incompatible modes with $option is forbidden" "
> + test_expect_success 'mixing incompatible modes with $option is forbidden' '
> test_must_fail git tag -d $option HEAD &&
> test_must_fail git tag -d $option HEAD some-tag &&
> test_must_fail git tag -v $option HEAD
> - "
> - test_expect_success "Doing 'git tag --list-like $option <commit> <pattern> is permitted" "
> + '
> + test_expect_success 'Doing "git tag --list-like $option <commit> <pattern> is permitted' '
> git tag -n $option HEAD HEAD &&
> git tag $option HEAD HEAD &&
> git tag $option
> - "
> + '
> done
... changing the double-quotes to single-quotes for the test _titles_
in these instances is actively wrong. In this case, we _want_
interpolation of `$option` to happen in the title string so that the
output looks like this:
ok 167 - mixing incompatible modes with --contains is forbidden
ok 169 - mixing incompatible modes with --with is forbidden
ok 171 - mixing incompatible modes with --no-contains is forbidden
By changing the title to use single-quotes, you suppress interpolation
of `$option`, with the result that the displayed titles become rather
useless:
ok 167 - mixing incompatible modes with $option is forbidden
ok 169 - mixing incompatible modes with $option is forbidden
ok 171 - mixing incompatible modes with $option is forbidden
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 2/8] [Newcomer] t7004: Do not lose exit status to pipe
2024-08-05 23:59 ` [PATCH v4 2/8] [Newcomer] t7004: Do not lose exit status to pipe AbdAlRahman Gad
@ 2024-08-06 3:13 ` Eric Sunshine
2024-08-06 8:38 ` AbdAlRahman Gad
0 siblings, 1 reply; 21+ messages in thread
From: Eric Sunshine @ 2024-08-06 3:13 UTC (permalink / raw)
To: AbdAlRahman Gad; +Cc: git
On Mon, Aug 5, 2024 at 8:00 PM AbdAlRahman Gad <abdobngad@gmail.com> wrote:
> Split "test-tool ... | sed" pipeline into two commands to avoid losing
> exit status from test-tool.
>
> Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
> ---
> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
> @@ -97,7 +97,8 @@ test_expect_success 'creating a tag with --create-reflog should create reflog' '
> - test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 | sed -e "s/^.* //" >actual &&
> + test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 >actual.body &&
> + sed -e "s/^.* //" actual.body >actual &&
It's not just `test_tool` we care about; we also (importantly) don't
want to see `git` itself upstream of a pipe, and there are many such
instances remaining in this script. Here are some common examples:
test $(git tag -l | wc -l) -eq 0 &&
git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
git tag -l | grep "^tag-one-line" >actual &&
forged=$(git cat-file tag ... | sed -e ... | git mktag) &&
git tag -l --no-sort "foo*" | sort >actual &&
By the way, these days, rather than:
test $(git tag -l | wc -l) -eq 0 &&
we would say:
test_stdout_line_count = 0 git tag -l &&
which nicely avoids placing `git` upstream of a pipe.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 4/8] [Newcomer] t7004: Do not prepare things outside test_expect_success
2024-08-05 23:59 ` [PATCH v4 4/8] [Newcomer] t7004: Do not prepare things outside test_expect_success AbdAlRahman Gad
@ 2024-08-06 3:29 ` Eric Sunshine
2024-08-06 8:41 ` AbdAlRahman Gad
0 siblings, 1 reply; 21+ messages in thread
From: Eric Sunshine @ 2024-08-06 3:29 UTC (permalink / raw)
To: AbdAlRahman Gad; +Cc: git
On Mon, Aug 5, 2024 at 8:00 PM AbdAlRahman Gad <abdobngad@gmail.com> wrote:
> Do not prepare expect and other things outside test_expect_success.
> Also add '\' before EOF to avoid shell interpolation and '-' to allow
> indentation of the body.
>
> Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
When you reroll, it might be a good idea to explain _why_ we don't
want to run code outside of `test_expect_success`: in particular, if
such code fails for some reason, we won't necessarily hear about it in
a timely fashion (or perhaps at all). By placing all code inside
`test_expect_success` it ensures that we know immediately if it fails.
> test_expect_success GPG,RFC1991 \
> 'reediting a signed tag body omits signature' '
> + cat >fakeeditor <<-\EOF &&
> + #!/bin/sh
> + cp "$1" actual
> + EOF
> + chmod +x fakeeditor &&
It's completely outside the scope of this particular patch, but
another modernization which could be done in a separate patch (or a
separate patch series -- it doesn't need to be part of this series)
would be to take advantage of `write_script` which eliminates some of
the boilerplate-work that the above code is doing. For instance:
write_script fakeeditor <<-\EOF
cp "$1" actual
EOF
Notice that `write_script` takes care of emitting the `#!/bin/sh` line
and the `chmod +x`.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 2/8] [Newcomer] t7004: Do not lose exit status to pipe
2024-08-06 3:13 ` Eric Sunshine
@ 2024-08-06 8:38 ` AbdAlRahman Gad
2024-08-06 18:05 ` Eric Sunshine
0 siblings, 1 reply; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-06 8:38 UTC (permalink / raw)
To: Eric Sunshine; +Cc: git
On 8/6/24 06:13, Eric Sunshine wrote:
> On Mon, Aug 5, 2024 at 8:00 PM AbdAlRahman Gad <abdobngad@gmail.com> wrote:
>> Split "test-tool ... | sed" pipeline into two commands to avoid losing
>> exit status from test-tool.
>>
>> Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
>> ---
>> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
>> @@ -97,7 +97,8 @@ test_expect_success 'creating a tag with --create-reflog should create reflog' '
>> - test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 | sed -e "s/^.* //" >actual &&
>> + test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 >actual.body &&
>> + sed -e "s/^.* //" actual.body >actual &&
>
> It's not just `test_tool` we care about; we also (importantly) don't
> want to see `git` itself upstream of a pipe, and there are many such
> instances remaining in this script. Here are some common examples:
>
> test $(git tag -l | wc -l) -eq 0 &&
> git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
> git tag -l | grep "^tag-one-line" >actual &&
> forged=$(git cat-file tag ... | sed -e ... | git mktag) &&
> git tag -l --no-sort "foo*" | sort >actual &&
>
> By the way, these days, rather than:
>
> test $(git tag -l | wc -l) -eq 0 &&
>
> we would say:
>
> test_stdout_line_count = 0 git tag -l &&
>
> which nicely avoids placing `git` upstream of a pipe.
Thanks for the review. Could this be done in a separate patch series? As
modifying a patch in the beginning of a patch series requires lots of
time to adapt the rest of the series to the change.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 4/8] [Newcomer] t7004: Do not prepare things outside test_expect_success
2024-08-06 3:29 ` Eric Sunshine
@ 2024-08-06 8:41 ` AbdAlRahman Gad
0 siblings, 0 replies; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-06 8:41 UTC (permalink / raw)
To: Eric Sunshine; +Cc: git
On 8/6/24 06:29, Eric Sunshine wrote:
> On Mon, Aug 5, 2024 at 8:00 PM AbdAlRahman Gad <abdobngad@gmail.com> wrote:
>> Do not prepare expect and other things outside test_expect_success.
>> Also add '\' before EOF to avoid shell interpolation and '-' to allow
>> indentation of the body.
>>
>> Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
>
> When you reroll, it might be a good idea to explain _why_ we don't
> want to run code outside of `test_expect_success`: in particular, if
> such code fails for some reason, we won't necessarily hear about it in
> a timely fashion (or perhaps at all). By placing all code inside
> `test_expect_success` it ensures that we know immediately if it fails.
Thanks! I'll do that in the next version.
>> test_expect_success GPG,RFC1991 \
>> 'reediting a signed tag body omits signature' '
>> + cat >fakeeditor <<-\EOF &&
>> + #!/bin/sh
>> + cp "$1" actual
>> + EOF
>> + chmod +x fakeeditor &&
>
> It's completely outside the scope of this particular patch, but
> another modernization which could be done in a separate patch (or a
> separate patch series -- it doesn't need to be part of this series)
> would be to take advantage of `write_script` which eliminates some of
> the boilerplate-work that the above code is doing. For instance:
>
> write_script fakeeditor <<-\EOF
> cp "$1" actual
> EOF
>
> Notice that `write_script` takes care of emitting the `#!/bin/sh` line
> and the `chmod +x`.
There is only two cases in this file. I'll add a patch to the end of v5.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 0/8] t7004: Modernize the style
2024-08-06 0:45 ` [PATCH v4 0/8] t7004: Modernize the style Junio C Hamano
@ 2024-08-06 8:44 ` AbdAlRahman Gad
0 siblings, 0 replies; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-06 8:44 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On 8/6/24 03:45, Junio C Hamano wrote:
> AbdAlRahman Gad <abdobngad@gmail.com> writes:
>
>> AbdAlRahman Gad (8):
>> [Newcomer] t7004: Remove space after redirect operators
>> [Newcomer] t7004: Do not lose exit status to pipe
>> [Newcomer] t7004: One command per line
>> [Newcomer] t7004: Do not prepare things outside test_expect_success
>> [Newcomer] t7004: Use indented here-doc
>> [Newcomer] t7004: Description on the same line as test_expect_success
>> [Newcomer] t7004: Description and test body seperated with backslash
>> [Newcomer] t7004: Use single quotes instead of double quotes
>
> As you can see from "git shortlog --no-merges --since=6.months", we
> do not capitalize the first word of the title description of each
> patch.
>
> Also, I haven't looked at the individual patches, it seems the patch
> is somewhoat whitespace damaged.
>
> $ git am -s ./+ag8-v4
> Applying: t7004: remove space after redirect operators
> .git/rebase-apply/patch:169: indent with spaces.
> git checkout stable &&
> .git/rebase-apply/patch:193: indent with spaces.
> git tag v4.0
> warning: 2 lines add whitespace errors.
> Applying: t7004: do not lose exit status to pipe
> Applying: t7004: one command per line
> Applying: t7004: do not prepare things outside test_expect_success
> .git/rebase-apply/patch:1188: indent with spaces.
> git tag v4.0
> warning: 1 line adds whitespace errors.
> Applying: t7004: use indented here-doc
> Applying: t7004: description on the same line as test_expect_success
> Applying: t7004: test description and test body seperated with backslash
> Applying: t7004: use single quotes instead of double quotes
> .git/rebase-apply/patch:133: indent with spaces.
> git tag v4.0
> warning: 1 line adds whitespace errors.
>
Thanks! I'll fix that and send a v5.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 8/8] [Newcomer] t7004: Use single quotes instead of double quotes
2024-08-06 3:02 ` Eric Sunshine
@ 2024-08-06 10:10 ` AbdAlRahman Gad
2024-08-06 17:21 ` Eric Sunshine
2024-08-06 16:35 ` Junio C Hamano
1 sibling, 1 reply; 21+ messages in thread
From: AbdAlRahman Gad @ 2024-08-06 10:10 UTC (permalink / raw)
To: Eric Sunshine; +Cc: git
On 8/6/24 06:02, Eric Sunshine wrote:
> On Mon, Aug 5, 2024 at 8:00 PM AbdAlRahman Gad <abdobngad@gmail.com> wrote:
>> Some test bodies and test description are surrounded with double
>> quotes instead of single quotes, violating our coding style.
>>
>> Signed-off-by: AbdAlRahman Gad <abdobngad@gmail.com>
>> ---
>> diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
>> @@ -1585,7 +1585,7 @@ test_expect_success 'creating third commit without tag' '
>> -test_expect_success 'checking that first commit is in all tags (hash)' "
>> +test_expect_success 'checking that first commit is in all tags (hash)' '
>> hash3=$(git rev-parse HEAD) &&
>> ...
>> git tag -l --contains $hash1 v* >actual &&
>> test_cmp expected actual
>> -"
>> +'
>
> We need to exercise a bit of caution when making this sort of change
> because a "..." string differs from a '...' string in shell. For
> instance, in a "..." string, interpolation occurs as the string is
> scanned by the shell, whereas a '...' string is taken as a literal.
> Thus, in the above, when it was using a double-quoted string,
> expressions such as `$(git rev-parse HEAD)` and `$hash1` were being
> evaluated and interpolated into the string _before_ the
> test_expect_success() function is even called. On the other hand, with
> a single-quoted string, those expression do not get evaluated when the
> string is scanned, thus remain as-is when passed to
> test_expect_success() as an argument, and they are evaluated only
> later when test_expect_success() invokes `eval` on that argument.
> Depending upon the situation, this difference in evaluation context
> may have a significant impact.
>
> As a practical example, consider a test with a body like this:
>
> echo nothing >nothing &&
> git add nothing &&
> git commit -m nothing &&
> hash=$(git rev-parse HEAD) &&
> ...
>
> If this body is inside a double-quoted string, then `$(git rev-parse
> HEAD)` will be evaluated and its value assigned to `hash` _before_
> test_expect_success() is called, thus also before the `git commit`
> command inside the test body (which is almost certainly not what the
> author intended). On the other hand, inside a single-quoted string,
> `$(git rev-parse HEAD)` will be evaluated only once
> test_expect_success() runs the test body, meaning `$(git rev-parse
> HEAD)` will correctly be evaluated _after_ `git commit`. Hence, `hash`
> will have a different value depending upon whether single- or
> double-quotes are used.
>
> Having said all that, in this case, you seem to have lucked out and
> nothing broke by changing the double-quotes to single-quotes around
> the test bodies.
>
> However...
>
>> @@ -1800,16 +1800,16 @@ test_expect_success 'mixing incompatibles modes and options is forbidden' '
>> for option in --contains --with --no-contains --without --merged --no-merged --points-at
>> do
>> - test_expect_success "mixing incompatible modes with $option is forbidden" "
>> + test_expect_success 'mixing incompatible modes with $option is forbidden' '
>> test_must_fail git tag -d $option HEAD &&
>> test_must_fail git tag -d $option HEAD some-tag &&
>> test_must_fail git tag -v $option HEAD
>> - "
>> - test_expect_success "Doing 'git tag --list-like $option <commit> <pattern> is permitted" "
>> + '
>> + test_expect_success 'Doing "git tag --list-like $option <commit> <pattern> is permitted' '
>> git tag -n $option HEAD HEAD &&
>> git tag $option HEAD HEAD &&
>> git tag $option
>> - "
>> + '
>> done
>
> ... changing the double-quotes to single-quotes for the test _titles_
> in these instances is actively wrong. In this case, we _want_
> interpolation of `$option` to happen in the title string so that the
> output looks like this:
>
> ok 167 - mixing incompatible modes with --contains is forbidden
> ok 169 - mixing incompatible modes with --with is forbidden
> ok 171 - mixing incompatible modes with --no-contains is forbidden
>
> By changing the title to use single-quotes, you suppress interpolation
> of `$option`, with the result that the displayed titles become rather
> useless:
>
> ok 167 - mixing incompatible modes with $option is forbidden
> ok 169 - mixing incompatible modes with $option is forbidden
> ok 171 - mixing incompatible modes with $option is forbidden
Thanks for the through explanation! Should I not include this patch in
v5 as the test body is error-prune or should I revert changing the
double-quotes to single-quotes for test description and keep the changes
to the test body and send the patch with v5?
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 8/8] [Newcomer] t7004: Use single quotes instead of double quotes
2024-08-06 3:02 ` Eric Sunshine
2024-08-06 10:10 ` AbdAlRahman Gad
@ 2024-08-06 16:35 ` Junio C Hamano
2024-08-06 17:11 ` Eric Sunshine
1 sibling, 1 reply; 21+ messages in thread
From: Junio C Hamano @ 2024-08-06 16:35 UTC (permalink / raw)
To: Eric Sunshine; +Cc: AbdAlRahman Gad, git
Eric Sunshine <sunshine@sunshineco.com> writes:
> As a practical example, consider a test with a body like this:
>
> echo nothing >nothing &&
> git add nothing &&
> git commit -m nothing &&
> hash=$(git rev-parse HEAD) &&
> ...
>
> If this body is inside a double-quoted string, then `$(git rev-parse
> HEAD)` will be evaluated and its value assigned to `hash` _before_
> test_expect_success() is called,
I know it is just your finger slipping, but the variable "hash" is
not assigned to before test_expect_success is called even with the
body inside dq.
What happens is that the value of HEAD is expanded in the string
that will be evaled by test_expect_success so the 4th line in the
above becomes "hash=3469a23659d8197190d2765cf9f31dec5ab602fa &&";
as the resulting string is then eval'ed by test_expect_success,
the end result is as you descirbed, i.e., ...
> thus also before the `git commit`
> command inside the test body (which is almost certainly not what the
> author intended).
... $hash does not get the name of the commit object resulting from
the "git commit" command before it.
>> - "
>> - test_expect_success "Doing 'git tag --list-like $option <commit> <pattern> is permitted" "
>> + '
>> + test_expect_success 'Doing "git tag --list-like $option <commit> <pattern> is permitted' '
>
> ... changing the double-quotes to single-quotes for the test _titles_
> in these instances is actively wrong. In this case, we _want_
> interpolation of `$option` to happen in the title string so that the
> output looks like this:
>
> ok 167 - mixing incompatible modes with --contains is forbidden
> ok 169 - mixing incompatible modes with --with is forbidden
> ok 171 - mixing incompatible modes with --no-contains is forbidden
>
> By changing the title to use single-quotes, you suppress interpolation
> of `$option`, with the result that the displayed titles become rather
> useless:
>
> ok 167 - mixing incompatible modes with $option is forbidden
> ok 169 - mixing incompatible modes with $option is forbidden
> ok 171 - mixing incompatible modes with $option is forbidden
Yes, these has to be done carefully, both for titles and bodies.
Thanks.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 8/8] [Newcomer] t7004: Use single quotes instead of double quotes
2024-08-06 16:35 ` Junio C Hamano
@ 2024-08-06 17:11 ` Eric Sunshine
0 siblings, 0 replies; 21+ messages in thread
From: Eric Sunshine @ 2024-08-06 17:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: AbdAlRahman Gad, git
On Tue, Aug 6, 2024 at 12:35 PM Junio C Hamano <gitster@pobox.com> wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
> > As a practical example, consider a test with a body like this:
> >
> > echo nothing >nothing &&
> > git add nothing &&
> > git commit -m nothing &&
> > hash=$(git rev-parse HEAD) &&
> > ...
> >
> > If this body is inside a double-quoted string, then `$(git rev-parse
> > HEAD)` will be evaluated and its value assigned to `hash` _before_
> > test_expect_success() is called,
>
> I know it is just your finger slipping, but the variable "hash" is
> not assigned to before test_expect_success is called even with the
> body inside dq.
Ugh, you're quite correct, of course. The "and its value assigned to
`hash`" part was one of those last-moment-edits which come back to
haunt the author. That's not so much a finger slip as an outright
bungle. Thanks for catching and correcting this.
> What happens is that the value of HEAD is expanded in the string
> that will be evaled by test_expect_success so the 4th line in the
> above becomes "hash=3469a23659d8197190d2765cf9f31dec5ab602fa &&";
> as the resulting string is then eval'ed by test_expect_success,
> the end result is as you descirbed, i.e., ...
> ... $hash does not get the name of the commit object resulting from
> the "git commit" command before it.
Including an actual example of the resulting string, as you did here,
does a much better job of illustrating the issue than my bungled
last-moment-edit.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 8/8] [Newcomer] t7004: Use single quotes instead of double quotes
2024-08-06 10:10 ` AbdAlRahman Gad
@ 2024-08-06 17:21 ` Eric Sunshine
0 siblings, 0 replies; 21+ messages in thread
From: Eric Sunshine @ 2024-08-06 17:21 UTC (permalink / raw)
To: AbdAlRahman Gad; +Cc: git
On Tue, Aug 6, 2024 at 6:10 AM AbdAlRahman Gad <abdobngad@gmail.com> wrote:
> On 8/6/24 06:02, Eric Sunshine wrote:
> > We need to exercise a bit of caution when making this sort of change
> > because a "..." string differs from a '...' string in shell. [...]
> > [...]
> > Having said all that, in this case, you seem to have lucked out and
> > nothing broke by changing the double-quotes to single-quotes around
> > the test bodies.
> >
> > However...
> > ... changing the double-quotes to single-quotes for the test _titles_
> > in these instances is actively wrong. In this case, we _want_
> > interpolation of `$option` to happen in the title string so that the
> > output looks like this:
> > ok 167 - mixing incompatible modes with --contains is forbidden
> >
> > By changing the title to use single-quotes, you suppress interpolation
> > of `$option`, with the result that the displayed titles become rather
> > useless:
> > ok 167 - mixing incompatible modes with $option is forbidden
>
> Thanks for the through explanation! Should I not include this patch in
> v5 as the test body is error-prune or should I revert changing the
> double-quotes to single-quotes for test description and keep the changes
> to the test body and send the patch with v5?
Overall, the changes made by this patch are valuable since it brings
the script more in line with modern practice and because single-quotes
around the test body make it easier for readers to reason about test
behavior. Coupled with the fact that none of the tests broke by
changing the bodies from double- to single-quote, it's a good idea to
keep this patch in v5 but omit the parts which break the test
descriptions.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 2/8] [Newcomer] t7004: Do not lose exit status to pipe
2024-08-06 8:38 ` AbdAlRahman Gad
@ 2024-08-06 18:05 ` Eric Sunshine
0 siblings, 0 replies; 21+ messages in thread
From: Eric Sunshine @ 2024-08-06 18:05 UTC (permalink / raw)
To: AbdAlRahman Gad; +Cc: git
On Tue, Aug 6, 2024 at 4:38 AM AbdAlRahman Gad <abdobngad@gmail.com> wrote:
> On 8/6/24 06:13, Eric Sunshine wrote:
> > On Mon, Aug 5, 2024 at 8:00 PM AbdAlRahman Gad <abdobngad@gmail.com> wrote:
> >> - test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 | sed -e "s/^.* //" >actual &&
> >> + test-tool ref-store main for-each-reflog-ent refs/tags/tag_with_reflog1 >actual.body &&
> >> + sed -e "s/^.* //" actual.body >actual &&
> >
> > It's not just `test_tool` we care about; we also (importantly) don't
> > want to see `git` itself upstream of a pipe, and there are many such
> > instances remaining in this script. Here are some common examples:
> >
> > test $(git tag -l | wc -l) -eq 0 &&
> > git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
> > git tag -l | grep "^tag-one-line" >actual &&
> > forged=$(git cat-file tag ... | sed -e ... | git mktag) &&
> > git tag -l --no-sort "foo*" | sort >actual &&
>
> Thanks for the review. Could this be done in a separate patch series? As
> modifying a patch in the beginning of a patch series requires lots of
> time to adapt the rest of the series to the change.
As the person doing the work and submitting the patches, you choose
how much effort to put in. If you feel that fixing all the "`git`
upstream of a pipe" problems is better left for a future
"modernization" series, then that's almost certainly fine. Since
reviewers are trying to help you polish your patches, they usually
prefer to review shorter series than longer ones anyhow. If you decide
not to make these changes, though, be sure to explain your decision in
the cover letter so that reviewers understand why such a cleanup is
missing from the current series.
Having said that, if you're not going to fix all the "`git` upstream
of a pipe" cases, then you might consider dropping this patch from the
current series since it is merely touching the "tip of the iceberg" by
fixing only these two minor cases while leaving all the more
significant cases unfixed. But other reviewers may feel differently.
If you're worried about the ripple effect of making significant
changes to this patch which sits near the beginning of the series,
then one way to sidestep the issue is to relocate this patch to the
end of the series. This is possible because, unlike many other patch
series in which there is inherent order in the patches where each
change must follow the preceding change, that is not the case with
this patch series. The specific order of patches in this series is
pretty much immaterial. So, moving this patch to the end of the series
would cause only a tiny ripple since it touches only two small chunks
of code, and once the patch is last in the series, then it becomes
easy to apply all the other "`git` upstream of a pipe" fixes.
But it's up to you if you want to do that extra work. As noted above,
reviewers usually prefer a shorter simpler series over a longer more
complex one, so relegating such fixes to a followup series is almost
certainly acceptable. (But be sure to explain your decision in the
cover letter.)
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2024-08-06 18:05 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-05 23:59 [PATCH v4 0/8] t7004: Modernize the style AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 1/8] [Newcomer] t7004: Remove space after redirect operators AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 2/8] [Newcomer] t7004: Do not lose exit status to pipe AbdAlRahman Gad
2024-08-06 3:13 ` Eric Sunshine
2024-08-06 8:38 ` AbdAlRahman Gad
2024-08-06 18:05 ` Eric Sunshine
2024-08-05 23:59 ` [PATCH v4 3/8] [Newcomer] t7004: One command per line AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 4/8] [Newcomer] t7004: Do not prepare things outside test_expect_success AbdAlRahman Gad
2024-08-06 3:29 ` Eric Sunshine
2024-08-06 8:41 ` AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 5/8] [Newcomer] t7004: Use indented here-doc AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 6/8] [Newcomer] t7004: Description on the same line as test_expect_success AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 7/8] [Newcomer] t7004: test Description and test body seperated with backslash AbdAlRahman Gad
2024-08-05 23:59 ` [PATCH v4 8/8] [Newcomer] t7004: Use single quotes instead of double quotes AbdAlRahman Gad
2024-08-06 3:02 ` Eric Sunshine
2024-08-06 10:10 ` AbdAlRahman Gad
2024-08-06 17:21 ` Eric Sunshine
2024-08-06 16:35 ` Junio C Hamano
2024-08-06 17:11 ` Eric Sunshine
2024-08-06 0:45 ` [PATCH v4 0/8] t7004: Modernize the style Junio C Hamano
2024-08-06 8:44 ` AbdAlRahman Gad
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).