Merge branch 'rj/svn-test'
[gitweb.git] / t / t1510-repo-setup.sh
index f1b5ea530e7f7a3fa0257d20728a9af91e5bfa60..c3798ce17917827c5a00bed09b2475d761fde32d 100755 (executable)
@@ -80,7 +80,7 @@ test_repo() {
 #  - cwd can't be outside worktree
 
 test_expect_success '#0: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 0 0/sub &&
        cd 0 && git init && cd ..
 '
@@ -123,7 +123,7 @@ EOF
 # GIT_WORK_TREE is ignored -> #0
 
 test_expect_success '#1: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 1 1/sub 1.wt 1.wt/sub 1/wt 1/wt/sub &&
        cd 1 &&
        git init &&
@@ -132,7 +132,7 @@ test_expect_success '#1: setup' '
        cd ..
 '
 
-test_expect_failure '#1: at root' '
+test_expect_success '#1: at root' '
        cat >1/expected <<EOF &&
 setup: git_dir: .git
 setup: worktree: $TRASH_DIRECTORY/1
@@ -142,7 +142,7 @@ EOF
        test_repo 1
 '
 
-test_expect_failure '#1: in subdir' '
+test_expect_success '#1: in subdir' '
        cat >1/sub/expected <<EOF &&
 setup: git_dir: .git
 setup: worktree: $TRASH_DIRECTORY/1
@@ -174,7 +174,7 @@ EOF
 #  - cwd can't be outside worktree
 
 test_expect_success '#2: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 2 2/sub &&
        cd 2 && git init && cd ..
 '
@@ -241,7 +241,7 @@ EOF
 #  - cwd can be outside worktree
 
 test_expect_success '#3: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 3 3/sub 3/sub/sub 3.wt 3.wt/sub 3/wt 3/wt/sub &&
        cd 3 && git init && cd ..
 '
@@ -504,7 +504,7 @@ EOF
 # core.worktree is ignored -> #0
 
 test_expect_success '#4: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 4 4/sub &&
        cd 4 &&
        git init &&
@@ -512,7 +512,7 @@ test_expect_success '#4: setup' '
        cd ..
 '
 
-test_expect_failure '#4: at root' '
+test_expect_success '#4: at root' '
        cat >4/expected <<EOF &&
 setup: git_dir: .git
 setup: worktree: $TRASH_DIRECTORY/4
@@ -522,7 +522,7 @@ EOF
        test_repo 4
 '
 
-test_expect_failure '#4: in subdir' '
+test_expect_success '#4: in subdir' '
        cat >4/sub/expected <<EOF &&
 setup: git_dir: .git
 setup: worktree: $TRASH_DIRECTORY/4
@@ -550,7 +550,7 @@ EOF
 # GIT_WORK_TREE/core.worktree are ignored -> #0
 
 test_expect_success '#5: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 5 5/sub &&
        cd 5 &&
        git init &&
@@ -560,7 +560,7 @@ test_expect_success '#5: setup' '
        cd ..
 '
 
-test_expect_failure '#5: at root' '
+test_expect_success '#5: at root' '
        cat >5/expected <<EOF &&
 setup: git_dir: .git
 setup: worktree: $TRASH_DIRECTORY/5
@@ -570,7 +570,7 @@ EOF
        test_repo 5
 '
 
-test_expect_failure '#5: in subdir' '
+test_expect_success '#5: in subdir' '
        cat >5/sub/expected <<EOF &&
 setup: git_dir: .git
 setup: worktree: $TRASH_DIRECTORY/5
@@ -602,7 +602,7 @@ EOF
 #  - cwd can be outside worktree
 
 test_expect_success '#6: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 6 6/sub 6/sub/sub 6.wt 6.wt/sub 6/wt 6/wt/sub &&
        cd 6 && git init && cd ..
 '
@@ -651,7 +651,7 @@ EOF
        test_repo 6 "$TRASH_DIRECTORY/6/.git"
 '
 
-test_expect_failure '#6: GIT_DIR(rel), core.worktree=.. in subdir' '
+test_expect_success '#6: GIT_DIR(rel), core.worktree=.. in subdir' '
        cat >6/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/6/.git
 setup: worktree: $TRASH_DIRECTORY/6
@@ -662,7 +662,7 @@ EOF
        test_repo 6/sub/sub ../../.git
 '
 
-test_expect_failure '#6: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
+test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
        cat >6/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/6/.git
 setup: worktree: $TRASH_DIRECTORY/6
@@ -783,7 +783,7 @@ EOF
        test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
 '
 
-test_expect_failure '#6: GIT_DIR(rel), core.worktree=../.. at root' '
+test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. at root' '
        cat >6/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/6/.git
 setup: worktree: $TRASH_DIRECTORY
@@ -794,7 +794,7 @@ EOF
        test_repo 6 .git
 '
 
-test_expect_failure '#6: GIT_DIR(rel), core.worktree=../..(rel) at root' '
+test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) at root' '
        cat >6/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/6/.git
 setup: worktree: $TRASH_DIRECTORY
@@ -827,7 +827,7 @@ EOF
        test_repo 6 "$TRASH_DIRECTORY/6/.git"
 '
 
-test_expect_failure '#6: GIT_DIR(rel), core.worktree=../.. in subdir' '
+test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. in subdir' '
        cat >6/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/6/.git
 setup: worktree: $TRASH_DIRECTORY
@@ -838,7 +838,7 @@ EOF
        test_repo 6/sub/sub ../../.git
 '
 
