[WIP PATCH 15/18] t1510: setup case #12
---
t/t1510-repo-setup.sh | 132 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 132 insertions(+), 0 deletions(-)
diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index f8ab969..1516ff6 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -1681,4 +1681,136 @@ EOF
GIT_DIR="$TRASH_DIRECTORY/11/.git" GIT_WORK_TREE="$TRASH_DIRECTORY" test_repo 11/sub/sub
'
+#
+# case #12
+#
+############################################################
+#
+# Input:
+#
+# - GIT_WORK_TREE is not set
+# - GIT_DIR is not set
+# - core.worktree is set
+# - .git is a file
+# - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# same as case #4 except that git_dir is set by .git file
+
+
+test_expect_success '#12: setup' '
+ 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 &&
+ mv .git ../12.git &&
+ echo gitdir: ../12.git >.git &&
+ cd ..
+'
+
+test_expect_failure '#12: core.worktree(rel), at root' '
+ cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12
+$TRASH_DIRECTORY/12
+EOF
+ git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree .. &&
+ test_repo 12
+'
+
+test_expect_success '#12: core.worktree, at root' '
+ cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12
+$TRASH_DIRECTORY/12
+EOF
+ git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree "$TRASH_DIRECTORY/12" &&
+ test_repo 12
+'
+
+test_expect_failure '#12: core.worktree(rel), in subdir' '
+ cat >12/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12
+$TRASH_DIRECTORY/12
+sub/sub/
+EOF
+ git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree .. &&
+ test_repo 12/sub/sub
+'
+
+test_expect_success '#12: core.worktree, in subdir' '
+ cat >12/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12
+$TRASH_DIRECTORY/12
+sub/sub/
+EOF
+ git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree "$TRASH_DIRECTORY/12" &&
+ test_repo 12/sub/sub
+'
+
+test_expect_failure '#12: core.worktree=wt(rel), at root' '
+ cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12/wt
+$TRASH_DIRECTORY/12
+EOF
+ git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree ../wt &&
+ test_repo 12
+'
+
+test_expect_success '#12: core.worktree=wt, at root' '
+ cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12/wt
+$TRASH_DIRECTORY/12
+EOF
+ git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree "$TRASH_DIRECTORY/12/wt" &&
+ test_repo 12
+'
+
+test_expect_failure '#12: core.worktree=wt(rel), in subdir' '
+ cat >12/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12/wt
+$TRASH_DIRECTORY/12/sub/sub
+EOF
+ git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree ../wt &&
+ test_repo 12/sub/sub
+'
+
+test_expect_success '#12: core.worktree=wt, in subdir' '
+ cat >12/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY/12/wt
+$TRASH_DIRECTORY/12/sub/sub
+EOF
+ git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree "$TRASH_DIRECTORY/12/wt" &&
+ test_repo 12/sub/sub
+'
+
+test_expect_failure '#12: core.worktree=..(rel), at root' '
+ cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+12/
+EOF
+ git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree ../.. &&
+ test_repo 12
+'
+
+test_expect_failure '#12: core.worktree=.., at root' '
+ cat >12/expected <<EOF &&
+$TRASH_DIRECTORY/12.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+12/
+EOF
+ git config --file="$TRASH_DIRECTORY/12.git/config" core.worktree "$TRASH_DIRECTORY/12" &&
+ test_repo 12
+'
+
test_done
--
1.7.0.2.445.gcbdb3