Skip to content

Commit 4a00884

Browse files
pcloudsgitster
authored andcommitted
t1510: setup case #20
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 09327fd commit 4a00884

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

t/t1510-repo-setup.sh

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,4 +2826,132 @@ EOF
28262826
test_repo 19/sub/sub "$TRASH_DIRECTORY/19/.git" "$TRASH_DIRECTORY"
28272827
'
28282828

2829+
#
2830+
# case #20.1
2831+
#
2832+
############################################################
2833+
#
2834+
# Input:
2835+
#
2836+
# - GIT_WORK_TREE is not set
2837+
# - GIT_DIR is not set
2838+
# - core.worktree is set
2839+
# - .git is a directory
2840+
# - cwd is inside .git
2841+
#
2842+
# Output:
2843+
#
2844+
# core.worktree is ignored -> #16.1
2845+
2846+
test_expect_success '#20.1: setup' '
2847+
unset GIT_DIR GIT_WORK_TREE &&
2848+
mkdir 20 20/sub &&
2849+
cd 20 &&
2850+
git init &&
2851+
git config core.worktree non-existent &&
2852+
mkdir .git/wt .git/wt/sub &&
2853+
cd ..
2854+
'
2855+
2856+
test_expect_failure '#20.1: at .git' '
2857+
cat >20/.git/expected <<EOF &&
2858+
setup: git_dir: .
2859+
setup: worktree: (null)
2860+
setup: cwd: $TRASH_DIRECTORY/20/.git
2861+
setup: prefix: (null)
2862+
EOF
2863+
test_repo 20/.git
2864+
'
2865+
2866+
test_expect_failure '#20.1: in .git/wt' '
2867+
cat >20/.git/wt/expected <<EOF &&
2868+
setup: git_dir: $TRASH_DIRECTORY/20/.git
2869+
setup: worktree: (null)
2870+
setup: cwd: $TRASH_DIRECTORY/20/.git/wt
2871+
setup: prefix: (null)
2872+
EOF
2873+
test_repo 20/.git/wt
2874+
'
2875+
2876+
test_expect_failure '#20.1: in .git/wt/sub' '
2877+
cat >20/.git/wt/sub/expected <<EOF &&
2878+
setup: git_dir: $TRASH_DIRECTORY/20/.git
2879+
setup: worktree: (null)
2880+
setup: cwd: $TRASH_DIRECTORY/20/.git/wt/sub
2881+
setup: prefix: (null)
2882+
EOF
2883+
test_repo 20/.git/wt/sub
2884+
'
2885+
2886+
#
2887+
# case #20.2
2888+
#
2889+
############################################################
2890+
#
2891+
# Input:
2892+
#
2893+
# - GIT_WORK_TREE is not set
2894+
# - GIT_DIR is not set
2895+
# - core.worktree is set
2896+
# - .git is a directory
2897+
# - core.bare is set
2898+
#
2899+
# Output:
2900+
#
2901+
# core.worktree is ignored -> #16.2
2902+
2903+
test_expect_success '#20.2: setup' '
2904+
git config --file="$TRASH_DIRECTORY/20/.git/config" core.bare true
2905+
'
2906+
2907+
test_expect_success '#20.2: at .git' '
2908+
cat >20/.git/expected <<EOF &&
2909+
setup: git_dir: .
2910+
setup: worktree: (null)
2911+
setup: cwd: $TRASH_DIRECTORY/20/.git
2912+
setup: prefix: (null)
2913+
EOF
2914+
test_repo 20/.git
2915+
'
2916+
2917+
test_expect_success '#20.2: in .git/wt' '
2918+
cat >20/.git/wt/expected <<EOF &&
2919+
setup: git_dir: $TRASH_DIRECTORY/20/.git
2920+
setup: worktree: (null)
2921+
setup: cwd: $TRASH_DIRECTORY/20/.git/wt
2922+
setup: prefix: (null)
2923+
EOF
2924+
test_repo 20/.git/wt
2925+
'
2926+
2927+
test_expect_success '#20.2: in .git/wt/sub' '
2928+
cat >20/.git/wt/sub/expected <<EOF &&
2929+
setup: git_dir: $TRASH_DIRECTORY/20/.git
2930+
setup: worktree: (null)
2931+
setup: cwd: $TRASH_DIRECTORY/20/.git/wt/sub
2932+
setup: prefix: (null)
2933+
EOF
2934+
test_repo 20/.git/wt/sub
2935+
'
2936+
2937+
test_expect_success '#20.2: at root' '
2938+
cat >20/expected <<EOF &&
2939+
setup: git_dir: .git
2940+
setup: worktree: (null)
2941+
setup: cwd: $TRASH_DIRECTORY/20
2942+
setup: prefix: (null)
2943+
EOF
2944+
test_repo 20
2945+
'
2946+
2947+
test_expect_failure '#20.2: in subdir' '
2948+
cat >20/sub/expected <<EOF &&
2949+
setup: git_dir: $TRASH_DIRECTORY/20/.git
2950+
setup: worktree: (null)
2951+
setup: cwd: $TRASH_DIRECTORY/20/sub
2952+
setup: prefix: (null)
2953+
EOF
2954+
test_repo 20/sub
2955+
'
2956+
28292957
test_done

0 commit comments

Comments
 (0)