Skip to content

Commit 5362cbf

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

File tree

1 file changed

+267
-0
lines changed

1 file changed

+267
-0
lines changed

t/t1510-repo-setup.sh

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3421,4 +3421,271 @@ test_expect_failure '#22.2: at root' '
34213421
)
34223422
'
34233423

3424+
#
3425+
# case #23
3426+
#
3427+
############################################################
3428+
#
3429+
# Input:
3430+
#
3431+
# - GIT_WORK_TREE is set
3432+
# - GIT_DIR is set
3433+
# - core.worktree is set
3434+
# - .git is a directory
3435+
# - core.bare is set
3436+
#
3437+
# Output:
3438+
#
3439+
# core.worktree is overridden by GIT_WORK_TREE -> #19
3440+
3441+
test_expect_success '#23: setup' '
3442+
unset GIT_DIR GIT_WORK_TREE &&
3443+
mkdir 23 23/sub 23/sub/sub 23.wt 23.wt/sub 23/wt 23/wt/sub &&
3444+
cd 23 &&
3445+
git init &&
3446+
git config core.bare true &&
3447+
git config core.worktree non-existent &&
3448+
cd ..
3449+
'
3450+
3451+
test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
3452+
cat >23/expected <<EOF &&
3453+
setup: git_dir: .git
3454+
setup: worktree: $TRASH_DIRECTORY/23
3455+
setup: cwd: $TRASH_DIRECTORY/23
3456+
setup: prefix: (null)
3457+
EOF
3458+
test_repo 23 .git "$TRASH_DIRECTORY/23"
3459+
'
3460+
3461+
test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
3462+
cat >23/expected <<EOF &&
3463+
setup: git_dir: .git
3464+
setup: worktree: $TRASH_DIRECTORY/23
3465+
setup: cwd: $TRASH_DIRECTORY/23
3466+
setup: prefix: (null)
3467+
EOF
3468+
test_repo 23 .git .
3469+
'
3470+
3471+
test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root at root' '
3472+
cat >23/expected <<EOF &&
3473+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3474+
setup: worktree: $TRASH_DIRECTORY/23
3475+
setup: cwd: $TRASH_DIRECTORY/23
3476+
setup: prefix: (null)
3477+
EOF
3478+
test_repo 23 "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY/23"
3479+
'
3480+
3481+
test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
3482+
cat >23/expected <<EOF &&
3483+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3484+
setup: worktree: $TRASH_DIRECTORY/23
3485+
setup: cwd: $TRASH_DIRECTORY/23
3486+
setup: prefix: (null)
3487+
EOF
3488+
test_repo 23 "$TRASH_DIRECTORY/23/.git" .
3489+
'
3490+
3491+
test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
3492+
cat >23/sub/sub/expected <<EOF &&
3493+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3494+
setup: worktree: $TRASH_DIRECTORY/23
3495+
setup: cwd: $TRASH_DIRECTORY/23
3496+
setup: prefix: sub/sub/
3497+
EOF
3498+
test_repo 23/sub/sub ../../.git "$TRASH_DIRECTORY/23"
3499+
'
3500+
3501+
test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
3502+
cat >23/sub/sub/expected <<EOF &&
3503+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3504+
setup: worktree: $TRASH_DIRECTORY/23
3505+
setup: cwd: $TRASH_DIRECTORY/23
3506+
setup: prefix: sub/sub/
3507+
EOF
3508+
test_repo 23/sub/sub ../../.git ../..
3509+
'
3510+
3511+
test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root in subdir' '
3512+
cat >23/sub/expected <<EOF &&
3513+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3514+
setup: worktree: $TRASH_DIRECTORY/23
3515+
setup: cwd: $TRASH_DIRECTORY/23
3516+
setup: prefix: sub/
3517+
EOF
3518+
test_repo 23/sub "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY/23"
3519+
'
3520+
3521+
test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
3522+
cat >23/sub/sub/expected <<EOF &&
3523+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3524+
setup: worktree: $TRASH_DIRECTORY/23
3525+
setup: cwd: $TRASH_DIRECTORY/23
3526+
setup: prefix: sub/sub/
3527+
EOF
3528+
test_repo 23/sub/sub "$TRASH_DIRECTORY/23/.git" ../..
3529+
'
3530+
3531+
test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
3532+
cat >23/expected <<EOF &&
3533+
setup: git_dir: .git
3534+
setup: worktree: $TRASH_DIRECTORY/23/wt
3535+
setup: cwd: $TRASH_DIRECTORY/23
3536+
setup: prefix: (null)
3537+
EOF
3538+
test_repo 23 .git "$TRASH_DIRECTORY/23/wt"
3539+
'
3540+
3541+
test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
3542+
cat >23/expected <<EOF &&
3543+
setup: git_dir: .git
3544+
setup: worktree: $TRASH_DIRECTORY/23/wt
3545+
setup: cwd: $TRASH_DIRECTORY/23
3546+
setup: prefix: (null)
3547+
EOF
3548+
test_repo 23 .git wt
3549+
'
3550+
3551+
test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
3552+
cat >23/expected <<EOF &&
3553+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3554+
setup: worktree: $TRASH_DIRECTORY/23/wt
3555+
setup: cwd: $TRASH_DIRECTORY/23
3556+
setup: prefix: (null)
3557+
EOF
3558+
test_repo 23 "$TRASH_DIRECTORY/23/.git" wt
3559+
'
3560+
3561+
test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt at root' '
3562+
cat >23/expected <<EOF &&
3563+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3564+
setup: worktree: $TRASH_DIRECTORY/23/wt
3565+
setup: cwd: $TRASH_DIRECTORY/23
3566+
setup: prefix: (null)
3567+
EOF
3568+
test_repo 23 "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY/23/wt"
3569+
'
3570+
3571+
test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
3572+
cat >23/sub/sub/expected <<EOF &&
3573+
setup: git_dir: ../../.git
3574+
setup: worktree: $TRASH_DIRECTORY/23/wt
3575+
setup: cwd: $TRASH_DIRECTORY/23/sub/sub
3576+
setup: prefix: (null)
3577+
EOF
3578+
test_repo 23/sub/sub ../../.git "$TRASH_DIRECTORY/23/wt"
3579+
'
3580+
3581+
test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
3582+
cat >23/sub/sub/expected <<EOF &&
3583+
setup: git_dir: ../../.git
3584+
setup: worktree: $TRASH_DIRECTORY/23/wt
3585+
setup: cwd: $TRASH_DIRECTORY/23/sub/sub
3586+
setup: prefix: (null)
3587+
EOF
3588+
test_repo 23/sub/sub ../../.git ../../wt
3589+
'
3590+
3591+
test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
3592+
cat >23/sub/sub/expected <<EOF &&
3593+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3594+
setup: worktree: $TRASH_DIRECTORY/23/wt
3595+
setup: cwd: $TRASH_DIRECTORY/23/sub/sub
3596+
setup: prefix: (null)
3597+
EOF
3598+
test_repo 23/sub/sub "$TRASH_DIRECTORY/23/.git" ../../wt
3599+
'
3600+
3601+
test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
3602+
cat >23/sub/sub/expected <<EOF &&
3603+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3604+
setup: worktree: $TRASH_DIRECTORY/23/wt
3605+
setup: cwd: $TRASH_DIRECTORY/23/sub/sub
3606+
setup: prefix: (null)
3607+
EOF
3608+
test_repo 23/sub/sub "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY/23/wt"
3609+
'
3610+
3611+
test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
3612+
cat >23/expected <<EOF &&
3613+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3614+
setup: worktree: $TRASH_DIRECTORY
3615+
setup: cwd: $TRASH_DIRECTORY
3616+
setup: prefix: 23/
3617+
EOF
3618+
test_repo 23 .git "$TRASH_DIRECTORY"
3619+
'
3620+
3621+
test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
3622+
cat >23/expected <<EOF &&
3623+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3624+
setup: worktree: $TRASH_DIRECTORY
3625+
setup: cwd: $TRASH_DIRECTORY
3626+
setup: prefix: 23/
3627+
EOF
3628+
test_repo 23 .git ..
3629+
'
3630+
3631+
test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
3632+
cat >23/expected <<EOF &&
3633+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3634+
setup: worktree: $TRASH_DIRECTORY
3635+
setup: cwd: $TRASH_DIRECTORY
3636+
setup: prefix: 23/
3637+
EOF
3638+
test_repo 23 "$TRASH_DIRECTORY/23/.git" ..
3639+
'
3640+
3641+
test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. at root' '
3642+
cat >23/expected <<EOF &&
3643+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3644+
setup: worktree: $TRASH_DIRECTORY
3645+
setup: cwd: $TRASH_DIRECTORY
3646+
setup: prefix: 23/
3647+
EOF
3648+
test_repo 23 "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY"
3649+
'
3650+
3651+
test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
3652+
cat >23/sub/sub/expected <<EOF &&
3653+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3654+
setup: worktree: $TRASH_DIRECTORY
3655+
setup: cwd: $TRASH_DIRECTORY
3656+
setup: prefix: 23/sub/sub/
3657+
EOF
3658+
test_repo 23/sub/sub ../../.git "$TRASH_DIRECTORY"
3659+
'
3660+
3661+
test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
3662+
cat >23/sub/sub/expected <<EOF &&
3663+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3664+
setup: worktree: $TRASH_DIRECTORY
3665+
setup: cwd: $TRASH_DIRECTORY
3666+
setup: prefix: 23/sub/sub/
3667+
EOF
3668+
test_repo 23/sub/sub ../../.git ../../..
3669+
'
3670+
3671+
test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
3672+
cat >23/sub/sub/expected <<EOF &&
3673+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3674+
setup: worktree: $TRASH_DIRECTORY
3675+
setup: cwd: $TRASH_DIRECTORY
3676+
setup: prefix: 23/sub/sub/
3677+
EOF
3678+
test_repo 23/sub/sub "$TRASH_DIRECTORY/23/.git" ../../../
3679+
'
3680+
3681+
test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
3682+
cat >23/sub/sub/expected <<EOF &&
3683+
setup: git_dir: $TRASH_DIRECTORY/23/.git
3684+
setup: worktree: $TRASH_DIRECTORY
3685+
setup: cwd: $TRASH_DIRECTORY
3686+
setup: prefix: 23/sub/sub/
3687+
EOF
3688+
test_repo 23/sub/sub "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY"
3689+
'
3690+
34243691
test_done

0 commit comments

Comments
 (0)