test-lib-functions-tg.sh: introduce TopGit-specific test functions library
[topgit/pro.git] / t / t1020-top-bases-sniff-out.sh
blob10adc065bb69d32de26f4c995dee72f7a1b5aa21
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 test_plan 9
14 test_expect_success 'no repo refs bases default' '
15 test_must_fail tg status >/dev/null 2>&1 &&
16 test "$(tg --top-bases)" = "refs/top-bases"
19 test_expect_success 'no repo hard-coded refs bases' '
20 test_must_fail tg status >/dev/null 2>&1 &&
21 test_must_fail tg -c topgit.top-bases=bad --top-bases &&
22 test "$(tg -c topgit.top-bases=refs --top-bases)" = "refs/top-bases" &&
23 test "$(tg -c topgit.top-bases=heads -c topgit.top-bases=refs --top-bases)" = "refs/top-bases"
26 test_expect_success 'test setup' '
27 test_create_repo noset-mt &&
28 test_create_repo noset-refs &&
29 test_create_repo noset-heads &&
30 test_create_repo noset-both &&
31 test_create_repo refs &&
32 test_create_repo heads &&
33 git -C refs config topgit.top-bases refs &&
34 git -C heads config topgit.top-bases heads &&
35 test "$(cd refs && git config topgit.top-bases)" = "refs" &&
36 test "$(cd heads && git config topgit.top-bases)" = "heads" &&
37 test "$(cd noset-mt && git config --get topgit.top-bases)" = "" &&
38 test "$(cd noset-refs && git config --get topgit.top-bases)" = "" &&
39 test "$(cd noset-heads && git config --get topgit.top-bases)" = "" &&
40 test "$(cd noset-both && git config --get topgit.top-bases)" = "" &&
41 (cd noset-refs && test_commit initial) &&
42 (cd noset-heads && test_commit initial) &&
43 (cd noset-both && test_commit initial) &&
44 git -C noset-refs update-ref refs/heads/t/branch master &&
45 git -C noset-refs update-ref refs/top-bases/t/branch master &&
46 git -C noset-heads update-ref refs/heads/t/branch master &&
47 git -C noset-heads update-ref refs/heads/{top-bases}/t/branch master &&
48 git -C noset-both update-ref refs/heads/t/branch master &&
49 git -C noset-both update-ref refs/top-bases/t/branch master &&
50 git -C noset-both update-ref refs/heads/{top-bases}/t/branch master &&
51 git -C noset-refs rev-parse --verify t/branch >/dev/null &&
52 git -C noset-refs rev-parse --verify top-bases/t/branch >/dev/null &&
53 git -C noset-heads rev-parse --verify t/branch >/dev/null &&
54 git -C noset-heads rev-parse --verify {top-bases}/t/branch >/dev/null &&
55 git -C noset-both rev-parse --verify t/branch >/dev/null &&
56 git -C noset-both rev-parse --verify top-bases/t/branch >/dev/null &&
57 git -C noset-both rev-parse --verify {top-bases}/t/branch >/dev/null
60 test_expect_success 'hard-coded refs bases' '
61 test "$(tg -C refs --top-bases)" = "refs/top-bases" &&
62 test "$(tg -C noset-mt -c topgit.top-bases=refs --top-bases)" = "refs/top-bases" &&
63 test "$(tg -C noset-mt -c topgit.top-bases=heads -c topgit.top-bases=refs --top-bases)" = "refs/top-bases"
66 test_expect_success 'hard-coded heads bases' '
67 test "$(tg -C heads --top-bases)" = "refs/heads/{top-bases}" &&
68 test "$(tg -C noset-mt -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}" &&
69 test "$(tg -C noset-mt -c topgit.top-bases=refs -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}"
72 test_expect_success 'both is confusing and override' '
73 test_must_fail tg -C noset-both --top-bases >/dev/null 2>&1 &&
74 test "$(tg -C noset-both -c topgit.top-bases=refs --top-bases)" = "refs/top-bases" &&
75 test "$(tg -C noset-both -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}"
78 test_expect_success 'auto detect refs and override' '
79 test "$(tg -C noset-refs --top-bases)" = "refs/top-bases" &&
80 test "$(tg -C noset-refs -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}"
83 test_expect_success 'auto detect heads and override' '
84 test "$(tg -C noset-heads --top-bases)" = "refs/heads/{top-bases}" &&
85 test "$(tg -C noset-heads -c topgit.top-bases=refs --top-bases)" = "refs/top-bases"
88 test_expect_success 'default is refs until 0.20.0' '
89 test "$(tg -C noset-mt --top-bases)" = "refs/top-bases"
92 test_done