Blame


1 cbd1af7a 2019-03-18 stsp #!/bin/sh
2 cbd1af7a 2019-03-18 stsp #
3 5aa81393 2020-01-06 stsp # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
4 cbd1af7a 2019-03-18 stsp #
5 cbd1af7a 2019-03-18 stsp # Permission to use, copy, modify, and distribute this software for any
6 cbd1af7a 2019-03-18 stsp # purpose with or without fee is hereby granted, provided that the above
7 cbd1af7a 2019-03-18 stsp # copyright notice and this permission notice appear in all copies.
8 cbd1af7a 2019-03-18 stsp #
9 cbd1af7a 2019-03-18 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 cbd1af7a 2019-03-18 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 cbd1af7a 2019-03-18 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 cbd1af7a 2019-03-18 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 cbd1af7a 2019-03-18 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 cbd1af7a 2019-03-18 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 cbd1af7a 2019-03-18 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 cbd1af7a 2019-03-18 stsp
17 cbd1af7a 2019-03-18 stsp . ./common.sh
18 cbd1af7a 2019-03-18 stsp
19 f6cae3ed 2020-09-13 naddy test_log_in_repo() {
20 e7301579 2019-03-18 stsp local testroot=`test_init log_in_repo`
21 e7301579 2019-03-18 stsp local head_rev=`git_show_head $testroot/repo`
22 e7301579 2019-03-18 stsp
23 e7301579 2019-03-18 stsp echo "commit $head_rev (master)" > $testroot/stdout.expected
24 e7301579 2019-03-18 stsp
25 e7301579 2019-03-18 stsp for p in "" "." alpha epsilon epsilon/zeta; do
26 e7301579 2019-03-18 stsp (cd $testroot/repo && got log $p | \
27 e7301579 2019-03-18 stsp grep ^commit > $testroot/stdout)
28 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
29 49c543a6 2022-03-31 naddy ret=$?
30 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
31 e7301579 2019-03-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
32 e7301579 2019-03-18 stsp test_done "$testroot" "$ret"
33 e7301579 2019-03-18 stsp return 1
34 e7301579 2019-03-18 stsp fi
35 e7301579 2019-03-18 stsp done
36 e7301579 2019-03-18 stsp
37 b70703ad 2019-03-18 stsp for p in "" "." zeta; do
38 b70703ad 2019-03-18 stsp (cd $testroot/repo/epsilon && got log $p | \
39 b70703ad 2019-03-18 stsp grep ^commit > $testroot/stdout)
40 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
41 49c543a6 2022-03-31 naddy ret=$?
42 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
43 b70703ad 2019-03-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
44 b70703ad 2019-03-18 stsp test_done "$testroot" "$ret"
45 b70703ad 2019-03-18 stsp return 1
46 b70703ad 2019-03-18 stsp fi
47 b70703ad 2019-03-18 stsp done
48 b70703ad 2019-03-18 stsp
49 e7301579 2019-03-18 stsp test_done "$testroot" "0"
50 e7301579 2019-03-18 stsp }
51 e7301579 2019-03-18 stsp
52 f6cae3ed 2020-09-13 naddy test_log_in_bare_repo() {
53 b70703ad 2019-03-18 stsp local testroot=`test_init log_in_bare_repo`
54 b70703ad 2019-03-18 stsp local head_rev=`git_show_head $testroot/repo`
55 b70703ad 2019-03-18 stsp
56 b70703ad 2019-03-18 stsp echo "commit $head_rev (master)" > $testroot/stdout.expected
57 b70703ad 2019-03-18 stsp
58 b70703ad 2019-03-18 stsp for p in "" "." alpha epsilon epsilon/zeta; do
59 b70703ad 2019-03-18 stsp (cd $testroot/repo/.git && got log $p | \
60 b70703ad 2019-03-18 stsp grep ^commit > $testroot/stdout)
61 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
62 49c543a6 2022-03-31 naddy ret=$?
63 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
64 b70703ad 2019-03-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
65 b70703ad 2019-03-18 stsp test_done "$testroot" "$ret"
66 b70703ad 2019-03-18 stsp return 1
67 b70703ad 2019-03-18 stsp fi
68 b70703ad 2019-03-18 stsp done
69 b70703ad 2019-03-18 stsp
70 b70703ad 2019-03-18 stsp test_done "$testroot" "0"
71 b70703ad 2019-03-18 stsp }
72 b70703ad 2019-03-18 stsp
73 f6cae3ed 2020-09-13 naddy test_log_in_worktree() {
74 f43793a4 2020-01-27 stsp local testroot=`test_init log_in_worktree 1`
75 cbd1af7a 2019-03-18 stsp
76 f43793a4 2020-01-27 stsp make_test_tree $testroot/repo
77 f43793a4 2020-01-27 stsp mkdir -p $testroot/repo/epsilon/d
78 f43793a4 2020-01-27 stsp echo foo > $testroot/repo/epsilon/d/foo
79 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add .
80 f43793a4 2020-01-27 stsp git_commit $testroot/repo -m "adding the test tree"
81 f43793a4 2020-01-27 stsp local head_commit=`git_show_head $testroot/repo`
82 f43793a4 2020-01-27 stsp
83 cbd1af7a 2019-03-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
84 49c543a6 2022-03-31 naddy ret=$?
85 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
86 cbd1af7a 2019-03-18 stsp test_done "$testroot" "$ret"
87 cbd1af7a 2019-03-18 stsp return 1
88 cbd1af7a 2019-03-18 stsp fi
89 cbd1af7a 2019-03-18 stsp
90 f43793a4 2020-01-27 stsp echo "commit $head_commit (master)" > $testroot/stdout.expected
91 cbd1af7a 2019-03-18 stsp
92 cbd1af7a 2019-03-18 stsp for p in "" "." alpha epsilon; do
93 cbd1af7a 2019-03-18 stsp (cd $testroot/wt && got log $p | \
94 cbd1af7a 2019-03-18 stsp grep ^commit > $testroot/stdout)
95 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
96 49c543a6 2022-03-31 naddy ret=$?
97 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
98 cbd1af7a 2019-03-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
99 cbd1af7a 2019-03-18 stsp test_done "$testroot" "$ret"
100 cbd1af7a 2019-03-18 stsp return 1
101 cbd1af7a 2019-03-18 stsp fi
102 cbd1af7a 2019-03-18 stsp done
103 cbd1af7a 2019-03-18 stsp
104 cbd1af7a 2019-03-18 stsp for p in "" "." zeta; do
105 cbd1af7a 2019-03-18 stsp (cd $testroot/wt/epsilon && got log $p | \
106 cbd1af7a 2019-03-18 stsp grep ^commit > $testroot/stdout)
107 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
108 49c543a6 2022-03-31 naddy ret=$?
109 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
110 cbd1af7a 2019-03-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
111 cbd1af7a 2019-03-18 stsp test_done "$testroot" "$ret"
112 cbd1af7a 2019-03-18 stsp return 1
113 cbd1af7a 2019-03-18 stsp fi
114 cbd1af7a 2019-03-18 stsp done
115 cbd1af7a 2019-03-18 stsp
116 f43793a4 2020-01-27 stsp for p in "" "." foo; do
117 f43793a4 2020-01-27 stsp (cd $testroot/wt/epsilon && got log d/$p | \
118 f43793a4 2020-01-27 stsp grep ^commit > $testroot/stdout)
119 f43793a4 2020-01-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
120 49c543a6 2022-03-31 naddy ret=$?
121 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
122 f43793a4 2020-01-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
123 f43793a4 2020-01-27 stsp test_done "$testroot" "$ret"
124 f43793a4 2020-01-27 stsp return 1
125 f43793a4 2020-01-27 stsp fi
126 f43793a4 2020-01-27 stsp done
127 f43793a4 2020-01-27 stsp
128 cbd1af7a 2019-03-18 stsp test_done "$testroot" "0"
129 cbd1af7a 2019-03-18 stsp }
130 cbd1af7a 2019-03-18 stsp
131 f6cae3ed 2020-09-13 naddy test_log_in_worktree_with_path_prefix() {
132 0c2ef172 2023-02-13 op local testroot=`test_init log_in_worktree_with_path_prefix`
133 0cfcb52d 2019-08-27 stsp local head_rev=`git_show_head $testroot/repo`
134 0cfcb52d 2019-08-27 stsp
135 0cfcb52d 2019-08-27 stsp echo "modified zeta" > $testroot/repo/epsilon/zeta
136 0cfcb52d 2019-08-27 stsp git_commit $testroot/repo -m "modified zeta"
137 0cfcb52d 2019-08-27 stsp local zeta_rev=`git_show_head $testroot/repo`
138 0cfcb52d 2019-08-27 stsp
139 0cfcb52d 2019-08-27 stsp echo "modified delta" > $testroot/repo/gamma/delta
140 0cfcb52d 2019-08-27 stsp git_commit $testroot/repo -m "modified delta"
141 603cdeb0 2020-10-22 stsp local delta_rev=`git_show_head $testroot/repo`
142 0cfcb52d 2019-08-27 stsp
143 0cfcb52d 2019-08-27 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
144 49c543a6 2022-03-31 naddy ret=$?
145 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
146 603cdeb0 2020-10-22 stsp test_done "$testroot" "$ret"
147 603cdeb0 2020-10-22 stsp return 1
148 603cdeb0 2020-10-22 stsp fi
149 603cdeb0 2020-10-22 stsp
150 603cdeb0 2020-10-22 stsp echo "commit $delta_rev (master)" > $testroot/stdout.expected
151 603cdeb0 2020-10-22 stsp echo "commit $zeta_rev" >> $testroot/stdout.expected
152 603cdeb0 2020-10-22 stsp echo "commit $head_rev" >> $testroot/stdout.expected
153 603cdeb0 2020-10-22 stsp
154 603cdeb0 2020-10-22 stsp (cd $testroot/wt && got log | grep ^commit > $testroot/stdout)
155 603cdeb0 2020-10-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
156 49c543a6 2022-03-31 naddy ret=$?
157 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
158 603cdeb0 2020-10-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
159 0cfcb52d 2019-08-27 stsp test_done "$testroot" "$ret"
160 0cfcb52d 2019-08-27 stsp return 1
161 0cfcb52d 2019-08-27 stsp fi
162 0cfcb52d 2019-08-27 stsp
163 0cfcb52d 2019-08-27 stsp echo "commit $zeta_rev" > $testroot/stdout.expected
164 0cfcb52d 2019-08-27 stsp echo "commit $head_rev" >> $testroot/stdout.expected
165 0cfcb52d 2019-08-27 stsp
166 603cdeb0 2020-10-22 stsp for p in "." zeta; do
167 0cfcb52d 2019-08-27 stsp (cd $testroot/wt && got log $p | \
168 0cfcb52d 2019-08-27 stsp grep ^commit > $testroot/stdout)
169 0cfcb52d 2019-08-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
170 49c543a6 2022-03-31 naddy ret=$?
171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
172 0cfcb52d 2019-08-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
173 0cfcb52d 2019-08-27 stsp test_done "$testroot" "$ret"
174 0cfcb52d 2019-08-27 stsp return 1
175 0cfcb52d 2019-08-27 stsp fi
176 0cfcb52d 2019-08-27 stsp done
177 0cfcb52d 2019-08-27 stsp
178 0cfcb52d 2019-08-27 stsp test_done "$testroot" "0"
179 0cfcb52d 2019-08-27 stsp }
180 0cfcb52d 2019-08-27 stsp
181 f6cae3ed 2020-09-13 naddy test_log_tag() {
182 303e2782 2019-08-09 stsp local testroot=`test_init log_tag`
183 303e2782 2019-08-09 stsp local commit_id=`git_show_head $testroot/repo`
184 303e2782 2019-08-09 stsp local tag="1.0.0"
185 5a8ddf14 2019-08-13 stsp local tag2="2.0.0"
186 303e2782 2019-08-09 stsp
187 303e2782 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
188 49c543a6 2022-03-31 naddy ret=$?
189 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
190 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
191 303e2782 2019-08-09 stsp return 1
192 303e2782 2019-08-09 stsp fi
193 303e2782 2019-08-09 stsp
194 f73bf5bd 2023-10-01 naddy git -C $testroot/repo tag -a -m "test" $tag
195 303e2782 2019-08-09 stsp
196 a436ad14 2019-08-13 stsp echo "commit $commit_id (master, tags/$tag)" > $testroot/stdout.expected
197 303e2782 2019-08-09 stsp (cd $testroot/wt && got log -l1 -c $tag | grep ^commit \
198 303e2782 2019-08-09 stsp > $testroot/stdout)
199 303e2782 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
200 49c543a6 2022-03-31 naddy ret=$?
201 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
202 303e2782 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
203 5a8ddf14 2019-08-13 stsp test_done "$testroot" "$ret"
204 5a8ddf14 2019-08-13 stsp return 1
205 303e2782 2019-08-09 stsp fi
206 5a8ddf14 2019-08-13 stsp
207 992eb9d8 2020-02-07 tracey # test a "lightweight" tag
208 f73bf5bd 2023-10-01 naddy git -C $testroot/repo tag $tag2
209 5a8ddf14 2019-08-13 stsp
210 5a8ddf14 2019-08-13 stsp echo "commit $commit_id (master, tags/$tag, tags/$tag2)" \
211 5a8ddf14 2019-08-13 stsp > $testroot/stdout.expected
212 5a8ddf14 2019-08-13 stsp (cd $testroot/wt && got log -l1 -c $tag2 | grep ^commit \
213 5a8ddf14 2019-08-13 stsp > $testroot/stdout)
214 5a8ddf14 2019-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
215 49c543a6 2022-03-31 naddy ret=$?
216 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
217 5a8ddf14 2019-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
218 5a8ddf14 2019-08-13 stsp fi
219 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
220 303e2782 2019-08-09 stsp }
221 303e2782 2019-08-09 stsp
222 f6cae3ed 2020-09-13 naddy test_log_limit() {
223 b1ebc001 2019-08-13 stsp local testroot=`test_init log_limit`
224 b1ebc001 2019-08-13 stsp local commit_id0=`git_show_head $testroot/repo`
225 303e2782 2019-08-09 stsp
226 b1ebc001 2019-08-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
227 49c543a6 2022-03-31 naddy ret=$?
228 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
229 b1ebc001 2019-08-13 stsp test_done "$testroot" "$ret"
230 b1ebc001 2019-08-13 stsp return 1
231 b1ebc001 2019-08-13 stsp fi
232 b1ebc001 2019-08-13 stsp
233 b1ebc001 2019-08-13 stsp echo "modified alpha" > $testroot/wt/alpha
234 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
235 b1ebc001 2019-08-13 stsp local commit_id1=`git_show_head $testroot/repo`
236 b1ebc001 2019-08-13 stsp
237 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got rm beta >/dev/null)
238 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
239 b1ebc001 2019-08-13 stsp local commit_id2=`git_show_head $testroot/repo`
240 b1ebc001 2019-08-13 stsp
241 b1ebc001 2019-08-13 stsp echo "new file" > $testroot/wt/new
242 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got add new >/dev/null)
243 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
244 b1ebc001 2019-08-13 stsp local commit_id3=`git_show_head $testroot/repo`
245 b1ebc001 2019-08-13 stsp
246 b1ebc001 2019-08-13 stsp # -l1 should print the first commit only
247 b1ebc001 2019-08-13 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
248 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got log -l1 | grep ^commit > $testroot/stdout)
249 b1ebc001 2019-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
250 49c543a6 2022-03-31 naddy ret=$?
251 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
252 b1ebc001 2019-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
253 b1ebc001 2019-08-13 stsp test_done "$testroot" "$ret"
254 b1ebc001 2019-08-13 stsp return 1
255 b1ebc001 2019-08-13 stsp fi
256 b1ebc001 2019-08-13 stsp
257 b1ebc001 2019-08-13 stsp # env var can be used to set a log limit without -l option
258 b1ebc001 2019-08-13 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
259 b1ebc001 2019-08-13 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
260 b1ebc001 2019-08-13 stsp (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=2 got log | \
261 b1ebc001 2019-08-13 stsp grep ^commit > $testroot/stdout)
262 b1ebc001 2019-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
263 49c543a6 2022-03-31 naddy ret=$?
264 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
265 b1ebc001 2019-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 b1ebc001 2019-08-13 stsp test_done "$testroot" "$ret"
267 b1ebc001 2019-08-13 stsp return 1
268 b1ebc001 2019-08-13 stsp fi
269 b1ebc001 2019-08-13 stsp
270 b1ebc001 2019-08-13 stsp # non-numeric env var is ignored
271 b1ebc001 2019-08-13 stsp (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=foobar got log | \
272 b1ebc001 2019-08-13 stsp grep ^commit > $testroot/stdout)
273 b1ebc001 2019-08-13 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
274 b1ebc001 2019-08-13 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
275 b1ebc001 2019-08-13 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
276 b1ebc001 2019-08-13 stsp echo "commit $commit_id0" >> $testroot/stdout.expected
277 b1ebc001 2019-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
278 49c543a6 2022-03-31 naddy ret=$?
279 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
280 b1ebc001 2019-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
281 b1ebc001 2019-08-13 stsp test_done "$testroot" "$ret"
282 b1ebc001 2019-08-13 stsp return 1
283 b1ebc001 2019-08-13 stsp fi
284 b1ebc001 2019-08-13 stsp
285 b1ebc001 2019-08-13 stsp # -l option takes precedence over env var
286 b1ebc001 2019-08-13 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
287 b1ebc001 2019-08-13 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
288 b1ebc001 2019-08-13 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
289 b1ebc001 2019-08-13 stsp echo "commit $commit_id0" >> $testroot/stdout.expected
290 b1ebc001 2019-08-13 stsp (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=1 got log -l0 | \
291 b1ebc001 2019-08-13 stsp grep ^commit > $testroot/stdout)
292 b1ebc001 2019-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
293 49c543a6 2022-03-31 naddy ret=$?
294 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
295 b1ebc001 2019-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
296 b1ebc001 2019-08-13 stsp fi
297 b1ebc001 2019-08-13 stsp test_done "$testroot" "0"
298 b1ebc001 2019-08-13 stsp }
299 c1c775eb 2022-06-08 stsp
300 c1c775eb 2022-06-08 stsp test_log_oneline() {
301 c1c775eb 2022-06-08 stsp local testroot=`test_init log_oneline`
302 c1c775eb 2022-06-08 stsp local commit_id0=`git_show_head $testroot/repo`
303 c1c775eb 2022-06-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
304 c1c775eb 2022-06-08 stsp ret=$?
305 c1c775eb 2022-06-08 stsp if [ $ret -ne 0 ]; then
306 c1c775eb 2022-06-08 stsp test_done "$testroot" "$ret"
307 c1c775eb 2022-06-08 stsp return 1
308 c1c775eb 2022-06-08 stsp fi
309 2e8c69d1 2020-05-04 stsp
310 c1c775eb 2022-06-08 stsp echo "modified alpha" > $testroot/wt/alpha
311 c1c775eb 2022-06-08 stsp (cd $testroot/wt && got commit -m "test oneline
312 c1c775eb 2022-06-08 stsp no" > /dev/null)
313 c1c775eb 2022-06-08 stsp local commit_id1=`git_show_head $testroot/repo`
314 783ffc01 2022-06-13 stsp local author_time1=`git_show_author_time $testroot/repo`
315 c1c775eb 2022-06-08 stsp
316 c1c775eb 2022-06-08 stsp echo "modified beta" > $testroot/wt/beta
317 c1c775eb 2022-06-08 stsp (cd $testroot/wt && got commit -m " test oneline
318 c1c775eb 2022-06-08 stsp no" > /dev/null)
319 c1c775eb 2022-06-08 stsp local commit_id2=`git_show_head $testroot/repo`
320 783ffc01 2022-06-13 stsp local author_time2=`git_show_author_time $testroot/repo`
321 c1c775eb 2022-06-08 stsp
322 783ffc01 2022-06-13 stsp d=`date -u -r $author_time1 +"%G-%m-%d"`
323 783ffc01 2022-06-13 stsp printf "$d %-7s test oneline\n" master > $testroot/stdout.expected
324 783ffc01 2022-06-13 stsp d=`date -u -r $author_time2 +"%G-%m-%d"`
325 783ffc01 2022-06-13 stsp printf "$d %.7s test oneline\n" $commit_id1 >> $testroot/stdout.expected
326 c1c775eb 2022-06-08 stsp
327 c1c775eb 2022-06-08 stsp (cd $testroot/repo && got log -s | head -n 2 > $testroot/stdout)
328 c1c775eb 2022-06-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
329 c1c775eb 2022-06-08 stsp ret=$?
330 c1c775eb 2022-06-08 stsp if [ $ret -ne 0 ]; then
331 c1c775eb 2022-06-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
332 c1c775eb 2022-06-08 stsp test_done "$testroot" "$ret"
333 c1c775eb 2022-06-08 stsp return 1
334 c1c775eb 2022-06-08 stsp fi
335 c1c775eb 2022-06-08 stsp test_done "$testroot" "0"
336 c1c775eb 2022-06-08 stsp }
337 c1c775eb 2022-06-08 stsp
338 f6cae3ed 2020-09-13 naddy test_log_patch_added_file() {
339 2e8c69d1 2020-05-04 stsp local testroot=`test_init log_patch_added_file`
340 2e8c69d1 2020-05-04 stsp local commit_id0=`git_show_head $testroot/repo`
341 5175b31a 2020-01-04 stsp
342 2e8c69d1 2020-05-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
343 49c543a6 2022-03-31 naddy ret=$?
344 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
345 2e8c69d1 2020-05-04 stsp test_done "$testroot" "$ret"
346 2e8c69d1 2020-05-04 stsp return 1
347 2e8c69d1 2020-05-04 stsp fi
348 2e8c69d1 2020-05-04 stsp
349 2e8c69d1 2020-05-04 stsp echo "new file" > $testroot/wt/new
350 2e8c69d1 2020-05-04 stsp (cd $testroot/wt && got add new >/dev/null)
351 2e8c69d1 2020-05-04 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
352 2e8c69d1 2020-05-04 stsp local commit_id1=`git_show_head $testroot/repo`
353 2e8c69d1 2020-05-04 stsp
354 2e8c69d1 2020-05-04 stsp echo "commit $commit_id1 (master)" > $testroot/stdout.expected
355 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
356 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
357 2e8c69d1 2020-05-04 stsp # This used to fail with 'got: no such entry found in tree'
358 2e8c69d1 2020-05-04 stsp (cd $testroot/wt && got log -l1 -p new > $testroot/stdout.patch)
359 49c543a6 2022-03-31 naddy ret=$?
360 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
361 2e8c69d1 2020-05-04 stsp echo "got log command failed unexpectedly" >&2
362 2e8c69d1 2020-05-04 stsp test_done "$testroot" "$ret"
363 2e8c69d1 2020-05-04 stsp return 1
364 2e8c69d1 2020-05-04 stsp fi
365 2e8c69d1 2020-05-04 stsp grep ^commit $testroot/stdout.patch > $testroot/stdout
366 2e8c69d1 2020-05-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
367 49c543a6 2022-03-31 naddy ret=$?
368 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
369 2e8c69d1 2020-05-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
370 2e8c69d1 2020-05-04 stsp fi
371 2e8c69d1 2020-05-04 stsp test_done "$testroot" "$ret"
372 2e8c69d1 2020-05-04 stsp }
373 2e8c69d1 2020-05-04 stsp
374 f6cae3ed 2020-09-13 naddy test_log_nonexistent_path() {
375 5175b31a 2020-01-04 stsp local testroot=`test_init log_nonexistent_path`
376 5175b31a 2020-01-04 stsp local head_rev=`git_show_head $testroot/repo`
377 5175b31a 2020-01-04 stsp
378 5175b31a 2020-01-04 stsp echo "commit $head_rev (master)" > $testroot/stdout.expected
379 b1ebc001 2019-08-13 stsp
380 5175b31a 2020-01-04 stsp (cd $testroot/repo && got log this/does/not/exist \
381 5175b31a 2020-01-04 stsp > $testroot/stdout 2> $testroot/stderr)
382 49c543a6 2022-03-31 naddy ret=$?
383 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
384 5175b31a 2020-01-04 stsp echo "log command succeeded unexpectedly" >&2
385 5175b31a 2020-01-04 stsp test_done "$testroot" "1"
386 5175b31a 2020-01-04 stsp return 1
387 5175b31a 2020-01-04 stsp fi
388 5175b31a 2020-01-04 stsp
389 5175b31a 2020-01-04 stsp echo -n > $testroot/stdout.expected
390 5175b31a 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
391 49c543a6 2022-03-31 naddy ret=$?
392 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
393 5175b31a 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
394 5175b31a 2020-01-04 stsp test_done "$testroot" "$ret"
395 5175b31a 2020-01-04 stsp return 1
396 5175b31a 2020-01-04 stsp fi
397 5175b31a 2020-01-04 stsp
398 5175b31a 2020-01-04 stsp echo "got: this/does/not/exist: no such entry found in tree" \
399 5175b31a 2020-01-04 stsp > $testroot/stderr.expected
400 5175b31a 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
401 49c543a6 2022-03-31 naddy ret=$?
402 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
403 5175b31a 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
404 5175b31a 2020-01-04 stsp fi
405 5175b31a 2020-01-04 stsp test_done "$testroot" "$ret"
406 5175b31a 2020-01-04 stsp }
407 d1fe46f9 2020-04-18 stsp
408 f6cae3ed 2020-09-13 naddy test_log_end_at_commit() {
409 d1fe46f9 2020-04-18 stsp local testroot=`test_init log_end_at_commit`
410 d1fe46f9 2020-04-18 stsp local commit_id0=`git_show_head $testroot/repo`
411 d1fe46f9 2020-04-18 stsp
412 d1fe46f9 2020-04-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
413 49c543a6 2022-03-31 naddy ret=$?
414 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
415 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
416 d1fe46f9 2020-04-18 stsp return 1
417 d1fe46f9 2020-04-18 stsp fi
418 d1fe46f9 2020-04-18 stsp
419 d1fe46f9 2020-04-18 stsp echo "modified alpha" > $testroot/wt/alpha
420 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
421 d1fe46f9 2020-04-18 stsp local commit_id1=`git_show_head $testroot/repo`
422 d1fe46f9 2020-04-18 stsp
423 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got rm beta >/dev/null)
424 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
425 d1fe46f9 2020-04-18 stsp local commit_id2=`git_show_head $testroot/repo`
426 d1fe46f9 2020-04-18 stsp
427 d1fe46f9 2020-04-18 stsp echo "new file" > $testroot/wt/new
428 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got add new >/dev/null)
429 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
430 d1fe46f9 2020-04-18 stsp local commit_id3=`git_show_head $testroot/repo`
431 5175b31a 2020-01-04 stsp
432 d1fe46f9 2020-04-18 stsp # Print commit 3 only
433 d1fe46f9 2020-04-18 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
434 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -x $commit_id3 | grep ^commit \
435 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
436 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
437 49c543a6 2022-03-31 naddy ret=$?
438 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
439 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
440 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
441 d1fe46f9 2020-04-18 stsp return 1
442 d1fe46f9 2020-04-18 stsp fi
443 d1fe46f9 2020-04-18 stsp
444 d1fe46f9 2020-04-18 stsp # Print commit 3 up to commit 1 inclusive
445 d1fe46f9 2020-04-18 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
446 d1fe46f9 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
447 d1fe46f9 2020-04-18 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
448 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -c $commit_id3 -x $commit_id1 | \
449 d1fe46f9 2020-04-18 stsp grep ^commit > $testroot/stdout)
450 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
451 49c543a6 2022-03-31 naddy ret=$?
452 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
453 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
454 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
455 d1fe46f9 2020-04-18 stsp return 1
456 d1fe46f9 2020-04-18 stsp fi
457 d1fe46f9 2020-04-18 stsp
458 d1fe46f9 2020-04-18 stsp # Create commits on an unrelated branch
459 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got br foo > /dev/null)
460 d1fe46f9 2020-04-18 stsp echo bar >> $testroot/wt/alpha
461 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m "change on branch foo" >/dev/null)
462 d1fe46f9 2020-04-18 stsp local commit_id4=`git_show_branch_head $testroot/repo foo`
463 d1fe46f9 2020-04-18 stsp
464 d1fe46f9 2020-04-18 stsp # Print commit 4 only (in work tree)
465 d1fe46f9 2020-04-18 stsp echo "commit $commit_id4 (foo)" > $testroot/stdout.expected
466 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -x foo | grep ^commit \
467 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
468 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
469 49c543a6 2022-03-31 naddy ret=$?
470 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
471 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
472 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
473 d1fe46f9 2020-04-18 stsp return 1
474 d1fe46f9 2020-04-18 stsp fi
475 d1fe46f9 2020-04-18 stsp
476 d1fe46f9 2020-04-18 stsp # Print commit 4 only (in repository)
477 d1fe46f9 2020-04-18 stsp echo "commit $commit_id4 (foo)" > $testroot/stdout.expected
478 d1fe46f9 2020-04-18 stsp (cd $testroot/repo && got log -c foo -x foo | grep ^commit \
479 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
480 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
481 49c543a6 2022-03-31 naddy ret=$?
482 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
483 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
484 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
485 d1fe46f9 2020-04-18 stsp return 1
486 d1fe46f9 2020-04-18 stsp fi
487 d1fe46f9 2020-04-18 stsp
488 d1fe46f9 2020-04-18 stsp # Repository's HEAD is on master branch so -x foo without an explicit
489 d1fe46f9 2020-04-18 stsp # '-c foo' start commit has no effect there
490 d1fe46f9 2020-04-18 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
491 d1fe46f9 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
492 d1fe46f9 2020-04-18 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
493 d1fe46f9 2020-04-18 stsp echo "commit $commit_id0" >> $testroot/stdout.expected
494 d1fe46f9 2020-04-18 stsp (cd $testroot/repo && got log -x foo | grep ^commit \
495 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
496 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
497 49c543a6 2022-03-31 naddy ret=$?
498 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
499 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
500 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
501 d1fe46f9 2020-04-18 stsp return 1
502 d1fe46f9 2020-04-18 stsp fi
503 d1fe46f9 2020-04-18 stsp
504 d1fe46f9 2020-04-18 stsp # got will refuse -x with a non-existent commit
505 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -x nonexistent \
506 5e91dae4 2022-08-30 stsp > $testroot/stdout 2> $testroot/stderr)
507 49c543a6 2022-03-31 naddy ret=$?
508 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
509 d1fe46f9 2020-04-18 stsp echo "log command succeeded unexpectedly" >&2
510 d1fe46f9 2020-04-18 stsp test_done "$testroot" "1"
511 d1fe46f9 2020-04-18 stsp return 1
512 d1fe46f9 2020-04-18 stsp fi
513 d1fe46f9 2020-04-18 stsp echo -n > $testroot/stdout.expected
514 7f9bfb31 2020-11-01 stsp echo "got: reference nonexistent not found" \
515 d1fe46f9 2020-04-18 stsp > $testroot/stderr.expected
516 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stderr.expected $testroot/stderr
517 49c543a6 2022-03-31 naddy ret=$?
518 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
519 d1fe46f9 2020-04-18 stsp diff -u $testroot/stderr.expected $testroot/stderr
520 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
521 d1fe46f9 2020-04-18 stsp return 1
522 d1fe46f9 2020-04-18 stsp fi
523 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
524 49c543a6 2022-03-31 naddy ret=$?
525 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
526 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
527 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
528 d1fe46f9 2020-04-18 stsp return 1
529 d1fe46f9 2020-04-18 stsp fi
530 d1fe46f9 2020-04-18 stsp
531 d1fe46f9 2020-04-18 stsp # try the same with the hash of an empty string which is very
532 d1fe46f9 2020-04-18 stsp # unlikely to match any object
533 5e91dae4 2022-08-30 stsp local empty_sha1=da39a3ee5e6b4b0d3255bfef95601890afd80709
534 b90c3048 2020-04-19 stsp (cd $testroot/wt && got log -x $empty_sha1 \
535 5e91dae4 2022-08-30 stsp > $testroot/stdout 2> $testroot/stderr)
536 49c543a6 2022-03-31 naddy ret=$?
537 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
538 d1fe46f9 2020-04-18 stsp echo "log command succeeded unexpectedly" >&2
539 d1fe46f9 2020-04-18 stsp test_done "$testroot" "1"
540 d1fe46f9 2020-04-18 stsp return 1
541 d1fe46f9 2020-04-18 stsp fi
542 d1fe46f9 2020-04-18 stsp echo -n > $testroot/stdout.expected
543 138e4f47 2021-10-09 stsp echo "got: commit $empty_sha1: object not found" \
544 138e4f47 2021-10-09 stsp > $testroot/stderr.expected
545 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stderr.expected $testroot/stderr
546 49c543a6 2022-03-31 naddy ret=$?
547 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
548 d1fe46f9 2020-04-18 stsp diff -u $testroot/stderr.expected $testroot/stderr
549 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
550 d1fe46f9 2020-04-18 stsp return 1
551 d1fe46f9 2020-04-18 stsp fi
552 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
553 49c543a6 2022-03-31 naddy ret=$?
554 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
555 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
556 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
557 d1fe46f9 2020-04-18 stsp return 1
558 d1fe46f9 2020-04-18 stsp fi
559 d1fe46f9 2020-04-18 stsp
560 d1fe46f9 2020-04-18 stsp test_done "$testroot" "0"
561 d1fe46f9 2020-04-18 stsp }
562 dbec59df 2020-04-18 stsp
563 f6cae3ed 2020-09-13 naddy test_log_reverse_display() {
564 dbec59df 2020-04-18 stsp local testroot=`test_init log_reverse_display`
565 dbec59df 2020-04-18 stsp local commit_id0=`git_show_head $testroot/repo`
566 dbec59df 2020-04-18 stsp
567 dbec59df 2020-04-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
568 49c543a6 2022-03-31 naddy ret=$?
569 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
570 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
571 dbec59df 2020-04-18 stsp return 1
572 dbec59df 2020-04-18 stsp fi
573 dbec59df 2020-04-18 stsp
574 dbec59df 2020-04-18 stsp echo "modified alpha" > $testroot/wt/alpha
575 dbec59df 2020-04-18 stsp (cd $testroot/wt && got commit -m 'commit1' > /dev/null)
576 dbec59df 2020-04-18 stsp local commit_id1=`git_show_head $testroot/repo`
577 dbec59df 2020-04-18 stsp
578 dbec59df 2020-04-18 stsp (cd $testroot/wt && got rm beta >/dev/null)
579 dbec59df 2020-04-18 stsp (cd $testroot/wt && got commit -m 'commit2' > /dev/null)
580 dbec59df 2020-04-18 stsp local commit_id2=`git_show_head $testroot/repo`
581 dbec59df 2020-04-18 stsp
582 dbec59df 2020-04-18 stsp echo "new file" > $testroot/wt/new
583 dbec59df 2020-04-18 stsp (cd $testroot/wt && got add new >/dev/null)
584 dbec59df 2020-04-18 stsp (cd $testroot/wt && got commit -m 'commit3' > /dev/null)
585 dbec59df 2020-04-18 stsp local commit_id3=`git_show_head $testroot/repo`
586 d1fe46f9 2020-04-18 stsp
587 dbec59df 2020-04-18 stsp # -R alone should display all commits in reverse
588 dbec59df 2020-04-18 stsp echo "commit $commit_id0" > $testroot/stdout.expected
589 dbec59df 2020-04-18 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
590 dbec59df 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
591 dbec59df 2020-04-18 stsp echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
592 dbec59df 2020-04-18 stsp (cd $testroot/wt && got log -R | grep ^commit > $testroot/stdout)
593 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
594 49c543a6 2022-03-31 naddy ret=$?
595 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
596 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
597 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
598 dbec59df 2020-04-18 stsp return 1
599 dbec59df 2020-04-18 stsp fi
600 dbec59df 2020-04-18 stsp
601 dbec59df 2020-04-18 stsp # -R takes effect after the -l commit traversal limit
602 dbec59df 2020-04-18 stsp echo "commit $commit_id2" > $testroot/stdout.expected
603 dbec59df 2020-04-18 stsp echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
604 dbec59df 2020-04-18 stsp (cd $testroot/wt && got log -R -l2 | grep ^commit > $testroot/stdout)
605 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
606 49c543a6 2022-03-31 naddy ret=$?
607 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
608 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
609 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
610 dbec59df 2020-04-18 stsp return 1
611 dbec59df 2020-04-18 stsp fi
612 dbec59df 2020-04-18 stsp
613 dbec59df 2020-04-18 stsp # -R works with commit ranges specified via -c and -x
614 dbec59df 2020-04-18 stsp echo "commit $commit_id1" > $testroot/stdout.expected
615 dbec59df 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
616 dbec59df 2020-04-18 stsp echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
617 dbec59df 2020-04-18 stsp (cd $testroot/wt && got log -R -c $commit_id3 -x $commit_id1 | \
618 dbec59df 2020-04-18 stsp grep ^commit > $testroot/stdout)
619 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
620 49c543a6 2022-03-31 naddy ret=$?
621 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
622 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
623 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
624 a9662115 2021-08-29 naddy return 1
625 dbec59df 2020-04-18 stsp fi
626 dbec59df 2020-04-18 stsp
627 dbec59df 2020-04-18 stsp # commit matching with -s applies before -R
628 dbec59df 2020-04-18 stsp echo "commit $commit_id1" > $testroot/stdout.expected
629 dbec59df 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
630 c1c775eb 2022-06-08 stsp (cd $testroot/wt && got log -R -S 'commit[12]' | \
631 dbec59df 2020-04-18 stsp grep ^commit > $testroot/stdout)
632 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
633 49c543a6 2022-03-31 naddy ret=$?
634 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
635 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
636 502b9684 2020-07-31 stsp test_done "$testroot" "$ret"
637 502b9684 2020-07-31 stsp return 1
638 dbec59df 2020-04-18 stsp fi
639 502b9684 2020-07-31 stsp
640 502b9684 2020-07-31 stsp # -R works in combination with -P
641 502b9684 2020-07-31 stsp echo "" > $testroot/stdout.expected
642 502b9684 2020-07-31 stsp (cd $testroot/wt && got log -R -P | grep -E '^(commit| [MDmA])' \
643 502b9684 2020-07-31 stsp > $testroot/stdout)
644 502b9684 2020-07-31 stsp echo "commit $commit_id0" > $testroot/stdout.expected
645 502b9684 2020-07-31 stsp echo " A alpha" >> $testroot/stdout.expected
646 502b9684 2020-07-31 stsp echo " A beta" >> $testroot/stdout.expected
647 502b9684 2020-07-31 stsp echo " A epsilon/zeta" >> $testroot/stdout.expected
648 502b9684 2020-07-31 stsp echo " A gamma/delta" >> $testroot/stdout.expected
649 502b9684 2020-07-31 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
650 502b9684 2020-07-31 stsp echo " M alpha" >> $testroot/stdout.expected
651 502b9684 2020-07-31 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
652 502b9684 2020-07-31 stsp echo " D beta" >> $testroot/stdout.expected
653 502b9684 2020-07-31 stsp echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
654 502b9684 2020-07-31 stsp echo " A new" >> $testroot/stdout.expected
655 502b9684 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
656 49c543a6 2022-03-31 naddy ret=$?
657 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
658 502b9684 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
659 502b9684 2020-07-31 stsp fi
660 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
661 50f2fada 2020-04-24 stsp }
662 50f2fada 2020-04-24 stsp
663 f6cae3ed 2020-09-13 naddy test_log_in_worktree_different_repo() {
664 50f2fada 2020-04-24 stsp local testroot=`test_init log_in_worktree_different_repo 1`
665 50f2fada 2020-04-24 stsp
666 50f2fada 2020-04-24 stsp make_test_tree $testroot/repo
667 50f2fada 2020-04-24 stsp mkdir -p $testroot/repo/epsilon/d
668 50f2fada 2020-04-24 stsp echo foo > $testroot/repo/epsilon/d/foo
669 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add .
670 50f2fada 2020-04-24 stsp git_commit $testroot/repo -m "adding the test tree"
671 50f2fada 2020-04-24 stsp local head_commit=`git_show_head $testroot/repo`
672 50f2fada 2020-04-24 stsp
673 02a5c5d0 2022-07-04 stsp gotadmin init $testroot/other-repo
674 50f2fada 2020-04-24 stsp mkdir -p $testroot/tree
675 50f2fada 2020-04-24 stsp make_test_tree $testroot/tree
676 50f2fada 2020-04-24 stsp got import -mm -b foo -r $testroot/other-repo $testroot/tree >/dev/null
677 50f2fada 2020-04-24 stsp got checkout -b foo $testroot/other-repo $testroot/wt > /dev/null
678 49c543a6 2022-03-31 naddy ret=$?
679 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
680 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
681 50f2fada 2020-04-24 stsp return 1
682 50f2fada 2020-04-24 stsp fi
683 50f2fada 2020-04-24 stsp
684 50f2fada 2020-04-24 stsp echo "commit $head_commit (master)" > $testroot/stdout.expected
685 50f2fada 2020-04-24 stsp
686 50f2fada 2020-04-24 stsp # 'got log' used to fail with "reference refs/heads/foo not found"
687 50f2fada 2020-04-24 stsp # even though that reference belongs to an unrelated repository
688 50f2fada 2020-04-24 stsp # found via a worktree via the current working directory
689 50f2fada 2020-04-24 stsp for p in "" alpha epsilon; do
690 50f2fada 2020-04-24 stsp (cd $testroot/wt && got log -r $testroot/repo $p | \
691 50f2fada 2020-04-24 stsp grep ^commit > $testroot/stdout)
692 50f2fada 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
693 49c543a6 2022-03-31 naddy ret=$?
694 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
695 50f2fada 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
696 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
697 50f2fada 2020-04-24 stsp return 1
698 50f2fada 2020-04-24 stsp fi
699 50f2fada 2020-04-24 stsp done
700 50f2fada 2020-04-24 stsp
701 50f2fada 2020-04-24 stsp for p in "" epsilon/zeta; do
702 50f2fada 2020-04-24 stsp (cd $testroot/wt/epsilon && got log -r $testroot/repo $p | \
703 50f2fada 2020-04-24 stsp grep ^commit > $testroot/stdout)
704 50f2fada 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
705 49c543a6 2022-03-31 naddy ret=$?
706 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
707 50f2fada 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
708 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
709 50f2fada 2020-04-24 stsp return 1
710 50f2fada 2020-04-24 stsp fi
711 50f2fada 2020-04-24 stsp done
712 50f2fada 2020-04-24 stsp
713 50f2fada 2020-04-24 stsp for p in "" foo; do
714 50f2fada 2020-04-24 stsp (cd $testroot/wt/epsilon && got log -r $testroot/repo epsilon/d/$p | \
715 50f2fada 2020-04-24 stsp grep ^commit > $testroot/stdout)
716 50f2fada 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
717 49c543a6 2022-03-31 naddy ret=$?
718 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
719 50f2fada 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
720 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
721 50f2fada 2020-04-24 stsp return 1
722 50f2fada 2020-04-24 stsp fi
723 50f2fada 2020-04-24 stsp done
724 50f2fada 2020-04-24 stsp
725 50f2fada 2020-04-24 stsp test_done "$testroot" "0"
726 dbec59df 2020-04-18 stsp }
727 0208f208 2020-05-05 stsp
728 f6cae3ed 2020-09-13 naddy test_log_changed_paths() {
729 0208f208 2020-05-05 stsp local testroot=`test_init log_changed_paths`
730 0208f208 2020-05-05 stsp local commit_id0=`git_show_head $testroot/repo`
731 0208f208 2020-05-05 stsp
732 0208f208 2020-05-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
733 49c543a6 2022-03-31 naddy ret=$?
734 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
735 0208f208 2020-05-05 stsp test_done "$testroot" "$ret"
736 0208f208 2020-05-05 stsp return 1
737 0208f208 2020-05-05 stsp fi
738 0208f208 2020-05-05 stsp
739 0208f208 2020-05-05 stsp echo "modified alpha" > $testroot/wt/alpha
740 0208f208 2020-05-05 stsp (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
741 0208f208 2020-05-05 stsp local commit_id1=`git_show_head $testroot/repo`
742 dbec59df 2020-04-18 stsp
743 0208f208 2020-05-05 stsp (cd $testroot/wt && got rm beta >/dev/null)
744 0208f208 2020-05-05 stsp (cd $testroot/wt && chmod +x epsilon/zeta >/dev/null)
745 0208f208 2020-05-05 stsp (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
746 0208f208 2020-05-05 stsp local commit_id2=`git_show_head $testroot/repo`
747 0208f208 2020-05-05 stsp
748 0208f208 2020-05-05 stsp echo "new file" > $testroot/wt/new
749 0208f208 2020-05-05 stsp (cd $testroot/wt && got add new >/dev/null)
750 0208f208 2020-05-05 stsp (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
751 0208f208 2020-05-05 stsp local commit_id3=`git_show_head $testroot/repo`
752 0208f208 2020-05-05 stsp
753 0208f208 2020-05-05 stsp (cd $testroot/wt && got log -P | grep '^ [MDmA]' > $testroot/stdout)
754 0208f208 2020-05-05 stsp
755 0208f208 2020-05-05 stsp echo " A new" > $testroot/stdout.expected
756 0208f208 2020-05-05 stsp echo " D beta" >> $testroot/stdout.expected
757 0208f208 2020-05-05 stsp echo " m epsilon/zeta" >> $testroot/stdout.expected
758 0208f208 2020-05-05 stsp echo " M alpha" >> $testroot/stdout.expected
759 0208f208 2020-05-05 stsp echo " A alpha" >> $testroot/stdout.expected
760 0208f208 2020-05-05 stsp echo " A beta" >> $testroot/stdout.expected
761 0208f208 2020-05-05 stsp echo " A epsilon/zeta" >> $testroot/stdout.expected
762 0208f208 2020-05-05 stsp echo " A gamma/delta" >> $testroot/stdout.expected
763 e7303626 2020-05-14 stsp
764 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
765 49c543a6 2022-03-31 naddy ret=$?
766 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
767 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
768 e7303626 2020-05-14 stsp fi
769 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
770 e7303626 2020-05-14 stsp }
771 f9a64b14 2024-02-03 falsifian
772 f9a64b14 2024-02-03 falsifian test_log_merge_commit_nonexistent_path() {
773 f9a64b14 2024-02-03 falsifian local testroot=`test_init log_merge_commit_corner_case 1`
774 e7303626 2020-05-14 stsp
775 f9a64b14 2024-02-03 falsifian # Create the following commit graph (most recent commit shown first):
776 f9a64b14 2024-02-03 falsifian #
777 f9a64b14 2024-02-03 falsifian # o create dir/beta
778 f9a64b14 2024-02-03 falsifian # |
779 f9a64b14 2024-02-03 falsifian # o merge (does not touch dir)
780 f9a64b14 2024-02-03 falsifian # / \
781 f9a64b14 2024-02-03 falsifian # o o changes which don't touch the directory "dir"
782 f9a64b14 2024-02-03 falsifian # \ /
783 f9a64b14 2024-02-03 falsifian # o initial commit, which includes directory "dir" but not dir/beta
784 f9a64b14 2024-02-03 falsifian
785 f9a64b14 2024-02-03 falsifian
786 f9a64b14 2024-02-03 falsifian mkdir $testroot/repo/dir
787 f9a64b14 2024-02-03 falsifian touch $testroot/repo/dir/alpha
788 f9a64b14 2024-02-03 falsifian git -C $testroot/repo add dir/alpha
789 f9a64b14 2024-02-03 falsifian git_commit $testroot/repo -m "initial commit"
790 f9a64b14 2024-02-03 falsifian
791 f9a64b14 2024-02-03 falsifian git -C $testroot/repo checkout -q -b aux
792 f9a64b14 2024-02-03 falsifian touch $testroot/repo/gamma
793 f9a64b14 2024-02-03 falsifian git -C $testroot/repo add gamma
794 f9a64b14 2024-02-03 falsifian git_commit $testroot/repo -m "change on aux"
795 f9a64b14 2024-02-03 falsifian
796 f9a64b14 2024-02-03 falsifian git -C $testroot/repo checkout -q master
797 f9a64b14 2024-02-03 falsifian touch $testroot/repo/delta
798 f9a64b14 2024-02-03 falsifian git -C $testroot/repo add delta
799 f9a64b14 2024-02-03 falsifian git_commit $testroot/repo -m "change on master"
800 f9a64b14 2024-02-03 falsifian
801 f9a64b14 2024-02-03 falsifian git -C $testroot/repo merge -q -m "merge" aux
802 f9a64b14 2024-02-03 falsifian
803 f9a64b14 2024-02-03 falsifian touch $testroot/repo/dir/beta
804 f9a64b14 2024-02-03 falsifian git -C $testroot/repo add dir/beta
805 f9a64b14 2024-02-03 falsifian git_commit $testroot/repo -m "add beta"
806 f9a64b14 2024-02-03 falsifian
807 f9a64b14 2024-02-03 falsifian head_commit=`git_show_head $testroot/repo`
808 f9a64b14 2024-02-03 falsifian
809 f9a64b14 2024-02-03 falsifian got log -r $testroot/repo -b dir/beta | grep ^commit > $testroot/stdout
810 f9a64b14 2024-02-03 falsifian ret=$?
811 f9a64b14 2024-02-03 falsifian if [ $ret -ne 0 ]; then
812 f9a64b14 2024-02-03 falsifian echo "log command failed unexpectedly" >&2
813 f9a64b14 2024-02-03 falsifian test_done "$testroot" "1"
814 f9a64b14 2024-02-03 falsifian return 1
815 f9a64b14 2024-02-03 falsifian fi
816 f9a64b14 2024-02-03 falsifian
817 f9a64b14 2024-02-03 falsifian echo "commit $head_commit (master)" > $testroot/stdout.expected
818 f9a64b14 2024-02-03 falsifian cmp -s $testroot/stdout.expected $testroot/stdout
819 f9a64b14 2024-02-03 falsifian ret=$?
820 f9a64b14 2024-02-03 falsifian if [ $ret -ne 0 ]; then
821 f9a64b14 2024-02-03 falsifian diff -u $testroot/stdout.expected $testroot/stdout
822 f9a64b14 2024-02-03 falsifian fi
823 f9a64b14 2024-02-03 falsifian test_done "$testroot" "$ret"
824 f9a64b14 2024-02-03 falsifian }
825 f9a64b14 2024-02-03 falsifian
826 f6cae3ed 2020-09-13 naddy test_log_submodule() {
827 e7303626 2020-05-14 stsp local testroot=`test_init log_submodule`
828 e7303626 2020-05-14 stsp
829 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
830 e7303626 2020-05-14 stsp
831 f73bf5bd 2023-10-01 naddy git -C $testroot/repo -c protocol.file.allow=always \
832 f73bf5bd 2023-10-01 naddy submodule -q add ../repo2
833 f73bf5bd 2023-10-01 naddy git -C $testroot/repo commit -q -m 'adding submodule'
834 e7303626 2020-05-14 stsp local head_commit=`git_show_head $testroot/repo`
835 e7303626 2020-05-14 stsp
836 e7303626 2020-05-14 stsp echo "commit $head_commit (master)" > $testroot/stdout.expected
837 e7303626 2020-05-14 stsp
838 e7303626 2020-05-14 stsp got log -r $testroot/repo -l1 repo2 | grep ^commit > $testroot/stdout
839 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
840 49c543a6 2022-03-31 naddy ret=$?
841 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
842 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
843 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
844 e7303626 2020-05-14 stsp return 1
845 e7303626 2020-05-14 stsp fi
846 e7303626 2020-05-14 stsp
847 e7303626 2020-05-14 stsp echo " A .gitmodules" > $testroot/stdout.expected
848 e7303626 2020-05-14 stsp
849 e7303626 2020-05-14 stsp got log -r $testroot/repo -l1 -P repo2 | grep '^ [MDmA]' \
850 e7303626 2020-05-14 stsp > $testroot/stdout
851 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
852 49c543a6 2022-03-31 naddy ret=$?
853 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
854 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
855 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
856 e7303626 2020-05-14 stsp return 1
857 e7303626 2020-05-14 stsp fi
858 e7303626 2020-05-14 stsp
859 e7303626 2020-05-14 stsp got log -p -r $testroot/repo -l1 repo2 \
860 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr
861 49c543a6 2022-03-31 naddy ret=$?
862 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
863 e7303626 2020-05-14 stsp echo "log command succeeded unexpectedly" >&2
864 e7303626 2020-05-14 stsp test_done "$testroot" "1"
865 e7303626 2020-05-14 stsp return 1
866 e7303626 2020-05-14 stsp fi
867 e7303626 2020-05-14 stsp local submodule_id=$(got tree -r $testroot/repo -i | \
868 e7303626 2020-05-14 stsp grep 'repo2\$$' | cut -d ' ' -f1)
869 e7303626 2020-05-14 stsp echo "got: object $submodule_id not found" > $testroot/stderr.expected
870 0208f208 2020-05-05 stsp
871 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
872 49c543a6 2022-03-31 naddy ret=$?
873 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
874 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
875 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
876 e7303626 2020-05-14 stsp return 1
877 e7303626 2020-05-14 stsp fi
878 e7303626 2020-05-14 stsp
879 e7303626 2020-05-14 stsp echo "modified foo" > $testroot/repo2/foo
880 f73bf5bd 2023-10-01 naddy git -C $testroot/repo2 commit -q -a -m 'modified a submodule'
881 e7303626 2020-05-14 stsp
882 e7303626 2020-05-14 stsp # Update the repo/repo2 submodule link
883 f73bf5bd 2023-10-01 naddy git -C $testroot/repo/repo2 pull -q
884 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add repo2
885 e7303626 2020-05-14 stsp git_commit $testroot/repo -m "changed submodule link"
886 e7303626 2020-05-14 stsp
887 e7303626 2020-05-14 stsp # log -P does not show the changed submodule path
888 e7303626 2020-05-14 stsp got log -P -r $testroot/repo -l1 repo2 > $testroot/stdout.full
889 49c543a6 2022-03-31 naddy ret=$?
890 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
891 e7303626 2020-05-14 stsp echo "log command failed unexpectedly" >&2
892 e7303626 2020-05-14 stsp test_done "$testroot" "1"
893 e7303626 2020-05-14 stsp return 1
894 e7303626 2020-05-14 stsp fi
895 e7303626 2020-05-14 stsp grep '^ [MDmA]' $testroot/stdout.full > $testroot/stdout
896 e7303626 2020-05-14 stsp
897 e7303626 2020-05-14 stsp echo -n > $testroot/stdout.expected
898 8f4e3da9 2023-01-07 mark cmp -s $testroot/stdout.expected $testroot/stdout
899 8f4e3da9 2023-01-07 mark ret=$?
900 8f4e3da9 2023-01-07 mark if [ $ret -ne 0 ]; then
901 8f4e3da9 2023-01-07 mark diff -u $testroot/stdout.expected $testroot/stdout
902 8f4e3da9 2023-01-07 mark fi
903 8f4e3da9 2023-01-07 mark test_done "$testroot" "$ret"
904 8f4e3da9 2023-01-07 mark }
905 8f4e3da9 2023-01-07 mark
906 8f4e3da9 2023-01-07 mark test_log_diffstat() {
907 8f4e3da9 2023-01-07 mark local testroot=`test_init log_diffstat`
908 8f4e3da9 2023-01-07 mark
909 8f4e3da9 2023-01-07 mark got checkout $testroot/repo $testroot/wt > /dev/null
910 8f4e3da9 2023-01-07 mark ret=$?
911 8f4e3da9 2023-01-07 mark if [ $ret -ne 0 ]; then
912 8f4e3da9 2023-01-07 mark test_done "$testroot" "$ret"
913 8f4e3da9 2023-01-07 mark return 1
914 8f4e3da9 2023-01-07 mark fi
915 8f4e3da9 2023-01-07 mark
916 5763426a 2023-01-07 op printf "modified\nalpha.\n" > $testroot/wt/alpha
917 8f4e3da9 2023-01-07 mark (cd $testroot/wt && got commit -m 'log_diffstat mod file' > /dev/null)
918 8f4e3da9 2023-01-07 mark
919 8f4e3da9 2023-01-07 mark (cd $testroot/wt && got rm beta >/dev/null)
920 8f4e3da9 2023-01-07 mark (cd $testroot/wt && chmod +x epsilon/zeta >/dev/null)
921 8f4e3da9 2023-01-07 mark (cd $testroot/wt && got commit -m 'log_diffstat rm file' > /dev/null)
922 8f4e3da9 2023-01-07 mark
923 8f4e3da9 2023-01-07 mark echo "new file" > $testroot/wt/new
924 8f4e3da9 2023-01-07 mark (cd $testroot/wt && got add new >/dev/null)
925 8f4e3da9 2023-01-07 mark (cd $testroot/wt && got commit -m 'log_diffstat add file' > /dev/null)
926 8f4e3da9 2023-01-07 mark
927 5763426a 2023-01-07 op cat <<EOF >$testroot/stdout.expected
928 5763426a 2023-01-07 op A new | 1+ 0-
929 8f4e3da9 2023-01-07 mark
930 4a1a7373 2023-01-16 mark 1 file changed, 1 insertion(+), 0 deletions(-)
931 5763426a 2023-01-07 op D beta | 0+ 1-
932 5763426a 2023-01-07 op m epsilon/zeta | 0+ 0-
933 5763426a 2023-01-07 op
934 4a1a7373 2023-01-16 mark 2 files changed, 0 insertions(+), 1 deletion(-)
935 5763426a 2023-01-07 op M alpha | 2+ 1-
936 5763426a 2023-01-07 op
937 4a1a7373 2023-01-16 mark 1 file changed, 2 insertions(+), 1 deletion(-)
938 5763426a 2023-01-07 op A alpha | 1+ 0-
939 5763426a 2023-01-07 op A beta | 1+ 0-
940 5763426a 2023-01-07 op A epsilon/zeta | 1+ 0-
941 5763426a 2023-01-07 op A gamma/delta | 1+ 0-
942 5763426a 2023-01-07 op
943 5763426a 2023-01-07 op 4 files changed, 4 insertions(+), 0 deletions(-)
944 5763426a 2023-01-07 op EOF
945 5763426a 2023-01-07 op
946 0778bf80 2023-08-08 mark # try different -dPp combinations
947 0778bf80 2023-08-08 mark for flags in -d -dP -dp -dPp; do
948 0778bf80 2023-08-08 mark (cd $testroot/wt && got log $flags | grep -A2 '^ [MDmA]' | \
949 0778bf80 2023-08-08 mark sed '/^--/d' > $testroot/stdout)
950 0778bf80 2023-08-08 mark
951 0778bf80 2023-08-08 mark cmp -s $testroot/stdout.expected $testroot/stdout
952 0778bf80 2023-08-08 mark ret=$?
953 0778bf80 2023-08-08 mark if [ $ret -ne 0 ]; then
954 0778bf80 2023-08-08 mark diff -u $testroot/stdout.expected $testroot/stdout
955 0778bf80 2023-08-08 mark test_done "$testroot" "$ret"
956 0778bf80 2023-08-08 mark return 1
957 0778bf80 2023-08-08 mark fi
958 0778bf80 2023-08-08 mark done
959 0778bf80 2023-08-08 mark
960 0778bf80 2023-08-08 mark test_done "$testroot" "0"
961 0208f208 2020-05-05 stsp }
962 fd7552d2 2023-07-17 mark
963 fd7552d2 2023-07-17 mark test_log_commit_keywords() {
964 fd7552d2 2023-07-17 mark local testroot=$(test_init log_commit_keywords)
965 fd7552d2 2023-07-17 mark local commit_time=`git_show_author_time $testroot/repo`
966 fd7552d2 2023-07-17 mark local d=`date -u -r $commit_time +"%G-%m-%d"`
967 fd7552d2 2023-07-17 mark
968 79c49d84 2023-07-24 mark set -- "$(git_show_head $testroot/repo)"
969 fd7552d2 2023-07-17 mark
970 fd7552d2 2023-07-17 mark got checkout $testroot/repo $testroot/wt > /dev/null
971 fd7552d2 2023-07-17 mark ret=$?
972 fd7552d2 2023-07-17 mark if [ $ret -ne 0 ]; then
973 fd7552d2 2023-07-17 mark echo "checkout failed unexpectedly" >&2
974 fd7552d2 2023-07-17 mark test_done "$testroot" "$ret"
975 fd7552d2 2023-07-17 mark return 1
976 fd7552d2 2023-07-17 mark fi
977 fd7552d2 2023-07-17 mark
978 fd7552d2 2023-07-17 mark for i in $(seq 16); do
979 fd7552d2 2023-07-17 mark echo "alpha change $i" > "$testroot/wt/alpha"
980 fd7552d2 2023-07-17 mark
981 fd7552d2 2023-07-17 mark (cd "$testroot/wt" && got ci -m "commit number $i" > /dev/null)
982 fd7552d2 2023-07-17 mark ret=$?
983 fd7552d2 2023-07-17 mark if [ $ret -ne 0 ]; then
984 fd7552d2 2023-07-17 mark echo "commit failed unexpectedly" >&2
985 fd7552d2 2023-07-17 mark test_done "$testroot" "$ret"
986 fd7552d2 2023-07-17 mark return 1
987 fd7552d2 2023-07-17 mark fi
988 79c49d84 2023-07-24 mark set -- "$@" "$(git_show_head $testroot/repo)"
989 fd7552d2 2023-07-17 mark done
990 fd7552d2 2023-07-17 mark
991 fd7552d2 2023-07-17 mark for i in $(seq 16 2); do
992 fd7552d2 2023-07-17 mark printf '%s %.7s commit number %s\n' \
993 79c49d84 2023-07-24 mark "$d" $(pop_idx $i $@) "$(( i-1 ))" \
994 fd7552d2 2023-07-17 mark >> $testroot/stdout.expected
995 fd7552d2 2023-07-17 mark done
996 fd7552d2 2023-07-17 mark
997 0778bf80 2023-08-08 mark got log -r "$testroot/repo" -s -cmaster:- -l15 > $testroot/stdout
998 fd7552d2 2023-07-17 mark
999 fd7552d2 2023-07-17 mark cmp -s $testroot/stdout.expected $testroot/stdout
1000 fd7552d2 2023-07-17 mark ret=$?
1001 fd7552d2 2023-07-17 mark if [ $ret -ne 0 ]; then
1002 fd7552d2 2023-07-17 mark diff -u $testroot/stdout.expected $testroot/stdout
1003 fd7552d2 2023-07-17 mark test_done "$testroot" "$ret"
1004 fd7552d2 2023-07-17 mark return 1
1005 fd7552d2 2023-07-17 mark fi
1006 0208f208 2020-05-05 stsp
1007 0778bf80 2023-08-08 mark # request same set of commits now with log -x
1008 0778bf80 2023-08-08 mark got log -r "$testroot/repo" -s -cmaster:- -xmaster:-15 > \
1009 0778bf80 2023-08-08 mark $testroot/stdout
1010 0778bf80 2023-08-08 mark
1011 0778bf80 2023-08-08 mark cmp -s $testroot/stdout.expected $testroot/stdout
1012 0778bf80 2023-08-08 mark ret=$?
1013 0778bf80 2023-08-08 mark if [ $ret -ne 0 ]; then
1014 0778bf80 2023-08-08 mark diff -u $testroot/stdout.expected $testroot/stdout
1015 0778bf80 2023-08-08 mark test_done "$testroot" "$ret"
1016 0778bf80 2023-08-08 mark return 1
1017 0778bf80 2023-08-08 mark fi
1018 0778bf80 2023-08-08 mark
1019 fd7552d2 2023-07-17 mark (cd $testroot/wt && got update -c:head:-8 > /dev/null)
1020 fd7552d2 2023-07-17 mark ret=$?
1021 fd7552d2 2023-07-17 mark if [ $ret -ne 0 ]; then
1022 fd7552d2 2023-07-17 mark echo "update failed unexpectedly" >&2
1023 fd7552d2 2023-07-17 mark test_done "$testroot" "1"
1024 fd7552d2 2023-07-17 mark return 1
1025 fd7552d2 2023-07-17 mark fi
1026 fd7552d2 2023-07-17 mark
1027 fd7552d2 2023-07-17 mark echo -n > "$testroot/stdout.expected"
1028 fd7552d2 2023-07-17 mark
1029 fd7552d2 2023-07-17 mark for i in $(seq 9 2); do
1030 fd7552d2 2023-07-17 mark printf '%s %.7s commit number %s\n' \
1031 79c49d84 2023-07-24 mark "$d" $(pop_idx $i $@) "$(( i-1 ))" \
1032 fd7552d2 2023-07-17 mark >> $testroot/stdout.expected
1033 fd7552d2 2023-07-17 mark done
1034 79c49d84 2023-07-24 mark printf '%s %.7s adding the test tree\n' "$d" $(pop_idx 1 $@) >> \
1035 fd7552d2 2023-07-17 mark $testroot/stdout.expected
1036 fd7552d2 2023-07-17 mark
1037 0778bf80 2023-08-08 mark (cd $testroot/wt && got log -s -c:base > $testroot/stdout)
1038 fd7552d2 2023-07-17 mark
1039 fd7552d2 2023-07-17 mark cmp -s $testroot/stdout.expected $testroot/stdout
1040 fd7552d2 2023-07-17 mark ret=$?
1041 fd7552d2 2023-07-17 mark if [ $ret -ne 0 ]; then
1042 fd7552d2 2023-07-17 mark diff -u $testroot/stdout.expected $testroot/stdout
1043 fd7552d2 2023-07-17 mark test_done "$testroot" "$ret"
1044 fd7552d2 2023-07-17 mark return 1
1045 fd7552d2 2023-07-17 mark fi
1046 fd7552d2 2023-07-17 mark
1047 0778bf80 2023-08-08 mark # from head to the base commit using -x
1048 0778bf80 2023-08-08 mark printf '%s %-7s commit number 16\n' "$d" "master" > \
1049 0778bf80 2023-08-08 mark $testroot/stdout.expected
1050 0778bf80 2023-08-08 mark for i in $(seq 16 9); do
1051 0778bf80 2023-08-08 mark printf '%s %.7s commit number %s\n' \
1052 0778bf80 2023-08-08 mark "$d" $(pop_idx $i $@) $(( i-1 )) \
1053 0778bf80 2023-08-08 mark >> $testroot/stdout.expected
1054 0778bf80 2023-08-08 mark done
1055 0778bf80 2023-08-08 mark
1056 0778bf80 2023-08-08 mark (cd $testroot/wt && got log -s -c:head -x:base > $testroot/stdout)
1057 0778bf80 2023-08-08 mark
1058 0778bf80 2023-08-08 mark cmp -s $testroot/stdout.expected $testroot/stdout
1059 0778bf80 2023-08-08 mark ret=$?
1060 0778bf80 2023-08-08 mark if [ $ret -ne 0 ]; then
1061 0778bf80 2023-08-08 mark diff -u $testroot/stdout.expected $testroot/stdout
1062 0778bf80 2023-08-08 mark test_done "$testroot" "$ret"
1063 0778bf80 2023-08-08 mark return 1
1064 0778bf80 2023-08-08 mark fi
1065 0778bf80 2023-08-08 mark
1066 fd7552d2 2023-07-17 mark # if + modifier is too great, use HEAD commit
1067 fd7552d2 2023-07-17 mark printf '%s %-7s commit number %s\n' "$d" master 16 > \
1068 fd7552d2 2023-07-17 mark $testroot/stdout.expected
1069 79c49d84 2023-07-24 mark printf '%s %.7s commit number %s\n' "$d" $(pop_idx 16 $@) 15 >> \
1070 fd7552d2 2023-07-17 mark $testroot/stdout.expected
1071 fd7552d2 2023-07-17 mark
1072 0778bf80 2023-08-08 mark (cd $testroot/wt && got log -s -c:base:+20 -l2 > $testroot/stdout)
1073 fd7552d2 2023-07-17 mark
1074 fd7552d2 2023-07-17 mark cmp -s $testroot/stdout.expected $testroot/stdout
1075 fd7552d2 2023-07-17 mark ret=$?
1076 fd7552d2 2023-07-17 mark if [ $ret -ne 0 ]; then
1077 fd7552d2 2023-07-17 mark diff -u $testroot/stdout.expected $testroot/stdout
1078 fd7552d2 2023-07-17 mark test_done "$testroot" "$ret"
1079 fd7552d2 2023-07-17 mark return 1
1080 fd7552d2 2023-07-17 mark fi
1081 fd7552d2 2023-07-17 mark
1082 fd7552d2 2023-07-17 mark # if - modifier is too great, use root commit
1083 79c49d84 2023-07-24 mark printf '%s %.7s adding the test tree\n' "$d" $(pop_idx 1 $@) > \
1084 fd7552d2 2023-07-17 mark $testroot/stdout.expected
1085 fd7552d2 2023-07-17 mark
1086 0778bf80 2023-08-08 mark (cd $testroot/wt && got log -s -c:base:-10 > $testroot/stdout)
1087 fd7552d2 2023-07-17 mark cmp -s $testroot/stdout.expected $testroot/stdout
1088 fd7552d2 2023-07-17 mark ret=$?
1089 fd7552d2 2023-07-17 mark if [ $ret -ne 0 ]; then
1090 fd7552d2 2023-07-17 mark diff -u $testroot/stdout.expected $testroot/stdout
1091 fd7552d2 2023-07-17 mark test_done "$testroot" "$ret"
1092 fd7552d2 2023-07-17 mark return 1
1093 fd7552d2 2023-07-17 mark fi
1094 fd7552d2 2023-07-17 mark
1095 79c49d84 2023-07-24 mark got br -r "$testroot/repo" -c $(pop_idx 1 $@) base+
1096 fd7552d2 2023-07-17 mark
1097 79c49d84 2023-07-24 mark printf '%s %.7s commit number 1\n' "$d" $(pop_idx 2 $@) > \
1098 fd7552d2 2023-07-17 mark $testroot/stdout.expected
1099 fd7552d2 2023-07-17 mark
1100 0778bf80 2023-08-08 mark (cd $testroot/wt && got log -s -cbase+:+ -l1 > $testroot/stdout)
1101 fd7552d2 2023-07-17 mark
1102 fd7552d2 2023-07-17 mark cmp -s $testroot/stdout.expected $testroot/stdout
1103 fd7552d2 2023-07-17 mark ret=$?
1104 fd7552d2 2023-07-17 mark if [ $ret -ne 0 ]; then
1105 fd7552d2 2023-07-17 mark diff -u $testroot/stdout.expected $testroot/stdout
1106 fd7552d2 2023-07-17 mark test_done "$testroot" "$ret"
1107 fd7552d2 2023-07-17 mark return 1
1108 fd7552d2 2023-07-17 mark fi
1109 fd7552d2 2023-07-17 mark
1110 79c49d84 2023-07-24 mark got br -r "$testroot/repo" -c $(pop_idx 3 $@) head-1
1111 fd7552d2 2023-07-17 mark
1112 79c49d84 2023-07-24 mark printf '%s %.7s commit number 1\n' "$d" $(pop_idx 2 $@) > \
1113 fd7552d2 2023-07-17 mark $testroot/stdout.expected
1114 fd7552d2 2023-07-17 mark
1115 0778bf80 2023-08-08 mark (cd $testroot/wt && got log -s -chead-1:- -l1 > $testroot/stdout)
1116 fd7552d2 2023-07-17 mark
1117 fd7552d2 2023-07-17 mark cmp -s $testroot/stdout.expected $testroot/stdout
1118 fd7552d2 2023-07-17 mark ret=$?
1119 fd7552d2 2023-07-17 mark if [ $ret -ne 0 ]; then
1120 fd7552d2 2023-07-17 mark diff -u $testroot/stdout.expected $testroot/stdout
1121 fd7552d2 2023-07-17 mark test_done "$testroot" "$ret"
1122 fd7552d2 2023-07-17 mark return 1
1123 fd7552d2 2023-07-17 mark fi
1124 fd7552d2 2023-07-17 mark
1125 79c49d84 2023-07-24 mark got br -r "$testroot/repo" -c $(pop_idx 16 $@) base-1+2
1126 fd7552d2 2023-07-17 mark
1127 79c49d84 2023-07-24 mark printf '%s %.7s commit number 12\n' "$d" $(pop_idx 13 $@) > \
1128 fd7552d2 2023-07-17 mark $testroot/stdout.expected
1129 fd7552d2 2023-07-17 mark
1130 0778bf80 2023-08-08 mark (cd $testroot/wt && got log -s -cbase-1+2:-3 -l1 > $testroot/stdout)
1131 fd7552d2 2023-07-17 mark
1132 fd7552d2 2023-07-17 mark cmp -s $testroot/stdout.expected $testroot/stdout
1133 fd7552d2 2023-07-17 mark ret=$?
1134 fd7552d2 2023-07-17 mark if [ $ret -ne 0 ]; then
1135 fd7552d2 2023-07-17 mark diff -u $testroot/stdout.expected $testroot/stdout
1136 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1137 c8d1a97c 2023-07-17 mark return 1
1138 fd7552d2 2023-07-17 mark fi
1139 c8d1a97c 2023-07-17 mark
1140 c8d1a97c 2023-07-17 mark echo "got: '::base:+': invalid commit keyword" > \
1141 c8d1a97c 2023-07-17 mark $testroot/stderr.expected
1142 c8d1a97c 2023-07-17 mark
1143 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got log -c::base:+ 2> $testroot/stderr)
1144 fd7552d2 2023-07-17 mark
1145 0778bf80 2023-08-08 mark cmp -s $testroot/stderr.expected $testroot/stderr
1146 c8d1a97c 2023-07-17 mark ret=$?
1147 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1148 0778bf80 2023-08-08 mark diff -u $testroot/stderr.expected $testroot/stderr
1149 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1150 c8d1a97c 2023-07-17 mark return 1
1151 c8d1a97c 2023-07-17 mark fi
1152 c8d1a97c 2023-07-17 mark
1153 c8d1a97c 2023-07-17 mark echo "got: ':head:-:': invalid commit keyword" > \
1154 c8d1a97c 2023-07-17 mark $testroot/stderr.expected
1155 c8d1a97c 2023-07-17 mark
1156 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got log -c:head:-: 2> $testroot/stderr)
1157 c8d1a97c 2023-07-17 mark
1158 0778bf80 2023-08-08 mark cmp -s $testroot/stderr.expected $testroot/stderr
1159 c8d1a97c 2023-07-17 mark ret=$?
1160 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1161 0778bf80 2023-08-08 mark diff -u $testroot/stderr.expected $testroot/stderr
1162 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1163 c8d1a97c 2023-07-17 mark return 1
1164 c8d1a97c 2023-07-17 mark fi
1165 c8d1a97c 2023-07-17 mark
1166 c8d1a97c 2023-07-17 mark echo "got: 'master::+': invalid commit keyword" > \
1167 c8d1a97c 2023-07-17 mark $testroot/stderr.expected
1168 c8d1a97c 2023-07-17 mark
1169 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got log -cmaster::+ 2> $testroot/stderr)
1170 c8d1a97c 2023-07-17 mark
1171 0778bf80 2023-08-08 mark cmp -s $testroot/stderr.expected $testroot/stderr
1172 c8d1a97c 2023-07-17 mark ret=$?
1173 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1174 0778bf80 2023-08-08 mark diff -u $testroot/stderr.expected $testroot/stderr
1175 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1176 c8d1a97c 2023-07-17 mark return 1
1177 c8d1a97c 2023-07-17 mark fi
1178 c8d1a97c 2023-07-17 mark
1179 c8d1a97c 2023-07-17 mark echo "got: 'master:1+': invalid commit keyword" > \
1180 c8d1a97c 2023-07-17 mark $testroot/stderr.expected
1181 c8d1a97c 2023-07-17 mark
1182 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got log -cmaster:1+ 2> $testroot/stderr)
1183 c8d1a97c 2023-07-17 mark
1184 0778bf80 2023-08-08 mark cmp -s $testroot/stderr.expected $testroot/stderr
1185 c8d1a97c 2023-07-17 mark ret=$?
1186 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1187 0778bf80 2023-08-08 mark diff -u $testroot/stderr.expected $testroot/stderr
1188 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1189 c8d1a97c 2023-07-17 mark return 1
1190 c8d1a97c 2023-07-17 mark fi
1191 c8d1a97c 2023-07-17 mark
1192 c8d1a97c 2023-07-17 mark echo "got: ':base:-1:base:-1': invalid commit keyword" > \
1193 c8d1a97c 2023-07-17 mark $testroot/stderr.expected
1194 c8d1a97c 2023-07-17 mark
1195 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got log -c:base:-1:base:-1 2> $testroot/stderr)
1196 c8d1a97c 2023-07-17 mark
1197 0778bf80 2023-08-08 mark cmp -s $testroot/stderr.expected $testroot/stderr
1198 c8d1a97c 2023-07-17 mark ret=$?
1199 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1200 0778bf80 2023-08-08 mark diff -u $testroot/stderr.expected $testroot/stderr
1201 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1202 c8d1a97c 2023-07-17 mark return 1
1203 c8d1a97c 2023-07-17 mark fi
1204 c8d1a97c 2023-07-17 mark
1205 c8d1a97c 2023-07-17 mark echo "got: 'main:-main:-': invalid commit keyword" > \
1206 c8d1a97c 2023-07-17 mark $testroot/stderr.expected
1207 c8d1a97c 2023-07-17 mark
1208 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got log -cmain:-main:- 2> $testroot/stderr)
1209 c8d1a97c 2023-07-17 mark
1210 0778bf80 2023-08-08 mark cmp -s $testroot/stderr.expected $testroot/stderr
1211 c8d1a97c 2023-07-17 mark ret=$?
1212 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1213 0778bf80 2023-08-08 mark diff -u $testroot/stderr.expected $testroot/stderr
1214 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1215 c8d1a97c 2023-07-17 mark return 1
1216 c8d1a97c 2023-07-17 mark fi
1217 c8d1a97c 2023-07-17 mark
1218 c8d1a97c 2023-07-17 mark echo "got: ':base:*1': invalid commit keyword" > \
1219 c8d1a97c 2023-07-17 mark $testroot/stderr.expected
1220 c8d1a97c 2023-07-17 mark
1221 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got log -c:base:*1 2> $testroot/stderr)
1222 c8d1a97c 2023-07-17 mark
1223 0778bf80 2023-08-08 mark cmp -s $testroot/stderr.expected $testroot/stderr
1224 c8d1a97c 2023-07-17 mark ret=$?
1225 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1226 0778bf80 2023-08-08 mark diff -u $testroot/stderr.expected $testroot/stderr
1227 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1228 c8d1a97c 2023-07-17 mark return 1
1229 c8d1a97c 2023-07-17 mark fi
1230 c8d1a97c 2023-07-17 mark
1231 c8d1a97c 2023-07-17 mark echo "got: reference null not found" > $testroot/stderr.expected
1232 c8d1a97c 2023-07-17 mark
1233 c8d1a97c 2023-07-17 mark (cd $testroot/wt && got log -cnull:+ 2> $testroot/stderr)
1234 c8d1a97c 2023-07-17 mark
1235 c8d1a97c 2023-07-17 mark cmp -s $testroot/stderr.expected $testroot/stderr
1236 c8d1a97c 2023-07-17 mark ret=$?
1237 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1238 c8d1a97c 2023-07-17 mark diff -u $testroot/stderr.expected $testroot/stderr
1239 c8d1a97c 2023-07-17 mark fi
1240 c8d1a97c 2023-07-17 mark
1241 fd7552d2 2023-07-17 mark test_done "$testroot" "$ret"
1242 fd7552d2 2023-07-17 mark }
1243 fd7552d2 2023-07-17 mark
1244 83e5e9a1 2024-03-27 stsp test_log_toposort() {
1245 83e5e9a1 2024-03-27 stsp local testroot=`test_init log_toposort`
1246 83e5e9a1 2024-03-27 stsp local commit0=`git_show_head $testroot/repo`
1247 83e5e9a1 2024-03-27 stsp local author_time0=`git_show_author_time $testroot/repo`
1248 83e5e9a1 2024-03-27 stsp
1249 83e5e9a1 2024-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1250 83e5e9a1 2024-03-27 stsp ret=$?
1251 83e5e9a1 2024-03-27 stsp if [ $ret -ne 0 ]; then
1252 83e5e9a1 2024-03-27 stsp test_done "$testroot" "$ret"
1253 83e5e9a1 2024-03-27 stsp return 1
1254 83e5e9a1 2024-03-27 stsp fi
1255 83e5e9a1 2024-03-27 stsp
1256 83e5e9a1 2024-03-27 stsp echo aaa > $testroot/wt/alpha
1257 83e5e9a1 2024-03-27 stsp (cd $testroot/wt && got commit -m 'change alpha' >/dev/null)
1258 83e5e9a1 2024-03-27 stsp local commit1=`git_show_head $testroot/repo`
1259 83e5e9a1 2024-03-27 stsp local author_time1=`git_show_author_time $testroot/repo`
1260 83e5e9a1 2024-03-27 stsp
1261 83e5e9a1 2024-03-27 stsp got branch -r $testroot/repo -c $commit0 newbranch
1262 83e5e9a1 2024-03-27 stsp (cd $testroot/wt && got update -b newbranch > /dev/null)
1263 83e5e9a1 2024-03-27 stsp echo ddd > $testroot/wt/gamma/delta
1264 83e5e9a1 2024-03-27 stsp (cd $testroot/wt && got commit -m 'change delta' >/dev/null)
1265 83e5e9a1 2024-03-27 stsp local commit2=`git_show_branch_head $testroot/repo newbranch`
1266 83e5e9a1 2024-03-27 stsp local author_time2=`git_show_author_time $testroot/repo newbranch`
1267 83e5e9a1 2024-03-27 stsp
1268 83e5e9a1 2024-03-27 stsp echo zzz > $testroot/wt/epsilon/zeta
1269 83e5e9a1 2024-03-27 stsp (cd $testroot/wt && got commit -m 'change zeta' >/dev/null)
1270 83e5e9a1 2024-03-27 stsp local commit3=`git_show_head $testroot/repo`
1271 83e5e9a1 2024-03-27 stsp local author_time3=`git_show_author_time $testroot/repo newbranch`
1272 83e5e9a1 2024-03-27 stsp
1273 83e5e9a1 2024-03-27 stsp (cd $testroot/wt && got update -b master > /dev/null)
1274 83e5e9a1 2024-03-27 stsp (cd $testroot/wt && got merge newbranch > /dev/null)
1275 83e5e9a1 2024-03-27 stsp local merge_commit=`git_show_head $testroot/repo`
1276 83e5e9a1 2024-03-27 stsp local merge_time=`git_show_author_time $testroot/repo`
1277 83e5e9a1 2024-03-27 stsp
1278 83e5e9a1 2024-03-27 stsp local short_commit0=`trim_obj_id 33 $commit0`
1279 83e5e9a1 2024-03-27 stsp local short_commit1=`trim_obj_id 33 $commit1`
1280 83e5e9a1 2024-03-27 stsp local short_commit2=`trim_obj_id 33 $commit2`
1281 83e5e9a1 2024-03-27 stsp local short_commit3=`trim_obj_id 33 $commit3`
1282 83e5e9a1 2024-03-27 stsp
1283 83e5e9a1 2024-03-27 stsp d_0=`date -u -r $author_time0 +"%G-%m-%d"`
1284 83e5e9a1 2024-03-27 stsp d_1=`date -u -r $author_time1 +"%G-%m-%d"`
1285 83e5e9a1 2024-03-27 stsp d_2=`date -u -r $author_time2 +"%G-%m-%d"`
1286 83e5e9a1 2024-03-27 stsp d_3=`date -u -r $author_time3 +"%G-%m-%d"`
1287 83e5e9a1 2024-03-27 stsp d_m=`date -u -r $merge_time +"%G-%m-%d"`
1288 83e5e9a1 2024-03-27 stsp
1289 83e5e9a1 2024-03-27 stsp got log -r $testroot/repo -s -b -t > $testroot/stdout
1290 83e5e9a1 2024-03-27 stsp cat > $testroot/stdout.expected <<EOF
1291 83e5e9a1 2024-03-27 stsp $d_m master merge refs/heads/newbranch into refs/heads/master
1292 83e5e9a1 2024-03-27 stsp $d_1 $short_commit1 change alpha
1293 83e5e9a1 2024-03-27 stsp $d_3 newbranch change zeta
1294 83e5e9a1 2024-03-27 stsp $d_2 $short_commit2 change delta
1295 83e5e9a1 2024-03-27 stsp $d_0 $short_commit0 adding the test tree
1296 83e5e9a1 2024-03-27 stsp EOF
1297 83e5e9a1 2024-03-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1298 83e5e9a1 2024-03-27 stsp ret=$?
1299 83e5e9a1 2024-03-27 stsp if [ $ret -ne 0 ]; then
1300 83e5e9a1 2024-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1301 83e5e9a1 2024-03-27 stsp fi
1302 83e5e9a1 2024-03-27 stsp test_done "$testroot" "$ret"
1303 83e5e9a1 2024-03-27 stsp }
1304 83e5e9a1 2024-03-27 stsp
1305 83e5e9a1 2024-03-27 stsp
1306 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1307 e7301579 2019-03-18 stsp run_test test_log_in_repo
1308 b70703ad 2019-03-18 stsp run_test test_log_in_bare_repo
1309 cbd1af7a 2019-03-18 stsp run_test test_log_in_worktree
1310 dfe70b4b 2019-08-27 stsp run_test test_log_in_worktree_with_path_prefix
1311 303e2782 2019-08-09 stsp run_test test_log_tag
1312 b1ebc001 2019-08-13 stsp run_test test_log_limit
1313 c1c775eb 2022-06-08 stsp run_test test_log_oneline
1314 2e8c69d1 2020-05-04 stsp run_test test_log_patch_added_file
1315 5175b31a 2020-01-04 stsp run_test test_log_nonexistent_path
1316 d1fe46f9 2020-04-18 stsp run_test test_log_end_at_commit
1317 dbec59df 2020-04-18 stsp run_test test_log_reverse_display
1318 50f2fada 2020-04-24 stsp run_test test_log_in_worktree_different_repo
1319 0208f208 2020-05-05 stsp run_test test_log_changed_paths
1320 f9a64b14 2024-02-03 falsifian run_test test_log_merge_commit_nonexistent_path
1321 e7303626 2020-05-14 stsp run_test test_log_submodule
1322 8f4e3da9 2023-01-07 mark run_test test_log_diffstat
1323 fd7552d2 2023-07-17 mark run_test test_log_commit_keywords
1324 83e5e9a1 2024-03-27 stsp run_test test_log_toposort