From: Junio C Hamano Date: Mon, 20 Aug 2018 18:33:48 +0000 (-0700) Subject: Merge branch 'ab/test-must-be-empty-for-master' X-Git-Tag: v2.19.0-rc0~33 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/14677d25ab50efcf57621ae69d6ba858a5f86165?hp=-c Merge branch 'ab/test-must-be-empty-for-master' Test updates. * ab/test-must-be-empty-for-master: tests: make use of the test_must_be_empty function --- 14677d25ab50efcf57621ae69d6ba858a5f86165 diff --combined t/t1507-rev-parse-upstream.sh index 349f6e10af,f121890cc2..fa3e499641 --- a/t/t1507-rev-parse-upstream.sh +++ b/t/t1507-rev-parse-upstream.sh @@@ -123,9 -123,9 +123,9 @@@ test_expect_success 'checkout -b new my test_expect_success 'merge my-side@{u} records the correct name' ' ( - cd clone || exit - git checkout master || exit - git branch -D new ;# can fail but is ok + cd clone && + git checkout master && + test_might_fail git branch -D new && git branch -t new my-side@{u} && git merge -s ours new@{u} && git show -s --pretty=tformat:%s >actual && @@@ -138,8 -138,7 +138,7 @@@ test_expect_success 'branch -d other@{u git checkout -t -b other master && git branch -d @{u} && git for-each-ref refs/heads/master >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'checkout other@{u}' ' diff --combined t/t2202-add-addremove.sh index 17744e8c57,e84079d81f..9ee659098c --- a/t/t2202-add-addremove.sh +++ b/t/t2202-add-addremove.sh @@@ -6,12 -6,12 +6,12 @@@ test_description='git add --all test_expect_success setup ' ( - echo .gitignore + echo .gitignore && echo will-remove ) >expect && ( - echo actual - echo expect + echo actual && + echo expect && echo ignored ) >.gitignore && git --literal-pathspecs add --all && @@@ -25,10 -25,10 +25,10 @@@ test_expect_success 'git add --all' ' ( - echo .gitignore - echo not-ignored - echo "M .gitignore" - echo "A not-ignored" + echo .gitignore && + echo not-ignored && + echo "M .gitignore" && + echo "A not-ignored" && echo "D will-remove" ) >expect && >ignored && @@@ -48,8 -48,7 +48,7 @@@ test_expect_success 'Just "git add" is >will-not-be-added && git add && git diff-index --name-status --cached HEAD >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_done diff --combined t/t3700-add.sh index 618750167a,0dc8759447..37729ba258 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@@ -156,9 -156,9 +156,9 @@@ test_expect_success 'git add with filem test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over stage 1' ' git rm --cached -f file symlink && ( - echo "100644 $(git hash-object -w stage1) 1 file" - echo "100755 $(git hash-object -w stage2) 2 file" - echo "100644 $(printf 1 | git hash-object -w -t blob --stdin) 1 symlink" + echo "100644 $(git hash-object -w stage1) 1 file" && + echo "100755 $(git hash-object -w stage2) 2 file" && + echo "100644 $(printf 1 | git hash-object -w -t blob --stdin) 1 symlink" && echo "120000 $(printf 2 | git hash-object -w -t blob --stdin) 2 symlink" ) | git update-index --index-info && git config core.filemode 0 && @@@ -188,9 -188,8 +188,8 @@@ test_expect_success 'git add --refresh git add foo bar baz && H=$(git rev-parse :foo) && git rm -f foo && echo "100644 $H 3 foo" | git update-index --index-info && test-tool chmtime -60 bar baz && - >expect && git add --refresh bar >actual && - test_cmp expect actual && + test_must_be_empty actual && git diff-files --name-only >actual && ! grep bar actual&& @@@ -265,7 -264,7 +264,7 @@@ test_expect_success 'git add to resolv git reset --hard && H=$(git rev-parse :1/2/a) && ( - echo "100644 $H 1 track-this" + echo "100644 $H 1 track-this" && echo "100644 $H 3 track-this" ) | git update-index --index-info && echo track-this >>.gitignore && diff --combined t/t4010-diff-pathspec.sh index b7f25071cf,b95cc91a3f..281f8fad0c --- a/t/t4010-diff-pathspec.sh +++ b/t/t4010-diff-pathspec.sh @@@ -74,8 -74,7 +74,7 @@@ test_expect_success 'diff-tree pathspec tree2=$(git write-tree) && echo "$tree2" && git diff-tree -r --name-only $tree $tree2 -- pa path1/a >current && - >expected && - test_cmp expected current + test_must_be_empty current ' test_expect_success 'diff-tree with wildcard shows dir also matches' ' @@@ -111,10 -110,10 +110,10 @@@ test_expect_success 'diff-tree -r with test_expect_success 'setup submodules' ' test_tick && git init submod && - ( cd submod && test_commit first; ) && + ( cd submod && test_commit first ) && git add submod && git commit -m first && - ( cd submod && test_commit second; ) && + ( cd submod && test_commit second ) && git add submod && git commit -m second ' diff --combined t/t4015-diff-whitespace.sh index e2dc1895ba,5659c2612d..35fc8b5c2a --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@@ -93,21 -93,20 +93,20 @@@ test_expect_success 'another test, with git diff >out && test_cmp expect out && - >expect && git diff -w >out && - test_cmp expect out && + test_must_be_empty out && git diff -w -b >out && - test_cmp expect out && + test_must_be_empty out && git diff -w --ignore-space-at-eol >out && - test_cmp expect out && + test_must_be_empty out && git diff -w -b --ignore-space-at-eol >out && - test_cmp expect out && + test_must_be_empty out && git diff -w --ignore-cr-at-eol >out && - test_cmp expect out && + test_must_be_empty out && tr "Q_" "\015 " <<-\EOF >expect && diff --git a/x b/x @@@ -182,8 -181,7 +181,7 @@@ test_expect_success 'ignore-blank-lines test_seq 5 | sed "/3/i\\ " >x && git diff --ignore-blank-lines >out && - >expect && - test_cmp expect out + test_must_be_empty out ' test_expect_success 'ignore-blank-lines: only new lines with space' ' @@@ -192,8 -190,7 +190,7 @@@ test_seq 5 | sed "/3/i\\ " >x && git diff -w --ignore-blank-lines >out && - >expect && - test_cmp expect out + test_must_be_empty out ' test_expect_success 'ignore-blank-lines: after change' ' @@@ -1223,7 -1220,7 +1220,7 @@@ test_expect_success 'plain moved code, test_cmp expected actual ' -test_expect_success 'detect permutations inside moved code -- dimmed_zebra' ' +test_expect_success 'detect blocks of moved code' ' git reset --hard && cat <<-\EOF >lines.txt && long line 1 @@@ -1271,52 -1268,9 +1268,52 @@@ test_config color.diff.newMovedDimmed "normal cyan" && test_config color.diff.oldMovedAlternativeDimmed "normal blue" && test_config color.diff.newMovedAlternativeDimmed "normal yellow" && - git diff HEAD --no-renames --color-moved=dimmed_zebra --color | - grep -v "index" | - test_decode_color >actual && + git diff HEAD --no-renames --color-moved=blocks --color >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && + cat <<-\EOF >expected && + diff --git a/lines.txt b/lines.txt + --- a/lines.txt + +++ b/lines.txt + @@ -1,16 +1,16 @@ + -long line 1 + -long line 2 + -long line 3 + line 4 + line 5 + line 6 + line 7 + line 8 + line 9 + +long line 1 + +long line 2 + +long line 3 + +long line 14 + +long line 15 + +long line 16 + line 10 + line 11 + line 12 + line 13 + -long line 14 + -long line 15 + -long line 16 + EOF + test_cmp expected actual + +' + +test_expect_success 'detect permutations inside moved code -- dimmed-zebra' ' + # reuse setup from test before! + test_config color.diff.oldMoved "magenta" && + test_config color.diff.newMoved "cyan" && + test_config color.diff.oldMovedAlternative "blue" && + test_config color.diff.newMovedAlternative "yellow" && + test_config color.diff.oldMovedDimmed "normal magenta" && + test_config color.diff.newMovedDimmed "normal cyan" && + test_config color.diff.oldMovedAlternativeDimmed "normal blue" && + test_config color.diff.newMovedAlternativeDimmed "normal yellow" && + git diff HEAD --no-renames --color-moved=dimmed-zebra --color >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && cat <<-\EOF >expected && diff --git a/lines.txt b/lines.txt --- a/lines.txt @@@ -1358,8 -1312,9 +1355,8 @@@ test_expect_success 'cmd option assume test_config color.diff.oldMovedAlternativeDimmed "normal blue" && test_config color.diff.newMovedAlternativeDimmed "normal yellow" && test_config diff.colorMoved zebra && - git diff HEAD --no-renames --color-moved --color | - grep -v "index" | - test_decode_color >actual && + git diff HEAD --no-renames --color-moved --color >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && cat <<-\EOF >expected && diff --git a/lines.txt b/lines.txt --- a/lines.txt @@@ -1437,8 -1392,9 +1434,8 @@@ test_expect_success 'move detection ign line 4 line 5 EOF - git diff HEAD --no-renames --color-moved --color | - grep -v "index" | - test_decode_color >actual && + git diff HEAD --no-renames --color-moved --color >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && cat <<-\EOF >expected && diff --git a/lines.txt b/lines.txt --- a/lines.txt @@@ -1460,9 -1416,9 +1457,9 @@@ EOF test_cmp expected actual && - git diff HEAD --no-renames -w --color-moved --color | - grep -v "index" | - test_decode_color >actual && + git diff HEAD --no-renames --color-moved --color \ + --color-moved-ws=ignore-all-space >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && cat <<-\EOF >expected && diff --git a/lines.txt b/lines.txt --- a/lines.txt @@@ -1500,8 -1456,9 +1497,8 @@@ test_expect_success 'move detection ign line 5 EOF - git diff HEAD --no-renames --color-moved --color | - grep -v "index" | - test_decode_color >actual && + git diff HEAD --no-renames --color-moved --color >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && cat <<-\EOF >expected && diff --git a/lines.txt b/lines.txt --- a/lines.txt @@@ -1523,9 -1480,9 +1520,9 @@@ EOF test_cmp expected actual && - git diff HEAD --no-renames -b --color-moved --color | - grep -v "index" | - test_decode_color >actual && + git diff HEAD --no-renames --color-moved --color \ + --color-moved-ws=ignore-space-change >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && cat <<-\EOF >expected && diff --git a/lines.txt b/lines.txt --- a/lines.txt @@@ -1566,8 -1523,9 +1563,8 @@@ test_expect_success 'move detection ign # avoid cluttering the output with complaints about our eol whitespace test_config core.whitespace -blank-at-eol && - git diff HEAD --no-renames --color-moved --color | - grep -v "index" | - test_decode_color >actual && + git diff HEAD --no-renames --color-moved --color >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && cat <<-\EOF >expected && diff --git a/lines.txt b/lines.txt --- a/lines.txt @@@ -1589,9 -1547,9 +1586,9 @@@ EOF test_cmp expected actual && - git diff HEAD --no-renames --ignore-space-at-eol --color-moved --color | - grep -v "index" | - test_decode_color >actual && + git diff HEAD --no-renames --color-moved --color \ + --color-moved-ws=ignore-space-at-eol >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && cat <<-\EOF >expected && diff --git a/lines.txt b/lines.txt --- a/lines.txt @@@ -1636,8 -1594,9 +1633,8 @@@ test_expect_success '--color-moved bloc irrelevant_line EOF - git diff HEAD --color-moved=zebra --color --no-renames | - grep -v "index" | - test_decode_color >actual && + git diff HEAD --color-moved=zebra --color --no-renames >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && cat >expected <<-\EOF && diff --git a/bar b/bar --- a/bar @@@ -1674,8 -1633,9 +1671,8 @@@ test_expect_success '--color-moved resp nineteen chars 456789 EOF - git diff HEAD --color-moved=zebra --color --no-renames | - grep -v "index" | - test_decode_color >actual && + git diff HEAD --color-moved=zebra --color --no-renames >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && cat >expected <<-\EOF && diff --git a/bar b/bar --- a/bar @@@ -1716,8 -1676,7 +1713,8 @@@ test_expect_success '--color-moved trea 7charsA EOF - git diff HEAD --color-moved=zebra --color --no-renames | grep -v "index" | test_decode_color >actual && + git diff HEAD --color-moved=zebra --color --no-renames >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && cat >expected <<-\EOF && diff --git a/bar b/bar --- a/bar @@@ -1760,146 -1719,7 +1757,146 @@@ test_expect_success 'move detection wit # nor did we mess with it another way git diff --submodule=diff --color | test_decode_color >expect && - test_cmp expect decoded_actual + test_cmp expect decoded_actual && + rm -rf bananas && + git submodule deinit bananas +' + +test_expect_success 'only move detection ignores white spaces' ' + git reset --hard && + q_to_tab <<-\EOF >text.txt && + a long line to exceed per-line minimum + another long line to exceed per-line minimum + original file + EOF + git add text.txt && + git commit -m "add text" && + q_to_tab <<-\EOF >text.txt && + Qa long line to exceed per-line minimum + Qanother long line to exceed per-line minimum + new file + EOF + + # Make sure we get a different diff using -w + git diff --color --color-moved -w >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && + q_to_tab <<-\EOF >expected && + diff --git a/text.txt b/text.txt + --- a/text.txt + +++ b/text.txt + @@ -1,3 +1,3 @@ + Qa long line to exceed per-line minimum + Qanother long line to exceed per-line minimum + -original file + +new file + EOF + test_cmp expected actual && + + # And now ignoring white space only in the move detection + git diff --color --color-moved \ + --color-moved-ws=ignore-all-space,ignore-space-change,ignore-space-at-eol >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && + q_to_tab <<-\EOF >expected && + diff --git a/text.txt b/text.txt + --- a/text.txt + +++ b/text.txt + @@ -1,3 +1,3 @@ + -a long line to exceed per-line minimum + -another long line to exceed per-line minimum + -original file + +Qa long line to exceed per-line minimum + +Qanother long line to exceed per-line minimum + +new file + EOF + test_cmp expected actual +' + +test_expect_success 'compare whitespace delta across moved blocks' ' + + git reset --hard && + q_to_tab <<-\EOF >text.txt && + QIndented + QText across + Qsome lines + QBut! <- this stands out + QAdjusting with + QQdifferent starting + Qwhite spaces + QAnother outlier + QQQIndented + QQQText across + QQQfive lines + QQQthat has similar lines + QQQto previous blocks, but with different indent + QQQYetQAnotherQoutlierQ + EOF + + git add text.txt && + git commit -m "add text.txt" && + + q_to_tab <<-\EOF >text.txt && + QQIndented + QQText across + QQsome lines + QQQBut! <- this stands out + Adjusting with + Qdifferent starting + white spaces + AnotherQoutlier + QQIndented + QQText across + QQfive lines + QQthat has similar lines + QQto previous blocks, but with different indent + QQYetQAnotherQoutlier + EOF + + git diff --color --color-moved --color-moved-ws=allow-indentation-change >actual.raw && + grep -v "index" actual.raw | test_decode_color >actual && + + q_to_tab <<-\EOF >expected && + diff --git a/text.txt b/text.txt + --- a/text.txt + +++ b/text.txt + @@ -1,14 +1,14 @@ + -QIndented + -QText across + -Qsome lines + -QBut! <- this stands out + -QAdjusting with + -QQdifferent starting + -Qwhite spaces + -QAnother outlier + -QQQIndented + -QQQText across + -QQQfive lines + -QQQthat has similar lines + -QQQto previous blocks, but with different indent + -QQQYetQAnotherQoutlierQ + +QQIndented + +QQText across + +QQsome lines + +QQQBut! <- this stands out + +Adjusting with + +Qdifferent starting + +white spaces + +AnotherQoutlier + +QQIndented + +QQText across + +QQfive lines + +QQthat has similar lines + +QQto previous blocks, but with different indent + +QQYetQAnotherQoutlier + EOF + + test_cmp expected actual +' + +test_expect_success 'compare whitespace delta incompatible with other space options' ' + test_must_fail git diff \ + --color-moved-ws=allow-indentation-change,ignore-all-space \ + 2>err && + test_i18ngrep allow-indentation-change err ' test_done diff --combined t/t4202-log.sh index 05d3707e38,0b1cd3408b..153a506151 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@@ -340,10 -340,9 +340,9 @@@ test_expect_success PCRE 'log -F -E --p ' test_expect_success 'log with grep.patternType configuration' ' - >expect && git -c grep.patterntype=fixed \ log -1 --pretty=tformat:%s --grep=s.c.nd >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'log with grep.patternType configuration and command line' ' @@@ -1556,28 -1555,12 +1555,28 @@@ test_expect_success GPG 'setup signed b git commit -S -m signed_commit ' +test_expect_success GPGSM 'setup signed branch x509' ' + test_when_finished "git reset --hard && git checkout master" && + git checkout -b signed-x509 master && + echo foo >foo && + git add foo && + test_config gpg.format x509 && + test_config user.signingkey $GIT_COMMITTER_EMAIL && + git commit -S -m signed_commit +' + test_expect_success GPG 'log --graph --show-signature' ' git log --graph --show-signature -n1 signed >actual && grep "^| gpg: Signature made" actual && grep "^| gpg: Good signature" actual ' +test_expect_success GPGSM 'log --graph --show-signature x509' ' + git log --graph --show-signature -n1 signed-x509 >actual && + grep "^| gpgsm: Signature made" actual && + grep "^| gpgsm: Good signature" actual +' + test_expect_success GPG 'log --graph --show-signature for merged tag' ' test_when_finished "git reset --hard && git checkout master" && git checkout -b plain master && @@@ -1597,27 -1580,6 +1596,27 @@@ grep "^| | gpg: Good signature" actual ' +test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' ' + test_when_finished "git reset --hard && git checkout master" && + test_config gpg.format x509 && + test_config user.signingkey $GIT_COMMITTER_EMAIL && + git checkout -b plain-x509 master && + echo aaa >bar && + git add bar && + git commit -m bar_commit && + git checkout -b tagged-x509 master && + echo bbb >baz && + git add baz && + git commit -m baz_commit && + git tag -s -m signed_tag_msg signed_tag_x509 && + git checkout plain-x509 && + git merge --no-ff -m msg signed_tag_x509 && + git log --graph --show-signature -n1 plain-x509 >actual && + grep "^|\\\ merged tag" actual && + grep "^| | gpgsm: Signature made" actual && + grep "^| | gpgsm: Good signature" actual +' + test_expect_success GPG '--no-show-signature overrides --show-signature' ' git log -1 --show-signature --no-show-signature signed >actual && ! grep "^gpg:" actual @@@ -1662,9 -1624,8 +1661,8 @@@ test_expect_success 'log diagnoses bogu ' test_expect_success 'log does not default to HEAD when rev input is given' ' - >expect && git log --branches=does-not-exist >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'set up --source tests' ' diff --combined t/t5505-remote.sh index a6856e052b,6f8c2442bf..241e6a319d --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@@ -74,8 -74,7 +74,7 @@@ test_expect_success 'add another remote git for-each-ref "--format=%(refname)" refs/remotes | sed -e "/^refs\/remotes\/origin\//d" \ -e "/^refs\/remotes\/second\//d" >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ) ' @@@ -112,8 -111,7 +111,7 @@@ test_expect_success C_LOCALE_OUTPUT 're check_remote_track origin master side && git for-each-ref "--format=%(refname)" refs/remotes | sed -e "/^refs\/remotes\/origin\//d" >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ) ' @@@ -348,13 -346,17 +346,13 @@@ URL: $(pwd)/on EOF test_expect_success 'prune --dry-run' ' - ( - cd one && - git branch -m side2 side) && + git -C one branch -m side2 side && + test_when_finished "git -C one branch -m side side2" && ( cd test && git remote prune --dry-run origin >output && git rev-parse refs/remotes/origin/side2 && test_must_fail git rev-parse refs/remotes/origin/side && - ( - cd ../one && - git branch -m side side2) && test_i18ncmp expect output ) ' @@@ -844,7 -846,7 +842,7 @@@ test_expect_success 'migrate a remote f git remote rename origin origin && test_path_is_missing .git/branches/origin && test "$(git config remote.origin.url)" = "quux" && - test "$(git config remote.origin.fetch)" = "refs/heads/foom:refs/heads/origin" + test "$(git config remote.origin.fetch)" = "refs/heads/foom:refs/heads/origin" && test "$(git config remote.origin.push)" = "HEAD:refs/heads/foom" ) ' @@@ -872,7 -874,7 +870,7 @@@ test_expect_success 'remote prune to ca cd eight && test_must_fail git branch nomore origin ) 2>err && - grep "dangling symref" err + test_i18ngrep "dangling symref" err ' test_expect_success 'show empty remote' ' diff --combined t/t5512-ls-remote.sh index ea020040e8,f2c05ae0b4..bc5703ff9b --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@@ -15,7 -15,7 +15,7 @@@ test_expect_success setup git tag mark1.10 && git show-ref --tags -d | sed -e "s/ / /" >expected.tag && ( - echo "$(git rev-parse HEAD) HEAD" + echo "$(git rev-parse HEAD) HEAD" && git show-ref -d | sed -e "s/ / /" ) >expected.all && @@@ -105,7 -105,7 +105,7 @@@ test_expect_success 'use branch.. git clone . other.git && ( cd other.git && - echo "$(git rev-parse HEAD) HEAD" + echo "$(git rev-parse HEAD) HEAD" && git show-ref | sed -e "s/ / /" ) >exp && @@@ -155,14 -155,12 +155,12 @@@ test_expect_success 'die with non-2 fo test_expect_success 'Report success even when nothing matches' ' git ls-remote other.git "refs/nsn/*" >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'Report no-match with --exit-code' ' test_expect_code 2 git ls-remote --exit-code other.git "refs/nsn/*" >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'Report match with --exit-code' ' diff --combined t/t7004-tag.sh index 2147938aa1,93a6694f0e..465eb4ea3f --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@@ -693,9 -693,8 +693,8 @@@ test_expect_success ' test_expect_success 'The -n 100 invocation means -n --list 100, not -n100' ' - >expect && git tag -n 100 >actual && - test_cmp expect actual && + test_must_be_empty actual && git tag -m "A msg" 100 && echo "100 A msg" >expect && @@@ -974,9 -973,8 +973,8 @@@ test_expect_success GPG 'verifying a pr ' test_expect_success GPG 'verifying a forged tag with --format should fail silently' ' - >expect && test_must_fail git tag -v --format="tagname : %(tag)" "forged-tag" >actual && - test_cmp expect actual + test_must_be_empty actual ' # blank and empty messages for signed tags: @@@ -1354,19 -1352,6 +1352,19 @@@ test_expect_success GPG 'test_config gpg.program echo && test_must_fail git tag -s -m tail tag-gpg-failure' +# 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' + +# 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' # try to verify without gpg: @@@ -1395,9 -1380,8 +1393,8 @@@ test_expect_success 'message in editor test_expect_success \ 'message in editor has initial comment: remainder' ' # remove commented lines from the remainder -- should be empty - >rest.expect && sed -e 1d -e "/^#/d" rest.actual && - test_cmp rest.expect rest.actual + test_must_be_empty rest.actual ' get_tag_header reuse $commit commit $time >expect @@@ -1479,19 -1463,18 +1476,18 @@@ test_expect_success 'checking that firs # 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)' " - >expected && git tag -l --no-contains $hash1 v* >actual && - test_cmp expected actual + test_must_be_empty actual " test_expect_success 'checking that first commit is in all tags (tag)' " git tag -l --no-contains v1.0 v* >actual && - test_cmp expected actual + test_must_be_empty actual " test_expect_success 'checking that first commit is in all tags (relative)' " git tag -l --no-contains HEAD~2 v* >actual && - test_cmp expected actual + test_must_be_empty actual " cat > expected <expected && git tag -l --no-contains $hash1 v* >actual && - test_cmp expected actual + test_must_be_empty actual " # mixing modes and options: @@@ -1918,7 -1900,6 +1913,6 @@@ test_expect_success 'version sort with ' test_expect_success ULIMIT_STACK_SIZE '--contains and --no-contains work in a deep repo' ' - >expect && i=1 && while test $i -lt 8000 do @@@ -1933,7 -1914,7 +1927,7 @@@ EOF git checkout master && git tag far-far-away HEAD^ && run_with_limited_stack git tag --contains HEAD >actual && - test_cmp expect actual && + test_must_be_empty actual && run_with_limited_stack git tag --no-contains HEAD >actual && test_line_count "-gt" 10 actual ' diff --combined t/t7030-verify-tag.sh index 99f35a5bbe,1f068714c5..041e319e79 --- a/t/t7030-verify-tag.sh +++ b/t/t7030-verify-tag.sh @@@ -41,13 -41,6 +41,13 @@@ test_expect_success GPG 'create signed git tag -uB7227189 -m eighth eighth-signed-alt ' +test_expect_success GPGSM 'create signed tags x509 ' ' + test_config gpg.format x509 && + test_config user.signingkey $GIT_COMMITTER_EMAIL && + echo 9 >file && test_tick && git commit -a -m "nineth gpgsm-signed" && + git tag -s -m nineth nineth-signed-x509 +' + test_expect_success GPG 'verify and show signatures' ' ( for tag in initial second merge fourth-signed sixth-signed seventh-signed @@@ -79,13 -72,6 +79,13 @@@ ) ' +test_expect_success GPGSM 'verify and show signatures x509' ' + git verify-tag nineth-signed-x509 2>actual && + grep "Good signature from" actual && + ! grep "BAD signature from" actual && + echo nineth-signed-x509 OK +' + test_expect_success GPG 'detect fudged signature' ' git cat-file tag seventh-signed >raw && sed -e "/^tag / s/seventh/7th forged/" raw >forged1 && @@@ -126,13 -112,6 +126,13 @@@ test_expect_success GPG 'verify signatu ) ' +test_expect_success GPGSM 'verify signatures with --raw x509' ' + git verify-tag --raw nineth-signed-x509 2>actual && + grep "GOODSIG" actual && + ! grep "BADSIG" actual && + echo nineth-signed-x509 OK +' + test_expect_success GPG 'verify multiple tags' ' tags="fourth-signed sixth-signed seventh-signed" && for i in $tags @@@ -146,19 -125,6 +146,19 @@@ test_cmp expect.stderr actual.stderr ' +test_expect_success GPGSM 'verify multiple tags x509' ' + tags="seventh-signed nineth-signed-x509" && + for i in $tags + do + git verify-tag -v --raw $i || return 1 + done >expect.stdout 2>expect.stderr.1 && + grep "^.GNUPG:." expect.stderr && + git verify-tag -v --raw $tags >actual.stdout 2>actual.stderr.1 && + grep "^.GNUPG:." actual.stderr && + test_cmp expect.stdout actual.stdout && + test_cmp expect.stderr actual.stderr +' + test_expect_success GPG 'verifying tag with --format' ' cat >expect <<-\EOF && tagname : fourth-signed @@@ -168,9 -134,8 +168,8 @@@ ' test_expect_success GPG 'verifying a forged tag with --format should fail silently' ' - >expect && test_must_fail git verify-tag --format="tagname : %(tag)" $(cat forged1.tag) >actual-forged && - test_cmp expect actual-forged + test_must_be_empty actual-forged ' test_done diff --combined t/t7063-status-untracked-cache.sh index c9162c54f4,6d8256a424..2da57fce7b --- a/t/t7063-status-untracked-cache.sh +++ b/t/t7063-status-untracked-cache.sh @@@ -26,9 -26,8 +26,8 @@@ avoid_racy() } status_is_clean() { - >../status.expect && git status --porcelain >../status.actual && - test_cmp ../status.expect ../status.actual + test_must_be_empty ../status.actual } test_lazy_prereq UNTRACKED_CACHE ' @@@ -666,7 -665,7 +665,7 @@@ test_expect_success 'test ident field i mkdir ../other_worktree && cp -R done dthree dtwo four three ../other_worktree && GIT_WORK_TREE=../other_worktree git status 2>../err && - echo "warning: Untracked cache is disabled on this system or location." >../expect && + echo "warning: untracked cache is disabled on this system or location" >../expect && test_i18ncmp ../expect ../err ' diff --combined t/t7610-mergetool.sh index 047156e9d5,4d46c599f8..b18503de81 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@@ -57,18 -57,18 +57,18 @@@ test_expect_success 'setup' git checkout -b delete-base branch1 && mkdir -p a/a && - (echo one; echo two; echo 3; echo 4) >a/a/file.txt && + test_write_lines one two 3 4 >a/a/file.txt && git add a/a/file.txt && git commit -m"base file" && git checkout -b move-to-b delete-base && mkdir -p b/b && git mv a/a/file.txt b/b/file.txt && - (echo one; echo two; echo 4) >b/b/file.txt && + test_write_lines one two 4 >b/b/file.txt && git commit -a -m"move to b" && git checkout -b move-to-c delete-base && mkdir -p c/c && git mv a/a/file.txt c/c/file.txt && - (echo one; echo two; echo 3) >c/c/file.txt && + test_write_lines one two 3 >c/c/file.txt && git commit -a -m"move to c" && git checkout -b stash1 master && @@@ -349,7 -349,7 +349,7 @@@ test_expect_success 'mergetool keeps te git checkout -b test$test_count move-to-c && test_config mergetool.keepTemporaries true && test_must_fail git merge move-to-b && - ! (echo a; echo n) | git mergetool a/a/file.txt && + ! test_write_lines a n | git mergetool a/a/file.txt && test -d a/a && cat >expect <<-\EOF && file_BASE_.txt @@@ -620,8 -620,7 +620,7 @@@ test_expect_success 'file with no base git checkout -b test$test_count branch1 && test_must_fail git merge master && git mergetool --no-prompt --tool mybase -- both && - >expected && - test_cmp expected both + test_must_be_empty both ' test_expect_success 'custom commands override built-ins' ' diff --combined t/t7810-grep.sh index dcaab1557b,fc44ec96aa..d826e24b45 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@@ -262,21 -262,6 +262,21 @@@ d fi ' + test_expect_success "grep $L (with --column, --only-matching)" ' + { + echo ${HC}file:1:5:mmap + echo ${HC}file:2:5:mmap + echo ${HC}file:3:5:mmap + echo ${HC}file:3:13:mmap + echo ${HC}file:4:5:mmap + echo ${HC}file:4:13:mmap + echo ${HC}file:5:5:mmap + echo ${HC}file:5:13:mmap + } >expected && + git grep --column -n -o -e mmap $H >actual && + test_cmp expected actual + ' + test_expect_success "grep $L (t-1)" ' echo "${HC}t/t:1:test" >expected && git grep -n -e test $H >actual && @@@ -691,8 -676,7 +691,7 @@@ test_expect_success 'log grep (5)' test_expect_success 'log grep (6)' ' git log --author=-0700 --pretty=tformat:%s >actual && - >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'log grep (7)' ' @@@ -955,9 -939,10 +954,9 @@@ test_expect_success 'grep from a subdir test_expect_success 'grep from a subdirectory to search wider area (2)' ' mkdir -p s && ( - cd s || exit 1 - ( git grep xxyyzz .. >out ; echo $? >status ) - ! test -s out && - test 1 = $(cat status) + cd s && + test_expect_code 1 git grep xxyyzz .. >out && + ! test -s out ) ' diff --combined t/t9001-send-email.sh index b8e919e25d,b734224494..1ef1a19003 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@@ -253,10 -253,9 +253,9 @@@ test_suppress_self () mv msgtxt1 msgtxt1-$3 && sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" && - >"expected-no-cc-$3" && (grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3"; - test_cmp expected-no-cc-$3 actual-no-cc-$3) + test_must_be_empty actual-no-cc-$3) } test_suppress_self_unquoted () { @@@ -332,7 -331,7 +331,7 @@@ test_expect_success $PREREQ 'Show all h test_expect_success $PREREQ 'Prompting works' ' clean_fake_sendmail && - (echo "to@example.com" + (echo "to@example.com" && echo "" ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \ --smtp-server="$(pwd)/fake.sendmail" \ @@@ -509,8 -508,8 +508,8 @@@ test_expect_success $PREREQ 'Invalid In test_expect_success $PREREQ 'Valid In-Reply-To when prompting' ' clean_fake_sendmail && - (echo "From Example " - echo "To Example " + (echo "From Example " && + echo "To Example " && echo "" ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \ --smtp-server="$(pwd)/fake.sendmail" \ @@@ -2023,11 -2022,11 +2022,11 @@@ test_expect_success $PREREQ 'invoke hoo # Verify error message when a patch is rejected by the hook sed -e "s/add master/x/" ../0001-add-master.patch >../another.patch && - git send-email \ + test_must_fail git send-email \ --from="Example " \ --to=nobody@example.com \ --smtp-server="$(pwd)/../fake.sendmail" \ - ../another.patch 2>err + ../another.patch 2>err && test_i18ngrep "rejected by sendemail-validate hook" err ) ' diff --combined t/t9300-fast-import.sh index fac33e524c,f8f869e26a..40fe7e4976 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@@ -2191,12 -2191,11 +2191,11 @@@ test_expect_success 'R: --import-marks- test_expect_success 'R: feature import-marks-if-exists' ' rm -f io.marks && - >expect && git fast-import --export-marks=io.marks <<-\EOF && feature import-marks-if-exists=not_io.marks EOF - test_cmp expect io.marks && + test_must_be_empty io.marks && blob=$(echo hi | git hash-object --stdin) && @@@ -2227,13 -2226,11 +2226,11 @@@ EOF test_cmp expect io.marks && - >expect && - git fast-import --import-marks-if-exists=not_io.marks \ --export-marks=io.marks <<-\EOF && feature import-marks-if-exists=io.marks EOF - test_cmp expect io.marks + test_must_be_empty io.marks ' test_expect_success 'R: import to output marks works without any content' ' @@@ -3147,10 -3144,7 +3144,10 @@@ background_import_then_checkpoint () echo $! >V.pid # We don't mind if fast-import has already died by the time the test # ends. - test_when_finished "exec 8>&-; exec 9>&-; kill $(cat V.pid) || true" + test_when_finished " + exec 8>&-; exec 9>&-; + kill $(cat V.pid) && wait $(cat V.pid) + true" # Start in the background to ensure we adhere strictly to (blocking) # pipes writing sequence. We want to assume that the write below could