]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: don't spuriously close and reopen quotes
authorMartin Ågren <martin.agren@gmail.com>
Thu, 6 Aug 2020 20:08:53 +0000 (22:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Aug 2020 22:14:32 +0000 (15:14 -0700)
In the test scripts, the recommended style is, e.g.:

    test_expect_success 'name' '
        do-something somehow &&
        do-some-more testing
    '

When using this style, any single quote in the multi-line test section
is actually closing the lone single quotes that surround it.

It can be a non-issue in practice:

    test_expect_success 'sed a little' '
        sed -e 's/hi/lo/' in >out # "ok": no whitespace in s/hi/lo/
    '

Or it can be a bug in the test, e.g., because variable interpolation
happens before the test even begins executing:

    v=abc

    test_expect_success 'variable interpolation' '
        v=def &&
        echo '"$v"' # abc
    '

Change several such in-test single quotes to use double quotes instead
or, in a few cases, drop them altogether. These were identified using
some crude grepping. We're not fixing any test bugs here, but we're
hopefully making these tests slightly easier to grok and to maintain.

There are legitimate use cases for closing a quote and opening a new
one, e.g., both '\'' and '"'"' can be used to produce a literal single
quote. I'm not touching any of those here.

In t9401, tuck the redirecting ">" to the filename while we're touching
those lines.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
17 files changed:
t/t1400-update-ref.sh
t/t3501-revert-cherry-pick.sh
t/t3507-cherry-pick-conflict.sh
t/t4005-diff-rename-2.sh
t/t4034-diff-words.sh
t/t4150-am.sh
t/t4200-rerere.sh
t/t5302-pack-index.sh
t/t5510-fetch.sh
t/t5553-set-upstream.sh
t/t6026-merge-attr.sh
t/t7001-mv.sh
t/t7600-merge.sh
t/t9001-send-email.sh
t/t9100-git-svn-basic.sh
t/t9401-git-cvsserver-crlf.sh
t/t9402-git-cvsserver-refs.sh

index 27171f826129168aa1e52262e2b2a9b4ca327989..d0d36750bcc8b8884264d6e11c23b5044a560406 100755 (executable)
@@ -324,7 +324,7 @@ test_expect_success "create $m (logged by config)" '
 test_expect_success "update $m (logged by config)" '
        test_config core.logAllRefUpdates true &&
        GIT_COMMITTER_DATE="2005-05-26 23:33" \
-       git update-ref HEAD'" $B $A "'-m "Switch" &&
+       git update-ref HEAD $B $A -m "Switch" &&
        test $B = $(git show-ref -s --verify $m)
 '
 test_expect_success "set $m (logged by config)" '
index 7c1da21df1493a501dc25e34c339c1bd5aecc2cf..3669dfb1bed5bee1130f672aace510dca020ae7c 100755 (executable)
@@ -47,7 +47,7 @@ test_expect_success 'cherry-pick --nonsense' '
        git diff --exit-code HEAD &&
        test_must_fail git cherry-pick --nonsense 2>msg &&
        git diff --exit-code HEAD "$pos" &&
-       test_i18ngrep '[Uu]sage:' msg
+       test_i18ngrep "[Uu]sage:" msg
 '
 
 test_expect_success 'revert --nonsense' '
@@ -56,7 +56,7 @@ test_expect_success 'revert --nonsense' '
        git diff --exit-code HEAD &&
        test_must_fail git revert --nonsense 2>msg &&
        git diff --exit-code HEAD "$pos" &&
-       test_i18ngrep '[Uu]sage:' msg
+       test_i18ngrep "[Uu]sage:" msg
 '
 
 test_expect_success 'cherry-pick after renaming branch' '
index 752bc43487196a4be33ff7df770384f331a68315..f107622a9e8c2daf4943f97834c4a05917aac6c8 100755 (executable)
@@ -512,7 +512,7 @@ test_expect_success 'commit after failed cherry-pick adds -s at the right place'
        Signed-off-by: C O Mitter <committer@example.com>
        # Conflicts:
        EOF
-       grep -e "^# Conflicts:" -e '^Signed-off-by' .git/COMMIT_EDITMSG >actual &&
+       grep -e "^# Conflicts:" -e "^Signed-off-by" .git/COMMIT_EDITMSG >actual &&
        test_cmp expect actual &&
 
        cat <<-\EOF >expected &&
@@ -541,7 +541,7 @@ test_expect_success 'commit --amend -s places the sign-off at the right place' '
        Signed-off-by: C O Mitter <committer@example.com>
        Conflicts:
        EOF
-       grep -e "^Conflicts:" -e '^Signed-off-by' .git/COMMIT_EDITMSG >actual &&
+       grep -e "^Conflicts:" -e "^Signed-off-by" .git/COMMIT_EDITMSG >actual &&
        test_cmp expect actual
 '
 
index f542d2929d2316fa8d858fc29c1bdfb5ef4c3c71..d18a80493c2274d19a6f779bd1c67c50b63a6290 100755 (executable)
@@ -14,8 +14,8 @@ test_expect_success 'setup reference tree' '
        git update-index --add COPYING rezrov &&
        tree=$(git write-tree) &&
        echo $tree &&
-       sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
-       sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
+       sed -e "s/HOWEVER/However/" <COPYING >COPYING.1 &&
+       sed -e "s/GPL/G.P.L/g" <COPYING >COPYING.2 &&
        origoid=$(git hash-object COPYING) &&
        oid1=$(git hash-object COPYING.1) &&
        oid2=$(git hash-object COPYING.2)
index fb145aa173ee4ea4c79bcb01336c433e16fa81e5..0c8fb39cedaa31f6f586895cd57a878158624f13 100755 (executable)
@@ -102,7 +102,7 @@ test_expect_success 'word diff with runs of whitespace' '
 '
 
 test_expect_success '--word-diff=porcelain' '
-       sed 's/#.*$//' >expect <<-EOF &&
+       sed "s/#.*$//" >expect <<-EOF &&
                diff --git a/pre b/post
                index $pre..$post 100644
                --- a/pre
index bda4586a7951a234b50ffbb28cdd4d7df05e4c56..855ed11b3275fef53202f6f24d3f5ef3d582fa27 100755 (executable)
@@ -989,7 +989,7 @@ test_expect_success 'am -s unexpected trailer block' '
        Signed-off-by: J C H <j@c.h>
        EOF
        git commit -F msg &&
-       git cat-file commit HEAD | sed -e '1,/^$/d' >original &&
+       git cat-file commit HEAD | sed -e "1,/^$/d" >original &&
        git format-patch --stdout -1 >patch &&
 
        git reset --hard HEAD^ &&
@@ -998,7 +998,7 @@ test_expect_success 'am -s unexpected trailer block' '
                cat original &&
                echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
        ) >expect &&
