]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2300-cd-to-toplevel.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/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
412b9a16
JS
7EXEC_PATH="$(git --exec-path)"
8test_have_prereq !MINGW ||
9case "$EXEC_PATH" in
10[A-Za-z]:/*)
11 EXEC_PATH="/${EXEC_PATH%%:*}${EXEC_PATH#?:}"
12 ;;
13esac
14
08fc0608 15test_cd_to_toplevel () {
704a3143 16 test_expect_success $3 "$2" '
08fc0608
MC
17 (
18 cd '"'$1'"' &&
412b9a16 19 PATH="$EXEC_PATH:$PATH" &&
fe17fc00 20 . git-sh-setup &&
08fc0608 21 cd_to_toplevel &&
2c3c395e 22 [ "$(pwd -P)" = "$TOPLEVEL" ]
08fc0608
MC
23 )
24 '
25}
26
2c3c395e 27TOPLEVEL="$(pwd -P)/repo"
08fc0608
MC
28mkdir -p repo/sub/dir
29mv .git repo/
30SUBDIRECTORY_OK=1
31
32test_cd_to_toplevel repo 'at physical root'
33
34test_cd_to_toplevel repo/sub/dir 'at physical subdir'
35
704a3143
JS
36ln -s repo symrepo 2>/dev/null
37test_cd_to_toplevel symrepo 'at symbolic root' SYMLINKS
08fc0608 38
704a3143
JS
39ln -s repo/sub/dir subdir-link 2>/dev/null
40test_cd_to_toplevel subdir-link 'at symbolic subdir' SYMLINKS
08fc0608
MC
41
42cd repo
704a3143
JS
43ln -s sub/dir internal-link 2>/dev/null
44test_cd_to_toplevel internal-link 'at internal symbolic subdir' SYMLINKS
08fc0608
MC
45
46test_done