]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2300-cd-to-toplevel.sh
Start the 2.46 cycle
[thirdparty/git.git] / t / t2300-cd-to-toplevel.sh
CommitLineData
08fc0608
MC
1#!/bin/sh
2
3test_description='cd_to_toplevel'
4
288a4806 5TEST_PASSES_SANITIZE_LEAK=true
08fc0608
MC
6. ./test-lib.sh
7
412b9a16
JS
8EXEC_PATH="$(git --exec-path)"
9test_have_prereq !MINGW ||
10case "$EXEC_PATH" in
11[A-Za-z]:/*)
12 EXEC_PATH="/${EXEC_PATH%%:*}${EXEC_PATH#?:}"
13 ;;
14esac
15
08fc0608 16test_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 28TOPLEVEL="$(pwd -P)/repo"
08fc0608
MC
29mkdir -p repo/sub/dir
30mv .git repo/
31SUBDIRECTORY_OK=1
32
33test_cd_to_toplevel repo 'at physical root'
34
35test_cd_to_toplevel repo/sub/dir 'at physical subdir'
36
704a3143
JS
37ln -s repo symrepo 2>/dev/null
38test_cd_to_toplevel symrepo 'at symbolic root' SYMLINKS
08fc0608 39
704a3143
JS
40ln -s repo/sub/dir subdir-link 2>/dev/null
41test_cd_to_toplevel subdir-link 'at symbolic subdir' SYMLINKS
08fc0608
MC
42
43cd repo
704a3143
JS
44ln -s sub/dir internal-link 2>/dev/null
45test_cd_to_toplevel internal-link 'at internal symbolic subdir' SYMLINKS
08fc0608
MC
46
47test_done