--- t/t1510-repo-setup.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 63 insertions(+), 0 deletions(-) diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index d450b4a..20ad6d4 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -139,4 +139,67 @@ EOF GIT_WORK_TREE=non-existent test_repo 1/sub ' +# +# case #2 +# +############################################################ +# +# Input: +# +# - GIT_WORK_TREE is not set +# - GIT_DIR is set +# - core.worktree is not set +# - .git is a directory +# - core.bare is not set, cwd is outside .git +# +# Output: +# +# - worktree is at original cwd +# - cwd is unchanged +# - prefix is NULL +# - git_dir is set to $GIT_DIR +# - cwd can't be outside worktree + +test_expect_success '#2: setup' ' + unset GIT_DIR GIT_WORK_TREE && + mkdir 2 2/sub && + cd 2 && git init && cd .. +' + +test_expect_success '#2: at root' ' + cat >2/expected <<EOF && +$TRASH_DIRECTORY/2/.git +$TRASH_DIRECTORY/2 +$TRASH_DIRECTORY/2 +EOF + GIT_DIR="$TRASH_DIRECTORY/2/.git" test_repo 2 +' + +test_expect_success '#2: in subdir' ' + cat >2/sub/expected <<EOF && +$TRASH_DIRECTORY/2/.git +$TRASH_DIRECTORY/2/sub +$TRASH_DIRECTORY/2/sub +EOF + GIT_DIR="$TRASH_DIRECTORY/2/.git" test_repo 2/sub +' + +test_expect_success '#2: relative GIT_DIR at root' ' + cat >2/expected <<EOF && +.git +$TRASH_DIRECTORY/2 +$TRASH_DIRECTORY/2 +EOF + GIT_DIR=.git test_repo 2 +' + +test_expect_success '#2: relative GIT_DIR in subdir' ' + cat >2/sub/expected <<EOF && +../.git +$TRASH_DIRECTORY/2/sub +$TRASH_DIRECTORY/2/sub +EOF + GIT_DIR=../.git test_repo 2/sub +' + 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