[PATCH v2 2/4] t1500-rev-parse: add tests executed from sub path of the main worktree
From: Michael Rappazzo <hidden>
Date: 2016-06-16 02:18:55
Subsystem:
the rest · Maintainer:
Linus Torvalds
Signed-off-by: Michael Rappazzo <redacted> --- t/t1500-rev-parse.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 48ee077..1e220f7 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh@@ -36,6 +36,7 @@ test_rev_parse() { # label is-bare is-inside-git is-inside-work prefix git-dir ROOT=$(pwd) +original_core_bare=$(git config core.bare) test_rev_parse toplevel false false true '' .git
@@ -84,4 +85,40 @@ test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false false '' git config --unset core.bare test_rev_parse 'GIT_DIR=../repo.git, core.bare undefined' false false true '' +#cleanup from the above +cd .. +rm -r work +mv repo.git .git || exit 1 +unset GIT_DIR +unset GIT_CONFIG +git config core.bare $original_core_bare + +test_expect_success 'git-common-dir from worktree root' ' + echo .git >expect && + git rev-parse --git-common-dir >actual && + test_cmp expect actual +' + +test_expect_success 'git-common-dir inside sub-dir' ' + mkdir -p path/to/child && + test_when_finished "rm -rf path" && + echo "$(git -C path/to/child rev-parse --show-cdup).git" >expect && + git -C path/to/child rev-parse --git-common-dir >actual && + test_cmp expect actual +' + +test_expect_success 'git-path from worktree root' ' + echo .git/objects >expect && + git rev-parse --git-path objects >actual && + test_cmp expect actual +' + +test_expect_success 'git-path inside sub-dir' ' + mkdir -p path/to/child && + test_when_finished "rm -rf path" && + echo "$(git -C path/to/child rev-parse --show-cdup).git/objects" >expect && + git -C path/to/child rev-parse --git-path objects >actual && + test_cmp expect actual +' + test_done
--
2.8.0