config.c: remove current_parsing_scope
[git.git] / t / t2300-cd-to-toplevel.sh
blobb40eeb263fe896a9553ef93f82e8a78b1dc2fb60
1 #!/bin/sh
3 test_description='cd_to_toplevel'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 EXEC_PATH="$(git --exec-path)"
9 test_have_prereq !MINGW ||
10 case "$EXEC_PATH" in
11 [A-Za-z]:/*)
12 EXEC_PATH="/${EXEC_PATH%%:*}${EXEC_PATH#?:}"
14 esac
16 test_cd_to_toplevel () {
17 test_expect_success $3 "$2" '
19 cd '"'$1'"' &&
20 PATH="$EXEC_PATH:$PATH" &&
21 . git-sh-setup &&
22 cd_to_toplevel &&
23 [ "$(pwd -P)" = "$TOPLEVEL" ]
28 TOPLEVEL="$(pwd -P)/repo"
29 mkdir -p repo/sub/dir
30 mv .git repo/
31 SUBDIRECTORY_OK=1
33 test_cd_to_toplevel repo 'at physical root'
35 test_cd_to_toplevel repo/sub/dir 'at physical subdir'
37 ln -s repo symrepo 2>/dev/null
38 test_cd_to_toplevel symrepo 'at symbolic root' SYMLINKS
40 ln -s repo/sub/dir subdir-link 2>/dev/null
41 test_cd_to_toplevel subdir-link 'at symbolic subdir' SYMLINKS
43 cd repo
44 ln -s sub/dir internal-link 2>/dev/null
45 test_cd_to_toplevel internal-link 'at internal symbolic subdir' SYMLINKS
47 test_done