--- t/t1510-repo-setup.sh | 135 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 135 insertions(+), 0 deletions(-) diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index ee2b02a..87db2c6 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -588,4 +588,139 @@ EOF test_repo 4 ' +# +# case #5 +# +############################################################ +# +# Input: +# +# - GIT_WORK_TREE is set +# - GIT_DIR is not set +# - core.worktree is set +# - .git is a directory +# - core.bare is not set, cwd is outside .git +# +# Output: +# +# GIT_WORK_TREE is only effective when GIT_DIR is +# set, which is not the case. So it is the same as case #4. +# +# - worktree is at core.worktree +# - cwd is at worktree root +# - prefix is calculated +# - git_dir is discovered +# - cwd can be outside worktree + +test_expect_success '#5: setup' ' + unset GIT_DIR GIT_WORK_TREE && + mkdir 5 5/sub 5/sub/sub 5.wt 5.wt/sub 5/wt 5/wt/sub && + cd 5 && git init && cd .. && + export GIT_WORK_TREE=non-existent +' + +test_expect_failure '#5: core.worktree(rel), at root' ' + cat >5/expected <<EOF && +.git +$TRASH_DIRECTORY/5 +$TRASH_DIRECTORY/5 +EOF + git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree .. && + test_repo 5 +' + +test_expect_failure '#5: core.worktree, at root' ' + cat >5/expected <<EOF && +.git +$TRASH_DIRECTORY/5 +$TRASH_DIRECTORY/5 +EOF + git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree "$TRASH_DIRECTORY/5" && + test_repo 5 +' + +test_expect_failure '#5: core.worktree(rel), in subdir' ' + cat >5/sub/sub/expected <<EOF && +.git +$TRASH_DIRECTORY/5 +$TRASH_DIRECTORY/5 +sub/sub/ +EOF + git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree .. && + test_repo 5/sub/sub +' + +test_expect_failure '#5: core.worktree, in subdir' ' + cat >5/sub/sub/expected <<EOF && +.git +$TRASH_DIRECTORY/5 +$TRASH_DIRECTORY/5 +sub/sub/ +EOF + git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree "$TRASH_DIRECTORY/5" && + test_repo 5/sub/sub +' + +test_expect_failure '#5: core.worktree=wt(rel), at root' ' + cat >5/expected <<EOF && +.git +$TRASH_DIRECTORY/5/wt +$TRASH_DIRECTORY/5 +EOF + git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree ../wt && + test_repo 5 +' + +test_expect_failure '#5: core.worktree=wt, at root' ' + cat >5/expected <<EOF && +.git +$TRASH_DIRECTORY/5/wt +$TRASH_DIRECTORY/5 +EOF + git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree "$TRASH_DIRECTORY/5/wt" && + test_repo 5 +' + +test_expect_failure '#5: core.worktree=wt(rel), in subdir' ' + cat >5/sub/sub/expected <<EOF && +../../.git +$TRASH_DIRECTORY/5/wt +$TRASH_DIRECTORY/5/sub/sub +EOF + git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree ../wt && + test_repo 5/sub/sub +' + +test_expect_failure '#5: core.worktree=wt, in subdir' ' + cat >5/sub/sub/expected <<EOF && +../../.git +$TRASH_DIRECTORY/5/wt +$TRASH_DIRECTORY/5/sub/sub +EOF + git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree "$TRASH_DIRECTORY/5/wt" && + test_repo 5/sub/sub +' + +test_expect_failure '#5: core.worktree=..(rel), at root' ' + cat >5/expected <<EOF && +5/.git +$TRASH_DIRECTORY +$TRASH_DIRECTORY +5/ +EOF + git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree ../.. && + test_repo 5 +' + +test_expect_failure '#5: core.worktree=.., at root' ' + cat >5/expected <<EOF && +5/.git +$TRASH_DIRECTORY +$TRASH_DIRECTORY +5/ +EOF + git config --file="$TRASH_DIRECTORY/5/.git/config" core.worktree "$TRASH_DIRECTORY/5" && + test_repo 5 +' + test_done -- 1.7.0.2.445.gcbdb3 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html