-test_expect_failure '#6: GIT_DIR(rel), core.worktree=../..(rel) in subdir' '
+test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) in subdir' '
        cat >6/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/6/.git
 setup: worktree: $TRASH_DIRECTORY
@@ -889,7 +889,7 @@ EOF
 # core.worktree is overridden by GIT_WORK_TREE -> #3
 
 test_expect_success '#7: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 7 7/sub 7/sub/sub 7.wt 7.wt/sub 7/wt 7/wt/sub &&
        cd 7 &&
        git init &&
@@ -1155,7 +1155,7 @@ EOF
 # #0 except that git_dir is set by .git file
 
 test_expect_success '#8: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 8 8/sub &&
        cd 8 &&
        git init &&
@@ -1202,7 +1202,7 @@ EOF
 # #1 except that git_dir is set by .git file
 
 test_expect_success '#9: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 9 9/sub 9.wt 9.wt/sub 9/wt 9/wt/sub &&
        cd 9 &&
        git init &&
@@ -1213,7 +1213,7 @@ test_expect_success '#9: setup' '
        cd ..
 '
 
-test_expect_failure '#9: at root' '
+test_expect_success '#9: at root' '
        cat >9/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/9.git
 setup: worktree: $TRASH_DIRECTORY/9
@@ -1223,7 +1223,7 @@ EOF
        test_repo 9
 '
 
-test_expect_failure '#9: in subdir' '
+test_expect_success '#9: in subdir' '
        cat >9/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/9.git
 setup: worktree: $TRASH_DIRECTORY/9
@@ -1251,7 +1251,7 @@ EOF
 # #2 except that git_dir is set by .git file
 
 test_expect_success '#10: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 10 10/sub &&
        cd 10 &&
        git init &&
@@ -1260,7 +1260,7 @@ test_expect_success '#10: setup' '
        cd ..
 '
 
-test_expect_failure '#10: at root' '
+test_expect_success '#10: at root' '
        cat >10/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/10.git
 setup: worktree: $TRASH_DIRECTORY/10
@@ -1270,7 +1270,7 @@ EOF
        test_repo 10 "$TRASH_DIRECTORY/10/.git"
 '
 
-test_expect_failure '#10: in subdir' '
+test_expect_success '#10: in subdir' '
        cat >10/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/10.git
 setup: worktree: $TRASH_DIRECTORY/10/sub
@@ -1280,7 +1280,7 @@ EOF
        test_repo 10/sub "$TRASH_DIRECTORY/10/.git"
 '
 
-test_expect_failure '#10: relative GIT_DIR at root' '
+test_expect_success '#10: relative GIT_DIR at root' '
        cat >10/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/10.git
 setup: worktree: $TRASH_DIRECTORY/10
@@ -1290,7 +1290,7 @@ EOF
        test_repo 10 .git
 '
 
-test_expect_failure '#10: relative GIT_DIR in subdir' '
+test_expect_success '#10: relative GIT_DIR in subdir' '
        cat >10/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/10.git
 setup: worktree: $TRASH_DIRECTORY/10/sub
@@ -1318,7 +1318,7 @@ EOF
 # #3 except that git_dir is set by .git file
 
 test_expect_success '#11: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 11 11/sub 11/sub/sub 11.wt 11.wt/sub 11/wt 11/wt/sub &&
        cd 11 &&
        git init &&
@@ -1327,7 +1327,7 @@ test_expect_success '#11: setup' '
        cd ..
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11
@@ -1337,7 +1337,7 @@ EOF
        test_repo 11 .git "$TRASH_DIRECTORY/11"
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11
@@ -1347,7 +1347,7 @@ EOF
        test_repo 11 .git .
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=root at root' '
+test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11
@@ -1357,7 +1357,7 @@ EOF
        test_repo 11 "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11"
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11
@@ -1367,7 +1367,7 @@ EOF
        test_repo 11 "$TRASH_DIRECTORY/11/.git" .
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
        cat >11/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11
@@ -1377,7 +1377,7 @@ EOF
        test_repo 11/sub/sub ../../.git "$TRASH_DIRECTORY/11"
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
        cat >11/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11
@@ -1387,7 +1387,7 @@ EOF
        test_repo 11/sub/sub ../../.git ../..
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORKTREE=root in subdir' '
+test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root in subdir' '
        cat >11/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11
@@ -1397,7 +1397,7 @@ EOF
        test_repo 11/sub "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11"
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
        cat >11/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11
@@ -1407,7 +1407,7 @@ EOF
        test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" ../..
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11/wt
@@ -1417,7 +1417,7 @@ EOF
        test_repo 11 .git "$TRASH_DIRECTORY/11/wt"
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11/wt
@@ -1427,7 +1427,7 @@ EOF
        test_repo 11 .git wt
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11/wt
@@ -1437,7 +1437,7 @@ EOF
        test_repo 11 "$TRASH_DIRECTORY/11/.git" wt
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt at root' '
+test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11/wt
@@ -1447,7 +1447,7 @@ EOF
        test_repo 11 "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11/wt"
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
        cat >11/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11/wt
@@ -1457,7 +1457,7 @@ EOF
        test_repo 11/sub/sub ../../.git "$TRASH_DIRECTORY/11/wt"
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
        cat >11/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11/wt
@@ -1467,7 +1467,7 @@ EOF
        test_repo 11/sub/sub ../../.git ../../wt
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
        cat >11/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11/wt
@@ -1477,7 +1477,7 @@ EOF
        test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" ../../wt
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
        cat >11/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY/11/wt