-       git cat-file commit HEAD | sed -e '1,/^$/d' >actual &&
+       git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
        test_cmp expect actual &&
 
        cat >msg <<-\EOF &&
@@ -1009,7 +1009,7 @@ test_expect_success 'am -s unexpected trailer block' '
        EOF
        git reset HEAD^ &&
        git commit -F msg file &&
-       git cat-file commit HEAD | sed -e '1,/^$/d' >original &&
+       git cat-file commit HEAD | sed -e "1,/^$/d" >original &&
        git format-patch --stdout -1 >patch &&
 
        git reset --hard HEAD^ &&
@@ -1020,7 +1020,7 @@ test_expect_success 'am -s unexpected trailer block' '
                echo &&
                echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
        ) >expect &&
-       git cat-file commit HEAD | sed -e '1,/^$/d' >actual &&
+       git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
        test_cmp expect actual
 '
 
index 831d424c4720924275b9071d4ad5edf8fc73734a..f99385c19102389093a5099832e2426de6552a19 100755 (executable)
@@ -364,7 +364,7 @@ test_expect_success 'set up an unresolved merge' '
        git reset --hard &&
        git checkout version2 &&
        fifth=$(git rev-parse fifth) &&
-       echo "$fifth            branch 'fifth' of ." |
+       echo "$fifth            branch fifth of ." |
        git fmt-merge-msg >msg &&
        ancestor=$(git merge-base version2 fifth) &&
        test_must_fail git merge-recursive "$ancestor" -- HEAD fifth &&
index 8981c9b90ebe1512c22402dd32308f0415708f21..d1a6a3c37a1279d3053e0d232bd004b1bcdbf45a 100755 (executable)
@@ -15,7 +15,7 @@ test_expect_success 'setup' '
        i=1 &&
        while test $i -le 100
        do
-               iii=$(printf '%03i' $i)
+               iii=$(printf "%03i" $i)
                test-tool genrandom "bar" 200 > wide_delta_$iii &&
                test-tool genrandom "baz $iii" 50 >> wide_delta_$iii &&
                test-tool genrandom "foo"$i 100 > deep_delta_$iii &&
index 7456c567cd1857a05703801b8f14fa78938b3f7a..6a6a760f5fcddd491a714b38d54a09cb0a855985 100755 (executable)
@@ -213,7 +213,7 @@ test_expect_success 'fetch tags when there is no tags' '
 test_expect_success 'fetch following tags' '
 
        cd "$D" &&
