Merge branch 'jc/t2300-setup'
[git/git.git] / t / t2300-cd-to-toplevel.sh
CommitLineData
08fc0608
MC
1#!/bin/sh
2
3test_description='cd_to_toplevel'
4
5. ./test-lib.sh
6
7test_cd_to_toplevel () {
704a3143 8 test_expect_success $3 "$2" '
08fc0608
MC
9 (
10 cd '"'$1'"' &&
fe17fc00
JH
11 PATH="$(git --exec-path):$PATH" &&
12 . git-sh-setup &&
08fc0608 13 cd_to_toplevel &&
2c3c395e 14 [ "$(pwd -P)" = "$TOPLEVEL" ]
08fc0608
MC
15 )
16 '
17}
18
2c3c395e 19TOPLEVEL="$(pwd -P)/repo"
08fc0608
MC
20mkdir -p repo/sub/dir
21mv .git repo/
22SUBDIRECTORY_OK=1
23
24test_cd_to_toplevel repo 'at physical root'
25
26test_cd_to_toplevel repo/sub/dir 'at physical subdir'
27
704a3143
JS
28ln -s repo symrepo 2>/dev/null
29test_cd_to_toplevel symrepo 'at symbolic root' SYMLINKS
08fc0608 30
704a3143
JS
31ln -s repo/sub/dir subdir-link 2>/dev/null
32test_cd_to_toplevel subdir-link 'at symbolic subdir' SYMLINKS
08fc0608
MC
33
34cd repo
704a3143
JS
35ln -s sub/dir internal-link 2>/dev/null
36test_cd_to_toplevel internal-link 'at internal symbolic subdir' SYMLINKS
08fc0608
MC
37
38test_done