@@ -1487,7 +1487,7 @@ EOF
        test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11/wt"
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1497,7 +1497,7 @@ EOF
        test_repo 11 .git "$TRASH_DIRECTORY"
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1507,7 +1507,7 @@ EOF
        test_repo 11 .git ..
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1517,7 +1517,7 @@ EOF
        test_repo 11 "$TRASH_DIRECTORY/11/.git" ..
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=.. at root' '
+test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. at root' '
        cat >11/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1527,7 +1527,7 @@ EOF
        test_repo 11 "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY"
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
        cat >11/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1537,7 +1537,7 @@ EOF
        test_repo 11/sub/sub ../../.git "$TRASH_DIRECTORY"
 '
 
-test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
        cat >11/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1547,7 +1547,7 @@ EOF
        test_repo 11/sub/sub ../../.git ../../..
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
        cat >11/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1557,7 +1557,7 @@ EOF
        test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" ../../../
 '
 
-test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
        cat >11/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/11.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1586,7 +1586,7 @@ EOF
 
 
 test_expect_success '#12: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 12 12/sub 12/sub/sub 12.wt 12.wt/sub 12/wt 12/wt/sub &&
        cd 12 &&
        git init &&
@@ -1596,7 +1596,7 @@ test_expect_success '#12: setup' '
        cd ..
 '
 
-test_expect_failure '#12: at root' '
+test_expect_success '#12: at root' '
        cat >12/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/12.git
 setup: worktree: $TRASH_DIRECTORY/12
@@ -1606,7 +1606,7 @@ EOF
        test_repo 12
 '
 
-test_expect_failure '#12: in subdir' '
+test_expect_success '#12: in subdir' '
        cat >12/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/12.git
 setup: worktree: $TRASH_DIRECTORY/12
@@ -1634,7 +1634,7 @@ EOF
 # #5 except that git_dir is set by .git file
 
 test_expect_success '#13: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 13 13/sub 13/sub/sub 13.wt 13.wt/sub 13/wt 13/wt/sub &&
        cd 13 &&
        git init &&
@@ -1646,7 +1646,7 @@ test_expect_success '#13: setup' '
        cd ..
 '
 
-test_expect_failure '#13: at root' '
+test_expect_success '#13: at root' '
        cat >13/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/13.git
 setup: worktree: $TRASH_DIRECTORY/13
@@ -1656,7 +1656,7 @@ EOF
        test_repo 13
 '
 
-test_expect_failure '#13: in subdir' '
+test_expect_success '#13: in subdir' '
        cat >13/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/13.git
 setup: worktree: $TRASH_DIRECTORY/13
@@ -1684,7 +1684,7 @@ EOF
 # #6 except that git_dir is set by .git file
 
 test_expect_success '#14: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 14 14/sub 14/sub/sub 14.wt 14.wt/sub 14/wt 14/wt/sub &&
        cd 14 &&
        git init &&
@@ -1693,7 +1693,7 @@ test_expect_success '#14: setup' '
        cd ..
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14 at root' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14
@@ -1704,7 +1704,7 @@ EOF
        test_repo 14 .git
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14(rel) at root' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14
@@ -1715,7 +1715,7 @@ EOF
        test_repo 14 .git
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=../14 at root' '
+test_expect_success '#14: GIT_DIR, core.worktree=../14 at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14
@@ -1726,7 +1726,7 @@ EOF
        test_repo 14 "$TRASH_DIRECTORY/14/.git"
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=../14(rel) at root' '
+test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14
@@ -1737,7 +1737,7 @@ EOF
        test_repo 14 "$TRASH_DIRECTORY/14/.git"
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14 in subdir' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 in subdir' '
        cat >14/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14
@@ -1748,7 +1748,7 @@ EOF
        test_repo 14/sub/sub ../../.git
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14(rel) in subdir' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) in subdir' '
        cat >14/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14
@@ -1759,7 +1759,7 @@ EOF
        test_repo 14/sub/sub ../../.git
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=../14 in subdir' '
+test_expect_success '#14: GIT_DIR, core.worktree=../14 in subdir' '
        cat >14/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14
@@ -1770,7 +1770,7 @@ EOF
        test_repo 14/sub "$TRASH_DIRECTORY/14/.git"
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=../14(rel) in subdir' '
+test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) in subdir' '
        cat >14/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14
@@ -1781,7 +1781,7 @@ EOF
        test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt at root' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14/wt
@@ -1792,7 +1792,7 @@ EOF
        test_repo 14 .git
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) at root' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14/wt
@@ -1803,7 +1803,7 @@ EOF
        test_repo 14 .git
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt(rel) at root' '
+test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14/wt
@@ -1814,7 +1814,7 @@ EOF
        test_repo 14 "$TRASH_DIRECTORY/14/.git"
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt at root' '
+test_expect_success '#14: GIT_DIR, core.worktree=../14/wt at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14/wt
@@ -1825,7 +1825,7 @@ EOF
        test_repo 14 "$TRASH_DIRECTORY/14/.git"
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt in subdir' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt in subdir' '
        cat >14/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14/wt
@@ -1836,7 +1836,7 @@ EOF
        test_repo 14/sub/sub ../../.git
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) in subdir' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) in subdir' '
        cat >14/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14/wt
@@ -1847,7 +1847,7 @@ EOF
        test_repo 14/sub/sub ../../.git
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt(rel) in subdir' '
+test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) in subdir' '
        cat >14/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14/wt
@@ -1858,7 +1858,7 @@ EOF
        test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt in subdir' '
