diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh index 6d52b824b1..f83df8eb8b 100755 --- a/t/t1007-hash-object.sh +++ b/t/t1007-hash-object.sh @@ -189,7 +189,7 @@ for args in "-w --stdin-paths" "--stdin-paths -w"; do done test_expect_success 'corrupt tree' ' - echo abc >malformed-tree + echo abc >malformed-tree && test_must_fail git hash-object -t tree malformed-tree ' diff --git a/t/t1013-loose-object-format.sh b/t/t1013-loose-object-format.sh index 0a9cedd374..fbf5f2fc00 100755 --- a/t/t1013-loose-object-format.sh +++ b/t/t1013-loose-object-format.sh @@ -34,7 +34,7 @@ assert_blob_equals() { } test_expect_success setup ' - cp -R "$TEST_DIRECTORY/t1013/objects" .git/ + cp -R "$TEST_DIRECTORY/t1013/objects" .git/ && git --version ' diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 51caff047b..0690e0edf4 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -38,7 +38,7 @@ cat > expect << EOF WhatEver = Second EOF test_expect_success 'similar section' ' - git config Cores.WhatEver Second + git config Cores.WhatEver Second && test_cmp expect .git/config ' diff --git a/t/t1412-reflog-loop.sh b/t/t1412-reflog-loop.sh index 647d888507..3acd895afb 100755 --- a/t/t1412-reflog-loop.sh +++ b/t/t1412-reflog-loop.sh @@ -20,7 +20,7 @@ test_expect_success 'setup reflog with alternating commits' ' ' test_expect_success 'reflog shows all entries' ' - cat >expect <<-\EOF + cat >expect <<-\EOF && topic@{0} reset: moving to two topic@{1} reset: moving to one topic@{2} reset: moving to two diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index 63849836c8..e661147c57 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -48,7 +48,7 @@ test_expect_success 'setup: helper for testing rev-parse' ' ' test_expect_success 'setup: core.worktree = relative path' ' - unset GIT_WORK_TREE; + sane_unset GIT_WORK_TREE && GIT_DIR=repo.git && GIT_CONFIG="$(pwd)"/$GIT_DIR/config && export GIT_DIR GIT_CONFIG && @@ -89,7 +89,7 @@ test_expect_success 'subdir of work tree' ' ' test_expect_success 'setup: core.worktree = absolute path' ' - unset GIT_WORK_TREE; + sane_unset GIT_WORK_TREE && GIT_DIR=$(pwd)/repo.git && GIT_CONFIG=$GIT_DIR/config && export GIT_DIR GIT_CONFIG && @@ -334,7 +334,7 @@ test_expect_success 'absolute pathspec should fail gracefully' ' ' test_expect_success 'make_relative_path handles double slashes in GIT_DIR' ' - >dummy_file + >dummy_file && echo git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file && git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file ' diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index ec50a9ad70..80aedfca8c 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -603,7 +603,7 @@ test_expect_success '#22a: core.worktree = GIT_DIR = .git dir' ' # like case #6. setup_repo 22a "$here/22a/.git" "" unset && - setup_repo 22ab . "" unset + setup_repo 22ab . "" unset && mkdir -p 22a/.git/sub 22a/sub && mkdir -p 22ab/.git/sub 22ab/sub && try_case 22a/.git unset . \ @@ -742,7 +742,7 @@ test_expect_success '#28: core.worktree and core.bare conflict (gitfile case)' ' # Case #29: GIT_WORK_TREE(+core.worktree) overrides core.bare (gitfile case). test_expect_success '#29: setup' ' setup_repo 29 non-existent gitfile true && - mkdir -p 29/sub/sub 29/wt/sub + mkdir -p 29/sub/sub 29/wt/sub && ( cd 29 && GIT_WORK_TREE="$here/29" && diff --git a/t/t1511-rev-parse-caret.sh b/t/t1511-rev-parse-caret.sh index e043cb7c64..eaefc777bd 100755 --- a/t/t1511-rev-parse-caret.sh +++ b/t/t1511-rev-parse-caret.sh @@ -6,7 +6,7 @@ test_description='tests for ref^{stuff}' test_expect_success 'setup' ' echo blob >a-blob && - git tag -a -m blob blob-tag `git hash-object -w a-blob` + git tag -a -m blob blob-tag `git hash-object -w a-blob` && mkdir a-tree && echo moreblobs >a-tree/another-blob && git add . && diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh index 55ef1895d7..a5e3da7e41 100755 --- a/t/t3030-merge-recursive.sh +++ b/t/t3030-merge-recursive.sh @@ -285,17 +285,7 @@ test_expect_success 'merge-recursive simple' ' rm -fr [abcd] && git checkout -f "$c2" && - git merge-recursive "$c0" -- "$c2" "$c1" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c2" "$c1" ' test_expect_success 'merge-recursive result' ' @@ -334,17 +324,7 @@ test_expect_success 'merge-recursive remove conflict' ' rm -fr [abcd] && git checkout -f "$c1" && - git merge-recursive "$c0" -- "$c1" "$c5" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c5" ' test_expect_success 'merge-recursive remove conflict' ' @@ -388,17 +368,7 @@ test_expect_success 'merge-recursive d/f conflict' ' git reset --hard && git checkout -f "$c1" && - git merge-recursive "$c0" -- "$c1" "$c4" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c4" ' test_expect_success 'merge-recursive d/f conflict result' ' @@ -422,17 +392,7 @@ test_expect_success 'merge-recursive d/f conflict the other way' ' git reset --hard && git checkout -f "$c4" && - git merge-recursive "$c0" -- "$c4" "$c1" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c4" "$c1" ' test_expect_success 'merge-recursive d/f conflict result the other way' ' @@ -456,17 +416,7 @@ test_expect_success 'merge-recursive d/f conflict' ' git reset --hard && git checkout -f "$c1" && - git merge-recursive "$c0" -- "$c1" "$c6" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c6" ' test_expect_success 'merge-recursive d/f conflict result' ' @@ -490,17 +440,7 @@ test_expect_success 'merge-recursive d/f conflict' ' git reset --hard && git checkout -f "$c6" && - git merge-recursive "$c0" -- "$c6" "$c1" - status=$? - case "$status" in - 1) - : happy - ;; - *) - echo >&2 "why status $status!!!" - false - ;; - esac + test_expect_code 1 git merge-recursive "$c0" -- "$c6" "$c1" ' test_expect_success 'merge-recursive d/f conflict result' ' diff --git a/t/t3040-subprojects-basic.sh b/t/t3040-subprojects-basic.sh index f6973e96a5..0a4ff6d824 100755 --- a/t/t3040-subprojects-basic.sh +++ b/t/t3040-subprojects-basic.sh @@ -3,81 +3,81 @@ test_description='Basic subproject functionality' . ./test-lib.sh -test_expect_success 'Super project creation' \ - ': >Makefile && - git add Makefile && - git commit -m "Superproject created"' +test_expect_success 'setup: create superproject' ' + : >Makefile && + git add Makefile && + git commit -m "Superproject created" +' +test_expect_success 'setup: create subprojects' ' + mkdir sub1 && + ( cd sub1 && git init && : >Makefile && git add * && + git commit -q -m "subproject 1" ) && + mkdir sub2 && + ( cd sub2 && git init && : >Makefile && git add * && + git commit -q -m "subproject 2" ) && + git update-index --add sub1 && + git add sub2 && + git commit -q -m "subprojects added" && + git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current && + git branch save HEAD && + cat >expected <<-\EOF && + :000000 160000 00000... A sub1 + :000000 160000 00000... A sub2 + EOF + test_cmp expected current +' -cat >expected <Makefile && git add * && - git commit -q -m "subproject 1" ) && - mkdir sub2 && - ( cd sub2 && git init && : >Makefile && git add * && - git commit -q -m "subproject 2" ) && - git update-index --add sub1 && - git add sub2 && - git commit -q -m "subprojects added" && - git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current && - test_cmp expected current' +test_expect_success 'check if fsck ignores the subprojects' ' + git fsck --full +' -git branch save HEAD +test_expect_success 'check if commit in a subproject detected' ' + ( cd sub1 && + echo "all:" >>Makefile && + echo " true" >>Makefile && + git commit -q -a -m "make all" ) && + test_expect_code 1 git diff-files --exit-code +' -test_expect_success 'check if fsck ignores the subprojects' \ - 'git fsck --full' +test_expect_success 'check if a changed subproject HEAD can be committed' ' + git commit -q -a -m "sub1 changed" && + test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD +' -test_expect_success 'check if commit in a subproject detected' \ - '( cd sub1 && - echo "all:" >>Makefile && - echo " true" >>Makefile && - git commit -q -a -m "make all" ) && { - git diff-files --exit-code - test $? = 1 - }' +test_expect_success 'check if diff-index works for subproject elements' ' + test_expect_code 1 git diff-index --exit-code --cached save -- sub1 +' -test_expect_success 'check if a changed subproject HEAD can be committed' \ - 'git commit -q -a -m "sub1 changed" && { - git diff-tree --exit-code HEAD^ HEAD - test $? = 1 - }' +test_expect_success 'check if diff-tree works for subproject elements' ' + test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD -- sub1 +' -test_expect_success 'check if diff-index works for subproject elements' \ - 'git diff-index --exit-code --cached save -- sub1 - test $? = 1' +test_expect_success 'check if git diff works for subproject elements' ' + test_expect_code 1 git diff --exit-code HEAD^ HEAD +' -test_expect_success 'check if diff-tree works for subproject elements' \ - 'git diff-tree --exit-code HEAD^ HEAD -- sub1 - test $? = 1' +test_expect_success 'check if clone works' ' + git ls-files -s >expected && + git clone -l -s . cloned && + ( cd cloned && git ls-files -s ) >current && + test_cmp expected current +' -test_expect_success 'check if git diff works for subproject elements' \ - 'git diff --exit-code HEAD^ HEAD - test $? = 1' - -test_expect_success 'check if clone works' \ - 'git ls-files -s >expected && - git clone -l -s . cloned && - ( cd cloned && git ls-files -s ) >current && - test_cmp expected current' - -test_expect_success 'removing and adding subproject' \ - 'git update-index --force-remove -- sub2 && - mv sub2 sub3 && - git add sub3 && - git commit -q -m "renaming a subproject" && { - git diff -M --name-status --exit-code HEAD^ HEAD - test $? = 1 - }' +test_expect_success 'removing and adding subproject' ' + git update-index --force-remove -- sub2 && + mv sub2 sub3 && + git add sub3 && + git commit -q -m "renaming a subproject" && + test_expect_code 1 git diff -M --name-status --exit-code HEAD^ HEAD +' # the index must contain the object name the HEAD of the # subproject sub1 was at the point "save" -test_expect_success 'checkout in superproject' \ - 'git checkout save && - git diff-index --exit-code --raw --cached save -- sub1' +test_expect_success 'checkout in superproject' ' + git checkout save && + git diff-index --exit-code --raw --cached save -- sub1 +' # just interesting what happened... # git diff --name-status -M save master diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 76903323af..ea82424e47 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -22,7 +22,7 @@ test_expect_success \ test_expect_success \ 'git branch --help should not have created a bogus branch' ' - git branch --help /dev/null 2>/dev/null; + test_might_fail git branch --help /dev/null 2>/dev/null && test_path_is_missing .git/refs/heads/--help ' @@ -88,7 +88,7 @@ test_expect_success \ test_expect_success \ 'git branch -m n/n n should work' \ 'git branch -l n/n && - git branch -m n/n n + git branch -m n/n n && test_path_is_file .git/logs/refs/heads/n' test_expect_success 'git branch -m o/o o should fail when o/p exists' ' diff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh index 4ec4d11450..4367197953 100755 --- a/t/t3310-notes-merge-manual-resolve.sh +++ b/t/t3310-notes-merge-manual-resolve.sh @@ -389,7 +389,7 @@ test_expect_success 'abort notes merge' ' test_must_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && test_cmp /dev/null output && # m has not moved (still == y) - test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_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) verify_notes w && verify_notes x && @@ -525,9 +525,9 @@ EOF test -f .git/NOTES_MERGE_WORKTREE/$commit_sha3 && test -f .git/NOTES_MERGE_WORKTREE/$commit_sha4 && # Refs are unchanged - test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" - 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)" + test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" && + 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 && @@ -545,7 +545,7 @@ test_expect_success 'resolve situation by aborting the notes merge' ' test_must_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && test_cmp /dev/null output && # m has not moved (still == w) - test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/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) verify_notes w && verify_notes x && diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 6eaecec906..c355533236 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -172,8 +172,8 @@ test_expect_success 'fail when upstream arg is missing and not configured' ' test_expect_success 'default to @{upstream} when upstream arg is missing' ' git checkout -b default topic && - git config branch.default.remote . - git config branch.default.merge refs/heads/master + git config branch.default.remote . && + git config branch.default.merge refs/heads/master && git rebase && test "$(git rev-parse default~1)" = "$(git rev-parse master)" ' diff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh index aea6685984..7ba17974c5 100755 --- a/t/t3401-rebase-partial.sh +++ b/t/t3401-rebase-partial.sh @@ -11,51 +11,35 @@ local branch. ' . ./test-lib.sh -test_expect_success \ - 'prepare repository with topic branch' \ - 'echo First > A && - git update-index --add A && - git commit -m "Add A." && - - git checkout -b my-topic-branch && - - echo Second > B && - git update-index --add B && - git commit -m "Add B." && - - echo AnotherSecond > C && - git update-index --add C && - git commit -m "Add C." && - - git checkout -f master && - - echo Third >> A && - git update-index A && - git commit -m "Modify A." +test_expect_success 'prepare repository with topic branch' ' + test_commit A && + git checkout -b my-topic-branch && + test_commit B && + test_commit C && + git checkout -f master && + test_commit A2 A.t ' -test_expect_success \ - 'pick top patch from topic branch into master' \ - 'git cherry-pick my-topic-branch^0 && - git checkout -f my-topic-branch && - git branch master-merge master && - git branch my-topic-branch-merge my-topic-branch +test_expect_success 'pick top patch from topic branch into master' ' + git cherry-pick C && + git checkout -f my-topic-branch ' -test_debug \ - 'git cherry master && - git format-patch -k --stdout --full-index master >/dev/null && - gitk --all & sleep 1 +test_debug ' + git cherry master && + git format-patch -k --stdout --full-index master >/dev/null && + gitk --all & sleep 1 ' -test_expect_success \ - 'rebase topic branch against new master and check git am did not get halted' \ - 'git rebase master && test ! -d .git/rebase-apply' +test_expect_success 'rebase topic branch against new master and check git am did not get halted' ' + git rebase master && + test_path_is_missing .git/rebase-apply +' -test_expect_success \ - 'rebase --merge topic branch that was partially merged upstream' \ - 'git checkout -f my-topic-branch-merge && - git rebase --merge master-merge && - test ! -d .git/rebase-merge' +test_expect_success 'rebase --merge topic branch that was partially merged upstream' ' + git reset --hard C && + git rebase --merge master && + test_path_is_missing .git/rebase-merge +' test_done diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 1e855cdae5..2680375628 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -51,7 +51,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' ' test_commit "commit-new-file-F3-on-topic-branch" F3 32 && test_when_finished "rm -fr test-bin funny.was.run" && mkdir test-bin && - cat >test-bin/git-merge-funny <<-EOF + cat >test-bin/git-merge-funny <<-EOF && #!$SHELL_PATH case "\$1" in --opt) ;; *) exit 2 ;; esac shift && @@ -77,7 +77,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' ' test_expect_success 'rebase --continue remembers --rerere-autoupdate' ' rm -fr .git/rebase-* && git reset --hard commit-new-file-F3-on-topic-branch && - git checkout master + git checkout master && test_commit "commit-new-file-F3" F3 3 && git config rerere.enabled true && test_must_fail git rebase -m master topic && diff --git a/t/t3419-rebase-patch-id.sh b/t/t3419-rebase-patch-id.sh index bd8efaf005..e70ac10a0c 100755 --- a/t/t3419-rebase-patch-id.sh +++ b/t/t3419-rebase-patch-id.sh @@ -39,7 +39,7 @@ run() } test_expect_success 'setup' ' - git commit --allow-empty -m initial + git commit --allow-empty -m initial && git tag root '