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

[WIP PATCH 17/18] t1510: setup case #14

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 2a69a78..5c1b96e 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -1945,4 +1945,283 @@ EOF
 	test_repo 13
 '
 
+#
+# case #14
+#
+############################################################
+#
+# Input:
+#
+#  - GIT_WORK_TREE is not set
+#  - GIT_DIR is set
+#  - core.worktree is set
+#  - .git is a file
+#  - core.bare is not set, cwd is outside .git
+#
+# Output:
+#
+# same as case #6 except that git_dir is set by .git file
+
+test_expect_success '#14: setup' '
+	unset GIT_DIR GIT_WORK_TREE &&
+	mkdir 14 14/sub 14/sub/sub 14.wt 14.wt/sub 14/wt 14/wt/sub &&
+	cd 14 &&
+	git init &&
+	mv .git ../14.git &&
+	echo gitdir: ../14.git >.git &&
+	cd ..
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORK_TREE at root' '
+	cat >14/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORK_TREE(rel) at root' '
+	cat >14/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE(rel) at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORKTREE in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORKTREE(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORKTREE in subdir' '
+	cat >14/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORKTREE(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14
+$TRASH_DIRECTORY/14
+sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
+	cat >14/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
+	cat >14/expected <<EOF &&
+.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../wt &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../wt &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE=wt at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+../../.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../wt &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../wt &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY/14/wt
+$TRASH_DIRECTORY/14/sub/sub
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
+	cat >14/expected <<EOF &&
+14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+14/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
+	cat >14/expected <<EOF &&
+14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+14/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../../ &&
+	GIT_DIR=.git test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+14/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../../ &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE=.. at root' '
+	cat >14/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+14/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+14/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+14/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../.. &&
+	GIT_DIR=../../.git test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+14/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../.. &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/sub/sub
+'
+
+test_expect_failure '#14: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
+	cat >14/sub/sub/expected <<EOF &&
+$TRASH_DIRECTORY/14/.git
+$TRASH_DIRECTORY
+$TRASH_DIRECTORY
+14/sub/sub/
+EOF
+	git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+	GIT_DIR="$TRASH_DIRECTORY/14/.git" test_repo 14/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