t1510: setup case #21
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Nov 26, 2010 at 22:32 UTC
21b3466f59847165a5f58208e94b832b448e5cb6
1 file changed
+130
t/t1510-repo-setup.sh
+130
@@ -2954,4 +2954,134 @@ EOF
2954
test_repo 20/sub
2955
'
2956
2957
+#
2958
+# case #21.1
2959
+#
2960
+############################################################
2961
+#
2962
+# Input:
2963
+#
2964
+# - GIT_WORK_TREE is set
2965
+# - GIT_DIR is not set
2966
+# - core.worktree is set
2967
+# - .git is a directory
2968
+# - cwd is inside .git
2969
+#
2970
+# Output:
2971
+#
2972
+# GIT_WORK_TREE/core.worktree are ignored -> #20.1
2973
+
2974
+test_expect_success '#21.1: setup' '
2975
+ unset GIT_DIR GIT_WORK_TREE &&
2976
+ mkdir 21 21/sub &&
2977
+ cd 21 &&
2978
+ git init &&
2979
+ git config core.worktree non-existent &&
2980
+ GIT_WORK_TREE=non-existent-too &&
2981
+ export GIT_WORK_TREE &&
2982
+ mkdir .git/wt .git/wt/sub &&
2983
+ cd ..
2984
+'
2985
+
2986
+test_expect_failure '#21.1: at .git' '
2987
+ cat >21/.git/expected <<EOF &&
2988
+setup: git_dir: .
2989
+setup: worktree: (null)
2990
+setup: cwd: $TRASH_DIRECTORY/21/.git
2991
+setup: prefix: (null)
2992
+EOF
2993
+ test_repo 21/.git
2994
+'
2995
+
2996
+test_expect_failure '#21.1: in .git/wt' '
2997
+ cat >21/.git/wt/expected <<EOF &&
2998
+setup: git_dir: $TRASH_DIRECTORY/21/.git
2999
+setup: worktree: (null)
3000
+setup: cwd: $TRASH_DIRECTORY/21/.git/wt
3001
+setup: prefix: (null)
3002
+EOF
3003
+ test_repo 21/.git/wt
3004
+'
3005
+
3006
+test_expect_failure '#21.1: in .git/wt/sub' '
3007
+ cat >21/.git/wt/sub/expected <<EOF &&
3008
+setup: git_dir: $TRASH_DIRECTORY/21/.git
3009
+setup: worktree: (null)
3010
+setup: cwd: $TRASH_DIRECTORY/21/.git/wt/sub
3011
+setup: prefix: (null)
3012
+EOF
3013
+ test_repo 21/.git/wt/sub
3014
+'
3015
+
3016
+#
3017
+# case #21.2
3018
+#
3019
+############################################################
3020
+#
3021
+# Input:
3022
+#
3023
+# - GIT_WORK_TREE is set
3024
+# - GIT_DIR is not set
3025
+# - core.worktree is set
3026
+# - .git is a directory
3027
+# - core.bare is set
3028
+#
3029
+# Output:
3030
+#
3031
+# GIT_WORK_TREE/core.worktree are ignored -> #20.2
3032
+
3033
+test_expect_success '#21.2: setup' '
3034
+ git config --file="$TRASH_DIRECTORY/21/.git/config" core.bare true
3035
+'
3036
+
3037
+test_expect_failure '#21.2: at .git' '
3038
+ cat >21/.git/expected <<EOF &&
3039
+setup: git_dir: .
3040
+setup: worktree: (null)
3041
+setup: cwd: $TRASH_DIRECTORY/21/.git
3042
+setup: prefix: (null)
3043
+EOF
3044
+ test_repo 21/.git
3045
+'
3046
+
3047
+test_expect_failure '#21.2: in .git/wt' '
3048
+ cat >21/.git/wt/expected <<EOF &&
3049
+setup: git_dir: $TRASH_DIRECTORY/21/.git
3050
+setup: worktree: (null)
3051
+setup: cwd: $TRASH_DIRECTORY/21/.git/wt
3052
+setup: prefix: (null)
3053
+EOF
3054
+ test_repo 21/.git/wt
3055
+'
3056
+
3057
+test_expect_failure '#21.2: in .git/wt/sub' '
3058
+ cat >21/.git/wt/sub/expected <<EOF &&
3059
+setup: git_dir: $TRASH_DIRECTORY/21/.git
3060
+setup: worktree: (null)
3061
+setup: cwd: $TRASH_DIRECTORY/21/.git/wt/sub
3062
+setup: prefix: (null)
3063
+EOF
3064
+ test_repo 21/.git/wt/sub
3065
+'
3066
+
3067
+test_expect_failure '#21.2: at root' '
3068
+ cat >21/expected <<EOF &&
3069
+setup: git_dir: .git
3070
+setup: worktree: (null)
3071
+setup: cwd: $TRASH_DIRECTORY/21
3072
+setup: prefix: (null)
3073
+EOF
3074
+ test_repo 21
3075
+'
3076
+
3077
+test_expect_failure '#21.2: in subdir' '
3078
+ cat >21/sub/expected <<EOF &&
3079
+setup: git_dir: $TRASH_DIRECTORY/21/.git
3080
+setup: worktree: (null)
3081
+setup: cwd: $TRASH_DIRECTORY/21/sub
3082
+setup: prefix: (null)
3083
+EOF
3084
+ test_repo 21/sub
3085
+'
3086
+
3087
test_done