-       git tag -a -m 'annotated' anno HEAD &&
+       git tag -a -m "annotated" anno HEAD &&
        git tag light HEAD &&
 
        mkdir four &&
@@ -331,7 +331,7 @@ test_expect_success 'bundle does not prerequisite objects' '
 test_expect_success 'bundle should be able to create a full history' '
 
        cd "$D" &&
-       git tag -a -m '1.0' v1.0 master &&
+       git tag -a -m "1.0" v1.0 master &&
        git bundle create bundle4 v1.0
 
 '
index 81975ad8f9ebcbe22d5066da228e333e2cd613df..7622981cbf25941260f5a7f21bd60f84cf8797f8 100755 (executable)
@@ -81,7 +81,7 @@ test_expect_success 'fetch --set-upstream http://nosuchdomain.example.com fails
 
 test_expect_success 'fetch --set-upstream with valid URL sets upstream to URL' '
        clear_config other other2 &&
-       url="file://'"$PWD"'" &&
+       url="file://$PWD" &&
        git fetch --set-upstream "$url" &&
        check_config master "$url" HEAD &&
        check_config_missing other &&
@@ -158,7 +158,7 @@ test_expect_success 'pull --set-upstream upstream with more than one branch does
 test_expect_success 'pull --set-upstream with valid URL sets upstream to URL' '
        clear_config master other other2 &&
        git checkout master &&
-       url="file://'"$PWD"'" &&
+       url="file://$PWD" &&
        git pull --set-upstream "$url" &&
        check_config master "$url" HEAD &&
        check_config_missing other &&
@@ -168,7 +168,7 @@ test_expect_success 'pull --set-upstream with valid URL sets upstream to URL' '
 test_expect_success 'pull --set-upstream with valid URL and branch sets branch' '
        clear_config master other other2 &&
        git checkout master &&
-       url="file://'"$PWD"'" &&
+       url="file://$PWD" &&
        git pull --set-upstream "$url" master &&
        check_config master "$url" refs/heads/master &&
        check_config_missing other &&
index 5900358ce9c0b7605a23266d9179bedba5ad32e6..76a55f838c4ac03cfba678c0f188f67d4f724e6a 100755 (executable)
@@ -122,7 +122,7 @@ test_expect_success 'custom merge backend' '
        o=$(git unpack-file master^:text) &&
        a=$(git unpack-file side^:text) &&
        b=$(git unpack-file master:text) &&
-       sh -c "./custom-merge $o $a $b 0 'text'" &&
+       sh -c "./custom-merge $o $a $b 0 text" &&
        sed -e 1,3d $a >check-2 &&
        cmp check-1 check-2 &&
        rm -f $o $a $b
@@ -149,7 +149,7 @@ test_expect_success 'custom merge backend' '
        o=$(git unpack-file master^:text) &&
        a=$(git unpack-file anchor:text) &&
        b=$(git unpack-file master:text) &&
-       sh -c "./custom-merge $o $a $b 0 'text'" &&
+       sh -c "./custom-merge $o $a $b 0 text" &&
        sed -e 1,3d $a >check-2 &&
        cmp check-1 check-2 &&
        sed -e 1,3d -e 4q $a >check-3 &&
index c978b6dee4a2559d5d4e4a8a9329f9288de93231..63d5f41a1247839412b9c6022fb3f4a07c4e6b0e 100755 (executable)
@@ -177,7 +177,7 @@ test_expect_success "Sergey Vlasov's test case" '
        date >ab.c &&
        date >ab/d &&
        git add ab.c ab &&
-       git commit -m 'initial' &&
+       git commit -m "initial" &&
        git mv ab a
 '
 
index 5883a6adc31b5f0580b9fea5a7863174e803dc99..1c85f7555507695b301428b7aabea3b65a199b40 100755 (executable)
@@ -246,7 +246,7 @@ test_expect_success 'merge --squash c3 with c7' '
        #       file
        EOF
        git cat-file commit HEAD >raw &&
-       sed -e '1,/^$/d' raw >actual &&
+       sed -e "1,/^$/d" raw >actual &&
        test_cmp expect actual
 '
 
@@ -268,7 +268,7 @@ test_expect_success 'merge c3 with c7 with commit.cleanup = scissors' '
        #       file
        EOF
        git cat-file commit HEAD >raw &&
-       sed -e '1,/^$/d' raw >actual &&
+       sed -e "1,/^$/d" raw >actual &&
        test_i18ncmp expect actual
 '
 
