summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Nguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-11-26 22:32:01 +0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-11-29 13:25:54 -0800
commit7194660205c39b39badcf555eb76200a80295814 (patch)
tree409cc9708708c21053e20ff63c5e4130f43588e7 /t
parentt1510: setup case #1 (diff)
downloadtgif-7194660205c39b39badcf555eb76200a80295814.tar.xz
t1510: setup case #2
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1510-repo-setup.sh67
1 files changed, 67 insertions, 0 deletions
diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 9324d3ff6c..74750b8d4c 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -152,4 +152,71 @@ EOF
test_repo 1/sub
'
+#
+# case #2
+#
+############################################################
+#
+# Input:
+#
+# - GIT_WORK_TREE is not set
+# - GIT_DIR is set
+# - core.worktree is not set
+# - .git is a directory
+# - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# - worktree is at original cwd
+# - cwd is unchanged
+# - prefix is NULL
+# - git_dir is set to $GIT_DIR
+# - cwd can't be outside worktree
+
+test_expect_success '#2: setup' '
+ unset GIT_DIR GIT_WORK_TREE &&
+ mkdir 2 2/sub &&
+ cd 2 && git init && cd ..
+'
+
+test_expect_success '#2: at root' '
+ cat >2/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/2/.git
+setup: worktree: $TRASH_DIRECTORY/2
+setup: cwd: $TRASH_DIRECTORY/2
+setup: prefix: (null)
+EOF
+ test_repo 2 "$TRASH_DIRECTORY/2/.git"
+'
+
+test_expect_success '#2: in subdir' '
+ cat >2/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/2/.git
+setup: worktree: $TRASH_DIRECTORY/2/sub
+setup: cwd: $TRASH_DIRECTORY/2/sub
+setup: prefix: (null)
+EOF
+ test_repo 2/sub "$TRASH_DIRECTORY/2/.git"
+'
+
+test_expect_success '#2: relative GIT_DIR at root' '
+ cat >2/expected <<EOF &&
+setup: git_dir: .git
+setup: worktree: $TRASH_DIRECTORY/2
+setup: cwd: $TRASH_DIRECTORY/2
+setup: prefix: (null)
+EOF
+ test_repo 2 .git
+'
+
+test_expect_success '#2: relative GIT_DIR in subdir' '
+ cat >2/sub/expected <<EOF &&
+setup: git_dir: ../.git
+setup: worktree: $TRASH_DIRECTORY/2/sub
+setup: cwd: $TRASH_DIRECTORY/2/sub
+setup: prefix: (null)
+EOF
+ test_repo 2/sub ../.git
+'
+
test_done