From: Junio C Hamano Date: Mon, 27 Aug 2018 21:33:43 +0000 (-0700) Subject: Merge branch 'sg/test-must-be-empty' X-Git-Tag: v2.19.0-rc1~15 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/986c5181071ce3aac42d0aaeb7bd691a1a0bdf4a?ds=inline;hp=-c Merge branch 'sg/test-must-be-empty' Test fixes. * sg/test-must-be-empty: tests: use 'test_must_be_empty' instead of 'test_cmp ' tests: use 'test_must_be_empty' instead of 'test_cmp /dev/null ' tests: use 'test_must_be_empty' instead of 'test ! -s' tests: use 'test_must_be_empty' instead of '! test -s' --- 986c5181071ce3aac42d0aaeb7bd691a1a0bdf4a diff --combined t/t0000-basic.sh index 34859fe4a5,4e588eda09..850f651e4e --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@@ -116,7 -116,7 +116,7 @@@ check_sub_test_lib_test () name="$1" # stdin is the expected output from the test ( cd "$name" && - ! test -s err && + test_must_be_empty err && sed -e 's/^> //' -e 's/Z$//' >expect && test_cmp expect out ) @@@ -1081,7 -1081,7 +1081,7 @@@ test_expect_success 'very long name in ( git ls-files -s path4 | sed -e "s/ .*/ /" | - tr -d "\012" + tr -d "\012" && echo "$a" ) | git update-index --index-info && len=$(git ls-files "a*" | wc -c) && diff --combined t/t0001-init.sh index ca85aae51e,28f34fd3bd..182da069f1 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@@ -167,9 -167,8 +167,8 @@@ test_expect_success 'reinit' ) && test_i18ngrep "Initialized empty" again/out1 && test_i18ngrep "Reinitialized existing" again/out2 && - >again/empty && - test_i18ncmp again/empty again/err1 && - test_i18ncmp again/empty again/err2 + test_must_be_empty again/err1 && + test_must_be_empty again/err2 ' test_expect_success 'init with --template' ' @@@ -408,7 -407,7 +407,7 @@@ is_hidden () test_expect_success MINGW '.git hidden' ' rm -rf newdir && ( - unset GIT_DIR GIT_WORK_TREE + sane_unset GIT_DIR GIT_WORK_TREE && mkdir newdir && cd newdir && git init && @@@ -420,7 -419,7 +419,7 @@@ test_expect_success MINGW 'bare git dir not hidden' ' rm -rf newdir && ( - unset GIT_DIR GIT_WORK_TREE GIT_CONFIG + sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG && mkdir newdir && cd newdir && git --bare init diff --combined t/t0003-attributes.sh index 5c37c2e1f8,ee2f5c2389..22499bce5f --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@@ -34,15 -34,15 +34,15 @@@ test_expect_success 'open-quoted pathna test_expect_success 'setup' ' mkdir -p a/b/d a/c b && ( - echo "[attr]notest !test" - echo "\" d \" test=d" - echo " e test=e" - echo " e\" test=e" - echo "f test=f" - echo "a/i test=a/i" - echo "onoff test -test" - echo "offon -test test" - echo "no notest" + echo "[attr]notest !test" && + echo "\" d \" test=d" && + echo " e test=e" && + echo " e\" test=e" && + echo "f test=f" && + echo "a/i test=a/i" && + echo "onoff test -test" && + echo "offon -test test" && + echo "no notest" && echo "A/e/F test=A/e/F" ) >.gitattributes && ( @@@ -51,7 -51,7 +51,7 @@@ ) >a/.gitattributes && ( echo "h test=a/b/h" && - echo "d/* test=a/b/d/*" + echo "d/* test=a/b/d/*" && echo "d/yes notest" ) >a/b/.gitattributes && ( @@@ -208,9 -208,8 +208,8 @@@ test_expect_success 'attribute test: -- ' test_expect_success 'attribute test: --cached option' ' - : >empty && git check-attr --cached --stdin --all actual && - test_cmp empty actual && + test_must_be_empty actual && git add .gitattributes a/.gitattributes a/b/.gitattributes && git check-attr --cached --stdin --all actual && test_cmp specified-all actual @@@ -287,7 -286,7 +286,7 @@@ test_expect_success 'bare repository: c ( cd bare.git && ( - echo "f test=f" + echo "f test=f" && echo "a/i test=a/i" ) >.gitattributes && attr_check f unspecified && @@@ -312,7 -311,7 +311,7 @@@ test_expect_success 'bare repository: t ( cd bare.git && ( - echo "f test=f" + echo "f test=f" && echo "a/i test=a/i" ) >info/attributes && attr_check f f && diff --combined t/t0090-cache-tree.sh index 28ea93f509,9e88a56d61..7de40141ca --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@@ -156,7 -156,7 +156,7 @@@ test_expect_success PERL 'commit --inte return 44; } EOT - (echo p; echo 1; echo; echo s; echo n; echo y; echo q) | + test_write_lines p 1 "" s n y q | git commit --interactive -m foo && test_cache_tree ' @@@ -239,7 -239,7 +239,7 @@@ test_expect_success 'no phantom error w >newdir/one && git add newdir/one && git checkout 2>errors && - ! test -s errors + test_must_be_empty errors ' test_expect_success 'switching trees does not invalidate shared index' ' diff --combined t/t1300-config.sh index 4976e2fcd3,84e88cf5a9..cdf1fed5d1 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@@ -346,12 -346,9 +346,9 @@@ test_expect_success 'working --list' git config --list > output && test_cmp expect output ' - cat > expect << EOF - EOF - test_expect_success '--list without repo produces empty output' ' git --git-dir=nonexistent config --list >output && - test_cmp expect output + test_must_be_empty output ' cat > expect << EOF @@@ -888,7 -885,7 +885,7 @@@ EO test_expect_success !MINGW 'get --path copes with unset $HOME' ' ( - unset HOME; + sane_unset HOME && test_must_fail git config --get --path path.home \ >result 2>msg && git config --get --path path.normal >>result && @@@ -1218,93 -1215,6 +1215,93 @@@ test_expect_success 'last one wins: thr test_cmp expect actual ' +test_expect_success 'old-fashioned settings are case insensitive' ' + test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" && + + cat >testConfig_actual <<-EOF && + [V.A] + r = value1 + EOF + q_to_tab >testConfig_expect <<-EOF && + [V.A] + Qr = value2 + EOF + git config -f testConfig_actual "v.a.r" value2 && + test_cmp testConfig_expect testConfig_actual && + + cat >testConfig_actual <<-EOF && + [V.A] + r = value1 + EOF + q_to_tab >testConfig_expect <<-EOF && + [V.A] + QR = value2 + EOF + git config -f testConfig_actual "V.a.R" value2 && + test_cmp testConfig_expect testConfig_actual && + + cat >testConfig_actual <<-EOF && + [V.A] + r = value1 + EOF + q_to_tab >testConfig_expect <<-EOF && + [V.A] + r = value1 + Qr = value2 + EOF + git config -f testConfig_actual "V.A.r" value2 && + test_cmp testConfig_expect testConfig_actual && + + cat >testConfig_actual <<-EOF && + [V.A] + r = value1 + EOF + q_to_tab >testConfig_expect <<-EOF && + [V.A] + r = value1 + Qr = value2 + EOF + git config -f testConfig_actual "v.A.r" value2 && + test_cmp testConfig_expect testConfig_actual +' + +test_expect_success 'setting different case sensitive subsections ' ' + test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" && + + cat >testConfig_actual <<-EOF && + [V "A"] + R = v1 + [K "E"] + Y = v1 + [a "b"] + c = v1 + [d "e"] + f = v1 + EOF + q_to_tab >testConfig_expect <<-EOF && + [V "A"] + Qr = v2 + [K "E"] + Qy = v2 + [a "b"] + Qc = v2 + [d "e"] + f = v1 + [d "E"] + Qf = v2 + EOF + # exact match + git config -f testConfig_actual a.b.c v2 && + # match section and subsection, key is cased differently. + git config -f testConfig_actual K.E.y v2 && + # section and key are matched case insensitive, but subsection needs + # to match; When writing out new values only the key is adjusted + git config -f testConfig_actual v.A.r v2 && + # subsection is not matched: + git config -f testConfig_actual d.E.f v2 && + test_cmp testConfig_expect testConfig_actual +' + for VAR in a .a a. a.0b a."b c". a."b c".0d do test_expect_success "git -c $VAR=VAL rejects invalid '$VAR'" ' diff --combined t/t1411-reflog-show.sh index 4d62ceef9c,26590f9a21..985daf1def --- a/t/t1411-reflog-show.sh +++ b/t/t1411-reflog-show.sh @@@ -136,13 -136,12 +136,12 @@@ test_expect_success '--date magic does test_cmp expect actual ' - : >expect test_expect_success 'empty reflog file' ' git branch empty && git reflog expire --expire=all refs/heads/empty && git log -g empty >actual && - test_cmp expect actual + test_must_be_empty actual ' # This guards against the alternative of showing the diffs vs. the @@@ -159,9 -158,9 +158,9 @@@ test_expect_success 'git log -g -p show git log -1 -p HEAD^ >log.one && git log -1 -p HEAD >log.two && ( - cat log.one; echo - cat log.two; echo - cat log.one; echo + cat log.one && echo && + cat log.two && echo && + cat log.one && echo && cat log.two ) >expect && test_cmp expect actual diff --combined t/t1450-fsck.sh index 7b7602ddb4,a652f6002a..0f2dd26f74 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@@ -16,8 -16,7 +16,7 @@@ test_expect_success setup git checkout HEAD^0 && test_commit B fileB two && git tag -d A B && - git reflog expire --expire=now --all && - >empty + git reflog expire --expire=now --all ' test_expect_success 'loose objects borrowed from alternate are not missing' ' @@@ -29,12 -28,12 +28,12 @@@ test_commit C fileC one && git fsck --no-dangling >../actual 2>&1 ) && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'HEAD is part of refs, valid objects appear valid' ' git fsck >actual 2>&1 && - test_cmp empty actual + test_must_be_empty actual ' # Corruption tests follow. Make sure to remove all traces of the @@@ -346,12 -345,12 +345,12 @@@ test_expect_success 'tag with NUL in he test_expect_success 'cleaned up' ' git fsck >actual 2>&1 && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'rev-list --verify-objects' ' git rev-list --verify-objects --all >/dev/null 2>out && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'rev-list --verify-objects with bad sha1' ' @@@ -372,7 -371,7 +371,7 @@@ test_might_fail git rev-list --verify-objects refs/heads/bogus >/dev/null 2>out && cat out && - grep -q "error: sha1 mismatch 63ffffffffffffffffffffffffffffffffffffff" out + test_i18ngrep -q "error: sha1 mismatch 63ffffffffffffffffffffffffffffffffffffff" out ' test_expect_success 'force fsck to ignore double author' ' diff --combined t/t1700-split-index.sh index 39133bcbc8,f85ba57803..b3b4d83eaf --- a/t/t1700-split-index.sh +++ b/t/t1700-split-index.sh @@@ -143,9 -143,7 +143,7 @@@ test_expect_success 'remove file not i test_expect_success 'remove file in base index' ' git update-index --force-remove one && git ls-files --stage >ls-files.actual && - cat >ls-files.expect <<-EOF && - EOF - test_cmp ls-files.expect ls-files.actual && + test_must_be_empty ls-files.actual && test-tool dump-split-index .git/index | sed "/^own/d" >actual && cat >expect <<-EOF && @@@ -435,7 -433,7 +433,7 @@@ test_expect_success 'writing split inde commit=$(git commit-tree $tree -p HEAD cache-tree.out || true) && + test_might_fail test-tool dump-cache-tree >cache-tree.out && test_line_count = 0 cache-tree.out ' diff --combined t/t3210-pack-refs.sh index 7333d7d545,112cbb0e62..9ea5fa4fd2 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@@ -127,7 -127,7 +127,7 @@@ test_expect_success 'explicit pack-ref git reflog expire --expire=all --all && git prune --expire=all && git pack-refs --all 2>result && - test_cmp /dev/null result + test_must_be_empty result ' test_expect_success 'delete ref with dangling packed version' ' @@@ -139,7 -139,7 +139,7 @@@ git reflog expire --expire=all --all && git prune --expire=all && git branch -d lamb 2>result && - test_cmp /dev/null result + test_must_be_empty result ' test_expect_success 'delete ref while another dangling packed ref' ' @@@ -150,7 -150,7 +150,7 @@@ git reflog expire --expire=all --all && git prune --expire=all && git branch -d lamb 2>result && - test_cmp /dev/null result + test_must_be_empty result ' test_expect_success 'pack ref directly below refs/' ' @@@ -186,7 -186,7 +186,7 @@@ test_expect_success 'notice d/f conflic test_expect_success 'existing directory reports concrete ref' ' test_must_fail git branch foo 2>stderr && - grep refs/heads/foo/bar/baz stderr + test_i18ngrep refs/heads/foo/bar/baz stderr ' test_expect_success 'notice d/f conflict with existing ref' ' @@@ -231,9 -231,9 +231,9 @@@ test_expect_success 'timeout if packed- test_expect_success 'retry acquiring packed-refs.lock' ' LOCK=.git/packed-refs.lock && >"$LOCK" && - test_when_finished "wait; rm -f $LOCK" && + test_when_finished "wait && rm -f $LOCK" && { - ( sleep 1 ; rm -f $LOCK ) & + ( sleep 1 && rm -f $LOCK ) & } && git -c core.packedrefstimeout=3000 pack-refs --all --prune ' diff --combined t/t3301-notes.sh index ac62dc0e8f,e5703a0d5b..84bbf88cf9 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh @@@ -481,10 -481,8 +481,8 @@@ test_expect_success 'list specific not ' test_expect_success 'listing non-existing notes fails' ' - cat >expect <<-EOF && - EOF test_must_fail git notes list HEAD >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'append to existing note with "git notes append"' ' @@@ -914,7 -912,7 +912,7 @@@ test_expect_success 'git notes copy --s ${indent} ${indent}yet another note EOF - (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \ + (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) && echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | git notes copy --stdin && git log -2 >actual && @@@ -939,7 -937,7 +937,7 @@@ test_expect_success 'git notes copy --f EOF test_commit 14th && test_commit 15th && - (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \ + (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) && echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | git notes copy --for-rewrite=foo && git log -2 >actual && @@@ -972,7 -970,7 +970,7 @@@ test_expect_success 'git notes copy --f EOF test_config notes.rewriteMode overwrite && test_config notes.rewriteRef "refs/notes/*" && - (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^); \ + (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) && echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | git notes copy --for-rewrite=foo && git log -2 >actual && @@@ -1059,7 -1057,7 +1057,7 @@@ test_expect_success 'git notes copy --f git notes add -f -m"append 2" HEAD^^ && test_config notes.rewriteMode concatenate && test_config notes.rewriteRef "refs/notes/*" && - (echo $(git rev-parse HEAD^) $(git rev-parse HEAD); + (echo $(git rev-parse HEAD^) $(git rev-parse HEAD) && echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) | git notes copy --for-rewrite=foo && git log -1 >actual && diff --combined t/t3310-notes-merge-manual-resolve.sh index 68436eed82,a1cf4ec385..2dea846e25 --- a/t/t3310-notes-merge-manual-resolve.sh +++ b/t/t3310-notes-merge-manual-resolve.sh @@@ -337,7 -337,7 +337,7 @@@ EO git notes merge --commit && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" && @@@ -399,7 -399,7 +399,7 @@@ test_expect_success 'abort notes merge git notes merge --abort && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # m has not moved (still == y) test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" && # Verify that other notes refs has not changed (w, x, y and z) @@@ -466,7 -466,7 +466,7 @@@ EO git notes merge --commit && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" && @@@ -541,9 -541,9 +541,9 @@@ EO test "$(git rev-parse refs/notes/y)" = "$(git rev-parse NOTES_MERGE_PARTIAL^1)" && test "$(git rev-parse refs/notes/m)" != "$(git rev-parse NOTES_MERGE_PARTIAL^1)" && # Mention refs/notes/m, and its current and expected value in output - grep -q "refs/notes/m" output && - grep -q "$(git rev-parse refs/notes/m)" output && - grep -q "$(git rev-parse NOTES_MERGE_PARTIAL^1)" output && + test_i18ngrep -q "refs/notes/m" output && + test_i18ngrep -q "$(git rev-parse refs/notes/m)" output && + test_i18ngrep -q "$(git rev-parse NOTES_MERGE_PARTIAL^1)" output && # Verify that other notes refs has not changed (w, x, y and z) verify_notes w && verify_notes x && @@@ -555,7 -555,7 +555,7 @@@ test_expect_success 'resolve situation git notes merge --abort && # No .git/NOTES_MERGE_* files left test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_cmp /dev/null output && + test_must_be_empty output && # m has not moved (still == w) test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" && # Verify that other notes refs has not changed (w, x, y and z) diff --combined t/t3404-rebase-interactive.sh index 4c7b1ea356,5997770dc3..259c27233d --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@@ -119,15 -119,6 +119,15 @@@ test_expect_success 'rebase -i with exe ) ' +test_expect_success 'rebase -i sets work tree properly' ' + test_when_finished "rm -rf subdir" && + test_when_finished "test_might_fail git rebase --abort" && + mkdir subdir && + git rebase -x "(cd subdir && git rev-parse --show-toplevel)" HEAD^ \ + >actual && + ! grep "/subdir$" actual +' + test_expect_success 'rebase -i with the exec command checks tree cleanness' ' git checkout master && set_fake_editor && @@@ -525,7 -516,7 +525,7 @@@ test_expect_success 'interrupted squas one=$(git rev-parse HEAD~3) && set_fake_editor && test_must_fail env FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 && - (echo one; echo two; echo four) > conflict && + test_write_lines one two four > conflict && git add conflict && test_must_fail git rebase --continue && echo resolved > conflict && @@@ -539,10 -530,10 +539,10 @@@ test_expect_success 'interrupted squas one=$(git rev-parse HEAD~3) && set_fake_editor && test_must_fail env FAKE_LINES="3 squash 1 2" git rebase -i HEAD~3 && - (echo one; echo four) > conflict && + test_write_lines one four > conflict && git add conflict && test_must_fail git rebase --continue && - (echo one; echo two; echo four) > conflict && + test_write_lines one two four > conflict && git add conflict && test_must_fail git rebase --continue && echo resolved > conflict && @@@ -796,16 -787,15 +796,15 @@@ test_expect_success 'always cherry-pic git tag original-no-ff-branch && set_fake_editor && git rebase -i --no-ff A && - touch empty && for p in 0 1 2 do test ! $(git rev-parse HEAD~$p) = $(git rev-parse original-no-ff-branch~$p) && git diff HEAD~$p original-no-ff-branch~$p > out && - test_cmp empty out + test_must_be_empty out done && test $(git rev-parse HEAD~3) = $(git rev-parse original-no-ff-branch~3) && git diff HEAD~3 original-no-ff-branch~3 > out && - test_cmp empty out + test_must_be_empty out ' test_expect_success 'set up commits with funny messages' ' @@@ -1247,7 -1237,7 +1246,7 @@@ rebase_setup_and_clean () test_might_fail git branch -D $1 && test_might_fail git rebase --abort " && - git checkout -b $1 master + git checkout -b $1 ${2:-master} } test_expect_success 'drop' ' @@@ -1424,12 -1414,4 +1423,12 @@@ test_expect_success 'rebase -i --gpg-si test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err ' +test_expect_success 'valid author header after --root swap' ' + rebase_setup_and_clean author-header no-conflict-branch && + set_fake_editor && + FAKE_LINES="2 1" git rebase -i --root && + git cat-file commit HEAD^ >out && + grep "^author ..*> [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$" out +' + test_done diff --combined t/t3600-rm.sh index 5829dfd12c,b178a376c4..04e5d42bd3 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@@ -14,13 -14,15 +14,13 @@@ test_expect_success git add -- foo bar baz 'space embedded' -q && git commit -m 'add normal files'" -if test_have_prereq !MINGW && touch -- 'tab embedded' 'newline -embedded' 2>/dev/null -then - test_set_prereq FUNNYNAMES -else +if test_have_prereq !FUNNYNAMES; then say 'Your filesystem does not allow tabs in filenames.' fi test_expect_success FUNNYNAMES 'add files with funny names' " + touch -- 'tab embedded' 'newline +embedded' && git add -- 'tab embedded' 'newline embedded' && git commit -m 'add files with tabs and newlines' @@@ -380,7 -382,7 +380,7 @@@ test_expect_success 'rm does not compla git submodule update && git rm .gitmodules && git rm submod >actual 2>actual.err && - ! test -s actual.err && + test_must_be_empty actual.err && ! test -d submod && ! test -f submod/.git && git status -s -uno >actual && @@@ -398,7 -400,7 +398,7 @@@ test_expect_success 'rm will error out git diff-files --quiet -- submod && git add .gitmodules && git rm submod >actual 2>actual.err && - ! test -s actual.err && + test_must_be_empty actual.err && ! test -d submod && ! test -f submod/.git && git status -s -uno >actual && @@@ -692,7 -694,7 +692,7 @@@ test_expect_success 'checking out a com test_cmp expected actual && rm -rf submod && git status -s -uno --ignore-submodules=none >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'rm of d/f when d has become a non-directory' ' diff --combined t/t4015-diff-whitespace.sh index 35fc8b5c2a,1ea9e0d21d..a9fb226c5a --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@@ -776,8 -776,6 +776,6 @@@ test_expect_success 'checkdiff allows n git diff --check ' - cat <expect - EOF test_expect_success 'whitespace-only changes not reported' ' git reset --hard && echo >x "hello world" && @@@ -785,7 -783,7 +783,7 @@@ git commit -m "hello 1" && echo >x "hello world" && git diff -b >actual && - test_cmp expect actual + test_must_be_empty actual ' cat <expect @@@ -1220,7 -1218,7 +1218,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 @@@ -1268,52 -1266,9 +1266,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 @@@ -1355,8 -1310,9 +1353,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 @@@ -1434,8 -1390,9 +1432,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 @@@ -1457,9 -1414,9 +1455,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 @@@ -1497,8 -1454,9 +1495,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 @@@ -1520,9 -1478,9 +1518,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 @@@ -1563,8 -1521,9 +1561,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 @@@ -1586,9 -1545,9 +1584,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 @@@ -1633,8 -1592,9 +1631,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 @@@ -1671,8 -1631,9 +1669,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 @@@ -1713,8 -1674,7 +1711,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 @@@ -1757,146 -1717,7 +1755,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/t4041-diff-submodule-option.sh index 4e3499ef84,7a4594224b..619bf97098 --- a/t/t4041-diff-submodule-option.sh +++ b/t/t4041-diff-submodule-option.sh @@@ -257,9 -257,7 +257,7 @@@ test_expect_success 'typechanged submod commit_file sm1 && test_expect_success 'submodule is up to date' ' git diff-index -p --submodule=log HEAD >actual && - cat >expected <<-EOF && - EOF - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content' ' @@@ -273,17 -271,17 +271,17 @@@ test_expect_success 'submodule contains untracked content (untracked ignored)' ' git diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content (dirty ignored)' ' git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content (all ignored)' ' git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked and modifed content' ' @@@ -308,13 -306,13 +306,13 @@@ test_expect_success 'submodule contain test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked and modifed content (all ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains modifed content' ' @@@ -368,7 -366,7 +366,7 @@@ test_expect_success 'modified submodul test_expect_success 'modified submodule contains untracked content (all ignored)' ' git diff-index -p --ignore-submodules=all --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'modified submodule contains untracked and modifed content' ' @@@ -407,7 -405,7 +405,7 @@@ test_expect_success 'modified submodul test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' ' echo modification >> sm1/foo6 && git diff-index -p --ignore-submodules --submodule=log HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'modified submodule contains modifed content' ' @@@ -498,7 -496,7 +496,7 @@@ test_expect_success 'given commit --sub test_expect_success 'setup .git file for sm2' ' (cd sm2 && REAL="$(pwd)/../.real" && - mv .git "$REAL" + mv .git "$REAL" && echo "gitdir: $REAL" >.git) ' @@@ -527,7 -525,7 +525,7 @@@ test_expect_success 'diff --submodule w git commit -m "sub a" ) && (cd sub_alt && - sha1_before=$(git rev-parse --short HEAD) + sha1_before=$(git rev-parse --short HEAD) && echo b >b && git add b && git commit -m b && diff --combined t/t4060-diff-submodule-option-diff-format.sh index 0eba4620f0,60c8dc75a9..9dcb69df5c --- a/t/t4060-diff-submodule-option-diff-format.sh +++ b/t/t4060-diff-submodule-option-diff-format.sh @@@ -392,9 -392,7 +392,7 @@@ test_expect_success 'typechanged submod commit_file sm1 && test_expect_success 'submodule is up to date' ' git diff-index -p --submodule=diff HEAD >actual && - cat >expected <<-EOF && - EOF - test_cmp expected actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content' ' @@@ -408,17 -406,17 +406,17 @@@ test_expect_success 'submodule contains untracked content (untracked ignored)' ' git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content (dirty ignored)' ' git diff-index -p --ignore-submodules=dirty --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked content (all ignored)' ' git diff-index -p --ignore-submodules=all --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked and modified content' ' @@@ -458,13 -456,13 +456,13 @@@ test_expect_success 'submodule contain test_expect_success 'submodule contains untracked and modified content (dirty ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules=dirty --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains untracked and modified content (all ignored)' ' echo new > sm1/foo6 && git diff-index -p --ignore-submodules --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'submodule contains modified content' ' @@@ -549,7 -547,7 +547,7 @@@ test_expect_success 'modified submodul test_expect_success 'modified submodule contains untracked content (all ignored)' ' git diff-index -p --ignore-submodules=all --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'modified submodule contains untracked and modified content' ' @@@ -609,7 -607,7 +607,7 @@@ test_expect_success 'modified submodul test_expect_success 'modified submodule contains untracked and modified content (all ignored)' ' echo modification >> sm1/foo6 && git diff-index -p --ignore-submodules --submodule=diff HEAD >actual && - ! test -s actual + test_must_be_empty actual ' # NOT OK @@@ -721,7 -719,7 +719,7 @@@ test_expect_success 'given commit' test_expect_success 'setup .git file for sm2' ' (cd sm2 && REAL="$(pwd)/../.real" && - mv .git "$REAL" + mv .git "$REAL" && echo "gitdir: $REAL" >.git) ' diff --combined t/t4150-am.sh index 01867a9898,38fe717c12..55b577d919 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@@ -69,15 -69,13 +69,15 @@@ test_expect_success 'setup: messages' EOF - cat >scissors-msg <<-\EOF && - Test git-am with scissors line + cat >msg-without-scissors-line <<-\EOF && + Test that git-am --scissors cuts at the scissors line This line should be included in the commit message. EOF - cat - scissors-msg >no-scissors-msg <<-\EOF && + printf "Subject: " >subject-prefix && + + cat - subject-prefix msg-without-scissors-line >msg-with-scissors-line <<-\EOF && This line should not be included in the commit message with --scissors enabled. - - >8 - - remove everything above this line - - >8 - - @@@ -150,17 -148,18 +150,17 @@@ test_expect_success setup } >patch1-hg.eml && - echo scissors-file >scissors-file && - git add scissors-file && - git commit -F scissors-msg && - git tag scissors && - git format-patch --stdout scissors^ >scissors-patch.eml && + echo file >file && + git add file && + git commit -F msg-without-scissors-line && + git tag expected-for-scissors && git reset --hard HEAD^ && - echo no-scissors-file >no-scissors-file && - git add no-scissors-file && - git commit -F no-scissors-msg && - git tag no-scissors && - git format-patch --stdout no-scissors^ >no-scissors-patch.eml && + echo file >file && + git add file && + git commit -F msg-with-scissors-line && + git tag expected-for-no-scissors && + git format-patch --stdout expected-for-no-scissors^ >patch-with-scissors-line.eml && git reset --hard HEAD^ && sed -n -e "3,\$p" msg >file && @@@ -417,10 -416,10 +417,10 @@@ test_expect_success 'am --scissors cut rm -fr .git/rebase-apply && git reset --hard && git checkout second && - git am --scissors scissors-patch.eml && + git am --scissors patch-with-scissors-line.eml && test_path_is_missing .git/rebase-apply && - git diff --exit-code scissors && - test_cmp_rev scissors HEAD + git diff --exit-code expected-for-scissors && + test_cmp_rev expected-for-scissors HEAD ' test_expect_success 'am --no-scissors overrides mailinfo.scissors' ' @@@ -428,10 -427,10 +428,10 @@@ git reset --hard && git checkout second && test_config mailinfo.scissors true && - git am --no-scissors no-scissors-patch.eml && + git am --no-scissors patch-with-scissors-line.eml && test_path_is_missing .git/rebase-apply && - git diff --exit-code no-scissors && - test_cmp_rev no-scissors HEAD + git diff --exit-code expected-for-no-scissors && + test_cmp_rev expected-for-no-scissors HEAD ' test_expect_success 'setup: new author and committer' ' @@@ -652,7 -651,7 +652,7 @@@ test_expect_success 'am -3 -q is quiet git checkout -f lorem2 && git reset base3way --hard && git am -3 -q lorem-move.patch >output.out 2>&1 && - ! test -s output.out + test_must_be_empty output.out ' test_expect_success 'am pauses on conflict' ' @@@ -875,7 -874,7 +875,7 @@@ test_expect_success 'am -q is quiet' git checkout first && test_tick && git am -q output.out 2>&1 && - ! test -s output.out + test_must_be_empty output.out ' test_expect_success 'am empty-file does not infloop' ' diff --combined t/t4211-line-log.sh index 436b13ad21,6e378b23c7..ef1322148e --- a/t/t4211-line-log.sh +++ b/t/t4211-line-log.sh @@@ -60,6 -60,7 +60,6 @@@ test_bad_opts "-L 1:nonexistent" "Ther test_bad_opts "-L 1:simple" "There is no path" test_bad_opts "-L '/foo:b.c'" "argument not .start,end:file" test_bad_opts "-L 1000:b.c" "has only.*lines" -test_bad_opts "-L 1,1000:b.c" "has only.*lines" test_bad_opts "-L :b.c" "argument not .start,end:file" test_bad_opts "-L :foo:b.c" "no match" @@@ -85,12 -86,12 +85,12 @@@ test_expect_success '-L ,Y (Y == nlines test_expect_success '-L ,Y (Y == nlines + 1)' ' n=$(expr $(wc -l output && - test ! -s output && + test_must_be_empty output && test_line_count = 70 log ' diff --combined t/t5401-update-hooks.sh index b5f886a0e2,ce151e71c1..956d69f5b1 --- a/t/t5401-update-hooks.sh +++ b/t/t5401-update-hooks.sh @@@ -82,13 -82,13 +82,13 @@@ test_expect_success 'hooks ran' ' test_expect_success 'pre-receive hook input' ' - (echo $commit0 $commit1 refs/heads/master; + (echo $commit0 $commit1 refs/heads/master && echo $commit1 $commit0 refs/heads/tofail ) | test_cmp - victim.git/pre-receive.stdin ' test_expect_success 'update hook arguments' ' - (echo refs/heads/master $commit0 $commit1; + (echo refs/heads/master $commit0 $commit1 && echo refs/heads/tofail $commit1 $commit0 ) | test_cmp - victim.git/update.args ' @@@ -104,17 -104,17 +104,17 @@@ test_expect_success 'post-update hook a ' test_expect_success 'all hook stdin is /dev/null' ' - ! test -s victim.git/update.stdin && - ! test -s victim.git/post-update.stdin + test_must_be_empty victim.git/update.stdin && + test_must_be_empty victim.git/post-update.stdin ' test_expect_success 'all *-receive hook args are empty' ' - ! test -s victim.git/pre-receive.args && - ! test -s victim.git/post-receive.args + test_must_be_empty victim.git/pre-receive.args && + test_must_be_empty victim.git/post-receive.args ' test_expect_success 'send-pack produced no output' ' - ! test -s send.out + test_must_be_empty send.out ' cat <expect diff --combined t/t5500-fetch-pack.sh index 8f945235e3,07fcea0474..1b5a4a6d38 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@@ -161,7 -161,7 +161,7 @@@ test_expect_success 'clone shallow obje test_expect_success 'clone shallow object count (part 2)' ' sed -e "/^in-pack:/d" -e "/^packs:/d" -e "/^size-pack:/d" \ -e "/: 0$/d" count.shallow > count_output && - ! test -s count_output + test_must_be_empty count_output ' test_expect_success 'fsck in shallow repo' ' @@@ -259,7 -259,7 +259,7 @@@ test_expect_success 'clone shallow obje test_expect_success 'pull in shallow repo with missing merge base' ' ( cd shallow && - git fetch --depth 4 .. A + git fetch --depth 4 .. A && test_must_fail git merge --allow-unrelated-histories FETCH_HEAD ) ' @@@ -403,7 -403,7 +403,7 @@@ test_expect_success 'fetch creating ne git fetch --depth=1 --progress 2>actual && # This should fetch only the empty commit, no tree or # blob objects - grep "remote: Total 1" actual + test_i18ngrep "remote: Total 1" actual ) ' @@@ -814,39 -814,6 +814,39 @@@ test_expect_success 'fetching deepen' ) ' +test_expect_success 'use ref advertisement to prune "have" lines sent' ' + rm -rf server client && + git init server && + test_commit -C server both_have_1 && + git -C server tag -d both_have_1 && + test_commit -C server both_have_2 && + + git clone server client && + test_commit -C server server_has && + test_commit -C client client_has && + + # In both protocol v0 and v2, ensure that the parent of both_have_2 is + # not sent as a "have" line. The client should know that the server has + # both_have_2, so it only needs to inform the server that it has + # both_have_2, and the server can infer the rest. + + rm -f trace && + cp -r client clientv0 && + GIT_TRACE_PACKET="$(pwd)/trace" git -C clientv0 \ + fetch origin server_has both_have_2 && + grep "have $(git -C client rev-parse client_has)" trace && + grep "have $(git -C client rev-parse both_have_2)" trace && + ! grep "have $(git -C client rev-parse both_have_2^)" trace && + + rm -f trace && + cp -r client clientv2 && + GIT_TRACE_PACKET="$(pwd)/trace" git -C clientv2 -c protocol.version=2 \ + fetch origin server_has both_have_2 && + grep "have $(git -C client rev-parse client_has)" trace && + grep "have $(git -C client rev-parse both_have_2)" trace && + ! grep "have $(git -C client rev-parse both_have_2^)" trace +' + test_expect_success 'filtering by size' ' rm -rf server client && test_create_repo server && diff --combined t/t5526-fetch-submodules.sh index 0f730d7781,fc95df0d0d..6c2f9b2ba2 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@@ -98,8 -98,8 +98,8 @@@ test_expect_success "fetch alone only f cd downstream && git fetch >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "fetch --no-recurse-submodules only fetches superproject" ' @@@ -107,8 -107,8 +107,8 @@@ cd downstream && git fetch --no-recurse-submodules >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "using fetchRecurseSubmodules=true in .gitmodules recurses into submodules" ' @@@ -127,8 -127,8 +127,8 @@@ test_expect_success "--no-recurse-submo cd downstream && git fetch --no-recurse-submodules >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "using fetchRecurseSubmodules=false in .git/config overrides setting in .gitmodules" ' @@@ -137,8 -137,8 +137,8 @@@ git config submodule.submodule.fetchRecurseSubmodules false && git fetch >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setting from .git/config" ' @@@ -157,8 -157,8 +157,8 @@@ test_expect_success "--quiet propagate cd downstream && git fetch --recurse-submodules --quiet >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "--quiet propagates to parallel submodules" ' @@@ -166,8 -166,8 +166,8 @@@ cd downstream && git fetch --recurse-submodules -j 2 --quiet >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "--dry-run propagates to submodules" ' @@@ -221,8 -221,8 +221,8 @@@ test_expect_success "--no-recurse-submo git config fetch.recurseSubmodules true && git fetch --no-recurse-submodules >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "Recursion doesn't happen when no new commits are fetched in the superproject" ' @@@ -235,8 -235,8 +235,8 @@@ git config --unset fetch.recurseSubmodules && git fetch >../actual.out 2>../actual.err ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "Recursion stops when no new submodule commits are fetched" ' @@@ -268,7 -268,7 +268,7 @@@ test_expect_success "Recursion doesn't cd downstream && git fetch >../actual.out 2>../actual.err ) && - ! test -s actual.out && + test_must_be_empty actual.out && test_i18ncmp expect.err.file actual.err ' @@@ -357,8 -357,8 +357,8 @@@ test_expect_success "'--recurse-submodu git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err && git config --unset fetch.recurseSubmodules ) && - ! test -s actual.out && - ! test -s actual.err + test_must_be_empty actual.out && + test_must_be_empty actual.err ' test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necessary (and ignores config)" ' @@@ -379,7 -379,7 +379,7 @@@ git config -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive false ) && git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err && - git config --unset fetch.recurseSubmodules + git config --unset fetch.recurseSubmodules && ( cd submodule && git config --unset -f .gitmodules submodule.subdir/deepsubmodule.fetchRecursive @@@ -402,7 -402,7 +402,7 @@@ test_expect_success "'--recurse-submodu cd downstream && git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err ) && - ! test -s actual.out && + test_must_be_empty actual.out && test_i18ncmp expect.err.file actual.err ' @@@ -477,7 -477,7 +477,7 @@@ test_expect_success "don't fetch submod cd downstream && git fetch >../actual.out 2>../actual.err ) && - ! test -s actual.out && + test_must_be_empty actual.out && test_i18ncmp expect.err actual.err && ( cd submodule && @@@ -495,7 -495,6 +495,6 @@@ test_expect_success "'fetch.recurseSubm git add submodule && git rm .gitmodules && git commit -m "new submodule without .gitmodules" && - printf "" >expect.out && head2=$(git rev-parse --short HEAD) && echo "From $pwd/." >expect.err.2 && echo " $head1..$head2 master -> origin/master" >>expect.err.2 && @@@ -514,7 -513,7 +513,7 @@@ git config --unset fetch.recurseSubmodules && git reset --hard ) && - test_i18ncmp expect.out actual.out && + test_must_be_empty actual.out && test_i18ncmp expect.err.2 actual.err && git checkout HEAD^ -- .gitmodules && git add .gitmodules && diff --combined t/t5541-http-push-smart.sh index a0fc4005e0,4319ef6ec7..5475afc052 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@@ -38,16 -38,25 +38,16 @@@ GET /smart/test_repo.git/info/refs?ser POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200 EOF test_expect_success 'no empty path components' ' + # Clear the log, so that it does not affect the "used receive-pack + # service" test which reads the log too. + test_when_finished ">\"\$HTTPD_ROOT_PATH\"/access.log" && + # In the URL, add a trailing slash, and see if git appends yet another # slash. cd "$ROOT_PATH" && git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone && - sed -e " - s/^.* \"// - s/\"// - s/ [1-9][0-9]*\$// - s/^GET /GET / - " >act <"$HTTPD_ROOT_PATH"/access.log && - - # Clear the log, so that it does not affect the "used receive-pack - # service" test which reads the log too. - # - # We do this before the actual comparison to ensure the log is cleared. - echo > "$HTTPD_ROOT_PATH"/access.log && - - test_cmp exp act + check_access_log exp ' test_expect_success 'clone remote repository' ' @@@ -115,6 -124,7 +115,6 @@@ test_expect_success 'rejected update pr rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" cat >exp <act <"$HTTPD_ROOT_PATH"/access.log && - test_cmp exp act + check_access_log exp ' test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ @@@ -210,7 -226,7 +210,7 @@@ test_expect_success TTY 'push --quiet s cd "$ROOT_PATH"/test_repo_clone && test_commit quiet && test_terminal git push --quiet >output 2>&1 && - test_cmp /dev/null output + test_must_be_empty output ' test_expect_success TTY 'push --no-progress silences progress but not status' ' diff --combined t/t5570-git-daemon.sh index a571f22bfd,12c1e43a84..7466aad111 --- a/t/t5570-git-daemon.sh +++ b/t/t5570-git-daemon.sh @@@ -7,9 -7,9 +7,9 @@@ test_description='test fetching over gi start_git_daemon check_verbose_connect () { - grep -F "Looking up 127.0.0.1 ..." stderr && - grep -F "Connecting to 127.0.0.1 (port " stderr && - grep -F "done." stderr + test_i18ngrep -F "Looking up 127.0.0.1 ..." stderr && + test_i18ngrep -F "Connecting to 127.0.0.1 (port " stderr && + test_i18ngrep -F "done." stderr } test_expect_success 'setup repository' ' @@@ -51,7 -51,7 +51,7 @@@ test_expect_success 'no-op fetch -v std test_expect_success 'no-op fetch without "-v" is quiet' ' (cd clone && git fetch 2>../stderr) && - ! test -s stderr + test_must_be_empty stderr ' test_expect_success 'remote detects correct HEAD' ' diff --combined t/t7001-mv.sh index 9e59e5a5dd,56ca467c0a..36b50d0b4c --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@@ -384,7 -384,7 +384,7 @@@ test_expect_success 'mv does not compla entry="$(git ls-files --stage sub | cut -f 1)" && mkdir mod && git mv sub mod/sub 2>actual.err && - ! test -s actual.err && + test_must_be_empty actual.err && ! test -e sub && [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] && ( @@@ -408,7 -408,7 +408,7 @@@ test_expect_success 'mv will error out git diff-files --quiet -- sub && git add .gitmodules && git mv sub mod/sub 2>actual.err && - ! test -s actual.err && + test_must_be_empty actual.err && ! test -e sub && [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] && ( @@@ -469,7 -469,7 +469,7 @@@ test_expect_success 'checking out a com git update-index --refresh && git diff-files --quiet -- sub .gitmodules && git status -s sub2 >actual && - ! test -s actual + test_must_be_empty actual ' test_expect_success 'mv -k does not accidentally destroy submodules' ' @@@ -509,7 -509,7 +509,7 @@@ test_expect_success 'moving nested subm touch nested_level1 && git init && git add . && - git commit -m "nested level 1" + git commit -m "nested level 1" && git submodule add ../sub_nested_nested && git commit -m "add nested level 2" ) && diff --combined t/t7004-tag.sh index 465eb4ea3f,2e17cdb084..0b01862c23 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@@ -325,11 -325,10 +325,10 @@@ test_expect_success test_cmp expect actual ' - >expect test_expect_success \ 'listing tags using v.* should print nothing because none have v.' ' git tag -l "v.*" > actual && - test_cmp expect actual + test_must_be_empty actual ' cat >expect < expected <actual && - test_cmp expected actual + test_must_be_empty actual " cat > expected <current.side && test_cmp expect.side current.side && - : >expect.index && git diff --cached >current.index && - test_cmp expect.index current.index + test_must_be_empty current.index ' test_expect_success "checkout -m with dirty tree, renamed" ' @@@ -139,7 -138,7 +138,7 @@@ test_cmp expect uno && ! test -f one && git diff --cached >current && - ! test -s current + test_must_be_empty current ' @@@ -163,7 -162,7 +162,7 @@@ test_expect_success 'checkout -m with m fill d2 aT d7 aS >expect && test_cmp current expect && git diff --cached two >current && - ! test -s current + test_must_be_empty current ' test_expect_success 'format of merge conflict from checkout -m' ' @@@ -528,10 -527,10 +527,10 @@@ test_expect_success 'checkout with --me cat sample >filf && git checkout -m -- fild file filf && ( - echo "<<<<<<< ours" - echo ourside - echo "=======" - echo theirside + echo "<<<<<<< ours" && + echo ourside && + echo "=======" && + echo theirside && echo ">>>>>>> theirs" ) >merged && test_cmp expect fild && @@@ -549,12 -548,12 +548,12 @@@ test_expect_success 'checkout with --me cat sample >filf && git checkout -m -- fild file filf && ( - echo "<<<<<<< ours" - echo ourside - echo "||||||| base" - echo original - echo "=======" - echo theirside + echo "<<<<<<< ours" && + echo ourside && + echo "||||||| base" && + echo original && + echo "=======" && + echo theirside && echo ">>>>>>> theirs" ) >merged && test_cmp expect fild && @@@ -572,10 -571,10 +571,10 @@@ test_expect_success 'checkout --conflic cat sample >filf && git checkout --conflict=merge -- fild file filf && ( - echo "<<<<<<< ours" - echo ourside - echo "=======" - echo theirside + echo "<<<<<<< ours" && + echo ourside && + echo "=======" && + echo theirside && echo ">>>>>>> theirs" ) >merged && test_cmp expect fild && @@@ -593,12 -592,12 +592,12 @@@ test_expect_success 'checkout --conflic cat sample >filf && git checkout --conflict=diff3 -- fild file filf && ( - echo "<<<<<<< ours" - echo ourside - echo "||||||| base" - echo original - echo "=======" - echo theirside + echo "<<<<<<< ours" && + echo ourside && + echo "||||||| base" && + echo original && + echo "=======" && + echo theirside && echo ">>>>>>> theirs" ) >merged && test_cmp expect fild && @@@ -673,6 -672,7 +672,6 @@@ test_expect_success 'custom merge drive do grep $t arm || exit 1 done - exit 0 ) && mv arm expect && diff --combined t/t7400-submodule-basic.sh index 2b71e62ec2,894ea2f27d..7d3d984210 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@@ -101,7 -101,6 +101,6 @@@ inspect() test_expect_success 'submodule add' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@@ -123,7 -122,7 +122,7 @@@ inspect addtest/submod ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'setup parent and one repository' ' @@@ -171,13 -170,12 +170,13 @@@ test_expect_success 'submodule add to . test_expect_success 'submodule add to reconfigure existing submodule with --force' ' ( cd addtest-ignore && - git submodule add --force bogus-url submod && - git submodule add -b initial "$submodurl" submod-branch && - test "bogus-url" = "$(git config -f .gitmodules submodule.submod.url)" && - test "bogus-url" = "$(git config submodule.submod.url)" && + bogus_url="$(pwd)/bogus-url" && + git submodule add --force "$bogus_url" submod && + git submodule add --force -b initial "$submodurl" submod-branch && + test "$bogus_url" = "$(git config -f .gitmodules submodule.submod.url)" && + test "$bogus_url" = "$(git config submodule.submod.url)" && # Restore the url - git submodule add --force "$submodurl" submod + git submodule add --force "$submodurl" submod && test "$submodurl" = "$(git config -f .gitmodules submodule.submod.url)" && test "$submodurl" = "$(git config submodule.submod.url)" ) @@@ -189,7 -187,6 +188,6 @@@ test_expect_success 'submodule add --br refs/heads/initial refs/heads/master EOF - >empty && ( cd addtest && @@@ -202,12 -199,11 +200,11 @@@ inspect addtest/submod-branch ../.. && test_cmp expect-heads heads && test_cmp expect-head head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with ./ in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@@ -219,12 -215,11 +216,11 @@@ inspect addtest/dotsubmod/frotz ../../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with /././ in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@@ -236,12 -231,11 +232,11 @@@ inspect addtest/dotslashdotsubmod/frotz ../../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with // in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@@ -253,12 -247,11 +248,11 @@@ inspect addtest/slashslashsubmod/frotz ../../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with /.. in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@@ -270,12 -263,11 +264,11 @@@ inspect addtest/realsubmod ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add with ./, /.. and // in path' ' echo "refs/heads/master" >expect && - >empty && ( cd addtest && @@@ -287,7 -279,7 +280,7 @@@ inspect addtest/realsubmod2 ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success !CYGWIN 'submodule add with \\ in path' ' @@@ -306,7 -298,6 +299,6 @@@ test_expect_success 'submodule add in subdirectory' ' echo "refs/heads/master" >expect && - >empty && mkdir addtest/sub && ( @@@ -319,7 -310,7 +311,7 @@@ inspect addtest/realsubmod3 ../.. && test_cmp expect heads && test_cmp expect head && - test_cmp empty untracked + test_must_be_empty untracked ' test_expect_success 'submodule add in subdirectory with relative path should fail' ' @@@ -378,7 -369,7 +370,7 @@@ test_expect_success 'init should regist test_failure_with_unknown_submodule () { test_must_fail git submodule $1 no-such-submodule 2>output.err && - grep "^error: .*no-such-submodule" output.err + test_i18ngrep "^error: .*no-such-submodule" output.err } test_expect_success 'init should fail with unknown submodule' ' @@@ -502,8 -493,6 +494,6 @@@ test_expect_success 'checkout superproj ' test_expect_success 'apply submodule diff' ' - >empty && - git branch second && ( cd init && @@@ -518,7 -507,7 +508,7 @@@ git apply --index P.diff && git diff --cached master >staged && - test_cmp empty staged + test_must_be_empty staged ' test_expect_success 'update --init' ' @@@ -819,7 -808,7 +809,7 @@@ test_expect_success '../bar/a/b/c work cp pristine-.git-config .git/config && cp pristine-.gitmodules .gitmodules && mkdir -p a/b/c && - (cd a/b/c; git init) && + (cd a/b/c && git init) && git config remote.origin.url ../foo/bar.git && git submodule add ../bar/a/b/c ./a/b/c && git submodule init && diff --combined t/t7501-commit.sh index 51646d8019,c1d232e92d..fb9337c708 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@@ -47,7 -47,7 +47,7 @@@ test_expect_success 'paths and -a do no test_expect_success PERL 'can use paths with --interactive' ' echo bong-o-bong >file && # 2: update, 1:st path, that is all, 7: quit - ( echo 2; echo 1; echo; echo 7 ) | + test_write_lines 2 1 "" 7 | git commit -m foo --interactive file && git reset --hard HEAD^ ' @@@ -293,7 -293,7 +293,7 @@@ test_expect_success PERL 'interactive a test_expect_success PERL "commit --interactive doesn't change index if editor aborts" ' echo zoo >file && test_must_fail git diff --exit-code >diff1 && - (echo u ; echo "*" ; echo q) | + test_write_lines u "*" q | ( EDITOR=: && export EDITOR && @@@ -411,8 -411,8 +411,8 @@@ test_expect_success 'sign off (1)' git commit -s -m "thank you" && git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && ( - echo thank you - echo + echo thank you && + echo && git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ) >expected && @@@ -430,9 -430,9 +430,9 @@@ test_expect_success 'sign off (2)' $existing" && git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && ( - echo thank you - echo - echo $existing + echo thank you && + echo && + echo $existing && git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ) >expected && @@@ -450,9 -450,9 +450,9 @@@ test_expect_success 'signoff gap' $alt" && git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && ( - echo welcome - echo - echo $alt + echo welcome && + echo && + echo $alt && git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ) >expected && @@@ -470,11 -470,11 +470,11 @@@ We have no $alt" && git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && ( - echo welcome - echo - echo We have now - echo $alt - echo + echo welcome && + echo && + echo We have now && + echo $alt && + echo && git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ) >expected && @@@ -491,11 -491,11 +491,11 @@@ non-trailer lin Myfooter: x" && git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && ( - echo subject - echo - echo non-trailer line - echo Myfooter: x - echo + echo subject && + echo && + echo non-trailer line && + echo Myfooter: x && + echo && echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" ) >expected && test_cmp expected actual && @@@ -508,10 -508,10 +508,10 @@@ non-trailer lin Myfooter: x" && git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && ( - echo subject - echo - echo non-trailer line - echo Myfooter: x + echo subject && + echo && + echo non-trailer line && + echo Myfooter: x && echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" ) >expected && test_cmp expected actual @@@ -524,10 -524,10 +524,10 @@@ test_expect_success 'multiple -m' git commit -m "one" -m "two" -m "three" && git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && ( - echo one - echo - echo two - echo + echo one && + echo && + echo two && + echo && echo three ) >expected && test_cmp expected actual @@@ -582,13 -582,11 +582,11 @@@ test_expect_success 'same tree (merge a git merge -s ours side -m "empty ok" && git diff HEAD^ HEAD >actual && - : >expected && - test_cmp expected actual && + test_must_be_empty actual && git commit --amend -m "empty really ok" && git diff HEAD^ HEAD >actual && - : >expected && - test_cmp expected actual + test_must_be_empty actual ' diff --combined t/t7610-mergetool.sh index b18503de81,78bed2aee1..a9fb971615 --- 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 && @@@ -328,9 -328,8 +328,8 @@@ test_expect_success 'mergetool produce git checkout -b test$test_count move-to-c && test_config mergetool.keepBackup true && test_must_fail git merge move-to-b && - : >expect && echo d | git mergetool a/a/file.txt 2>actual && - test_cmp expect actual && + test_must_be_empty actual && ! test -d a ' @@@ -349,7 -348,7 +348,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 diff --combined t/t7810-grep.sh index d826e24b45,c82c8f5f72..be5c1bd553 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@@ -217,9 -217,8 +217,8 @@@ d ' test_expect_success "grep -w $L (w)" ' - : >expected && test_must_fail git grep -n -w -e "^w" $H >actual && - test_cmp expected actual + test_must_be_empty actual ' test_expect_success "grep -w $L (x)" ' @@@ -239,44 -238,27 +238,42 @@@ ' test_expect_success "grep -w $L (y-2)" ' - : >expected && if git grep -n -w -e "^y y" $H >actual then echo should not have matched cat actual false else - test_cmp expected actual + test_must_be_empty actual fi ' test_expect_success "grep -w $L (z)" ' - : >expected && if git grep -n -w -e "^z" $H >actual then echo should not have matched cat actual false else - test_cmp expected actual + test_must_be_empty actual 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 && @@@ -498,7 -480,7 +495,7 @@@ test_expect_success 'grep -L -C' test_expect_success 'grep --files-without-match --quiet' ' git grep --files-without-match --quiet nonexistent_string >actual && - test_cmp /dev/null actual + test_must_be_empty actual ' cat >expected <empty && git grep -q mmap >actual && - test_cmp empty actual && + test_must_be_empty actual && test_must_fail git grep -q qfwfq >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success 'grep -C1 hunk mark between files' ' @@@ -716,8 -697,7 +712,7 @@@ test_expect_success 'log grep (9)' test_expect_success 'log grep (9)' ' git log -g --grep-reflog="commit: third" --author="non-existent" --pretty=tformat:%s >actual && - : >expect && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'log --grep-reflog can only be used under -g' ' @@@ -807,15 -787,13 +802,13 @@@ test_expect_success 'log --all-match -- ' test_expect_success 'log --author does not search in timestamp' ' - : >expect && git log --author="$GIT_AUTHOR_DATE" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'log --committer does not search in timestamp' ' - : >expect && git log --committer="$GIT_COMMITTER_DATE" >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'grep with CE_VALID file' ' @@@ -954,9 -932,10 +947,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_must_be_empty out && - test 1 = $(cat status) + cd s && + test_expect_code 1 git grep xxyyzz .. >out && - ! test -s out ++ test_must_be_empty out ) ' @@@ -1065,13 -1044,12 +1058,12 @@@ test_expect_success 'inside git reposit echo ".gitignore:.*o*" && cat is/expect.unignored } >is/expect.full && - : >is/expect.empty && echo file2:world >is/expect.sub && ( cd is/git && git init && test_must_fail git grep o >../actual.full && - test_cmp ../expect.empty ../actual.full && + test_must_be_empty ../actual.full && git grep --untracked o >../actual.unignored && test_cmp ../expect.unignored ../actual.unignored && @@@ -1084,7 -1062,7 +1076,7 @@@ cd sub && test_must_fail git grep o >../../actual.sub && - test_cmp ../../expect.empty ../../actual.sub && + test_must_be_empty ../../actual.sub && git grep --no-index o >../../actual.sub && test_cmp ../../expect.sub ../../actual.sub && @@@ -1250,10 -1228,9 +1242,9 @@@ test_expect_success !PCRE 'grep -P patt ' test_expect_success 'grep pattern with grep.extendedRegexp=true' ' - >empty && test_must_fail git -c grep.extendedregexp=true \ grep "\p{Ps}.*?\p{Pe}" hello.c >actual && - test_cmp empty actual + test_must_be_empty actual ' test_expect_success PCRE 'grep -P pattern with grep.extendedRegexp=true' ' diff --combined t/t9200-git-cvsexportcommit.sh index cd61288aa1,99d7aa621d..c5946cb0b8 --- a/t/t9200-git-cvsexportcommit.sh +++ b/t/t9200-git-cvsexportcommit.sh @@@ -43,11 -43,11 +43,11 @@@ check_entries () sed -ne '/^\//p' "$1/CVS/Entries" | sort | cut -d/ -f2,3,5 >actual if test -z "$2" then - >expected + test_must_be_empty actual else printf '%s\n' "$2" | tr '|' '\012' >expected + test_cmp expected actual fi - test_cmp expected actual } test_expect_success \ @@@ -187,7 -187,7 +187,7 @@@ test_expect_success git commit -a -m "Update with spaces" && id=$(git rev-list --max-count=1 HEAD) && (cd "$CVSWORK" && - git cvsexportcommit -c $id + git cvsexportcommit -c $id && check_entries "G g" "with spaces.png/1.2/-kb|with spaces.txt/1.2/" )' @@@ -245,7 -245,7 +245,7 @@@ test_expect_success FILEMODE git add G/off && git commit -a -m "Execute test" && (cd "$CVSWORK" && - git cvsexportcommit -c HEAD + git cvsexportcommit -c HEAD && test -x G/on && ! test -x G/off )' @@@ -303,7 -303,7 +303,7 @@@ test_expect_success 're-commit a remove git add attic_gremlin && git commit -m "Added attic_gremlin" && git cvsexportcommit -w "$CVSWORK" -c HEAD && - (cd "$CVSWORK"; cvs -Q update -d) && + (cd "$CVSWORK" && cvs -Q update -d) && test -f "$CVSWORK/attic_gremlin" ' diff --combined t/t9903-bash-prompt.sh index ab890d3d4b,056bf1dcda..81a5179e28 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@@ -63,15 -63,18 +63,15 @@@ test_expect_success 'prompt - unborn br test_cmp expected "$actual" ' -repo_with_newline='repo -with -newline' - -if test_have_prereq !MINGW && mkdir "$repo_with_newline" 2>/dev/null -then - test_set_prereq FUNNYNAMES -else +if test_have_prereq !FUNNYNAMES; then say 'Your filesystem does not allow newlines in filenames.' fi test_expect_success FUNNYNAMES 'prompt - with newline in path' ' + repo_with_newline="repo +with +newline" && + mkdir "$repo_with_newline" && printf " (master)" >expected && git init "$repo_with_newline" && test_when_finished "rm -rf \"$repo_with_newline\"" && @@@ -513,10 -516,9 +513,9 @@@ test_expect_success 'prompt - format st test_expect_success 'prompt - pc mode' ' printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmaster" >expected && - printf "" >expected_output && ( __git_ps1 "BEFORE:" ":AFTER" >"$actual" && - test_cmp expected_output "$actual" && + test_must_be_empty "$actual" && printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" ) && test_cmp expected "$actual" @@@ -526,7 -528,7 +525,7 @@@ test_expect_success 'prompt - bash colo printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmaster" >expected && ( GIT_PS1_SHOWCOLORHINTS=y && - __git_ps1 "BEFORE:" ":AFTER" >"$actual" + __git_ps1 "BEFORE:" ":AFTER" >"$actual" && printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual" ) && test_cmp expected "$actual" @@@ -712,13 -714,12 +711,12 @@@ test_expect_success 'prompt - hide if p ' test_expect_success 'prompt - hide if pwd ignored - env var set, config unset' ' - printf "" >expected && ( cd ignored_dir && GIT_PS1_HIDE_IF_PWD_IGNORED=y && __git_ps1 >"$actual" ) && - test_cmp expected "$actual" + test_must_be_empty "$actual" ' test_expect_success 'prompt - hide if pwd ignored - env var set, config unset, pc mode' '