test-lib*.sh: set GIT_CEILING_DIRECTORIES
[topgit/pro.git] / t / t1020-top-bases-sniff-out.sh
blob9b9b9265729ea4de76066558acdd331e05d9faeb
1 #!/bin/sh
3 test_description='tg --top-bases gets the right answer
5 We also use this to test the functionality of the tg -c option.
8 TEST_NO_CREATE_REPO=1
10 . ./test-lib.sh
12 GIT_CEILING_DIRECTORIES="$PWD" && export GIT_CEILING_DIRECTORIES
14 test_plan 7
16 test_expect_success 'test setup' '
17 test_create_repo noset-mt &&
18 test_create_repo noset-refs &&
19 test_create_repo noset-heads &&
20 test_create_repo noset-both &&
21 test_create_repo refs &&
22 test_create_repo heads &&
23 git -C refs config topgit.top-bases refs &&
24 git -C heads config topgit.top-bases heads &&
25 test "$(cd refs && git config topgit.top-bases)" = "refs" &&
26 test "$(cd heads && git config topgit.top-bases)" = "heads" &&
27 test "$(cd noset-mt && git config --get topgit.top-bases)" = "" &&
28 test "$(cd noset-refs && git config --get topgit.top-bases)" = "" &&
29 test "$(cd noset-heads && git config --get topgit.top-bases)" = "" &&
30 test "$(cd noset-both && git config --get topgit.top-bases)" = "" &&
31 (cd noset-refs && test_commit initial) &&
32 (cd noset-heads && test_commit initial) &&
33 (cd noset-both && test_commit initial) &&
34 git -C noset-refs update-ref refs/heads/t/branch master &&
35 git -C noset-refs update-ref refs/top-bases/t/branch master &&
36 git -C noset-heads update-ref refs/heads/t/branch master &&
37 git -C noset-heads update-ref refs/heads/{top-bases}/t/branch master &&
38 git -C noset-both update-ref refs/heads/t/branch master &&
39 git -C noset-both update-ref refs/top-bases/t/branch master &&
40 git -C noset-both update-ref refs/heads/{top-bases}/t/branch master &&
41 git -C noset-refs rev-parse --verify t/branch >/dev/null &&
42 git -C noset-refs rev-parse --verify top-bases/t/branch >/dev/null &&
43 git -C noset-heads rev-parse --verify t/branch >/dev/null &&
44 git -C noset-heads rev-parse --verify {top-bases}/t/branch >/dev/null &&
45 git -C noset-both rev-parse --verify t/branch >/dev/null &&
46 git -C noset-both rev-parse --verify top-bases/t/branch >/dev/null &&
47 git -C noset-both rev-parse --verify {top-bases}/t/branch >/dev/null
50 test_expect_success 'hard-coded refs bases' '
51 test "$(tg -C refs --top-bases)" = "refs/top-bases" &&
52 test "$(tg -C noset-mt -c topgit.top-bases=refs --top-bases)" = "refs/top-bases" &&
53 test "$(tg -C noset-mt -c topgit.top-bases=heads -c topgit.top-bases=refs --top-bases)" = "refs/top-bases"
56 test_expect_success 'hard-coded heads bases' '
57 test "$(tg -C heads --top-bases)" = "refs/heads/{top-bases}" &&
58 test "$(tg -C noset-mt -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}" &&
59 test "$(tg -C noset-mt -c topgit.top-bases=refs -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}"
62 test_expect_success 'both is confusing and override' '
63 test_must_fail tg -C noset-both --top-bases >/dev/null 2>&1 &&
64 test "$(tg -C noset-both -c topgit.top-bases=refs --top-bases)" = "refs/top-bases" &&
65 test "$(tg -C noset-both -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}"
68 test_expect_success 'auto detect refs and override' '
69 test "$(tg -C noset-refs --top-bases)" = "refs/top-bases" &&
70 test "$(tg -C noset-refs -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}"
73 test_expect_success 'auto detect heads and override' '
74 test "$(tg -C noset-heads --top-bases)" = "refs/heads/{top-bases}" &&
75 test "$(tg -C noset-heads -c topgit.top-bases=refs --top-bases)" = "refs/top-bases"
78 test_expect_success 'default is refs until 0.20.0' '
79 test "$(tg -C noset-mt --top-bases)" = "refs/top-bases"
82 test_done