-#
-# case #13
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# #5 except that git_dir is set by .git file
-
-test_expect_success '#13: setup' '
- 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 &&
- git config core.worktree non-existent &&
- GIT_WORK_TREE=non-existent-too &&
- export GIT_WORK_TREE &&
- mv .git ../13.git &&
- echo gitdir: ../13.git >.git &&
- cd ..
-'
-
-test_expect_success '#13: at root' '
- cat >13/expected <<EOF &&
-setup: git_dir: $here/13.git
-setup: worktree: $here/13
-setup: cwd: $here/13
-setup: prefix: (null)
-EOF
- test_repo 13
-'
-
-test_expect_success '#13: in subdir' '
- cat >13/sub/expected <<EOF &&
-setup: git_dir: $here/13.git
-setup: worktree: $here/13
-setup: cwd: $here/13
-setup: prefix: sub/
-EOF
- test_repo 13/sub
-'
-
-#
-# case #14
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# #6 except that git_dir is set by .git file
-
-test_expect_success '#14: setup' '
- 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 &&
- mv .git ../14.git &&
- echo gitdir: ../14.git >.git &&
- cd ..
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14
-setup: cwd: $here/14
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree "$here/14" &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14
-setup: cwd: $here/14
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree ../14 &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14 at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14
-setup: cwd: $here/14
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree "$here/14" &&
- test_repo 14 "$here/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14
-setup: cwd: $here/14
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree ../14 &&
- test_repo 14 "$here/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14
-setup: cwd: $here/14
-setup: prefix: sub/sub/
-EOF
- git config --file="$here/14.git/config" core.worktree "$here/14" &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14
-setup: cwd: $here/14
-setup: prefix: sub/sub/
-EOF
- git config --file="$here/14.git/config" core.worktree ../14 &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14 in subdir' '
- cat >14/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14
-setup: cwd: $here/14
-setup: prefix: sub/
-EOF
- git config --file="$here/14.git/config" core.worktree "$here/14" &&
- test_repo 14/sub "$here/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14
-setup: cwd: $here/14
-setup: prefix: sub/sub/
-EOF
- git config --file="$here/14.git/config" core.worktree ../14 &&
- test_repo 14/sub/sub "$here/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14/wt
-setup: cwd: $here/14
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14/wt
-setup: cwd: $here/14
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree ../14/wt &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14/wt
-setup: cwd: $here/14
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree ../14/wt &&
- test_repo 14 "$here/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14/wt
-setup: cwd: $here/14
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
- test_repo 14 "$here/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14/wt
-setup: cwd: $here/14/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14/wt
-setup: cwd: $here/14/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree ../14/wt &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14/wt
-setup: cwd: $here/14/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree ../14/wt &&
- test_repo 14/sub/sub "$here/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here/14/wt
-setup: cwd: $here/14/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
- test_repo 14/sub/sub "$here/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=.. at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 14/
-EOF
- git config --file="$here/14.git/config" core.worktree "$here" &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 14/
-EOF
- git config --file="$here/14.git/config" core.worktree .. &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=..(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 14/
-EOF
- git config --file="$here/14.git/config" core.worktree .. &&
- test_repo 14 "$here/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=.. at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 14/
-EOF
- git config --file="$here/14.git/config" core.worktree "$here" &&
- test_repo 14 "$here/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 14/sub/sub/
-EOF
- git config --file="$here/14.git/config" core.worktree "$here" &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 14/sub/sub/
-EOF
- git config --file="$here/14.git/config" core.worktree .. &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 14/sub/sub/
-EOF
- git config --file="$here/14.git/config" core.worktree .. &&
- test_repo 14/sub/sub "$here/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=.. in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $here/14.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 14/sub/sub/
-EOF
- git config --file="$here/14.git/config" core.worktree "$here" &&
- test_repo 14/sub/sub "$here/14/.git"
-'
-
-#
-# case #15
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# #7 except that git_dir is set by .git file
-
-test_expect_success '#15: setup' '
- 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 &&
- git config core.worktree non-existent &&
- mv .git ../15.git &&
- echo gitdir: ../15.git >.git &&
- cd ..
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15
-setup: cwd: $here/15
-setup: prefix: (null)
-EOF
- test_repo 15 .git "$here/15"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15
-setup: cwd: $here/15
-setup: prefix: (null)
-EOF
- test_repo 15 .git .
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15
-setup: cwd: $here/15
-setup: prefix: (null)
-EOF
- test_repo 15 "$here/15/.git" "$here/15"
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15
-setup: cwd: $here/15
-setup: prefix: (null)
-EOF
- test_repo 15 "$here/15/.git" .
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15
-setup: cwd: $here/15
-setup: prefix: sub/sub/
-EOF
- test_repo 15/sub/sub ../../.git "$here/15"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15
-setup: cwd: $here/15
-setup: prefix: sub/sub/
-EOF
- test_repo 15/sub/sub ../../.git ../..
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >15/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15
-setup: cwd: $here/15
-setup: prefix: sub/
-EOF
- test_repo 15/sub "$here/15/.git" "$here/15"
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15
-setup: cwd: $here/15
-setup: prefix: sub/sub/
-EOF
- test_repo 15/sub/sub "$here/15/.git" ../..
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15/wt
-setup: cwd: $here/15
-setup: prefix: (null)
-EOF
- test_repo 15 .git "$here/15/wt"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15/wt
-setup: cwd: $here/15
-setup: prefix: (null)
-EOF
- test_repo 15 .git wt
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15/wt
-setup: cwd: $here/15
-setup: prefix: (null)
-EOF
- test_repo 15 "$here/15/.git" wt
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15/wt
-setup: cwd: $here/15
-setup: prefix: (null)
-EOF
- test_repo 15 "$here/15/.git" "$here/15/wt"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15/wt
-setup: cwd: $here/15/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 15/sub/sub ../../.git "$here/15/wt"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15/wt
-setup: cwd: $here/15/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 15/sub/sub ../../.git ../../wt
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15/wt
-setup: cwd: $here/15/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 15/sub/sub "$here/15/.git" ../../wt
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here/15/wt
-setup: cwd: $here/15/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 15/sub/sub "$here/15/.git" "$here/15/wt"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 15/
-EOF
- test_repo 15 .git "$here"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 15/
-EOF
- test_repo 15 .git ..
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 15/
-EOF
- test_repo 15 "$here/15/.git" ..
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 15/
-EOF
- test_repo 15 "$here/15/.git" "$here"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 15/sub/sub/
-EOF
- test_repo 15/sub/sub ../../.git "$here"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 15/sub/sub/
-EOF
- test_repo 15/sub/sub ../../.git ../../..
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 15/sub/sub/
-EOF
- test_repo 15/sub/sub "$here/15/.git" ../../../
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $here/15.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 15/sub/sub/
-EOF
- test_repo 15/sub/sub "$here/15/.git" "$here"
-'
-
-#
-# case #16.1
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a directory
-# - cwd is inside .git
-#
-# Output:
-#
-# - no worktree
-# - cwd is unchanged
-# - prefix is NULL
-# - git_dir is set
-# - cwd can't be outside worktree
-
-test_expect_success '#16.1: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 16 16/sub &&
- cd 16 &&
- git init &&
- mkdir .git/wt .git/wt/sub &&
- cd ..
-'
-
-test_expect_success '#16.1: at .git' '
- cat >16/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $here/16/.git
-setup: prefix: (null)
-EOF
- test_repo 16/.git
-'
-
-test_expect_success '#16.1: in .git/wt' '
- cat >16/.git/wt/expected <<EOF &&
-setup: git_dir: $here/16/.git
-setup: worktree: (null)
-setup: cwd: $here/16/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 16/.git/wt
-'
-
-test_expect_success '#16.1: in .git/wt/sub' '
- cat >16/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $here/16/.git
-setup: worktree: (null)
-setup: cwd: $here/16/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 16/.git/wt/sub
-'
-
-#
-# case #16.2
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# - no worktree
-# - cwd is unchanged
-# - prefix is NULL
-# - git_dir is set
-# - cwd can't be outside worktree
-
-test_expect_success '#16.2: setup' '
- git config --file="$here/16/.git/config" core.bare true
-'
-
-test_expect_success '#16.2: at .git' '
- cat >16/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $here/16/.git
-setup: prefix: (null)
-EOF
- test_repo 16/.git
-'
-
-test_expect_success '#16.2: in .git/wt' '
- cat >16/.git/wt/expected <<EOF &&
-setup: git_dir: $here/16/.git
-setup: worktree: (null)
-setup: cwd: $here/16/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 16/.git/wt
-'
-
-test_expect_success '#16.2: in .git/wt/sub' '
- cat >16/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $here/16/.git
-setup: worktree: (null)
-setup: cwd: $here/16/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 16/.git/wt/sub
-'
-
-test_expect_success '#16.2: at root' '
- cat >16/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: (null)
-setup: cwd: $here/16
-setup: prefix: (null)
-EOF
- test_repo 16
-'
-
-test_expect_success '#16.2: in subdir' '
- cat >16/sub/expected <<EOF &&
-setup: git_dir: $here/16/.git
-setup: worktree: (null)
-setup: cwd: $here/16/sub
-setup: prefix: (null)
-EOF
- test_repo 16/sub
-'
-
-#
-# case #17.1
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a directory
-# - cwd is inside .git
-#
-# Output:
-#
-# GIT_WORK_TREE is ignored -> #16.1 (with warnings perhaps)
-
-test_expect_success '#17.1: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 17 17/sub &&
- cd 17 &&
- git init &&
- mkdir .git/wt .git/wt/sub &&
- GIT_WORK_TREE=non-existent &&
- export GIT_WORK_TREE &&
- cd ..
-'
-
-test_expect_success '#17.1: at .git' '
- cat >17/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $here/17/.git
-setup: prefix: (null)
-EOF
- test_repo 17/.git
-'
-
-test_expect_success '#17.1: in .git/wt' '
- cat >17/.git/wt/expected <<EOF &&
-setup: git_dir: $here/17/.git
-setup: worktree: (null)
-setup: cwd: $here/17/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 17/.git/wt
-'
-
-test_expect_success '#17.1: in .git/wt/sub' '
- cat >17/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $here/17/.git
-setup: worktree: (null)
-setup: cwd: $here/17/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 17/.git/wt/sub
-'
-
-#
-# case #17.2
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# GIT_WORK_TREE is ignored -> #16.2 (with warnings perhaps)
-
-test_expect_success '#17.2: setup' '
- git config --file="$here/17/.git/config" core.bare true
-'
-
-test_expect_success '#17.2: at .git' '
- cat >17/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $here/17/.git
-setup: prefix: (null)
-EOF
- test_repo 17/.git
-'
-
-test_expect_success '#17.2: in .git/wt' '
- cat >17/.git/wt/expected <<EOF &&
-setup: git_dir: $here/17/.git
-setup: worktree: (null)
-setup: cwd: $here/17/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 17/.git/wt
-'
-
-test_expect_success '#17.2: in .git/wt/sub' '
- cat >17/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $here/17/.git
-setup: worktree: (null)
-setup: cwd: $here/17/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 17/.git/wt/sub
-'
-
-test_expect_success '#17.2: at root' '
- cat >17/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: (null)
-setup: cwd: $here/17
-setup: prefix: (null)
-EOF
- test_repo 17
-'
-
-test_expect_success '#17.2: in subdir' '
- cat >17/sub/expected <<EOF &&
-setup: git_dir: $here/17/.git
-setup: worktree: (null)
-setup: cwd: $here/17/sub
-setup: prefix: (null)
-EOF
- test_repo 17/sub
-'
-
-#
-# case #18
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is not set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# - no worktree (rule #8)
-# - cwd is unchanged
-# - prefix is NULL
-# - git_dir is set to $GIT_DIR
-# - cwd can't be outside worktree
-
-test_expect_success '#18: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 18 18/sub &&
- cd 18 &&
- git init &&
- mkdir .git/wt .git/wt/sub &&
- git config core.bare true &&
- cd ..
-'
-
-test_expect_success '#18: (rel) at root' '
- cat >18/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: (null)
-setup: cwd: $here/18
-setup: prefix: (null)
-EOF
- test_repo 18 .git
-'
-
-test_expect_success '#18: at root' '
- cat >18/expected <<EOF &&
-setup: git_dir: $here/18/.git
-setup: worktree: (null)
-setup: cwd: $here/18
-setup: prefix: (null)
-EOF
- test_repo 18 "$here/18/.git"
-'
-
-test_expect_success '#18: (rel) in subdir' '
- cat >18/sub/expected <<EOF &&
-setup: git_dir: ../.git
-setup: worktree: (null)
-setup: cwd: $here/18/sub
-setup: prefix: (null)
-EOF
- test_repo 18/sub ../.git
-'
-
-test_expect_success '#18: in subdir' '
- cat >18/sub/expected <<EOF &&
-setup: git_dir: $here/18/.git
-setup: worktree: (null)
-setup: cwd: $here/18/sub
-setup: prefix: (null)
-EOF
- test_repo 18/sub "$here/18/.git"
-'
-
-#
-# case #19
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - .git is a directory
-# - core.worktree is not set
-# - core.bare is set
-#
-# Output:
-#
-# bare repo is overridden by GIT_WORK_TREE -> #3
-
-test_expect_success '#19: setup' '
- 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 &&
- git config core.bare true &&
- cd ..
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $here/19
-setup: cwd: $here/19
-setup: prefix: (null)
-EOF
- test_repo 19 .git "$here/19"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $here/19
-setup: cwd: $here/19
-setup: prefix: (null)
-EOF
- test_repo 19 .git .
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here/19
-setup: cwd: $here/19
-setup: prefix: (null)
-EOF
- test_repo 19 "$here/19/.git" "$here/19"
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here/19
-setup: cwd: $here/19
-setup: prefix: (null)
-EOF
- test_repo 19 "$here/19/.git" .
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here/19
-setup: cwd: $here/19
-setup: prefix: sub/sub/
-EOF
- test_repo 19/sub/sub ../../.git "$here/19"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here/19
-setup: cwd: $here/19
-setup: prefix: sub/sub/
-EOF
- test_repo 19/sub/sub ../../.git ../..
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >19/sub/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here/19
-setup: cwd: $here/19
-setup: prefix: sub/
-EOF
- test_repo 19/sub "$here/19/.git" "$here/19"
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here/19
-setup: cwd: $here/19
-setup: prefix: sub/sub/
-EOF
- test_repo 19/sub/sub "$here/19/.git" ../..
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $here/19/wt
-setup: cwd: $here/19
-setup: prefix: (null)
-EOF
- test_repo 19 .git "$here/19/wt"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $here/19/wt
-setup: cwd: $here/19
-setup: prefix: (null)
-EOF
- test_repo 19 .git wt
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here/19/wt
-setup: cwd: $here/19
-setup: prefix: (null)
-EOF
- test_repo 19 "$here/19/.git" wt
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here/19/wt
-setup: cwd: $here/19
-setup: prefix: (null)
-EOF
- test_repo 19 "$here/19/.git" "$here/19/wt"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $here/19/wt
-setup: cwd: $here/19/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 19/sub/sub ../../.git "$here/19/wt"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $here/19/wt
-setup: cwd: $here/19/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 19/sub/sub ../../.git ../../wt
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here/19/wt
-setup: cwd: $here/19/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 19/sub/sub "$here/19/.git" ../../wt
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here/19/wt
-setup: cwd: $here/19/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 19/sub/sub "$here/19/.git" "$here/19/wt"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 19/
-EOF
- test_repo 19 .git "$here"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 19/
-EOF
- test_repo 19 .git ..
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 19/
-EOF
- test_repo 19 "$here/19/.git" ..
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 19/
-EOF
- test_repo 19 "$here/19/.git" "$here"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 19/sub/sub/
-EOF
- test_repo 19/sub/sub ../../.git "$here"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 19/sub/sub/
-EOF
- test_repo 19/sub/sub ../../.git ../../..
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 19/sub/sub/
-EOF
- test_repo 19/sub/sub "$here/19/.git" ../../../
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $here/19/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 19/sub/sub/
-EOF
- test_repo 19/sub/sub "$here/19/.git" "$here"
-'
-
-#
-# case #20.1
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a directory
-# - cwd is inside .git
-#
-# Output:
-#
-# core.worktree is ignored -> #16.1
-
-test_expect_success '#20.1: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 20 20/sub &&
- cd 20 &&
- git init &&
- git config core.worktree non-existent &&
- mkdir .git/wt .git/wt/sub &&
- cd ..
-'
-
-test_expect_success '#20.1: at .git' '
- cat >20/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $here/20/.git
-setup: prefix: (null)
-EOF
- test_repo 20/.git
-'
-
-test_expect_success '#20.1: in .git/wt' '
- cat >20/.git/wt/expected <<EOF &&
-setup: git_dir: $here/20/.git
-setup: worktree: (null)
-setup: cwd: $here/20/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 20/.git/wt
-'
-
-test_expect_success '#20.1: in .git/wt/sub' '
- cat >20/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $here/20/.git
-setup: worktree: (null)
-setup: cwd: $here/20/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 20/.git/wt/sub
-'
-
-#
-# case #20.2
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# core.worktree is ignored -> #16.2
-
-test_expect_success '#20.2: setup' '
- git config --file="$here/20/.git/config" core.bare true
-'
-
-test_expect_success '#20.2: at .git' '
- cat >20/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $here/20/.git
-setup: prefix: (null)
-EOF
- test_repo 20/.git
-'
-
-test_expect_success '#20.2: in .git/wt' '
- cat >20/.git/wt/expected <<EOF &&
-setup: git_dir: $here/20/.git
-setup: worktree: (null)
-setup: cwd: $here/20/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 20/.git/wt
-'
-
-test_expect_success '#20.2: in .git/wt/sub' '
- cat >20/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $here/20/.git
-setup: worktree: (null)
-setup: cwd: $here/20/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 20/.git/wt/sub
-'
-
-test_expect_success '#20.2: at root' '
- cat >20/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: (null)
-setup: cwd: $here/20
-setup: prefix: (null)
-EOF
- test_repo 20
-'
-
-test_expect_success '#20.2: in subdir' '
- cat >20/sub/expected <<EOF &&
-setup: git_dir: $here/20/.git
-setup: worktree: (null)
-setup: cwd: $here/20/sub
-setup: prefix: (null)
-EOF
- test_repo 20/sub
-'
-
-#
-# case #21.1
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a directory
-# - cwd is inside .git
-#
-# Output:
-#
-# GIT_WORK_TREE/core.worktree are ignored -> #20.1
-
-test_expect_success '#21.1: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 21 21/sub &&
- cd 21 &&
- git init &&
- git config core.worktree non-existent &&
- GIT_WORK_TREE=non-existent-too &&
- export GIT_WORK_TREE &&
- mkdir .git/wt .git/wt/sub &&
- cd ..
-'
-
-test_expect_success '#21.1: at .git' '
- cat >21/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $here/21/.git
-setup: prefix: (null)
-EOF
- test_repo 21/.git
-'
-
-test_expect_success '#21.1: in .git/wt' '
- cat >21/.git/wt/expected <<EOF &&
-setup: git_dir: $here/21/.git
-setup: worktree: (null)
-setup: cwd: $here/21/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 21/.git/wt
-'
-
-test_expect_success '#21.1: in .git/wt/sub' '
- cat >21/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $here/21/.git
-setup: worktree: (null)
-setup: cwd: $here/21/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 21/.git/wt/sub
-'
-
-#
-# case #21.2
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# GIT_WORK_TREE/core.worktree are ignored -> #20.2
-
-test_expect_success '#21.2: setup' '
- git config --file="$here/21/.git/config" core.bare true
-'
-
-test_expect_success '#21.2: at .git' '
- cat >21/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $here/21/.git
-setup: prefix: (null)
-EOF
- test_repo 21/.git
-'
-
-test_expect_success '#21.2: in .git/wt' '
- cat >21/.git/wt/expected <<EOF &&
-setup: git_dir: $here/21/.git
-setup: worktree: (null)
-setup: cwd: $here/21/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 21/.git/wt
-'
-
-test_expect_success '#21.2: in .git/wt/sub' '
- cat >21/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $here/21/.git
-setup: worktree: (null)
-setup: cwd: $here/21/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 21/.git/wt/sub
-'
-
-test_expect_success '#21.2: at root' '
- cat >21/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: (null)
-setup: cwd: $here/21
-setup: prefix: (null)
-EOF
- test_repo 21
-'
-
-test_expect_success '#21.2: in subdir' '
- cat >21/sub/expected <<EOF &&
-setup: git_dir: $here/21/.git
-setup: worktree: (null)
-setup: cwd: $here/21/sub
-setup: prefix: (null)
-EOF
- test_repo 21/sub
-'
-
-#
-# case #22.1
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a directory
-# - cwd is inside .git
-#
-# Output:
-#
-# bare attribute is ignored
-#
-# - worktree is at core.worktree
-# - cwd is at worktree root
-# - prefix is calculated
-# - git_dir is at $GIT_DIR
-# - cwd can be outside worktree
-
-test_expect_success '#22.1: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 22 &&
- cd 22 &&
- git init &&
- mkdir .git/sub .git/wt .git/wt/sub &&
- cd ..
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: $here/22/.git
-setup: cwd: $here/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: $here/22/.git
-setup: cwd: $here/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree . &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=. at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22/.git
-setup: cwd: $here/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
- test_repo 22/.git "$here/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) at root' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22/.git
-setup: cwd: $here/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree . &&
- test_repo 22/.git "$here/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22/.git
-setup: cwd: $here/22/.git
-setup: prefix: sub/
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
- test_repo 22/.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: $here/22/.git
-setup: worktree: $here/22/.git
-setup: cwd: $here/22/.git
-setup: prefix: sub/
-EOF
- git config --file="$here/22/.git/config" core.worktree . &&
- test_repo 22/.git/sub/ ..
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=. in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22/.git
-setup: cwd: $here/22/.git
-setup: prefix: sub/
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
- test_repo 22/.git/sub "$here/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22/.git
-setup: cwd: $here/22/.git
-setup: prefix: sub/
-EOF
- git config --file="$here/22/.git/config" core.worktree . &&
- test_repo 22/.git/sub "$here/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: $here/22/.git/wt
-setup: cwd: $here/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: $here/22/.git/wt
-setup: cwd: $here/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree wt &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22/.git/wt
-setup: cwd: $here/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree wt &&
- test_repo 22/.git "$here/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22/.git/wt
-setup: cwd: $here/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
- test_repo 22/.git "$here/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: ..
-setup: worktree: $here/22/.git/wt
-setup: cwd: $here/22/.git/sub
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
- test_repo 22/.git/sub ..
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: ..
-setup: worktree: $here/22/.git/wt
-setup: cwd: $here/22/.git/sub
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree wt &&
- test_repo 22/.git/sub ..
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22/.git/wt
-setup: cwd: $here/22/.git/sub
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree wt &&
- test_repo 22/.git/sub "$here/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22/.git/wt
-setup: cwd: $here/22/.git/sub
-setup: prefix: (null)
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
- test_repo 22/.git/sub "$here/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22
-setup: cwd: $here/22
-setup: prefix: .git/
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22" &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22
-setup: cwd: $here/22
-setup: prefix: .git/
-EOF
- git config --file="$here/22/.git/config" core.worktree .. &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22
-setup: cwd: $here/22
-setup: prefix: .git/
-EOF
- git config --file="$here/22/.git/config" core.worktree .. &&
- test_repo 22/.git "$here/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=.. at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22
-setup: cwd: $here/22
-setup: prefix: .git/
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22" &&
- test_repo 22/.git "$here/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22
-setup: cwd: $here/22
-setup: prefix: .git/sub/
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22" &&
- test_repo 22/.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: $here/22/.git
-setup: worktree: $here/22
-setup: cwd: $here/22
-setup: prefix: .git/sub/
-EOF
- git config --file="$here/22/.git/config" core.worktree .. &&
- test_repo 22/.git/sub ..
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22
-setup: cwd: $here/22
-setup: prefix: .git/sub/
-EOF
- git config --file="$here/22/.git/config" core.worktree .. &&
- test_repo 22/.git/sub "$here/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=.. in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $here/22/.git
-setup: worktree: $here/22
-setup: cwd: $here/22
-setup: prefix: .git/sub/
-EOF
- git config --file="$here/22/.git/config" core.worktree "$here/22" &&
- test_repo 22/.git/sub "$here/22/.git"
-'
-
-#
-# case #22.2
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# core.worktree and core.bare conflict, won't fly.
-
-test_expect_success '#22.2: setup' '
- git config --file="$here/22/.git/config" core.bare true
-'
-
-test_expect_success '#22.2: at .git' '
- (
- cd 22/.git &&
- GIT_DIR=. &&
- export GIT_DIR &&
- test_must_fail git symbolic-ref HEAD 2>result &&
- grep "core.bare and core.worktree do not make sense" result
- )
-'
-
-test_expect_success '#22.2: at root' '
- (
- cd 22 &&
- 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 #23
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# core.worktree is overridden by GIT_WORK_TREE -> #19
-
-test_expect_success '#23: setup' '
- 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 &&
- git config core.bare true &&
- git config core.worktree non-existent &&
- cd ..
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $here/23
-setup: cwd: $here/23
-setup: prefix: (null)
-EOF
- test_repo 23 .git "$here/23"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $here/23
-setup: cwd: $here/23
-setup: prefix: (null)
-EOF
- test_repo 23 .git .
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here/23
-setup: cwd: $here/23
-setup: prefix: (null)
-EOF
- test_repo 23 "$here/23/.git" "$here/23"
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here/23
-setup: cwd: $here/23
-setup: prefix: (null)
-EOF
- test_repo 23 "$here/23/.git" .
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here/23
-setup: cwd: $here/23
-setup: prefix: sub/sub/
-EOF
- test_repo 23/sub/sub ../../.git "$here/23"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here/23
-setup: cwd: $here/23
-setup: prefix: sub/sub/
-EOF
- test_repo 23/sub/sub ../../.git ../..
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >23/sub/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here/23
-setup: cwd: $here/23
-setup: prefix: sub/
-EOF
- test_repo 23/sub "$here/23/.git" "$here/23"
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here/23
-setup: cwd: $here/23
-setup: prefix: sub/sub/
-EOF
- test_repo 23/sub/sub "$here/23/.git" ../..
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $here/23/wt
-setup: cwd: $here/23
-setup: prefix: (null)
-EOF
- test_repo 23 .git "$here/23/wt"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $here/23/wt
-setup: cwd: $here/23
-setup: prefix: (null)
-EOF
- test_repo 23 .git wt
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here/23/wt
-setup: cwd: $here/23
-setup: prefix: (null)
-EOF
- test_repo 23 "$here/23/.git" wt
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here/23/wt
-setup: cwd: $here/23
-setup: prefix: (null)
-EOF
- test_repo 23 "$here/23/.git" "$here/23/wt"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $here/23/wt
-setup: cwd: $here/23/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 23/sub/sub ../../.git "$here/23/wt"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $here/23/wt
-setup: cwd: $here/23/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 23/sub/sub ../../.git ../../wt
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here/23/wt
-setup: cwd: $here/23/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 23/sub/sub "$here/23/.git" ../../wt
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here/23/wt
-setup: cwd: $here/23/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 23/sub/sub "$here/23/.git" "$here/23/wt"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 23/
-EOF
- test_repo 23 .git "$here"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 23/
-EOF
- test_repo 23 .git ..
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 23/
-EOF
- test_repo 23 "$here/23/.git" ..
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 23/
-EOF
- test_repo 23 "$here/23/.git" "$here"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 23/sub/sub/
-EOF
- test_repo 23/sub/sub ../../.git "$here"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 23/sub/sub/
-EOF
- test_repo 23/sub/sub ../../.git ../../..
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 23/sub/sub/
-EOF
- test_repo 23/sub/sub "$here/23/.git" ../../../
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $here/23/.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 23/sub/sub/
-EOF
- test_repo 23/sub/sub "$here/23/.git" "$here"
-'
-
-#
-# case #24
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# #16.2 except git_dir is set according to .git file
-
-test_expect_success '#24: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 24 24/sub &&
- cd 24 &&
- git init &&
- git config core.bare true &&
- mv .git ../24.git &&
- echo gitdir: ../24.git >.git &&
- cd ..
-'
-
-test_expect_success '#24: at root' '
- cat >24/expected <<EOF &&
-setup: git_dir: $here/24.git
-setup: worktree: (null)
-setup: cwd: $here/24
-setup: prefix: (null)
-EOF
- test_repo 24
-'
-
-test_expect_success '#24: in subdir' '
- cat >24/sub/expected <<EOF &&
-setup: git_dir: $here/24.git
-setup: worktree: (null)
-setup: cwd: $here/24/sub
-setup: prefix: (null)
-EOF
- test_repo 24/sub
-'
-
-#
-# case #25
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# #17.2 except git_dir is set according to .git file
-
-test_expect_success '#25: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 25 25/sub &&
- cd 25 &&
- git init &&
- git config core.bare true &&
- GIT_WORK_TREE=non-existent &&
- export GIT_WORK_TREE &&
- mv .git ../25.git &&
- echo gitdir: ../25.git >.git &&
- cd ..
-'
-
-test_expect_success '#25: at root' '
- cat >25/expected <<EOF &&
-setup: git_dir: $here/25.git
-setup: worktree: (null)
-setup: cwd: $here/25
-setup: prefix: (null)
-EOF
- test_repo 25
-'
-
-test_expect_success '#25: in subdir' '
- cat >25/sub/expected <<EOF &&
-setup: git_dir: $here/25.git
-setup: worktree: (null)
-setup: cwd: $here/25/sub
-setup: prefix: (null)
-EOF
- test_repo 25/sub
-'
-
-#
-# case #26
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is not set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# #18 except git_dir is set according to .git file
-
-test_expect_success '#26: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 26 26/sub &&
- cd 26 &&
- git init &&
- git config core.bare true &&
- mv .git ../26.git &&
- echo gitdir: ../26.git >.git &&
- cd ..
-'
-
-test_expect_success '#26: (rel) at root' '
- cat >26/expected <<EOF &&
-setup: git_dir: $here/26.git
-setup: worktree: (null)
-setup: cwd: $here/26
-setup: prefix: (null)
-EOF
- test_repo 26 .git
-'
-
-test_expect_success '#26: at root' '
- cat >26/expected <<EOF &&
-setup: git_dir: $here/26.git
-setup: worktree: (null)
-setup: cwd: $here/26
-setup: prefix: (null)
-EOF
- test_repo 26 "$here/26/.git"
-'
-
-test_expect_success '#26: (rel) in subdir' '
- cat >26/sub/expected <<EOF &&
-setup: git_dir: $here/26.git
-setup: worktree: (null)
-setup: cwd: $here/26/sub
-setup: prefix: (null)
-EOF
- test_repo 26/sub ../.git
-'
-
-test_expect_success '#26: in subdir' '
- cat >26/sub/expected <<EOF &&
-setup: git_dir: $here/26.git
-setup: worktree: (null)
-setup: cwd: $here/26/sub
-setup: prefix: (null)
-EOF
- test_repo 26/sub "$here/26/.git"
-'
-
-#
-# case #27
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - .git is a file
-# - core.worktree is not set
-# - core.bare is set
-#
-# Output:
-#
-# #19 except git_dir is set according to .git file
-
-test_expect_success '#27: setup' '
- 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 &&
- git config core.bare true &&
- mv .git ../27.git &&
- echo gitdir: ../27.git >.git &&
- cd ..
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27
-setup: cwd: $here/27
-setup: prefix: (null)
-EOF
- test_repo 27 .git "$here/27"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27
-setup: cwd: $here/27
-setup: prefix: (null)
-EOF
- test_repo 27 .git .
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27
-setup: cwd: $here/27
-setup: prefix: (null)
-EOF
- test_repo 27 "$here/27/.git" "$here/27"
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27
-setup: cwd: $here/27
-setup: prefix: (null)
-EOF
- test_repo 27 "$here/27/.git" .
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27
-setup: cwd: $here/27
-setup: prefix: sub/sub/
-EOF
- test_repo 27/sub/sub ../../.git "$here/27"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27
-setup: cwd: $here/27
-setup: prefix: sub/sub/
-EOF
- test_repo 27/sub/sub ../../.git ../..
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >27/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27
-setup: cwd: $here/27
-setup: prefix: sub/
-EOF
- test_repo 27/sub "$here/27/.git" "$here/27"
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27
-setup: cwd: $here/27
-setup: prefix: sub/sub/
-EOF
- test_repo 27/sub/sub "$here/27/.git" ../..
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27/wt
-setup: cwd: $here/27
-setup: prefix: (null)
-EOF
- test_repo 27 .git "$here/27/wt"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27/wt
-setup: cwd: $here/27
-setup: prefix: (null)
-EOF
- test_repo 27 .git wt
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27/wt
-setup: cwd: $here/27
-setup: prefix: (null)
-EOF
- test_repo 27 "$here/27/.git" wt
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27/wt
-setup: cwd: $here/27
-setup: prefix: (null)
-EOF
- test_repo 27 "$here/27/.git" "$here/27/wt"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27/wt
-setup: cwd: $here/27/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 27/sub/sub ../../.git "$here/27/wt"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27/wt
-setup: cwd: $here/27/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 27/sub/sub ../../.git ../../wt
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27/wt
-setup: cwd: $here/27/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 27/sub/sub "$here/27/.git" ../../wt
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here/27/wt
-setup: cwd: $here/27/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 27/sub/sub "$here/27/.git" "$here/27/wt"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 27/
-EOF
- test_repo 27 .git "$here"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 27/
-EOF
- test_repo 27 .git ..
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 27/
-EOF
- test_repo 27 "$here/27/.git" ..
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 27/
-EOF
- test_repo 27 "$here/27/.git" "$here"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 27/sub/sub/
-EOF
- test_repo 27/sub/sub ../../.git "$here"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 27/sub/sub/
-EOF
- test_repo 27/sub/sub ../../.git ../../..
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 27/sub/sub/
-EOF
- test_repo 27/sub/sub "$here/27/.git" ../../../
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $here/27.git
-setup: worktree: $here
-setup: cwd: $here
-setup: prefix: 27/sub/sub/
-EOF
- test_repo 27/sub/sub "$here/27/.git" "$here"
-'
-
-#
-# case #28
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# core.worktree is ignored -> #24
-
-test_expect_success '#28: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 28 28/sub &&
- cd 28 &&
- git init &&
- git config core.bare true &&
- git config core.worktree non-existent &&
- mv .git ../28.git &&
- echo gitdir: ../28.git >.git &&
- cd ..
-'
-
-test_expect_success '#28: at root' '
- cat >28/expected <<EOF &&
-setup: git_dir: $here/28.git
-setup: worktree: (null)
-setup: cwd: $here/28
-setup: prefix: (null)
-EOF
- test_repo 28
-'
-
-test_expect_success '#28: in subdir' '
- cat >28/sub/expected <<EOF &&
-setup: git_dir: $here/28.git
-setup: worktree: (null)
-setup: cwd: $here/28/sub
-setup: prefix: (null)
-EOF
- test_repo 28/sub
-'
-
-#
-# case #29
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# GIT_WORK_TREE/core.worktree are ignored -> #28
-
-test_expect_success '#29: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 29 29/sub &&
- cd 29 &&
- git init &&
- git config core.bare true &&
- GIT_WORK_TREE=non-existent &&
- export GIT_WORK_TREE &&
- mv .git ../29.git &&
- echo gitdir: ../29.git >.git &&
- cd ..
-'
-
-test_expect_success '#29: at root' '
- cat >29/expected <<EOF &&
-setup: git_dir: $here/29.git
-setup: worktree: (null)
-setup: cwd: $here/29
-setup: prefix: (null)
-EOF
- test_repo 29
-'
-
-test_expect_success '#29: in subdir' '
- cat >29/sub/expected <<EOF &&
-setup: git_dir: $here/29.git
-setup: worktree: (null)
-setup: cwd: $here/29/sub
-setup: prefix: (null)
-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
-