tg.sh: handle help -h
[topgit/pro.git] / t / t4000-bare-branch-sanity.sh
blob17906faa34999b2fea42fb7d40e7cf92e4601fc2
1 #!/bin/sh
3 test_description='make sure bare branches show up'
5 TEST_NO_CREATE_REPO=1
7 . ./test-lib.sh
9 obj_count() {
10 set -- $(git -C "${1:-.}" count-objects) || die git count-objects failed
11 test z"${1%%[!0-9]*}" != z || die git count-objects returned nothing
12 echo "${1%%[!0-9]*}"
15 test_plan 18
17 test_expect_success 'setup r0 (contains empty blob and tree)' '
18 test_create_repo r0 && cd r0 &&
19 tg_test_create_branches <<-EOT &&
20 t/begin start here
23 t/branch use the base
24 t/begin
25 boo
27 boo bare branch
29 EOT
30 git checkout -f t/begin &&
31 test_commit hi &&
32 git checkout -f t/branch &&
33 test_commit gotit &&
34 git checkout -f boo &&
35 test_commit "boo boo" &&
36 git checkout --orphan unborn &&
37 git read-tree --empty &&
38 git clean -d -x -f
41 test_expect_success 'setup r1 (does not contain empty blob or tree)' '
42 test_create_repo r1 && cd r1 &&
43 test_commit initial &&
44 git checkout --orphan barely &&
45 git read-tree --empty &&
46 git clean -d -x -f &&
47 test_commit bare^commit &&
48 tg_test_create_branches <<-EOT &&
49 t/begin start here
50 :~master
52 t/branch use the base
53 t/begin
54 boo
56 boo bare branch
57 ::barely
58 EOT
59 git checkout -f t/begin &&
60 test_commit hi &&
61 git checkout -f t/branch &&
62 test_commit gotit &&
63 git checkout -f boo &&
64 test_commit "boo boo" &&
65 git checkout --orphan unborn &&
66 git read-tree --empty &&
67 git clean -d -x -f
70 test_expect_success 'setup r2 (read-only copy of r1)' '
71 { [ -d r1 ] || die missing setup r1 repo; } &&
72 { [ ! -e r2 ] || chmod -R u+rw r2; } &&
73 rm -rf r2 &&
74 cp -pR r1 r2 &&
75 chmod -R a-w r2
78 # should have same results whether empty blob and tree object are present or not
79 # r2 is a read-only copy of r1 to make things more challenging
81 for repo in r0 r1 r2; do
83 test_expect_success "($repo) "'tg summary --rdeps --heads' '
84 printf "%s" "\
85 t/branch
86 t/begin
87 boo
88 " > expected &&
89 tg -C $repo summary --rdeps --heads > actual &&
90 test_diff expected actual
93 test_expect_success "($repo) "'tg summary --list' '
94 printf "%s" "\
95 boo
96 t/begin
97 t/branch
98 " > expected &&
99 tg -C $repo summary --list > actual &&
100 test_diff expected actual
103 test_expect_success "($repo) "'tg summary --verbpse --list' '
104 ocntb="$(obj_count $repo)" &&
105 printf "%s" "\
106 boo branch boo (bare branch)
107 t/begin [PATCH] start here
108 t/branch [PATCH] use the base
109 " > expected &&
110 tg -C $repo summary --verbose --list > actual.raw &&
111 tab=" " && # a single tab in there
112 < actual.raw tr -s "$tab" " " > actual &&
113 test_diff expected actual &&
114 ocnta="$(obj_count $repo)" &&
115 test $ocntb -eq $ocnta
118 test_expect_success "($repo) "'tg summary' '
119 printf "%s" "\
120 * boo branch boo (bare branch)
121 * t/begin [PATCH] start here
122 D t/branch [PATCH] use the base
123 " > expected &&
124 tg -C $repo summary > actual.raw &&
125 tab=" " && # a single tab in there
126 < actual.raw tr -s "$tab" " " > actual &&
127 test_diff expected actual
130 test_expect_success "($repo) "'tg info --series' '
131 tab=" " && # a single tab in there
132 printf "%s" "\
133 * t/begin [PATCH] start here
134 boo branch boo (bare branch)
135 t/branch [PATCH] use the base
136 " > expected &&
137 tg -C $repo info --series t/begin > actual.raw &&
138 < actual.raw tr -s "$tab" " " > actual &&
139 test_diff expected actual &&
140 printf "%s" "\
141 t/begin [PATCH] start here
142 * boo branch boo (bare branch)
143 t/branch [PATCH] use the base
144 " > expected &&
145 tg -C $repo info --series boo > actual.raw &&
146 < actual.raw tr -s "$tab" " " > actual &&
147 test_diff expected actual &&
148 printf "%s" "\
149 t/begin [PATCH] start here
150 boo branch boo (bare branch)
151 t/branch [PATCH] use the base
152 " > expected &&
153 tg -C $repo info --series t/branch > actual.raw &&
154 < actual.raw tr -s "$tab" " " > actual &&
155 test_diff expected actual
158 done
160 test_done