Thread (23 messages) flat view 23 messages, 3 authors, 2016-06-15
DORMANTno replies

[WIP PATCH 09/18] t1510: setup case #6

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 22:49:52
Subsystem: the rest · Maintainer: Linus Torvalds

---
 t/t1510-repo-setup.sh |  279 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 279 insertions(+), 0 deletions(-)
diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 87db2c6..7e902b0 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -723,4 +723,283 @@ EOF
 	test_repo 5
 '
 
+#
+# case #6
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is 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 at $GIT_DIR
+#  - cwd can be outside worktree
+
+test_expect_success '#6: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 6 6/sub 6/sub/sub 6.wt 6.wt/sub 6/wt 6/wt/sub &&
+	cd 6 && git init && cd ..
+'
+
+test_expect_success '#6: GIT_DIR(rel), GIT_WORK_TREE at root' '
+	cat >6/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR(rel), GIT_WORK_TREE(rel) at root' '
+	cat >6/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE(rel) at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_failure '#6: GIT_DIR(rel), GIT_WORKTREE in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_failure '#6: GIT_DIR(rel), GIT_WORKTREE(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORKTREE in subdir' '
+	cat >6/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORKTREE(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6
+$TRASH_DIRECTORY/6
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+	cat >6/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+	cat >6/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE=wt at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY/6/wt
+$TRASH_DIRECTORY/6/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub/sub
+'
+
+test_expect_failure '#6: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+	cat >6/expected <<EOF &&
+6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+6/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_failure '#6: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+	cat >6/expected <<EOF &&
+6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+6/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../../ &&
+	GIT_DIR=.git test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+6/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../../ &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE=.. at root' '
+	cat >6/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+6/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6
+'
+
+test_expect_failure '#6: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+6/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_failure '#6: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+6/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../.. &&
+	GIT_DIR=../../.git test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+6/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../.. &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub/sub
+'
+
+test_expect_success '#6: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+	cat >6/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/6/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+6/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR="$TRASH_DIRECTORY/6/.git" test_repo 6/sub/sub
+'
+
 test_done
-- 
1.7.0.2.445.gcbdb3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help