Signed-off-by: Nguyán ThÃi Ngác Duy <pclouds@xxxxxxxxx> --- t/t1510-repo-setup.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index 0ff659a..bf008c6 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -149,4 +149,71 @@ EOF 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 && +setup: git_dir: $TRASH_DIRECTORY/2/.git +setup: worktree: $TRASH_DIRECTORY/2 +setup: cwd: $TRASH_DIRECTORY/2 +setup: prefix: (null) +EOF + GIT_DIR="$TRASH_DIRECTORY/2/.git" test_repo 2 +' + +test_expect_success '#2: in subdir' ' + cat >2/sub/expected <<EOF && +setup: git_dir: $TRASH_DIRECTORY/2/.git +setup: worktree: $TRASH_DIRECTORY/2/sub +setup: cwd: $TRASH_DIRECTORY/2/sub +setup: prefix: (null) +EOF + GIT_DIR="$TRASH_DIRECTORY/2/.git" test_repo 2/sub +' + +test_expect_success '#2: relative GIT_DIR at root' ' + cat >2/expected <<EOF && +setup: git_dir: .git +setup: worktree: $TRASH_DIRECTORY/2 +setup: cwd: $TRASH_DIRECTORY/2 +setup: prefix: (null) +EOF + GIT_DIR=.git test_repo 2 +' + +test_expect_success '#2: relative GIT_DIR in subdir' ' + cat >2/sub/expected <<EOF && +setup: git_dir: ../.git +setup: worktree: $TRASH_DIRECTORY/2/sub +setup: cwd: $TRASH_DIRECTORY/2/sub +setup: prefix: (null) +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