+test_expect_success '#14: GIT_DIR, core.worktree=../14/wt in subdir' '
        cat >14/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY/14/wt
@@ -1869,7 +1869,7 @@ EOF
        test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=.. at root' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=.. at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1880,7 +1880,7 @@ EOF
        test_repo 14 .git
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1891,7 +1891,7 @@ EOF
        test_repo 14 .git
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=..(rel) at root' '
+test_expect_success '#14: GIT_DIR, core.worktree=..(rel) at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1902,7 +1902,7 @@ EOF
        test_repo 14 "$TRASH_DIRECTORY/14/.git"
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=.. at root' '
+test_expect_success '#14: GIT_DIR, core.worktree=.. at root' '
        cat >14/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1913,7 +1913,7 @@ EOF
        test_repo 14 "$TRASH_DIRECTORY/14/.git"
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
        cat >14/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1924,7 +1924,7 @@ EOF
        test_repo 14/sub/sub ../../.git
 '
 
-test_expect_failure '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
+test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
        cat >14/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1935,7 +1935,7 @@ EOF
        test_repo 14/sub/sub ../../.git
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
+test_expect_success '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
        cat >14/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1946,7 +1946,7 @@ EOF
        test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
 '
 
-test_expect_failure '#14: GIT_DIR, core.worktree=.. in subdir' '
+test_expect_success '#14: GIT_DIR, core.worktree=.. in subdir' '
        cat >14/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/14.git
 setup: worktree: $TRASH_DIRECTORY
@@ -1975,7 +1975,7 @@ EOF
 # #7 except that git_dir is set by .git file
 
 test_expect_success '#15: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 15 15/sub 15/sub/sub 15.wt 15.wt/sub 15/wt 15/wt/sub &&
        cd 15 &&
        git init &&
@@ -1985,7 +1985,7 @@ test_expect_success '#15: setup' '
        cd ..
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15
@@ -1995,7 +1995,7 @@ EOF
        test_repo 15 .git "$TRASH_DIRECTORY/15"
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15
@@ -2005,7 +2005,7 @@ EOF
        test_repo 15 .git .
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=root at root' '
+test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15
@@ -2015,7 +2015,7 @@ EOF
        test_repo 15 "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15"
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15
@@ -2025,7 +2025,7 @@ EOF
        test_repo 15 "$TRASH_DIRECTORY/15/.git" .
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
        cat >15/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15
@@ -2035,7 +2035,7 @@ EOF
        test_repo 15/sub/sub ../../.git "$TRASH_DIRECTORY/15"
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
        cat >15/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15
@@ -2045,7 +2045,7 @@ EOF
        test_repo 15/sub/sub ../../.git ../..
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORKTREE=root in subdir' '
+test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root in subdir' '
        cat >15/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15
@@ -2055,7 +2055,7 @@ EOF
        test_repo 15/sub "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15"
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
        cat >15/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15
@@ -2065,7 +2065,7 @@ EOF
        test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" ../..
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15/wt
@@ -2075,7 +2075,7 @@ EOF
        test_repo 15 .git "$TRASH_DIRECTORY/15/wt"
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15/wt
@@ -2085,7 +2085,7 @@ EOF
        test_repo 15 .git wt
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15/wt
@@ -2095,7 +2095,7 @@ EOF
        test_repo 15 "$TRASH_DIRECTORY/15/.git" wt
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt at root' '
+test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15/wt
@@ -2105,7 +2105,7 @@ EOF
        test_repo 15 "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15/wt"
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
        cat >15/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15/wt
@@ -2115,7 +2115,7 @@ EOF
        test_repo 15/sub/sub ../../.git "$TRASH_DIRECTORY/15/wt"
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
        cat >15/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15/wt
@@ -2125,7 +2125,7 @@ EOF
        test_repo 15/sub/sub ../../.git ../../wt
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
        cat >15/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15/wt
@@ -2135,7 +2135,7 @@ EOF
        test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" ../../wt
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
        cat >15/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY/15/wt
@@ -2145,7 +2145,7 @@ EOF
        test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15/wt"
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY
@@ -2155,7 +2155,7 @@ EOF
        test_repo 15 .git "$TRASH_DIRECTORY"
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY
@@ -2165,7 +2165,7 @@ EOF
        test_repo 15 .git ..
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY
@@ -2175,7 +2175,7 @@ EOF
        test_repo 15 "$TRASH_DIRECTORY/15/.git" ..
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=.. at root' '
+test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. at root' '
        cat >15/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY
@@ -2185,7 +2185,7 @@ EOF
        test_repo 15 "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY"
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
        cat >15/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY
@@ -2195,7 +2195,7 @@ EOF
        test_repo 15/sub/sub ../../.git "$TRASH_DIRECTORY"
 '
 
-test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
        cat >15/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY
@@ -2205,7 +2205,7 @@ EOF
        test_repo 15/sub/sub ../../.git ../../..
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
        cat >15/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY
@@ -2215,7 +2215,7 @@ EOF
        test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" ../../../
 '
 
-test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
        cat >15/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/15.git
 setup: worktree: $TRASH_DIRECTORY
@@ -2247,7 +2247,7 @@ EOF
 #  - cwd can't be outside worktree
 
 test_expect_success '#16.1: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 16 16/sub &&
        cd 16 &&
        git init &&
@@ -2350,7 +2350,7 @@ EOF
        test_repo 16
 '
 
-test_expect_failure '#16.2: in subdir' '
+test_expect_success '#16.2: in subdir' '
        cat >16/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/16/.git
 setup: worktree: (null)
