t2300: run git-sh-setup in an environment that better mimics the real life
[git/git-svn.git] / t / t2300-cd-to-toplevel.sh
blobcccd7d923aae118b3f80aa52763648a2b4b189f2
1 #!/bin/sh
3 test_description='cd_to_toplevel'
5 . ./test-lib.sh
7 test_cd_to_toplevel () {
8 test_expect_success $3 "$2" '
10 cd '"'$1'"' &&
11 PATH="$(git --exec-path):$PATH" &&
12 . git-sh-setup &&
13 cd_to_toplevel &&
14 [ "$(pwd -P)" = "$TOPLEVEL" ]
19 TOPLEVEL="$(pwd -P)/repo"
20 mkdir -p repo/sub/dir
21 mv .git repo/
22 SUBDIRECTORY_OK=1
24 test_cd_to_toplevel repo 'at physical root'
26 test_cd_to_toplevel repo/sub/dir 'at physical subdir'
28 ln -s repo symrepo 2>/dev/null
29 test_cd_to_toplevel symrepo 'at symbolic root' SYMLINKS
31 ln -s repo/sub/dir subdir-link 2>/dev/null
32 test_cd_to_toplevel subdir-link 'at symbolic subdir' SYMLINKS
34 cd repo
35 ln -s sub/dir internal-link 2>/dev/null
36 test_cd_to_toplevel internal-link 'at internal symbolic subdir' SYMLINKS
38 test_done