tg status: behave reasonably in a bare repository
[topgit/pro.git] / t / t1020-top-bases-sniff-out.sh
blob318941ec0a38b4ccbd2af7f41257f905dc3e563a
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 7
14 test_expect_success 'test setup' '
15 test_create_repo noset-mt &&
16 test_create_repo noset-refs &&
17 test_create_repo noset-heads &&
18 test_create_repo noset-both &&
19 test_create_repo refs &&
20 test_create_repo heads &&
21 git -C refs config topgit.top-bases refs &&
22 git -C heads config topgit.top-bases heads &&
23 test "$(cd refs && git config topgit.top-bases)" = "refs" &&
24 test "$(cd heads && git config topgit.top-bases)" = "heads" &&
25 test "$(cd noset-mt && git config --get topgit.top-bases)" = "" &&
26 test "$(cd noset-refs && git config --get topgit.top-bases)" = "" &&
27 test "$(cd noset-heads && git config --get topgit.top-bases)" = "" &&
28 test "$(cd noset-both && git config --get topgit.top-bases)" = "" &&
29 (cd noset-refs && test_commit initial) &&
30 (cd noset-heads && test_commit initial) &&
31 (cd noset-both && test_commit initial) &&
32 git -C noset-refs update-ref refs/heads/t/branch master &&
33 git -C noset-refs update-ref refs/top-bases/t/branch master &&
34 git -C noset-heads update-ref refs/heads/t/branch master &&
35 git -C noset-heads update-ref refs/heads/{top-bases}/t/branch master &&
36 git -C noset-both update-ref refs/heads/t/branch master &&
37 git -C noset-both update-ref refs/top-bases/t/branch master &&
38 git -C noset-both update-ref refs/heads/{top-bases}/t/branch master &&
39 git -C noset-refs rev-parse --verify t/branch >/dev/null &&
40 git -C noset-refs rev-parse --verify top-bases/t/branch >/dev/null &&
41 git -C noset-heads rev-parse --verify t/branch >/dev/null &&
42 git -C noset-heads rev-parse --verify {top-bases}/t/branch >/dev/null &&
43 git -C noset-both rev-parse --verify t/branch >/dev/null &&
44 git -C noset-both rev-parse --verify top-bases/t/branch >/dev/null &&
45 git -C noset-both rev-parse --verify {top-bases}/t/branch >/dev/null
48 test_expect_success 'hard-coded refs bases' '
49 test "$(tg -C refs --top-bases)" = "refs/top-bases" &&
50 test "$(tg -C noset-mt -c topgit.top-bases=refs --top-bases)" = "refs/top-bases" &&
51 test "$(tg -C noset-mt -c topgit.top-bases=heads -c topgit.top-bases=refs --top-bases)" = "refs/top-bases"
54 test_expect_success 'hard-coded heads bases' '
55 test "$(tg -C heads --top-bases)" = "refs/heads/{top-bases}" &&
56 test "$(tg -C noset-mt -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}" &&
57 test "$(tg -C noset-mt -c topgit.top-bases=refs -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}"
60 test_expect_success 'both is confusing and override' '
61 test_must_fail tg -C noset-both --top-bases >/dev/null 2>&1 &&
62 test "$(tg -C noset-both -c topgit.top-bases=refs --top-bases)" = "refs/top-bases" &&
63 test "$(tg -C noset-both -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}"
66 test_expect_success 'auto detect refs and override' '
67 test "$(tg -C noset-refs --top-bases)" = "refs/top-bases" &&
68 test "$(tg -C noset-refs -c topgit.top-bases=heads --top-bases)" = "refs/heads/{top-bases}"
71 test_expect_success 'auto detect heads and override' '
72 test "$(tg -C noset-heads --top-bases)" = "refs/heads/{top-bases}" &&
73 test "$(tg -C noset-heads -c topgit.top-bases=refs --top-bases)" = "refs/top-bases"
76 test_expect_success 'default is refs until 0.20.0' '
77 test "$(tg -C noset-mt --top-bases)" = "refs/top-bases"
80 test_done