@@ -292,7 +292,7 @@ test_expect_success 'merge c3 with c7 with --squash commit.cleanup = scissors' '
        #       file
        EOF
        git cat-file commit HEAD >raw &&
-       sed -e '1,/^$/d' raw >actual &&
+       sed -e "1,/^$/d" raw >actual &&
        test_i18ncmp expect actual
 '
 
index ec261085ec68fdb8c9e9b54a9973be880a5c7db5..3d6857045070a82f9d4a1d424851990a8d4037bb 100755 (executable)
@@ -1551,7 +1551,7 @@ test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printab
                --smtp-server="$(pwd)/fake.sendmail" \
                email-using-8bit \
                2>errors >out &&
-       sed '1,/^$/d' msgtxt1 >actual &&
+       sed "1,/^$/d" msgtxt1 >actual &&
        test_cmp expected actual
 '
 
@@ -1568,7 +1568,7 @@ test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' '
                --smtp-server="$(pwd)/fake.sendmail" \
                email-using-8bit \
                2>errors >out &&
-       sed '1,/^$/d' msgtxt1 >actual &&
+       sed "1,/^$/d" msgtxt1 >actual &&
        test_cmp expected actual
 '
 
@@ -1594,7 +1594,7 @@ test_expect_success $PREREQ 'convert from quoted-printable to base64' '
                --smtp-server="$(pwd)/fake.sendmail" \
                email-using-qp \
                2>errors >out &&
-       sed '1,/^$/d' msgtxt1 >actual &&
+       sed "1,/^$/d" msgtxt1 >actual &&
        test_cmp expected actual
 '
 
@@ -1624,7 +1624,7 @@ test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printabl
                --smtp-server="$(pwd)/fake.sendmail" \
                email-using-crlf \
                2>errors >out &&
-       sed '1,/^$/d' msgtxt1 >actual &&
+       sed "1,/^$/d" msgtxt1 >actual &&
        test_cmp expected actual
 '
 
@@ -1641,7 +1641,7 @@ test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' '
                --smtp-server="$(pwd)/fake.sendmail" \
                email-using-crlf \
                2>errors >out &&
-       sed '1,/^$/d' msgtxt1 >actual &&
+       sed "1,/^$/d" msgtxt1 >actual &&
        test_cmp expected actual
 '
 
index 3055943a2208e00de53c3e4ec5d50c09a440972c..e4bb22034ee63d92d8a304f3e9754df9ec4131b8 100755 (executable)
@@ -63,16 +63,16 @@ test_expect_success "$name" '
 
 
 name='detect node change from file to directory #1'
-test_expect_success "$name" "
+test_expect_success "$name" '
        mkdir dir/new_file &&
        mv dir/file dir/new_file/file &&
        mv dir/new_file dir/file &&
        git update-index --remove dir/file &&
        git update-index --add dir/file/file &&
-       git commit -m '$name' &&
+       git commit -m "$name" &&
        test_must_fail git svn set-tree --find-copies-harder --rmdir \
                remotes/git-svn..mybranch
-"
+'
 
 
 name='detect node change from directory to file #1'
index 84787eee9acec4b65f2404356e06b2f4904cea42..c7a0dd84a4b8b8145b498ab1fa9cd8d82300c9c5 100755 (executable)
@@ -167,10 +167,10 @@ test_expect_success 'adding files' '
 
 test_expect_success 'updating' '
     git pull gitcvs.git &&
-    echo 'hi' > subdir/newfile.bin &&
-    echo 'junk' > subdir/file.h &&
-    echo 'hi' > subdir/newfile.c &&
-    echo 'hello' >> binfile.bin &&
+    echo "hi" >subdir/newfile.bin &&
+    echo "junk" >subdir/file.h &&
+    echo "hi" >subdir/newfile.c &&
+    echo "hello" >>binfile.bin &&
     git add subdir/newfile.bin subdir/file.h subdir/newfile.c binfile.bin &&
     git commit -q -m "Add and change some files" &&
     git push gitcvs.git >/dev/null &&
index cf31ace66763741a7f53e3b9a1cb3c0019255f56..6436c91a3cb73be56ee2e972b64fdaf5a386ee5e 100755 (executable)
@@ -178,7 +178,7 @@ test_expect_success 'setup v1.2 on b1' '
        mkdir cdir &&
        echo "cdir/cfile" >cdir/cfile &&
        git add -A cdir adir t3 t2 &&
-       git commit -q -m 'v1.2' &&
+       git commit -q -m "v1.2" &&
        git tag v1.2 &&
        git push --tags gitcvs.git b1:b1
 '