Code

t1510: setup case #14
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Fri, 26 Nov 2010 15:32:13 +0000 (22:32 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 Nov 2010 21:25:56 +0000 (13:25 -0800)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1510-repo-setup.sh

index b6fdd72374c902abc8cf983450ba80b89e4eff79..53816c9c6f6bb736d90d98666205a5cf0d94def5 100755 (executable)
@@ -1666,4 +1666,295 @@ EOF
        test_repo 13/sub
 '
 
+#
+# 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:
+#
+# #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), core.worktree=../14 at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+       test_repo 14 .git
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14(rel) at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
+       test_repo 14 .git
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../14 at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+       test_repo 14 "$TRASH_DIRECTORY/14/.git"
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../14(rel) at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
+       test_repo 14 "$TRASH_DIRECTORY/14/.git"
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14 in subdir' '
+       cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: sub/sub/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+       test_repo 14/sub/sub ../../.git
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14(rel) in subdir' '
+       cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: sub/sub/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
+       test_repo 14/sub/sub ../../.git
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../14 in subdir' '
+       cat >14/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: sub/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
+       test_repo 14/sub "$TRASH_DIRECTORY/14/.git"
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../14(rel) in subdir' '
+       cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: sub/sub/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
+       test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+       test_repo 14 .git
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
+       test_repo 14 .git
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt(rel) at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
+       test_repo 14 "$TRASH_DIRECTORY/14/.git"
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+       test_repo 14 "$TRASH_DIRECTORY/14/.git"
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt in subdir' '
+       cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14/sub/sub
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+       test_repo 14/sub/sub ../../.git
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) in subdir' '
+       cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14/sub/sub
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
+       test_repo 14/sub/sub ../../.git
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt(rel) in subdir' '
+       cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14/sub/sub
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
+       test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt in subdir' '
+       cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY/14/wt
+setup: cwd: $TRASH_DIRECTORY/14/sub/sub
+setup: prefix: (null)
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
+       test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=.. at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+       test_repo 14 .git
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+       test_repo 14 .git
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=..(rel) at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+       test_repo 14 "$TRASH_DIRECTORY/14/.git"
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=.. at root' '
+       cat >14/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+       test_repo 14 "$TRASH_DIRECTORY/14/.git"
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
+       cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/sub/sub/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+       test_repo 14/sub/sub ../../.git
+'
+
+test_expect_failure '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
+       cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/sub/sub/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+       test_repo 14/sub/sub ../../.git
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
+       cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/sub/sub/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
+       test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
+'
+
+test_expect_failure '#14: GIT_DIR, core.worktree=.. in subdir' '
+       cat >14/sub/sub/expected <<EOF &&
+setup: git_dir: $TRASH_DIRECTORY/14.git
+setup: worktree: $TRASH_DIRECTORY
+setup: cwd: $TRASH_DIRECTORY
+setup: prefix: 14/sub/sub/
+EOF
+       git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
+       test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
+'
+
 test_done