@@ -2378,7 +2378,7 @@ EOF
 # GIT_WORK_TREE is ignored -> #16.1 (with warnings perhaps)
 
 test_expect_success '#17.1: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 17 17/sub &&
        cd 17 &&
        git init &&
@@ -2388,7 +2388,7 @@ test_expect_success '#17.1: setup' '
        cd ..
 '
 
-test_expect_failure '#17.1: at .git' '
+test_expect_success '#17.1: at .git' '
        cat >17/.git/expected <<EOF &&
 setup: git_dir: .
 setup: worktree: (null)
@@ -2398,7 +2398,7 @@ EOF
        test_repo 17/.git
 '
 
-test_expect_failure '#17.1: in .git/wt' '
+test_expect_success '#17.1: in .git/wt' '
        cat >17/.git/wt/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/17/.git
 setup: worktree: (null)
@@ -2408,7 +2408,7 @@ EOF
        test_repo 17/.git/wt
 '
 
-test_expect_failure '#17.1: in .git/wt/sub' '
+test_expect_success '#17.1: in .git/wt/sub' '
        cat >17/.git/wt/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/17/.git
 setup: worktree: (null)
@@ -2439,7 +2439,7 @@ test_expect_success '#17.2: setup' '
        git config --file="$TRASH_DIRECTORY/17/.git/config" core.bare true
 '
 
-test_expect_failure '#17.2: at .git' '
+test_expect_success '#17.2: at .git' '
        cat >17/.git/expected <<EOF &&
 setup: git_dir: .
 setup: worktree: (null)
@@ -2449,7 +2449,7 @@ EOF
        test_repo 17/.git
 '
 
-test_expect_failure '#17.2: in .git/wt' '
+test_expect_success '#17.2: in .git/wt' '
        cat >17/.git/wt/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/17/.git
 setup: worktree: (null)
@@ -2459,7 +2459,7 @@ EOF
        test_repo 17/.git/wt
 '
 
-test_expect_failure '#17.2: in .git/wt/sub' '
+test_expect_success '#17.2: in .git/wt/sub' '
        cat >17/.git/wt/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/17/.git
 setup: worktree: (null)
@@ -2469,7 +2469,7 @@ EOF
        test_repo 17/.git/wt/sub
 '
 
-test_expect_failure '#17.2: at root' '
+test_expect_success '#17.2: at root' '
        cat >17/expected <<EOF &&
 setup: git_dir: .git
 setup: worktree: (null)
@@ -2479,7 +2479,7 @@ EOF
        test_repo 17
 '
 
-test_expect_failure '#17.2: in subdir' '
+test_expect_success '#17.2: in subdir' '
        cat >17/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/17/.git
 setup: worktree: (null)
@@ -2511,7 +2511,7 @@ EOF
 #  - cwd can't be outside worktree
 
 test_expect_success '#18: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 18 18/sub &&
        cd 18 &&
        git init &&
@@ -2578,7 +2578,7 @@ EOF
 # bare repo is overridden by GIT_WORK_TREE -> #3
 
 test_expect_success '#19: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 19 19/sub 19/sub/sub 19.wt 19.wt/sub 19/wt 19/wt/sub &&
        cd 19 &&
        git init &&
@@ -2844,7 +2844,7 @@ EOF
 # core.worktree is ignored -> #16.1
 
 test_expect_success '#20.1: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 20 20/sub &&
        cd 20 &&
        git init &&
@@ -2853,7 +2853,7 @@ test_expect_success '#20.1: setup' '
        cd ..
 '
 
-test_expect_failure '#20.1: at .git' '
+test_expect_success '#20.1: at .git' '
        cat >20/.git/expected <<EOF &&
 setup: git_dir: .
 setup: worktree: (null)
@@ -2863,7 +2863,7 @@ EOF
        test_repo 20/.git
 '
 
-test_expect_failure '#20.1: in .git/wt' '
+test_expect_success '#20.1: in .git/wt' '
        cat >20/.git/wt/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/20/.git
 setup: worktree: (null)
@@ -2873,7 +2873,7 @@ EOF
        test_repo 20/.git/wt
 '
 
-test_expect_failure '#20.1: in .git/wt/sub' '
+test_expect_success '#20.1: in .git/wt/sub' '
        cat >20/.git/wt/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/20/.git
 setup: worktree: (null)
@@ -2944,7 +2944,7 @@ EOF
        test_repo 20
 '
 
-test_expect_failure '#20.2: in subdir' '
+test_expect_success '#20.2: in subdir' '
        cat >20/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/20/.git
 setup: worktree: (null)
@@ -2972,7 +2972,7 @@ EOF
 # GIT_WORK_TREE/core.worktree are ignored -> #20.1
 
 test_expect_success '#21.1: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 21 21/sub &&
        cd 21 &&
        git init &&
@@ -2983,7 +2983,7 @@ test_expect_success '#21.1: setup' '
        cd ..
 '
 
-test_expect_failure '#21.1: at .git' '
+test_expect_success '#21.1: at .git' '
        cat >21/.git/expected <<EOF &&
 setup: git_dir: .
 setup: worktree: (null)
@@ -2993,7 +2993,7 @@ EOF
        test_repo 21/.git
 '
 
-test_expect_failure '#21.1: in .git/wt' '
+test_expect_success '#21.1: in .git/wt' '
        cat >21/.git/wt/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/21/.git
 setup: worktree: (null)
@@ -3003,7 +3003,7 @@ EOF
        test_repo 21/.git/wt
 '
 
