[WIP PATCH 07/18] t1510: setup case #4
---
t/t1510-repo-setup.sh | 131 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 131 insertions(+), 0 deletions(-)
diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 508b7e2..ee2b02a 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -457,4 +457,135 @@ EOF
GIT_DIR="$TRASH_DIRECTORY/3/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 3/sub/sub
'
+#
+# case #4
+#
+############################################################
+#
+# Input:
+#
+# - GIT_WORK_TREE is not set
+# - GIT_DIR is not set
+# - core.worktree is set
+# - .git is a directory
+# - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# - worktree is at core.worktree
+# - cwd is at worktree root
+# - prefix is calculated
+# - git_dir is discovered
+# - cwd can be outside worktree
+
+test_expect_success '#4: setup' '
+ unset GIT_DIR GIT_WORK_TREE &&
+ mkdir 4 4/sub 4/sub/sub 4.wt 4.wt/sub 4/wt 4/wt/sub &&
+ cd 4 && git init && cd ..
+'
+
+test_expect_success '#4: core.worktree(rel), at root' '
+ cat >4/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4
+$TRASH_DIRECTORY/4
+EOF
+ git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree .. &&
+ test_repo 4
+'
+
+test_expect_success '#4: core.worktree, at root' '
+ cat >4/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4
+$TRASH_DIRECTORY/4
+EOF
+ git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree "$TRASH_DIRECTORY/4" &&
+ test_repo 4
+'
+
+test_expect_failure '#4: core.worktree(rel), in subdir' '
+ cat >4/sub/sub/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4
+$TRASH_DIRECTORY/4
+sub/sub/
+EOF
+ git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree .. &&
+ test_repo 4/sub/sub
+'
+
+test_expect_success '#4: core.worktree, in subdir' '
+ cat >4/sub/sub/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4
+$TRASH_DIRECTORY/4
+sub/sub/
+EOF
+ git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree "$TRASH_DIRECTORY/4" &&
+ test_repo 4/sub/sub
+'
+
+test_expect_success '#4: core.worktree=wt(rel), at root' '
+ cat >4/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4/wt
+$TRASH_DIRECTORY/4
+EOF
+ git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree ../wt &&
+ test_repo 4
+'
+
+test_expect_success '#4: core.worktree=wt, at root' '
+ cat >4/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/4/wt
+$TRASH_DIRECTORY/4
+EOF
+ git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree "$TRASH_DIRECTORY/4/wt" &&
+ test_repo 4
+'
+
+test_expect_failure '#4: core.worktree=wt(rel), in subdir' '
+ cat >4/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/4/wt
+$TRASH_DIRECTORY/4/sub/sub
+EOF
+ git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree ../wt &&
+ test_repo 4/sub/sub
+'
+
+test_expect_failure '#4: core.worktree=wt, in subdir' '
+ cat >4/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/4/wt
+$TRASH_DIRECTORY/4/sub/sub
+EOF
+ git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree "$TRASH_DIRECTORY/4/wt" &&
+ test_repo 4/sub/sub
+'
+
+test_expect_failure '#4: core.worktree=..(rel), at root' '
+ cat >4/expected <<EOF &&
+4/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+4/
+EOF
+ git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree ../.. &&
+ test_repo 4
+'
+
+test_expect_failure '#4: core.worktree=.., at root' '
+ cat >4/expected <<EOF &&
+4/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+4/
+EOF
+ git config --file="$TRASH_DIRECTORY/4/.git/config" core.worktree "$TRASH_DIRECTORY/4" &&
+ test_repo 4
+'
+
test_done
--
1.7.0.2.445.gcbdb3