summaryrefslogtreecommitdiff
path: root/t/t1510-repo-setup.sh
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-11-26 15:32:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-11-29 21:25:54 (GMT)
commit7194660205c39b39badcf555eb76200a80295814 (patch)
tree409cc9708708c21053e20ff63c5e4130f43588e7 /t/t1510-repo-setup.sh
parent8fbee484a8ee0f00096571aff92c253ec39f28c2 (diff)
downloadgit-7194660205c39b39badcf555eb76200a80295814.zip
git-7194660205c39b39badcf555eb76200a80295814.tar.gz
git-7194660205c39b39badcf555eb76200a80295814.tar.bz2
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/t1510-repo-setup.sh')
-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 9324d3f..74750b8 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