-test_expect_failure '#21.1: in .git/wt/sub' '
+test_expect_success '#21.1: in .git/wt/sub' '
        cat >21/.git/wt/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/21/.git
 setup: worktree: (null)
@@ -3034,7 +3034,7 @@ test_expect_success '#21.2: setup' '
        git config --file="$TRASH_DIRECTORY/21/.git/config" core.bare true
 '
 
-test_expect_failure '#21.2: at .git' '
+test_expect_success '#21.2: at .git' '
        cat >21/.git/expected <<EOF &&
 setup: git_dir: .
 setup: worktree: (null)
@@ -3044,7 +3044,7 @@ EOF
        test_repo 21/.git
 '
 
-test_expect_failure '#21.2: in .git/wt' '
+test_expect_success '#21.2: in .git/wt' '
        cat >21/.git/wt/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/21/.git
 setup: worktree: (null)
@@ -3054,7 +3054,7 @@ EOF
        test_repo 21/.git/wt
 '
 
-test_expect_failure '#21.2: in .git/wt/sub' '
+test_expect_success '#21.2: in .git/wt/sub' '
        cat >21/.git/wt/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/21/.git
 setup: worktree: (null)
@@ -3064,7 +3064,7 @@ EOF
        test_repo 21/.git/wt/sub
 '
 
-test_expect_failure '#21.2: at root' '
+test_expect_success '#21.2: at root' '
        cat >21/expected <<EOF &&
 setup: git_dir: .git
 setup: worktree: (null)
@@ -3074,7 +3074,7 @@ EOF
        test_repo 21
 '
 
-test_expect_failure '#21.2: in subdir' '
+test_expect_success '#21.2: in subdir' '
        cat >21/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/21/.git
 setup: worktree: (null)
@@ -3108,7 +3108,7 @@ EOF
 #  - cwd can be outside worktree
 
 test_expect_success '#22.1: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 22 &&
        cd 22 &&
        git init &&
@@ -3160,7 +3160,7 @@ EOF
        test_repo 22/.git "$TRASH_DIRECTORY/22/.git"
 '
 
-test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=. in .git/sub' '
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. in .git/sub' '
        cat >22/.git/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/22/.git
 setup: worktree: $TRASH_DIRECTORY/22/.git
@@ -3171,7 +3171,7 @@ EOF
        test_repo 22/.git/sub ..
 '
 
-test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=.(rel) in .git/sub' '
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) in .git/sub' '
        cat >22/.git/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/22/.git
 setup: worktree: $TRASH_DIRECTORY/22/.git
@@ -3292,7 +3292,7 @@ EOF
        test_repo 22/.git/sub "$TRASH_DIRECTORY/22/.git"
 '
 
-test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=.. at .git' '
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. at .git' '
        cat >22/.git/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/22/.git
 setup: worktree: $TRASH_DIRECTORY/22
@@ -3303,7 +3303,7 @@ EOF
        test_repo 22/.git .
 '
 
-test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=..(rel) at .git' '
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) at .git' '
        cat >22/.git/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/22/.git
 setup: worktree: $TRASH_DIRECTORY/22
@@ -3336,7 +3336,7 @@ EOF
        test_repo 22/.git "$TRASH_DIRECTORY/22/.git"
 '
 
-test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=.. in .git/sub' '
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. in .git/sub' '
        cat >22/.git/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/22/.git
 setup: worktree: $TRASH_DIRECTORY/22
@@ -3347,7 +3347,7 @@ EOF
        test_repo 22/.git/sub ..
 '
 
-test_expect_failure '#22.1: GIT_DIR(rel), core.worktree=..(rel) in .git/sub' '
+test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) in .git/sub' '
        cat >22/.git/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/22/.git
 setup: worktree: $TRASH_DIRECTORY/22
@@ -3401,7 +3401,7 @@ test_expect_success '#22.2: setup' '
        git config --file="$TRASH_DIRECTORY/22/.git/config" core.bare true
 '
 
-test_expect_failure '#22.2: at .git' '
+test_expect_success '#22.2: at .git' '
        (
        cd 22/.git &&
        GIT_DIR=. &&
@@ -3411,7 +3411,7 @@ test_expect_failure '#22.2: at .git' '
        )
 '
 
