Blame


1 dc5351b4 2019-07-30 stsp #!/bin/sh
2 dc5351b4 2019-07-30 stsp #
3 dc5351b4 2019-07-30 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 dc5351b4 2019-07-30 stsp #
5 dc5351b4 2019-07-30 stsp # Permission to use, copy, modify, and distribute this software for any
6 dc5351b4 2019-07-30 stsp # purpose with or without fee is hereby granted, provided that the above
7 dc5351b4 2019-07-30 stsp # copyright notice and this permission notice appear in all copies.
8 dc5351b4 2019-07-30 stsp #
9 dc5351b4 2019-07-30 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 dc5351b4 2019-07-30 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 dc5351b4 2019-07-30 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 dc5351b4 2019-07-30 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 dc5351b4 2019-07-30 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 dc5351b4 2019-07-30 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 dc5351b4 2019-07-30 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 dc5351b4 2019-07-30 stsp
17 dc5351b4 2019-07-30 stsp . ./common.sh
18 dc5351b4 2019-07-30 stsp
19 f6cae3ed 2020-09-13 naddy test_branch_create() {
20 dc5351b4 2019-07-30 stsp local testroot=`test_init branch_create`
21 da76fce2 2020-02-24 stsp local commit_id0=`git_show_head $testroot/repo`
22 dc5351b4 2019-07-30 stsp
23 dc5351b4 2019-07-30 stsp # Create a branch based on repository's HEAD reference
24 dc5351b4 2019-07-30 stsp got branch -r $testroot/repo newbranch
25 fc414659 2022-04-16 thomas ret=$?
26 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
27 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
28 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
29 dc5351b4 2019-07-30 stsp return 1
30 dc5351b4 2019-07-30 stsp fi
31 dc5351b4 2019-07-30 stsp
32 dc5351b4 2019-07-30 stsp # Ensure that Git recognizes the branch Got has created
33 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q newbranch
34 fc414659 2022-04-16 thomas ret=$?
35 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
36 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
37 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
38 dc5351b4 2019-07-30 stsp return 1
39 dc5351b4 2019-07-30 stsp fi
40 dc5351b4 2019-07-30 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
41 dc5351b4 2019-07-30 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
42 dc5351b4 2019-07-30 stsp
43 dc5351b4 2019-07-30 stsp got checkout -b newbranch $testroot/repo $testroot/wt >/dev/null
44 fc414659 2022-04-16 thomas ret=$?
45 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
46 dc5351b4 2019-07-30 stsp echo "got checkout command failed unexpectedly"
47 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
48 dc5351b4 2019-07-30 stsp return 1
49 dc5351b4 2019-07-30 stsp fi
50 dc5351b4 2019-07-30 stsp
51 dc5351b4 2019-07-30 stsp echo "modified delta on branch" > $testroot/content.expected
52 dc5351b4 2019-07-30 stsp cat $testroot/wt/gamma/delta > $testroot/content
53 dc5351b4 2019-07-30 stsp cmp -s $testroot/content.expected $testroot/content
54 fc414659 2022-04-16 thomas ret=$?
55 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
56 dc5351b4 2019-07-30 stsp diff -u $testroot/content.expected $testroot/content
57 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
58 dc5351b4 2019-07-30 stsp return 1
59 dc5351b4 2019-07-30 stsp fi
60 dc5351b4 2019-07-30 stsp
61 dc5351b4 2019-07-30 stsp # Create a branch based on the work tree's branch
62 2f1457c6 2021-08-27 stsp (cd $testroot/wt && got branch -n refs/heads/anotherbranch)
63 fc414659 2022-04-16 thomas ret=$?
64 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
65 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
66 dc5351b4 2019-07-30 stsp return 1
67 dc5351b4 2019-07-30 stsp fi
68 dc5351b4 2019-07-30 stsp
69 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q anotherbranch
70 fc414659 2022-04-16 thomas ret=$?
71 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
72 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
73 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
74 dc5351b4 2019-07-30 stsp return 1
75 dc5351b4 2019-07-30 stsp fi
76 dc5351b4 2019-07-30 stsp
77 dc5351b4 2019-07-30 stsp # Create a branch based on another specific branch
78 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n -c master yetanotherbranch)
79 fc414659 2022-04-16 thomas ret=$?
80 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
81 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
82 dc5351b4 2019-07-30 stsp return 1
83 dc5351b4 2019-07-30 stsp fi
84 dc5351b4 2019-07-30 stsp
85 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q yetanotherbranch
86 fc414659 2022-04-16 thomas ret=$?
87 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
88 a4f89d48 2019-08-25 stsp echo "git checkout command failed unexpectedly"
89 a4f89d48 2019-08-25 stsp test_done "$testroot" "$ret"
90 a4f89d48 2019-08-25 stsp return 1
91 a4f89d48 2019-08-25 stsp fi
92 a4f89d48 2019-08-25 stsp
93 a4f89d48 2019-08-25 stsp # Create a branch based on a specific commit
94 a4f89d48 2019-08-25 stsp local commit_id=`git_show_head $testroot/repo`
95 a74f7e83 2019-11-10 stsp got branch -r $testroot/repo -c $commit_id commitbranch
96 fc414659 2022-04-16 thomas ret=$?
97 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
98 a4f89d48 2019-08-25 stsp echo "got branch command failed unexpectedly"
99 a4f89d48 2019-08-25 stsp test_done "$testroot" "$ret"
100 a4f89d48 2019-08-25 stsp return 1
101 a4f89d48 2019-08-25 stsp fi
102 a4f89d48 2019-08-25 stsp
103 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q commitbranch
104 fc414659 2022-04-16 thomas ret=$?
105 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
106 dc5351b4 2019-07-30 stsp echo "git checkout command failed unexpectedly"
107 da76fce2 2020-02-24 stsp test_done "$testroot" "$ret"
108 da76fce2 2020-02-24 stsp return 1
109 dc5351b4 2019-07-30 stsp fi
110 da76fce2 2020-02-24 stsp
111 da76fce2 2020-02-24 stsp # Create a branch and let the work tree be updated to it
112 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -c $commit_id0 updatebranch \
113 da76fce2 2020-02-24 stsp > $testroot/stdout)
114 da76fce2 2020-02-24 stsp
115 da76fce2 2020-02-24 stsp echo -n "Switching work tree from refs/heads/newbranch to " \
116 da76fce2 2020-02-24 stsp > $testroot/stdout.expected
117 da76fce2 2020-02-24 stsp echo "refs/heads/updatebranch" >> $testroot/stdout.expected
118 da76fce2 2020-02-24 stsp echo "U gamma/delta" >> $testroot/stdout.expected
119 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/updatebranch: $commit_id0" \
120 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
121 da76fce2 2020-02-24 stsp
122 da76fce2 2020-02-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
123 fc414659 2022-04-16 thomas ret=$?
124 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
125 da76fce2 2020-02-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
126 da76fce2 2020-02-24 stsp fi
127 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
128 dc5351b4 2019-07-30 stsp }
129 dc5351b4 2019-07-30 stsp
130 f6cae3ed 2020-09-13 naddy test_branch_list() {
131 dc5351b4 2019-07-30 stsp local testroot=`test_init branch_list`
132 dc5351b4 2019-07-30 stsp local commit_id=`git_show_head $testroot/repo`
133 dc5351b4 2019-07-30 stsp
134 dc5351b4 2019-07-30 stsp for b in branch1 branch2 branch3; do
135 dc5351b4 2019-07-30 stsp got branch -r $testroot/repo $b
136 fc414659 2022-04-16 thomas ret=$?
137 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
138 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
139 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
140 dc5351b4 2019-07-30 stsp return 1
141 dc5351b4 2019-07-30 stsp fi
142 dc5351b4 2019-07-30 stsp done
143 dc5351b4 2019-07-30 stsp
144 dc5351b4 2019-07-30 stsp got branch -l -r $testroot/repo > $testroot/stdout
145 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
146 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
147 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
148 dc5351b4 2019-07-30 stsp echo " master: $commit_id" >> $testroot/stdout.expected
149 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
150 fc414659 2022-04-16 thomas ret=$?
151 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
152 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
153 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
154 dc5351b4 2019-07-30 stsp return 1
155 dc5351b4 2019-07-30 stsp fi
156 dc5351b4 2019-07-30 stsp
157 dc5351b4 2019-07-30 stsp got checkout $testroot/repo $testroot/wt >/dev/null
158 fc414659 2022-04-16 thomas ret=$?
159 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
160 dc5351b4 2019-07-30 stsp echo "got checkout command failed unexpectedly"
161 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
162 dc5351b4 2019-07-30 stsp return 1
163 dc5351b4 2019-07-30 stsp fi
164 dc5351b4 2019-07-30 stsp
165 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
166 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
167 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
168 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
169 dc5351b4 2019-07-30 stsp echo "* master: $commit_id" >> $testroot/stdout.expected
170 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
171 fc414659 2022-04-16 thomas ret=$?
172 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
173 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
174 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
175 dc5351b4 2019-07-30 stsp return 1
176 dc5351b4 2019-07-30 stsp fi
177 dc5351b4 2019-07-30 stsp
178 dc5351b4 2019-07-30 stsp echo "modified delta" > $testroot/repo/gamma/delta
179 dc5351b4 2019-07-30 stsp git_commit $testroot/repo -m "committing to delta"
180 dc5351b4 2019-07-30 stsp local commit_id2=`git_show_head $testroot/repo`
181 dc5351b4 2019-07-30 stsp
182 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
183 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
184 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
185 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
186 dc5351b4 2019-07-30 stsp echo "~ master: $commit_id2" >> $testroot/stdout.expected
187 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
188 fc414659 2022-04-16 thomas ret=$?
189 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
190 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
191 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
192 dc5351b4 2019-07-30 stsp return 1
193 dc5351b4 2019-07-30 stsp fi
194 dc5351b4 2019-07-30 stsp
195 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got update > /dev/null)
196 fc414659 2022-04-16 thomas ret=$?
197 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
198 dc5351b4 2019-07-30 stsp echo "got update command failed unexpectedly"
199 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
200 dc5351b4 2019-07-30 stsp return 1
201 dc5351b4 2019-07-30 stsp fi
202 dc5351b4 2019-07-30 stsp
203 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
204 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
205 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
206 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
207 dc5351b4 2019-07-30 stsp echo "* master: $commit_id2" >> $testroot/stdout.expected
208 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
209 fc414659 2022-04-16 thomas ret=$?
210 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
211 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
212 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
213 dc5351b4 2019-07-30 stsp return 1
214 dc5351b4 2019-07-30 stsp fi
215 dc5351b4 2019-07-30 stsp
216 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got update -b branch1 > /dev/null)
217 fc414659 2022-04-16 thomas ret=$?
218 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
219 dc5351b4 2019-07-30 stsp echo "got update command failed unexpectedly"
220 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
221 dc5351b4 2019-07-30 stsp return 1
222 dc5351b4 2019-07-30 stsp fi
223 dc5351b4 2019-07-30 stsp
224 dc5351b4 2019-07-30 stsp (cd $testroot/wt && got branch -l > $testroot/stdout)
225 dc5351b4 2019-07-30 stsp echo "* branch1: $commit_id" > $testroot/stdout.expected
226 dc5351b4 2019-07-30 stsp echo " branch2: $commit_id" >> $testroot/stdout.expected
227 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
228 dc5351b4 2019-07-30 stsp echo " master: $commit_id2" >> $testroot/stdout.expected
229 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
230 fc414659 2022-04-16 thomas ret=$?
231 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
232 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
233 dc5351b4 2019-07-30 stsp fi
234 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
235 dc5351b4 2019-07-30 stsp }
236 dc5351b4 2019-07-30 stsp
237 f6cae3ed 2020-09-13 naddy test_branch_delete() {
238 dc5351b4 2019-07-30 stsp local testroot=`test_init branch_delete`
239 dc5351b4 2019-07-30 stsp local commit_id=`git_show_head $testroot/repo`
240 dc5351b4 2019-07-30 stsp
241 dc5351b4 2019-07-30 stsp for b in branch1 branch2 branch3; do
242 dc5351b4 2019-07-30 stsp got branch -r $testroot/repo $b
243 fc414659 2022-04-16 thomas ret=$?
244 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
245 dc5351b4 2019-07-30 stsp echo "got branch command failed unexpectedly"
246 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
247 dc5351b4 2019-07-30 stsp return 1
248 dc5351b4 2019-07-30 stsp fi
249 dc5351b4 2019-07-30 stsp done
250 dc5351b4 2019-07-30 stsp
251 dc5351b4 2019-07-30 stsp got branch -d branch2 -r $testroot/repo > $testroot/stdout
252 fc414659 2022-04-16 thomas ret=$?
253 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
254 2f1457c6 2021-08-27 stsp echo "got branch command failed unexpectedly"
255 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
256 dc5351b4 2019-07-30 stsp return 1
257 dc5351b4 2019-07-30 stsp fi
258 dc5351b4 2019-07-30 stsp
259 dc5351b4 2019-07-30 stsp got branch -l -r $testroot/repo > $testroot/stdout
260 dc5351b4 2019-07-30 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
261 dc5351b4 2019-07-30 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
262 dc5351b4 2019-07-30 stsp echo " master: $commit_id" >> $testroot/stdout.expected
263 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
264 fc414659 2022-04-16 thomas ret=$?
265 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
266 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
267 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
268 6aeab596 2019-08-28 stsp return 1
269 6aeab596 2019-08-28 stsp fi
270 6aeab596 2019-08-28 stsp
271 6aeab596 2019-08-28 stsp got ref -l -r $testroot/repo > $testroot/stdout
272 6aeab596 2019-08-28 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
273 6aeab596 2019-08-28 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
274 6aeab596 2019-08-28 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
275 6aeab596 2019-08-28 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
276 dc5351b4 2019-07-30 stsp cmp -s $testroot/stdout $testroot/stdout.expected
277 fc414659 2022-04-16 thomas ret=$?
278 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
279 dc5351b4 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
280 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
281 dc5351b4 2019-07-30 stsp return 1
282 dc5351b4 2019-07-30 stsp fi
283 dc5351b4 2019-07-30 stsp
284 dc5351b4 2019-07-30 stsp got branch -d bogus_branch_name -r $testroot/repo \
285 dc5351b4 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr
286 fc414659 2022-04-16 thomas ret=$?
287 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
288 2f1457c6 2021-08-27 stsp echo "got branch succeeded unexpectedly"
289 4e2bdb0d 2022-06-13 thomas test_done "$testroot" "1"
290 dc5351b4 2019-07-30 stsp return 1
291 dc5351b4 2019-07-30 stsp fi
292 dc5351b4 2019-07-30 stsp
293 dc5351b4 2019-07-30 stsp echo "got: reference refs/heads/bogus_branch_name not found" \
294 dc5351b4 2019-07-30 stsp > $testroot/stderr.expected
295 dc5351b4 2019-07-30 stsp cmp -s $testroot/stderr $testroot/stderr.expected
296 fc414659 2022-04-16 thomas ret=$?
297 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
298 dc5351b4 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
299 2f1457c6 2021-08-27 stsp test_done "$testroot" "$ret"
300 2f1457c6 2021-08-27 stsp return 1
301 dc5351b4 2019-07-30 stsp fi
302 2f1457c6 2021-08-27 stsp
303 2f1457c6 2021-08-27 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
304 2f1457c6 2021-08-27 stsp got ref -r $testroot/repo -c branch1 refs/remotes/origin/branch1
305 2f1457c6 2021-08-27 stsp got ref -r $testroot/repo -c branch3 refs/remotes/origin/branch3
306 2f1457c6 2021-08-27 stsp
307 2f1457c6 2021-08-27 stsp got ref -l -r $testroot/repo > $testroot/stdout
308 2f1457c6 2021-08-27 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
309 2f1457c6 2021-08-27 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
310 2f1457c6 2021-08-27 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
311 2f1457c6 2021-08-27 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
312 2f1457c6 2021-08-27 stsp echo "refs/remotes/origin/branch1: $commit_id" \
313 2f1457c6 2021-08-27 stsp >> $testroot/stdout.expected
314 2f1457c6 2021-08-27 stsp echo "refs/remotes/origin/branch3: $commit_id" \
315 2f1457c6 2021-08-27 stsp >> $testroot/stdout.expected
316 2f1457c6 2021-08-27 stsp echo "refs/remotes/origin/master: $commit_id" \
317 2f1457c6 2021-08-27 stsp >> $testroot/stdout.expected
318 2f1457c6 2021-08-27 stsp cmp -s $testroot/stdout $testroot/stdout.expected
319 fc414659 2022-04-16 thomas ret=$?
320 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
321 2f1457c6 2021-08-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
322 2f1457c6 2021-08-27 stsp test_done "$testroot" "$ret"
323 2f1457c6 2021-08-27 stsp return 1
324 2f1457c6 2021-08-27 stsp fi
325 2f1457c6 2021-08-27 stsp
326 2f1457c6 2021-08-27 stsp got branch -d origin/branch1 -r $testroot/repo > $testroot/stdout
327 fc414659 2022-04-16 thomas ret=$?
328 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
329 2f1457c6 2021-08-27 stsp echo "got branch command failed unexpectedly"
330 2f1457c6 2021-08-27 stsp test_done "$testroot" "$ret"
331 2f1457c6 2021-08-27 stsp return 1
332 2f1457c6 2021-08-27 stsp fi
333 2f1457c6 2021-08-27 stsp
334 2f1457c6 2021-08-27 stsp got branch -d refs/remotes/origin/branch3 -r $testroot/repo \
335 2f1457c6 2021-08-27 stsp > $testroot/stdout
336 fc414659 2022-04-16 thomas ret=$?
337 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
338 2f1457c6 2021-08-27 stsp echo "got branch command failed unexpectedly"
339 2f1457c6 2021-08-27 stsp test_done "$testroot" "$ret"
340 2f1457c6 2021-08-27 stsp return 1
341 2f1457c6 2021-08-27 stsp fi
342 2f1457c6 2021-08-27 stsp
343 2f1457c6 2021-08-27 stsp got ref -l -r $testroot/repo > $testroot/stdout
344 2f1457c6 2021-08-27 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
345 2f1457c6 2021-08-27 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
346 2f1457c6 2021-08-27 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
347 2f1457c6 2021-08-27 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
348 2f1457c6 2021-08-27 stsp echo "refs/remotes/origin/master: $commit_id" \
349 2f1457c6 2021-08-27 stsp >> $testroot/stdout.expected
350 2f1457c6 2021-08-27 stsp cmp -s $testroot/stdout $testroot/stdout.expected
351 fc414659 2022-04-16 thomas ret=$?
352 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
353 2f1457c6 2021-08-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
354 2f1457c6 2021-08-27 stsp fi
355 dc5351b4 2019-07-30 stsp test_done "$testroot" "$ret"
356 dc5351b4 2019-07-30 stsp }
357 dc5351b4 2019-07-30 stsp
358 f6cae3ed 2020-09-13 naddy test_branch_delete_current_branch() {
359 45cd4e47 2019-08-25 stsp local testroot=`test_init branch_delete_current_branch`
360 45cd4e47 2019-08-25 stsp local commit_id=`git_show_head $testroot/repo`
361 45cd4e47 2019-08-25 stsp
362 45cd4e47 2019-08-25 stsp got checkout $testroot/repo $testroot/wt >/dev/null
363 fc414659 2022-04-16 thomas ret=$?
364 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
365 45cd4e47 2019-08-25 stsp echo "got checkout command failed unexpectedly"
366 45cd4e47 2019-08-25 stsp test_done "$testroot" "$ret"
367 45cd4e47 2019-08-25 stsp return 1
368 45cd4e47 2019-08-25 stsp fi
369 dc5351b4 2019-07-30 stsp
370 45cd4e47 2019-08-25 stsp (cd $testroot/wt && got branch -d master > $testroot/stdout \
371 45cd4e47 2019-08-25 stsp 2> $testroot/stderr)
372 45cd4e47 2019-08-25 stsp
373 45cd4e47 2019-08-25 stsp echo "got: will not delete this work tree's current branch" \
374 6aeab596 2019-08-28 stsp > $testroot/stderr.expected
375 6aeab596 2019-08-28 stsp cmp -s $testroot/stderr $testroot/stderr.expected
376 fc414659 2022-04-16 thomas ret=$?
377 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
378 6aeab596 2019-08-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
379 6aeab596 2019-08-28 stsp fi
380 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
381 6aeab596 2019-08-28 stsp }
382 6aeab596 2019-08-28 stsp
383 f6cae3ed 2020-09-13 naddy test_branch_delete_packed() {
384 6aeab596 2019-08-28 stsp local testroot=`test_init branch_delete_packed`
385 6aeab596 2019-08-28 stsp local commit_id=`git_show_head $testroot/repo`
386 6aeab596 2019-08-28 stsp
387 6aeab596 2019-08-28 stsp for b in branch1 branch2 branch3; do
388 6aeab596 2019-08-28 stsp got branch -r $testroot/repo $b
389 fc414659 2022-04-16 thomas ret=$?
390 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
391 6aeab596 2019-08-28 stsp echo "got branch command failed unexpectedly"
392 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
393 6aeab596 2019-08-28 stsp return 1
394 6aeab596 2019-08-28 stsp fi
395 6aeab596 2019-08-28 stsp done
396 6aeab596 2019-08-28 stsp
397 d1e03b8c 2023-10-08 thomas git -C $testroot/repo pack-refs --all
398 6aeab596 2019-08-28 stsp
399 2f1457c6 2021-08-27 stsp got branch -d refs/heads/branch2 -r $testroot/repo > $testroot/stdout
400 fc414659 2022-04-16 thomas ret=$?
401 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
402 6aeab596 2019-08-28 stsp echo "got update command failed unexpectedly"
403 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
404 6aeab596 2019-08-28 stsp return 1
405 6aeab596 2019-08-28 stsp fi
406 6aeab596 2019-08-28 stsp
407 6aeab596 2019-08-28 stsp got branch -l -r $testroot/repo > $testroot/stdout
408 6aeab596 2019-08-28 stsp echo " branch1: $commit_id" > $testroot/stdout.expected
409 6aeab596 2019-08-28 stsp echo " branch3: $commit_id" >> $testroot/stdout.expected
410 6aeab596 2019-08-28 stsp echo " master: $commit_id" >> $testroot/stdout.expected
411 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
412 fc414659 2022-04-16 thomas ret=$?
413 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
414 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
415 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
416 6aeab596 2019-08-28 stsp return 1
417 6aeab596 2019-08-28 stsp fi
418 6aeab596 2019-08-28 stsp
419 6aeab596 2019-08-28 stsp got ref -l -r $testroot/repo > $testroot/stdout
420 6aeab596 2019-08-28 stsp echo "HEAD: refs/heads/master" > $testroot/stdout.expected
421 6aeab596 2019-08-28 stsp echo "refs/heads/branch1: $commit_id" >> $testroot/stdout.expected
422 6aeab596 2019-08-28 stsp echo "refs/heads/branch3: $commit_id" >> $testroot/stdout.expected
423 6aeab596 2019-08-28 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
424 6aeab596 2019-08-28 stsp cmp -s $testroot/stdout $testroot/stdout.expected
425 fc414659 2022-04-16 thomas ret=$?
426 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
427 6aeab596 2019-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
428 6aeab596 2019-08-28 stsp test_done "$testroot" "$ret"
429 6aeab596 2019-08-28 stsp return 1
430 6aeab596 2019-08-28 stsp fi
431 6aeab596 2019-08-28 stsp
432 6aeab596 2019-08-28 stsp got branch -d bogus_branch_name -r $testroot/repo \
433 6aeab596 2019-08-28 stsp > $testroot/stdout 2> $testroot/stderr
434 fc414659 2022-04-16 thomas ret=$?
435 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
436 6aeab596 2019-08-28 stsp echo "got update succeeded unexpectedly"
437 4e2bdb0d 2022-06-13 thomas test_done "$testroot" "1"
438 6aeab596 2019-08-28 stsp return 1
439 6aeab596 2019-08-28 stsp fi
440 6aeab596 2019-08-28 stsp
441 6aeab596 2019-08-28 stsp echo "got: reference refs/heads/bogus_branch_name not found" \
442 45cd4e47 2019-08-25 stsp > $testroot/stderr.expected
443 45cd4e47 2019-08-25 stsp cmp -s $testroot/stderr $testroot/stderr.expected
444 fc414659 2022-04-16 thomas ret=$?
445 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
446 45cd4e47 2019-08-25 stsp diff -u $testroot/stderr.expected $testroot/stderr
447 ad89fa31 2019-10-04 stsp fi
448 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
449 ad89fa31 2019-10-04 stsp }
450 ad89fa31 2019-10-04 stsp
451 f6cae3ed 2020-09-13 naddy test_branch_show() {
452 ad89fa31 2019-10-04 stsp local testroot=`test_init branch_show`
453 ad89fa31 2019-10-04 stsp local commit_id=`git_show_head $testroot/repo`
454 ad89fa31 2019-10-04 stsp
455 ad89fa31 2019-10-04 stsp for b in branch1 branch2 branch3; do
456 ad89fa31 2019-10-04 stsp got branch -r $testroot/repo $b
457 fc414659 2022-04-16 thomas ret=$?
458 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
459 ad89fa31 2019-10-04 stsp echo "got branch command failed unexpectedly"
460 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
461 ad89fa31 2019-10-04 stsp return 1
462 ad89fa31 2019-10-04 stsp fi
463 ad89fa31 2019-10-04 stsp done
464 ad89fa31 2019-10-04 stsp
465 ad89fa31 2019-10-04 stsp got checkout $testroot/repo $testroot/wt >/dev/null
466 fc414659 2022-04-16 thomas ret=$?
467 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
468 ad89fa31 2019-10-04 stsp echo "got checkout command failed unexpectedly"
469 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
470 ad89fa31 2019-10-04 stsp return 1
471 ad89fa31 2019-10-04 stsp fi
472 ad89fa31 2019-10-04 stsp
473 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got branch > $testroot/stdout)
474 ad89fa31 2019-10-04 stsp echo "master" > $testroot/stdout.expected
475 ad89fa31 2019-10-04 stsp cmp -s $testroot/stdout $testroot/stdout.expected
476 fc414659 2022-04-16 thomas ret=$?
477 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
478 ad89fa31 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
479 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
480 ad89fa31 2019-10-04 stsp return 1
481 45cd4e47 2019-08-25 stsp fi
482 ad89fa31 2019-10-04 stsp
483 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got update -b branch1 > /dev/null)
484 fc414659 2022-04-16 thomas ret=$?
485 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
486 ad89fa31 2019-10-04 stsp echo "got update command failed unexpectedly"
487 ad89fa31 2019-10-04 stsp test_done "$testroot" "$ret"
488 ad89fa31 2019-10-04 stsp return 1
489 ad89fa31 2019-10-04 stsp fi
490 ad89fa31 2019-10-04 stsp
491 ad89fa31 2019-10-04 stsp (cd $testroot/wt && got branch > $testroot/stdout)
492 ad89fa31 2019-10-04 stsp echo "branch1" > $testroot/stdout.expected
493 ad89fa31 2019-10-04 stsp cmp -s $testroot/stdout $testroot/stdout.expected
494 fc414659 2022-04-16 thomas ret=$?
495 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
496 ad89fa31 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
497 ad89fa31 2019-10-04 stsp fi
498 45cd4e47 2019-08-25 stsp test_done "$testroot" "$ret"
499 ad89fa31 2019-10-04 stsp
500 45cd4e47 2019-08-25 stsp }
501 21de8138 2022-09-05 thomas
502 21de8138 2022-09-05 thomas test_branch_packed_ref_collision() {
503 21de8138 2022-09-05 thomas local testroot=`test_init branch_packed_ref_collision`
504 21de8138 2022-09-05 thomas local commit_id=`git_show_head $testroot/repo`
505 45cd4e47 2019-08-25 stsp
506 21de8138 2022-09-05 thomas got br -r $testroot/repo zoo > $testroot/stdout
507 21de8138 2022-09-05 thomas got co -b zoo $testroot/repo $testroot/wt > /dev/null
508 21de8138 2022-09-05 thomas echo "modified alpha" > $testroot/wt/alpha
509 21de8138 2022-09-05 thomas
510 21de8138 2022-09-05 thomas # sleep in order to ensure that a significant fraction of time
511 21de8138 2022-09-05 thomas # passes between commits; required for got branch -t option below
512 21de8138 2022-09-05 thomas sleep 1
513 21de8138 2022-09-05 thomas
514 21de8138 2022-09-05 thomas (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
515 21de8138 2022-09-05 thomas local commit_id2=`git_show_branch_head $testroot/repo zoo`
516 21de8138 2022-09-05 thomas
517 21de8138 2022-09-05 thomas # Fabricate a packed reference which points to an older commit
518 21de8138 2022-09-05 thomas # and collides with the existing on-disk reference
519 21de8138 2022-09-05 thomas echo '# pack-refs with: peeled fully-peeled sorted' > \
520 21de8138 2022-09-05 thomas $testroot/repo/.git/packed-refs
521 21de8138 2022-09-05 thomas echo "$commit_id refs/heads/zoo" >> $testroot/repo/.git/packed-refs
522 21de8138 2022-09-05 thomas
523 21de8138 2022-09-05 thomas # Bug: This command used to show both packed and on-disk
524 21de8138 2022-09-05 thomas # variants of ref/heads/zoo:
525 21de8138 2022-09-05 thomas (cd $testroot/wt && got br -lt > $testroot/stdout)
526 21de8138 2022-09-05 thomas
527 44d79efa 2023-07-23 thomas echo "~ zoo: $commit_id2" > $testroot/stdout.expected
528 21de8138 2022-09-05 thomas echo " master: $commit_id" >> $testroot/stdout.expected
529 21de8138 2022-09-05 thomas cmp -s $testroot/stdout $testroot/stdout.expected
530 fb885120 2023-07-19 thomas ret=$?
531 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
532 fb885120 2023-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
533 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
534 fb885120 2023-07-19 thomas return 1
535 fb885120 2023-07-19 thomas fi
536 fb885120 2023-07-19 thomas
537 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
538 fb885120 2023-07-19 thomas }
539 fb885120 2023-07-19 thomas
540 fb885120 2023-07-19 thomas test_branch_commit_keywords() {
541 fb885120 2023-07-19 thomas local testroot=$(test_init branch_commit_keywords)
542 fb885120 2023-07-19 thomas
543 8642913b 2023-07-26 thomas set -- "$(git_show_head $testroot/repo)"
544 fb885120 2023-07-19 thomas
545 fb885120 2023-07-19 thomas got checkout $testroot/repo $testroot/wt > /dev/null
546 fb885120 2023-07-19 thomas ret=$?
547 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
548 fb885120 2023-07-19 thomas echo "checkout failed unexpectedly" >&2
549 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
550 fb885120 2023-07-19 thomas return 1
551 fb885120 2023-07-19 thomas fi
552 fb885120 2023-07-19 thomas
553 fb885120 2023-07-19 thomas for i in $(seq 4); do
554 fb885120 2023-07-19 thomas echo "beta change $i" > "$testroot/wt/beta"
555 fb885120 2023-07-19 thomas
556 fb885120 2023-07-19 thomas (cd "$testroot/wt" && got ci -m "commit number $i" > /dev/null)
557 fb885120 2023-07-19 thomas ret=$?
558 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
559 fb885120 2023-07-19 thomas echo "commit failed unexpectedly" >&2
560 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
561 fb885120 2023-07-19 thomas return 1
562 fb885120 2023-07-19 thomas fi
563 8642913b 2023-07-26 thomas set -- "$@" "$(git_show_head $testroot/repo)"
564 fb885120 2023-07-19 thomas done
565 fb885120 2023-07-19 thomas
566 fb885120 2023-07-19 thomas (cd "$testroot/wt" && got up > /dev/null)
567 fb885120 2023-07-19 thomas
568 8642913b 2023-07-26 thomas echo " kwbranch: $(pop_idx 3 $@)" > $testroot/stdout.expected
569 8642913b 2023-07-26 thomas echo " master: $(pop_idx 5 $@)" >> $testroot/stdout.expected
570 fb885120 2023-07-19 thomas
571 fb885120 2023-07-19 thomas (cd "$testroot/wt" && got br -nc :head:-2 kwbranch > /dev/null)
572 fb885120 2023-07-19 thomas got br -r "$testroot/repo" -l > "$testroot/stdout"
573 fb885120 2023-07-19 thomas
574 fb885120 2023-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
575 21de8138 2022-09-05 thomas ret=$?
576 21de8138 2022-09-05 thomas if [ $ret -ne 0 ]; then
577 21de8138 2022-09-05 thomas diff -u $testroot/stdout.expected $testroot/stdout
578 21de8138 2022-09-05 thomas test_done "$testroot" "$ret"
579 21de8138 2022-09-05 thomas return 1
580 21de8138 2022-09-05 thomas fi
581 21de8138 2022-09-05 thomas
582 8642913b 2023-07-26 thomas echo " kwbranch2: $(pop_idx 4 $@)" > $testroot/stdout.expected
583 fb885120 2023-07-19 thomas
584 fb885120 2023-07-19 thomas got br -r "$testroot/repo" -c master:- kwbranch2 > /dev/null
585 fb885120 2023-07-19 thomas got br -r "$testroot/repo" -l | grep kwbranch2 > "$testroot/stdout"
586 fb885120 2023-07-19 thomas
587 fb885120 2023-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
588 44d79efa 2023-07-23 thomas ret=$?
589 44d79efa 2023-07-23 thomas if [ $ret -ne 0 ]; then
590 44d79efa 2023-07-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
591 44d79efa 2023-07-23 thomas fi
592 44d79efa 2023-07-23 thomas
593 44d79efa 2023-07-23 thomas test_done "$testroot" "$ret"
594 44d79efa 2023-07-23 thomas }
595 44d79efa 2023-07-23 thomas
596 44d79efa 2023-07-23 thomas test_branch_list_worktree_state() {
597 44d79efa 2023-07-23 thomas local testroot=$(test_init branch_list_worktree_state)
598 44d79efa 2023-07-23 thomas local wt="$testroot/wt"
599 44d79efa 2023-07-23 thomas
600 44d79efa 2023-07-23 thomas set -- "$(git_show_head "$testroot/repo")"
601 44d79efa 2023-07-23 thomas
602 44d79efa 2023-07-23 thomas got checkout "$testroot/repo" "$wt" > /dev/null
603 44d79efa 2023-07-23 thomas ret=$?
604 44d79efa 2023-07-23 thomas if [ $ret -ne 0 ]; then
605 44d79efa 2023-07-23 thomas echo "checkout failed unexpectedly" >&2
606 44d79efa 2023-07-23 thomas test_done "$testroot" "$ret"
607 44d79efa 2023-07-23 thomas return 1
608 44d79efa 2023-07-23 thomas fi
609 44d79efa 2023-07-23 thomas
610 44d79efa 2023-07-23 thomas (cd "$wt" && got br -n newbranch > /dev/null)
611 44d79efa 2023-07-23 thomas ret=$?
612 44d79efa 2023-07-23 thomas if [ $ret -ne 0 ]; then
613 44d79efa 2023-07-23 thomas echo "branch failed unexpectedly" >&2
614 44d79efa 2023-07-23 thomas test_done "$testroot" "$ret"
615 44d79efa 2023-07-23 thomas return 1
616 44d79efa 2023-07-23 thomas fi
617 44d79efa 2023-07-23 thomas
618 44d79efa 2023-07-23 thomas # check up-to-date marker is shown with fresh checkout
619 44d79efa 2023-07-23 thomas (cd "$wt" && got br -l > "$testroot/stdout")
620 1a3a193e 2023-07-26 thomas echo "* master: $(pop_idx 1 $@)" > $testroot/stdout.expected
621 1a3a193e 2023-07-26 thomas echo " newbranch: $(pop_idx 1 $@)" >> $testroot/stdout.expected
622 44d79efa 2023-07-23 thomas cmp -s $testroot/stdout $testroot/stdout.expected
623 44d79efa 2023-07-23 thomas ret=$?
624 44d79efa 2023-07-23 thomas if [ $ret -ne 0 ]; then
625 44d79efa 2023-07-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
626 44d79efa 2023-07-23 thomas test_done "$testroot" "$ret"
627 44d79efa 2023-07-23 thomas return 1
628 44d79efa 2023-07-23 thomas fi
629 44d79efa 2023-07-23 thomas
630 44d79efa 2023-07-23 thomas # check out-of-date marker is shown with mixed-commit state
631 44d79efa 2023-07-23 thomas echo "mixed-commit" > "$wt/alpha"
632 44d79efa 2023-07-23 thomas (cd "$wt" && got commit -m "mixed-commit" > "$testroot/stdout")
633 44d79efa 2023-07-23 thomas set -- "$@" "$(git_show_head "$testroot/repo")"
634 44d79efa 2023-07-23 thomas
635 44d79efa 2023-07-23 thomas (cd "$wt" && got br -l > "$testroot/stdout")
636 1a3a193e 2023-07-26 thomas echo "~ master: $(pop_idx 2 $@)" > $testroot/stdout.expected
637 1a3a193e 2023-07-26 thomas echo " newbranch: $(pop_idx 1 $@)" >> $testroot/stdout.expected
638 44d79efa 2023-07-23 thomas cmp -s $testroot/stdout $testroot/stdout.expected
639 fb885120 2023-07-19 thomas ret=$?
640 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
641 fb885120 2023-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
642 44d79efa 2023-07-23 thomas test_done "$testroot" "$ret"
643 44d79efa 2023-07-23 thomas return 1
644 fb885120 2023-07-19 thomas fi
645 fb885120 2023-07-19 thomas
646 44d79efa 2023-07-23 thomas # check up-to-date marker is shown after 'got update'
647 44d79efa 2023-07-23 thomas (cd "$wt" && got up > /dev/null)
648 44d79efa 2023-07-23 thomas (cd "$wt" && got br -l > "$testroot/stdout")
649 1a3a193e 2023-07-26 thomas echo "* master: $(pop_idx 2 $@)" > $testroot/stdout.expected
650 1a3a193e 2023-07-26 thomas echo " newbranch: $(pop_idx 1 $@)" >> $testroot/stdout.expected
651 44d79efa 2023-07-23 thomas cmp -s $testroot/stdout $testroot/stdout.expected
652 44d79efa 2023-07-23 thomas ret=$?
653 44d79efa 2023-07-23 thomas if [ $ret -ne 0 ]; then
654 44d79efa 2023-07-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
655 44d79efa 2023-07-23 thomas test_done "$testroot" "$ret"
656 44d79efa 2023-07-23 thomas return 1
657 44d79efa 2023-07-23 thomas fi
658 44d79efa 2023-07-23 thomas
659 44d79efa 2023-07-23 thomas # check out-of-date marker is shown with out-of-date base commit
660 44d79efa 2023-07-23 thomas (cd "$wt" && got up -c:head:- > /dev/null)
661 44d79efa 2023-07-23 thomas (cd "$wt" && got br -l > "$testroot/stdout")
662 1a3a193e 2023-07-26 thomas echo "~ master: $(pop_idx 2 $@)" > $testroot/stdout.expected
663 1a3a193e 2023-07-26 thomas echo " newbranch: $(pop_idx 1 $@)" >> $testroot/stdout.expected
664 44d79efa 2023-07-23 thomas cmp -s $testroot/stdout $testroot/stdout.expected
665 44d79efa 2023-07-23 thomas ret=$?
666 44d79efa 2023-07-23 thomas if [ $ret -ne 0 ]; then
667 44d79efa 2023-07-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
668 44d79efa 2023-07-23 thomas test_done "$testroot" "$ret"
669 44d79efa 2023-07-23 thomas return 1
670 44d79efa 2023-07-23 thomas fi
671 44d79efa 2023-07-23 thomas
672 21de8138 2022-09-05 thomas test_done "$testroot" "$ret"
673 21de8138 2022-09-05 thomas }
674 21de8138 2022-09-05 thomas
675 7fb414ae 2020-08-08 stsp test_parseargs "$@"
676 dc5351b4 2019-07-30 stsp run_test test_branch_create
677 dc5351b4 2019-07-30 stsp run_test test_branch_list
678 dc5351b4 2019-07-30 stsp run_test test_branch_delete
679 45cd4e47 2019-08-25 stsp run_test test_branch_delete_current_branch
680 6aeab596 2019-08-28 stsp run_test test_branch_delete_packed
681 ad89fa31 2019-10-04 stsp run_test test_branch_show
682 21de8138 2022-09-05 thomas run_test test_branch_packed_ref_collision
683 fb885120 2023-07-19 thomas run_test test_branch_commit_keywords
684 44d79efa 2023-07-23 thomas run_test test_branch_list_worktree_state