]>
Commit | Line | Data |
---|---|---|
08fc0608 MC |
1 | #!/bin/sh |
2 | ||
3 | test_description='cd_to_toplevel' | |
4 | ||
288a4806 | 5 | TEST_PASSES_SANITIZE_LEAK=true |
08fc0608 MC |
6 | . ./test-lib.sh |
7 | ||
412b9a16 JS |
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#?:}" | |
13 | ;; | |
14 | esac | |
15 | ||
08fc0608 | 16 | test_cd_to_toplevel () { |
704a3143 | 17 | test_expect_success $3 "$2" ' |
08fc0608 MC |
18 | ( |
19 | cd '"'$1'"' && | |
412b9a16 | 20 | PATH="$EXEC_PATH:$PATH" && |
fe17fc00 | 21 | . git-sh-setup && |
08fc0608 | 22 | cd_to_toplevel && |
2c3c395e | 23 | [ "$(pwd -P)" = "$TOPLEVEL" ] |
08fc0608 MC |
24 | ) |
25 | ' | |
26 | } | |
27 | ||
2c3c395e | 28 | TOPLEVEL="$(pwd -P)/repo" |
08fc0608 MC |
29 | mkdir -p repo/sub/dir |
30 | mv .git repo/ | |
31 | SUBDIRECTORY_OK=1 | |
32 | ||
33 | test_cd_to_toplevel repo 'at physical root' | |
34 | ||
35 | test_cd_to_toplevel repo/sub/dir 'at physical subdir' | |
36 | ||
704a3143 JS |
37 | ln -s repo symrepo 2>/dev/null |
38 | test_cd_to_toplevel symrepo 'at symbolic root' SYMLINKS | |
08fc0608 | 39 | |
704a3143 JS |
40 | ln -s repo/sub/dir subdir-link 2>/dev/null |
41 | test_cd_to_toplevel subdir-link 'at symbolic subdir' SYMLINKS | |
08fc0608 MC |
42 | |
43 | cd repo | |
704a3143 JS |
44 | ln -s sub/dir internal-link 2>/dev/null |
45 | test_cd_to_toplevel internal-link 'at internal symbolic subdir' SYMLINKS | |
08fc0608 MC |
46 | |
47 | test_done |