-test_expect_failure '#22.2: at root' '
+test_expect_success '#22.2: at root' '
        (
        cd 22 &&
        GIT_DIR=.git &&
@@ -3439,7 +3439,7 @@ test_expect_failure '#22.2: at root' '
 # core.worktree is overridden by GIT_WORK_TREE -> #19
 
 test_expect_success '#23: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 23 23/sub 23/sub/sub 23.wt 23.wt/sub 23/wt 23/wt/sub &&
        cd 23 &&
        git init &&
@@ -3706,7 +3706,7 @@ EOF
 # #16.2 except git_dir is set according to .git file
 
 test_expect_success '#24: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 24 24/sub &&
        cd 24 &&
        git init &&
@@ -3754,7 +3754,7 @@ EOF
 # #17.2 except git_dir is set according to .git file
 
 test_expect_success '#25: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 25 25/sub &&
        cd 25 &&
        git init &&
@@ -3766,7 +3766,7 @@ test_expect_success '#25: setup' '
        cd ..
 '
 
-test_expect_failure '#25: at root' '
+test_expect_success '#25: at root' '
        cat >25/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/25.git
 setup: worktree: (null)
@@ -3776,7 +3776,7 @@ EOF
        test_repo 25
 '
 
-test_expect_failure '#25: in subdir' '
+test_expect_success '#25: in subdir' '
        cat >25/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/25.git
 setup: worktree: (null)
@@ -3804,7 +3804,7 @@ EOF
 # #18 except git_dir is set according to .git file
 
 test_expect_success '#26: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 26 26/sub &&
        cd 26 &&
        git init &&
@@ -3814,7 +3814,7 @@ test_expect_success '#26: setup' '
        cd ..
 '
 
-test_expect_failure '#26: (rel) at root' '
+test_expect_success '#26: (rel) at root' '
        cat >26/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/26.git
 setup: worktree: (null)
@@ -3824,7 +3824,7 @@ EOF
         test_repo 26 .git
 '
 
-test_expect_failure '#26: at root' '
+test_expect_success '#26: at root' '
        cat >26/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/26.git
 setup: worktree: (null)
@@ -3834,7 +3834,7 @@ EOF
         test_repo 26 "$TRASH_DIRECTORY/26/.git"
 '
 
-test_expect_failure '#26: (rel) in subdir' '
+test_expect_success '#26: (rel) in subdir' '
        cat >26/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/26.git
 setup: worktree: (null)
@@ -3844,7 +3844,7 @@ EOF
        test_repo 26/sub ../.git
 '
 
-test_expect_failure '#26: in subdir' '
+test_expect_success '#26: in subdir' '
        cat >26/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/26.git
 setup: worktree: (null)
@@ -3872,7 +3872,7 @@ EOF
 # #19 except git_dir is set according to .git file
 
 test_expect_success '#27: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 27 27/sub 27/sub/sub 27.wt 27.wt/sub 27/wt 27/wt/sub &&
        cd 27 &&
        git init &&
@@ -3882,7 +3882,7 @@ test_expect_success '#27: setup' '
        cd ..
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27
@@ -3892,7 +3892,7 @@ EOF
        test_repo 27 .git "$TRASH_DIRECTORY/27"
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27
@@ -3902,7 +3902,7 @@ EOF
        test_repo 27 .git .
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=root at root' '
+test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27
@@ -3912,7 +3912,7 @@ EOF
        test_repo 27 "$TRASH_DIRECTORY/27/.git" "$TRASH_DIRECTORY/27"
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27
@@ -3922,7 +3922,7 @@ EOF
        test_repo 27 "$TRASH_DIRECTORY/27/.git" .
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
        cat >27/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27
@@ -3932,7 +3932,7 @@ EOF
        test_repo 27/sub/sub ../../.git "$TRASH_DIRECTORY/27"
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
        cat >27/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27
@@ -3942,7 +3942,7 @@ EOF
        test_repo 27/sub/sub ../../.git ../..
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORKTREE=root in subdir' '
+test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root in subdir' '
        cat >27/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27
@@ -3952,7 +3952,7 @@ EOF
        test_repo 27/sub "$TRASH_DIRECTORY/27/.git" "$TRASH_DIRECTORY/27"
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
        cat >27/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27
@@ -3962,7 +3962,7 @@ EOF
        test_repo 27/sub/sub "$TRASH_DIRECTORY/27/.git" ../..
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27/wt
@@ -3972,7 +3972,7 @@ EOF
        test_repo 27 .git "$TRASH_DIRECTORY/27/wt"
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27/wt
@@ -3982,7 +3982,7 @@ EOF
        test_repo 27 .git wt
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27/wt
@@ -3992,7 +3992,7 @@ EOF
        test_repo 27 "$TRASH_DIRECTORY/27/.git" wt
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=wt at root' '
+test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27/wt
@@ -4002,7 +4002,7 @@ EOF
        test_repo 27 "$TRASH_DIRECTORY/27/.git" "$TRASH_DIRECTORY/27/wt"
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
        cat >27/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27/wt
@@ -4012,7 +4012,7 @@ EOF
        test_repo 27/sub/sub ../../.git "$TRASH_DIRECTORY/27/wt"
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
        cat >27/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27/wt
@@ -4022,7 +4022,7 @@ EOF
        test_repo 27/sub/sub ../../.git ../../wt
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
        cat >27/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27/wt
@@ -4032,7 +4032,7 @@ EOF
        test_repo 27/sub/sub "$TRASH_DIRECTORY/27/.git" ../../wt
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
        cat >27/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY/27/wt
@@ -4042,7 +4042,7 @@ EOF
        test_repo 27/sub/sub "$TRASH_DIRECTORY/27/.git" "$TRASH_DIRECTORY/27/wt"
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY
@@ -4052,7 +4052,7 @@ EOF
        test_repo 27 .git "$TRASH_DIRECTORY"
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY
@@ -4062,7 +4062,7 @@ EOF
        test_repo 27 .git ..
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY
@@ -4072,7 +4072,7 @@ EOF
        test_repo 27 "$TRASH_DIRECTORY/27/.git" ..
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=.. at root' '
+test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. at root' '
        cat >27/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY
@@ -4082,7 +4082,7 @@ EOF
        test_repo 27 "$TRASH_DIRECTORY/27/.git" "$TRASH_DIRECTORY"
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
        cat >27/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY
@@ -4092,7 +4092,7 @@ EOF
        test_repo 27/sub/sub ../../.git "$TRASH_DIRECTORY"
 '
 
-test_expect_failure '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
        cat >27/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY
@@ -4102,7 +4102,7 @@ EOF
        test_repo 27/sub/sub ../../.git ../../..
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
        cat >27/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY
@@ -4112,7 +4112,7 @@ EOF
        test_repo 27/sub/sub "$TRASH_DIRECTORY/27/.git" ../../../
 '
 
-test_expect_failure '#27: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
        cat >27/sub/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/27.git
 setup: worktree: $TRASH_DIRECTORY
@@ -4140,7 +4140,7 @@ EOF
 # core.worktree is ignored -> #24
 
 test_expect_success '#28: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 28 28/sub &&
        cd 28 &&
        git init &&
@@ -4189,7 +4189,7 @@ EOF
 # GIT_WORK_TREE/core.worktree are ignored -> #28
 
 test_expect_success '#29: setup' '
-       unset GIT_DIR GIT_WORK_TREE &&
+       sane_unset GIT_DIR GIT_WORK_TREE &&
        mkdir 29 29/sub &&
        cd 29 &&
        git init &&
@@ -4201,7 +4201,7 @@ test_expect_success '#29: setup' '
        cd ..
 '
 
-test_expect_failure '#29: at root' '
+test_expect_success '#29: at root' '
        cat >29/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/29.git
 setup: worktree: (null)
@@ -4211,7 +4211,7 @@ EOF
        test_repo 29
 '
 
-test_expect_failure '#29: in subdir' '
+test_expect_success '#29: in subdir' '
        cat >29/sub/expected <<EOF &&
 setup: git_dir: $TRASH_DIRECTORY/29.git
 setup: worktree: (null)
@@ -4221,4 +4221,312 @@ EOF
        test_repo 29/sub
 '
 
+#
+# case #30
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a file
+#  - core.bare is set
+#
+# Output:
+#
+# core.worktree and core.bare conflict, won't fly.
+
+test_expect_success '#30: setup' '
+       sane_unset GIT_DIR GIT_WORK_TREE &&
+       mkdir 30 &&
+       cd 30 &&
+       git init &&
+       git config core.bare true &&
+       git config core.worktree non-existent &&
+       mv .git ../30.git &&
+       echo gitdir: ../30.git >.git &&
+       cd ..
+'
+
+test_expect_success '#30: at root' '
+       (
+       cd 30 &&
+       GIT_DIR=.git &&
+       export GIT_DIR &&
+       test_must_fail git symbolic-ref HEAD 2>result &&
+       grep "core.bare and core.worktree do not make sense" result
+       )
+'
+
+#
+# case #31
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a file
+#  - core.bare is set
+#
+# Output:
+#
+# #23 except git_dir is set according to .git file
+
+test_expect_success '#31: setup' '
+       sane_unset GIT_DIR GIT_WORK_TREE &&
+       mkdir 31 31/sub 31/sub/sub 31.wt 31.wt/sub 31/wt 31/wt/sub &&
+       cd 31 &&
+       git init &&
+       git config core.bare true &&
+       git config core.worktree non-existent &&
+       mv .git ../31.git &&
+       echo gitdir: ../31.git >.git &&
+       cd ..
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+       test_repo 31 .git "$TRASH_DIRECTORY/31"
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+       test_repo 31 .git .
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+       test_repo 31 "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY/31"
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+       test_repo 31 "$TRASH_DIRECTORY/31/.git" .
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
+       cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: sub/sub/
+EOF
+       test_repo 31/sub/sub ../../.git "$TRASH_DIRECTORY/31"
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
+       cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: sub/sub/
+EOF
+       test_repo 31/sub/sub ../../.git ../..
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root in subdir' '
+       cat >31/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: sub/
+EOF
+       test_repo 31/sub "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY/31"
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
+       cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: sub/sub/
+EOF
+       test_repo 31/sub/sub "$TRASH_DIRECTORY/31/.git" ../..
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+       test_repo 31 .git "$TRASH_DIRECTORY/31/wt"
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+       test_repo 31 .git wt
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+       test_repo 31 "$TRASH_DIRECTORY/31/.git" wt
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31
+setup: prefix: (null)
+EOF
+       test_repo 31 "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY/31/wt"
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+       cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31/sub/sub
+setup: prefix: (null)
+EOF
+       test_repo 31/sub/sub ../../.git "$TRASH_DIRECTORY/31/wt"
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+       cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31/sub/sub
+setup: prefix: (null)
+EOF
+       test_repo 31/sub/sub ../../.git ../../wt
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+       cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31/sub/sub
+setup: prefix: (null)
+EOF
+       test_repo 31/sub/sub "$TRASH_DIRECTORY/31/.git" ../../wt
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+       cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY/31/wt
+setup: cwd: $TRASH_DIRECTORY/31/sub/sub
+setup: prefix: (null)
+EOF
+       test_repo 31/sub/sub "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY/31/wt"
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/
+EOF
+       test_repo 31 .git "$TRASH_DIRECTORY"
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/
+EOF
+       test_repo 31 .git ..
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/
+EOF
+       test_repo 31 "$TRASH_DIRECTORY/31/.git" ..
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=.. at root' '
+       cat >31/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/
+EOF
+       test_repo 31 "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY"
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+       cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/sub/sub/
+EOF
+       test_repo 31/sub/sub ../../.git "$TRASH_DIRECTORY"
+'
+
+test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+       cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/sub/sub/
+EOF
+       test_repo 31/sub/sub ../../.git ../../..
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+       cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/sub/sub/
+EOF
+       test_repo 31/sub/sub "$TRASH_DIRECTORY/31/.git" ../../../
+'
+
+test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+       cat >31/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/31.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 31/sub/sub/
+EOF
+       test_repo 31/sub/sub "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY"
+'
+
 test_done