From fc4045ee3eae49c829a466752da1937cfa13e048 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Fri, 26 Nov 2010 22:31:59 +0700 Subject: [PATCH] t1510: setup case #0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- t/t1510-repo-setup.sh | 53 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh index d19b9c8e8..26842274a 100755 --- a/t/t1510-repo-setup.sh +++ b/t/t1510-repo-setup.sh @@ -41,8 +41,10 @@ test_description='Tests of cwd/prefix/worktree/gitdir setup in all cases' test_repo() { ( - if test -n "$1"; then cd "$1"; fi && - if test -f trace; then rm trace; fi && + cd "$1" && + if test -n "$2"; then GIT_DIR="$2" && export GIT_DIR; fi && + if test -n "$3"; then GIT_WORK_TREE="$3" && export GIT_WORK_TREE; fi && + rm -f trace && GIT_TRACE="`pwd`/trace" git symbolic-ref HEAD >/dev/null && grep '^setup: ' trace >result && test_cmp expected result @@ -56,4 +58,51 @@ test_repo() { # Bit 4 = bare repo # Case# = encoding of the above 5 bits +# +# Case #0 +# +############################################################ +# +# Input: +# +# - GIT_WORK_TREE is not set +# - GIT_DIR is not set +# - core.worktree is not set +# - .git is a directory +# - core.bare is not set, cwd is outside .git +# +# Output: +# +# - worktree is .git's parent directory +# - cwd is at worktree root dir +# - prefix is calculated +# - git_dir is set to ".git" +# - cwd can't be outside worktree + +test_expect_success '#0: setup' ' + unset GIT_DIR GIT_WORK_TREE && + mkdir 0 0/sub && + cd 0 && git init && cd .. +' + +test_expect_success '#0: at root' ' + cat >0/expected <0/sub/expected <