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 f43793a4 2020-01-27 stsp (cd $testroot/repo && git 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 0cfcb52d 2019-08-27 stsp local testroot=`test_init log_in_prefixed_worktree`
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 303e2782 2019-08-09 stsp (cd $testroot/repo && git 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 5a8ddf14 2019-08-13 stsp (cd $testroot/repo && git 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 c1c775eb 2022-06-08 stsp
315 c1c775eb 2022-06-08 stsp echo "modified beta" > $testroot/wt/beta
316 c1c775eb 2022-06-08 stsp (cd $testroot/wt && got commit -m " test oneline
317 c1c775eb 2022-06-08 stsp no" > /dev/null)
318 c1c775eb 2022-06-08 stsp local commit_id2=`git_show_head $testroot/repo`
319 c1c775eb 2022-06-08 stsp
320 c1c775eb 2022-06-08 stsp printf "%.7s test oneline\n" $commit_id2 > $testroot/stdout.expected
321 c1c775eb 2022-06-08 stsp printf "%.7s test oneline\n" $commit_id1 >> $testroot/stdout.expected
322 c1c775eb 2022-06-08 stsp
323 c1c775eb 2022-06-08 stsp (cd $testroot/repo && got log -s | head -n 2 > $testroot/stdout)
324 c1c775eb 2022-06-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
325 c1c775eb 2022-06-08 stsp ret=$?
326 c1c775eb 2022-06-08 stsp if [ $ret -ne 0 ]; then
327 c1c775eb 2022-06-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 c1c775eb 2022-06-08 stsp test_done "$testroot" "$ret"
329 c1c775eb 2022-06-08 stsp return 1
330 c1c775eb 2022-06-08 stsp fi
331 c1c775eb 2022-06-08 stsp test_done "$testroot" "0"
332 c1c775eb 2022-06-08 stsp }
333 c1c775eb 2022-06-08 stsp
334 f6cae3ed 2020-09-13 naddy test_log_patch_added_file() {
335 2e8c69d1 2020-05-04 stsp local testroot=`test_init log_patch_added_file`
336 2e8c69d1 2020-05-04 stsp local commit_id0=`git_show_head $testroot/repo`
337 5175b31a 2020-01-04 stsp
338 2e8c69d1 2020-05-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
339 49c543a6 2022-03-31 naddy ret=$?
340 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
341 2e8c69d1 2020-05-04 stsp test_done "$testroot" "$ret"
342 2e8c69d1 2020-05-04 stsp return 1
343 2e8c69d1 2020-05-04 stsp fi
344 2e8c69d1 2020-05-04 stsp
345 2e8c69d1 2020-05-04 stsp echo "new file" > $testroot/wt/new
346 2e8c69d1 2020-05-04 stsp (cd $testroot/wt && got add new >/dev/null)
347 2e8c69d1 2020-05-04 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
348 2e8c69d1 2020-05-04 stsp local commit_id1=`git_show_head $testroot/repo`
349 2e8c69d1 2020-05-04 stsp
350 2e8c69d1 2020-05-04 stsp echo "commit $commit_id1 (master)" > $testroot/stdout.expected
351 2e8c69d1 2020-05-04 stsp # This used to fail with 'got: no such entry found in tree'
352 2e8c69d1 2020-05-04 stsp (cd $testroot/wt && got log -l1 -p new > $testroot/stdout.patch)
353 49c543a6 2022-03-31 naddy ret=$?
354 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
355 2e8c69d1 2020-05-04 stsp echo "got log command failed unexpectedly" >&2
356 2e8c69d1 2020-05-04 stsp test_done "$testroot" "$ret"
357 2e8c69d1 2020-05-04 stsp return 1
358 2e8c69d1 2020-05-04 stsp fi
359 2e8c69d1 2020-05-04 stsp grep ^commit $testroot/stdout.patch > $testroot/stdout
360 2e8c69d1 2020-05-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
361 49c543a6 2022-03-31 naddy ret=$?
362 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
363 2e8c69d1 2020-05-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
364 2e8c69d1 2020-05-04 stsp fi
365 2e8c69d1 2020-05-04 stsp test_done "$testroot" "$ret"
366 2e8c69d1 2020-05-04 stsp }
367 2e8c69d1 2020-05-04 stsp
368 f6cae3ed 2020-09-13 naddy test_log_nonexistent_path() {
369 5175b31a 2020-01-04 stsp local testroot=`test_init log_nonexistent_path`
370 5175b31a 2020-01-04 stsp local head_rev=`git_show_head $testroot/repo`
371 5175b31a 2020-01-04 stsp
372 5175b31a 2020-01-04 stsp echo "commit $head_rev (master)" > $testroot/stdout.expected
373 b1ebc001 2019-08-13 stsp
374 5175b31a 2020-01-04 stsp (cd $testroot/repo && got log this/does/not/exist \
375 5175b31a 2020-01-04 stsp > $testroot/stdout 2> $testroot/stderr)
376 49c543a6 2022-03-31 naddy ret=$?
377 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
378 5175b31a 2020-01-04 stsp echo "log command succeeded unexpectedly" >&2
379 5175b31a 2020-01-04 stsp test_done "$testroot" "1"
380 5175b31a 2020-01-04 stsp return 1
381 5175b31a 2020-01-04 stsp fi
382 5175b31a 2020-01-04 stsp
383 5175b31a 2020-01-04 stsp echo -n > $testroot/stdout.expected
384 5175b31a 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
385 49c543a6 2022-03-31 naddy ret=$?
386 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
387 5175b31a 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
388 5175b31a 2020-01-04 stsp test_done "$testroot" "$ret"
389 5175b31a 2020-01-04 stsp return 1
390 5175b31a 2020-01-04 stsp fi
391 5175b31a 2020-01-04 stsp
392 5175b31a 2020-01-04 stsp echo "got: this/does/not/exist: no such entry found in tree" \
393 5175b31a 2020-01-04 stsp > $testroot/stderr.expected
394 5175b31a 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
395 49c543a6 2022-03-31 naddy ret=$?
396 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
397 5175b31a 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
398 5175b31a 2020-01-04 stsp fi
399 5175b31a 2020-01-04 stsp test_done "$testroot" "$ret"
400 5175b31a 2020-01-04 stsp }
401 d1fe46f9 2020-04-18 stsp
402 f6cae3ed 2020-09-13 naddy test_log_end_at_commit() {
403 d1fe46f9 2020-04-18 stsp local testroot=`test_init log_end_at_commit`
404 d1fe46f9 2020-04-18 stsp local commit_id0=`git_show_head $testroot/repo`
405 d1fe46f9 2020-04-18 stsp
406 d1fe46f9 2020-04-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
407 49c543a6 2022-03-31 naddy ret=$?
408 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
409 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
410 d1fe46f9 2020-04-18 stsp return 1
411 d1fe46f9 2020-04-18 stsp fi
412 d1fe46f9 2020-04-18 stsp
413 d1fe46f9 2020-04-18 stsp echo "modified alpha" > $testroot/wt/alpha
414 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
415 d1fe46f9 2020-04-18 stsp local commit_id1=`git_show_head $testroot/repo`
416 d1fe46f9 2020-04-18 stsp
417 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got rm beta >/dev/null)
418 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
419 d1fe46f9 2020-04-18 stsp local commit_id2=`git_show_head $testroot/repo`
420 d1fe46f9 2020-04-18 stsp
421 d1fe46f9 2020-04-18 stsp echo "new file" > $testroot/wt/new
422 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got add new >/dev/null)
423 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
424 d1fe46f9 2020-04-18 stsp local commit_id3=`git_show_head $testroot/repo`
425 5175b31a 2020-01-04 stsp
426 d1fe46f9 2020-04-18 stsp # Print commit 3 only
427 d1fe46f9 2020-04-18 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
428 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -x $commit_id3 | grep ^commit \
429 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
430 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
431 49c543a6 2022-03-31 naddy ret=$?
432 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
433 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
434 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
435 d1fe46f9 2020-04-18 stsp return 1
436 d1fe46f9 2020-04-18 stsp fi
437 d1fe46f9 2020-04-18 stsp
438 d1fe46f9 2020-04-18 stsp # Print commit 3 up to commit 1 inclusive
439 d1fe46f9 2020-04-18 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
440 d1fe46f9 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
441 d1fe46f9 2020-04-18 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
442 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -c $commit_id3 -x $commit_id1 | \
443 d1fe46f9 2020-04-18 stsp grep ^commit > $testroot/stdout)
444 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
445 49c543a6 2022-03-31 naddy ret=$?
446 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
447 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
449 d1fe46f9 2020-04-18 stsp return 1
450 d1fe46f9 2020-04-18 stsp fi
451 d1fe46f9 2020-04-18 stsp
452 d1fe46f9 2020-04-18 stsp # Create commits on an unrelated branch
453 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got br foo > /dev/null)
454 d1fe46f9 2020-04-18 stsp echo bar >> $testroot/wt/alpha
455 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m "change on branch foo" >/dev/null)
456 d1fe46f9 2020-04-18 stsp local commit_id4=`git_show_branch_head $testroot/repo foo`
457 d1fe46f9 2020-04-18 stsp
458 d1fe46f9 2020-04-18 stsp # Print commit 4 only (in work tree)
459 d1fe46f9 2020-04-18 stsp echo "commit $commit_id4 (foo)" > $testroot/stdout.expected
460 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -x foo | grep ^commit \
461 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
462 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
463 49c543a6 2022-03-31 naddy ret=$?
464 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
465 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
466 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
467 d1fe46f9 2020-04-18 stsp return 1
468 d1fe46f9 2020-04-18 stsp fi
469 d1fe46f9 2020-04-18 stsp
470 d1fe46f9 2020-04-18 stsp # Print commit 4 only (in repository)
471 d1fe46f9 2020-04-18 stsp echo "commit $commit_id4 (foo)" > $testroot/stdout.expected
472 d1fe46f9 2020-04-18 stsp (cd $testroot/repo && got log -c foo -x foo | grep ^commit \
473 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
474 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
475 49c543a6 2022-03-31 naddy ret=$?
476 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
477 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
478 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
479 d1fe46f9 2020-04-18 stsp return 1
480 d1fe46f9 2020-04-18 stsp fi
481 d1fe46f9 2020-04-18 stsp
482 d1fe46f9 2020-04-18 stsp # Repository's HEAD is on master branch so -x foo without an explicit
483 d1fe46f9 2020-04-18 stsp # '-c foo' start commit has no effect there
484 d1fe46f9 2020-04-18 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
485 d1fe46f9 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
486 d1fe46f9 2020-04-18 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
487 d1fe46f9 2020-04-18 stsp echo "commit $commit_id0" >> $testroot/stdout.expected
488 d1fe46f9 2020-04-18 stsp (cd $testroot/repo && got log -x foo | grep ^commit \
489 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
490 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
491 49c543a6 2022-03-31 naddy ret=$?
492 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
493 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
494 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
495 d1fe46f9 2020-04-18 stsp return 1
496 d1fe46f9 2020-04-18 stsp fi
497 d1fe46f9 2020-04-18 stsp
498 d1fe46f9 2020-04-18 stsp # got will refuse -x with a non-existent commit
499 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -x nonexistent \
500 d1fe46f9 2020-04-18 stsp > $testroot/stdout 2> $testroot/stderr)
501 49c543a6 2022-03-31 naddy ret=$?
502 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
503 d1fe46f9 2020-04-18 stsp echo "log command succeeded unexpectedly" >&2
504 d1fe46f9 2020-04-18 stsp test_done "$testroot" "1"
505 d1fe46f9 2020-04-18 stsp return 1
506 d1fe46f9 2020-04-18 stsp fi
507 d1fe46f9 2020-04-18 stsp echo -n > $testroot/stdout.expected
508 7f9bfb31 2020-11-01 stsp echo "got: reference nonexistent not found" \
509 d1fe46f9 2020-04-18 stsp > $testroot/stderr.expected
510 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stderr.expected $testroot/stderr
511 49c543a6 2022-03-31 naddy ret=$?
512 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
513 d1fe46f9 2020-04-18 stsp diff -u $testroot/stderr.expected $testroot/stderr
514 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
515 d1fe46f9 2020-04-18 stsp return 1
516 d1fe46f9 2020-04-18 stsp fi
517 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
518 49c543a6 2022-03-31 naddy ret=$?
519 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
520 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
521 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
522 d1fe46f9 2020-04-18 stsp return 1
523 d1fe46f9 2020-04-18 stsp fi
524 d1fe46f9 2020-04-18 stsp
525 d1fe46f9 2020-04-18 stsp # try the same with the hash of an empty string which is very
526 d1fe46f9 2020-04-18 stsp # unlikely to match any object
527 b90c3048 2020-04-19 stsp local empty_sha1=da39a3ee5e6b4b0d3255bfef95601890afd80709
528 b90c3048 2020-04-19 stsp (cd $testroot/wt && got log -x $empty_sha1 \
529 d1fe46f9 2020-04-18 stsp > $testroot/stdout 2> $testroot/stderr)
530 49c543a6 2022-03-31 naddy ret=$?
531 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
532 d1fe46f9 2020-04-18 stsp echo "log command succeeded unexpectedly" >&2
533 d1fe46f9 2020-04-18 stsp test_done "$testroot" "1"
534 d1fe46f9 2020-04-18 stsp return 1
535 d1fe46f9 2020-04-18 stsp fi
536 d1fe46f9 2020-04-18 stsp echo -n > $testroot/stdout.expected
537 138e4f47 2021-10-09 stsp echo "got: commit $empty_sha1: object not found" \
538 138e4f47 2021-10-09 stsp > $testroot/stderr.expected
539 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stderr.expected $testroot/stderr
540 49c543a6 2022-03-31 naddy ret=$?
541 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
542 d1fe46f9 2020-04-18 stsp diff -u $testroot/stderr.expected $testroot/stderr
543 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
544 d1fe46f9 2020-04-18 stsp return 1
545 d1fe46f9 2020-04-18 stsp fi
546 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
547 49c543a6 2022-03-31 naddy ret=$?
548 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
549 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
550 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
551 d1fe46f9 2020-04-18 stsp return 1
552 d1fe46f9 2020-04-18 stsp fi
553 d1fe46f9 2020-04-18 stsp
554 d1fe46f9 2020-04-18 stsp test_done "$testroot" "0"
555 d1fe46f9 2020-04-18 stsp }
556 dbec59df 2020-04-18 stsp
557 f6cae3ed 2020-09-13 naddy test_log_reverse_display() {
558 dbec59df 2020-04-18 stsp local testroot=`test_init log_reverse_display`
559 dbec59df 2020-04-18 stsp local commit_id0=`git_show_head $testroot/repo`
560 dbec59df 2020-04-18 stsp
561 dbec59df 2020-04-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
562 49c543a6 2022-03-31 naddy ret=$?
563 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
564 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
565 dbec59df 2020-04-18 stsp return 1
566 dbec59df 2020-04-18 stsp fi
567 dbec59df 2020-04-18 stsp
568 dbec59df 2020-04-18 stsp echo "modified alpha" > $testroot/wt/alpha
569 dbec59df 2020-04-18 stsp (cd $testroot/wt && got commit -m 'commit1' > /dev/null)
570 dbec59df 2020-04-18 stsp local commit_id1=`git_show_head $testroot/repo`
571 dbec59df 2020-04-18 stsp
572 dbec59df 2020-04-18 stsp (cd $testroot/wt && got rm beta >/dev/null)
573 dbec59df 2020-04-18 stsp (cd $testroot/wt && got commit -m 'commit2' > /dev/null)
574 dbec59df 2020-04-18 stsp local commit_id2=`git_show_head $testroot/repo`
575 dbec59df 2020-04-18 stsp
576 dbec59df 2020-04-18 stsp echo "new file" > $testroot/wt/new
577 dbec59df 2020-04-18 stsp (cd $testroot/wt && got add new >/dev/null)
578 dbec59df 2020-04-18 stsp (cd $testroot/wt && got commit -m 'commit3' > /dev/null)
579 dbec59df 2020-04-18 stsp local commit_id3=`git_show_head $testroot/repo`
580 d1fe46f9 2020-04-18 stsp
581 dbec59df 2020-04-18 stsp # -R alone should display all commits in reverse
582 dbec59df 2020-04-18 stsp echo "commit $commit_id0" > $testroot/stdout.expected
583 dbec59df 2020-04-18 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
584 dbec59df 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
585 dbec59df 2020-04-18 stsp echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
586 dbec59df 2020-04-18 stsp (cd $testroot/wt && got log -R | grep ^commit > $testroot/stdout)
587 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
588 49c543a6 2022-03-31 naddy ret=$?
589 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
590 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
591 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
592 dbec59df 2020-04-18 stsp return 1
593 dbec59df 2020-04-18 stsp fi
594 dbec59df 2020-04-18 stsp
595 dbec59df 2020-04-18 stsp # -R takes effect after the -l commit traversal limit
596 dbec59df 2020-04-18 stsp echo "commit $commit_id2" > $testroot/stdout.expected
597 dbec59df 2020-04-18 stsp echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
598 dbec59df 2020-04-18 stsp (cd $testroot/wt && got log -R -l2 | grep ^commit > $testroot/stdout)
599 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
600 49c543a6 2022-03-31 naddy ret=$?
601 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
602 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
603 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
604 dbec59df 2020-04-18 stsp return 1
605 dbec59df 2020-04-18 stsp fi
606 dbec59df 2020-04-18 stsp
607 dbec59df 2020-04-18 stsp # -R works with commit ranges specified via -c and -x
608 dbec59df 2020-04-18 stsp echo "commit $commit_id1" > $testroot/stdout.expected
609 dbec59df 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
610 dbec59df 2020-04-18 stsp echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
611 dbec59df 2020-04-18 stsp (cd $testroot/wt && got log -R -c $commit_id3 -x $commit_id1 | \
612 dbec59df 2020-04-18 stsp grep ^commit > $testroot/stdout)
613 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
614 49c543a6 2022-03-31 naddy ret=$?
615 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
616 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
617 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
618 a9662115 2021-08-29 naddy return 1
619 dbec59df 2020-04-18 stsp fi
620 dbec59df 2020-04-18 stsp
621 dbec59df 2020-04-18 stsp # commit matching with -s applies before -R
622 dbec59df 2020-04-18 stsp echo "commit $commit_id1" > $testroot/stdout.expected
623 dbec59df 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
624 c1c775eb 2022-06-08 stsp (cd $testroot/wt && got log -R -S 'commit[12]' | \
625 dbec59df 2020-04-18 stsp grep ^commit > $testroot/stdout)
626 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
627 49c543a6 2022-03-31 naddy ret=$?
628 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
629 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
630 502b9684 2020-07-31 stsp test_done "$testroot" "$ret"
631 502b9684 2020-07-31 stsp return 1
632 dbec59df 2020-04-18 stsp fi
633 502b9684 2020-07-31 stsp
634 502b9684 2020-07-31 stsp # -R works in combination with -P
635 502b9684 2020-07-31 stsp echo "" > $testroot/stdout.expected
636 502b9684 2020-07-31 stsp (cd $testroot/wt && got log -R -P | grep -E '^(commit| [MDmA])' \
637 502b9684 2020-07-31 stsp > $testroot/stdout)
638 502b9684 2020-07-31 stsp echo "commit $commit_id0" > $testroot/stdout.expected
639 502b9684 2020-07-31 stsp echo " A alpha" >> $testroot/stdout.expected
640 502b9684 2020-07-31 stsp echo " A beta" >> $testroot/stdout.expected
641 502b9684 2020-07-31 stsp echo " A epsilon/zeta" >> $testroot/stdout.expected
642 502b9684 2020-07-31 stsp echo " A gamma/delta" >> $testroot/stdout.expected
643 502b9684 2020-07-31 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
644 502b9684 2020-07-31 stsp echo " M alpha" >> $testroot/stdout.expected
645 502b9684 2020-07-31 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
646 502b9684 2020-07-31 stsp echo " D beta" >> $testroot/stdout.expected
647 502b9684 2020-07-31 stsp echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
648 502b9684 2020-07-31 stsp echo " A new" >> $testroot/stdout.expected
649 502b9684 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
650 49c543a6 2022-03-31 naddy ret=$?
651 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
652 502b9684 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
653 502b9684 2020-07-31 stsp fi
654 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
655 50f2fada 2020-04-24 stsp }
656 50f2fada 2020-04-24 stsp
657 f6cae3ed 2020-09-13 naddy test_log_in_worktree_different_repo() {
658 50f2fada 2020-04-24 stsp local testroot=`test_init log_in_worktree_different_repo 1`
659 50f2fada 2020-04-24 stsp
660 50f2fada 2020-04-24 stsp make_test_tree $testroot/repo
661 50f2fada 2020-04-24 stsp mkdir -p $testroot/repo/epsilon/d
662 50f2fada 2020-04-24 stsp echo foo > $testroot/repo/epsilon/d/foo
663 50f2fada 2020-04-24 stsp (cd $testroot/repo && git add .)
664 50f2fada 2020-04-24 stsp git_commit $testroot/repo -m "adding the test tree"
665 50f2fada 2020-04-24 stsp local head_commit=`git_show_head $testroot/repo`
666 50f2fada 2020-04-24 stsp
667 50f2fada 2020-04-24 stsp got init $testroot/other-repo
668 50f2fada 2020-04-24 stsp mkdir -p $testroot/tree
669 50f2fada 2020-04-24 stsp make_test_tree $testroot/tree
670 50f2fada 2020-04-24 stsp got import -mm -b foo -r $testroot/other-repo $testroot/tree >/dev/null
671 50f2fada 2020-04-24 stsp got checkout -b foo $testroot/other-repo $testroot/wt > /dev/null
672 49c543a6 2022-03-31 naddy ret=$?
673 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
674 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
675 50f2fada 2020-04-24 stsp return 1
676 50f2fada 2020-04-24 stsp fi
677 50f2fada 2020-04-24 stsp
678 50f2fada 2020-04-24 stsp echo "commit $head_commit (master)" > $testroot/stdout.expected
679 50f2fada 2020-04-24 stsp
680 50f2fada 2020-04-24 stsp # 'got log' used to fail with "reference refs/heads/foo not found"
681 50f2fada 2020-04-24 stsp # even though that reference belongs to an unrelated repository
682 50f2fada 2020-04-24 stsp # found via a worktree via the current working directory
683 50f2fada 2020-04-24 stsp for p in "" alpha epsilon; do
684 50f2fada 2020-04-24 stsp (cd $testroot/wt && got log -r $testroot/repo $p | \
685 50f2fada 2020-04-24 stsp grep ^commit > $testroot/stdout)
686 50f2fada 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
687 49c543a6 2022-03-31 naddy ret=$?
688 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
689 50f2fada 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
690 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
691 50f2fada 2020-04-24 stsp return 1
692 50f2fada 2020-04-24 stsp fi
693 50f2fada 2020-04-24 stsp done
694 50f2fada 2020-04-24 stsp
695 50f2fada 2020-04-24 stsp for p in "" epsilon/zeta; do
696 50f2fada 2020-04-24 stsp (cd $testroot/wt/epsilon && got log -r $testroot/repo $p | \
697 50f2fada 2020-04-24 stsp grep ^commit > $testroot/stdout)
698 50f2fada 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
699 49c543a6 2022-03-31 naddy ret=$?
700 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
701 50f2fada 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
702 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
703 50f2fada 2020-04-24 stsp return 1
704 50f2fada 2020-04-24 stsp fi
705 50f2fada 2020-04-24 stsp done
706 50f2fada 2020-04-24 stsp
707 50f2fada 2020-04-24 stsp for p in "" foo; do
708 50f2fada 2020-04-24 stsp (cd $testroot/wt/epsilon && got log -r $testroot/repo epsilon/d/$p | \
709 50f2fada 2020-04-24 stsp grep ^commit > $testroot/stdout)
710 50f2fada 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
711 49c543a6 2022-03-31 naddy ret=$?
712 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
713 50f2fada 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
714 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
715 50f2fada 2020-04-24 stsp return 1
716 50f2fada 2020-04-24 stsp fi
717 50f2fada 2020-04-24 stsp done
718 50f2fada 2020-04-24 stsp
719 50f2fada 2020-04-24 stsp test_done "$testroot" "0"
720 dbec59df 2020-04-18 stsp }
721 0208f208 2020-05-05 stsp
722 f6cae3ed 2020-09-13 naddy test_log_changed_paths() {
723 0208f208 2020-05-05 stsp local testroot=`test_init log_changed_paths`
724 0208f208 2020-05-05 stsp local commit_id0=`git_show_head $testroot/repo`
725 0208f208 2020-05-05 stsp
726 0208f208 2020-05-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
727 49c543a6 2022-03-31 naddy ret=$?
728 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
729 0208f208 2020-05-05 stsp test_done "$testroot" "$ret"
730 0208f208 2020-05-05 stsp return 1
731 0208f208 2020-05-05 stsp fi
732 0208f208 2020-05-05 stsp
733 0208f208 2020-05-05 stsp echo "modified alpha" > $testroot/wt/alpha
734 0208f208 2020-05-05 stsp (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
735 0208f208 2020-05-05 stsp local commit_id1=`git_show_head $testroot/repo`
736 dbec59df 2020-04-18 stsp
737 0208f208 2020-05-05 stsp (cd $testroot/wt && got rm beta >/dev/null)
738 0208f208 2020-05-05 stsp (cd $testroot/wt && chmod +x epsilon/zeta >/dev/null)
739 0208f208 2020-05-05 stsp (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
740 0208f208 2020-05-05 stsp local commit_id2=`git_show_head $testroot/repo`
741 0208f208 2020-05-05 stsp
742 0208f208 2020-05-05 stsp echo "new file" > $testroot/wt/new
743 0208f208 2020-05-05 stsp (cd $testroot/wt && got add new >/dev/null)
744 0208f208 2020-05-05 stsp (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
745 0208f208 2020-05-05 stsp local commit_id3=`git_show_head $testroot/repo`
746 0208f208 2020-05-05 stsp
747 0208f208 2020-05-05 stsp (cd $testroot/wt && got log -P | grep '^ [MDmA]' > $testroot/stdout)
748 0208f208 2020-05-05 stsp
749 0208f208 2020-05-05 stsp echo " A new" > $testroot/stdout.expected
750 0208f208 2020-05-05 stsp echo " D beta" >> $testroot/stdout.expected
751 0208f208 2020-05-05 stsp echo " m epsilon/zeta" >> $testroot/stdout.expected
752 0208f208 2020-05-05 stsp echo " M alpha" >> $testroot/stdout.expected
753 0208f208 2020-05-05 stsp echo " A alpha" >> $testroot/stdout.expected
754 0208f208 2020-05-05 stsp echo " A beta" >> $testroot/stdout.expected
755 0208f208 2020-05-05 stsp echo " A epsilon/zeta" >> $testroot/stdout.expected
756 0208f208 2020-05-05 stsp echo " A gamma/delta" >> $testroot/stdout.expected
757 e7303626 2020-05-14 stsp
758 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
759 49c543a6 2022-03-31 naddy ret=$?
760 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
761 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
762 e7303626 2020-05-14 stsp fi
763 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
764 e7303626 2020-05-14 stsp }
765 e7303626 2020-05-14 stsp
766 f6cae3ed 2020-09-13 naddy test_log_submodule() {
767 e7303626 2020-05-14 stsp local testroot=`test_init log_submodule`
768 e7303626 2020-05-14 stsp
769 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
770 e7303626 2020-05-14 stsp
771 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
772 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
773 e7303626 2020-05-14 stsp local head_commit=`git_show_head $testroot/repo`
774 e7303626 2020-05-14 stsp
775 e7303626 2020-05-14 stsp echo "commit $head_commit (master)" > $testroot/stdout.expected
776 e7303626 2020-05-14 stsp
777 e7303626 2020-05-14 stsp got log -r $testroot/repo -l1 repo2 | grep ^commit > $testroot/stdout
778 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
779 49c543a6 2022-03-31 naddy ret=$?
780 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
781 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
782 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
783 e7303626 2020-05-14 stsp return 1
784 e7303626 2020-05-14 stsp fi
785 e7303626 2020-05-14 stsp
786 e7303626 2020-05-14 stsp echo " A .gitmodules" > $testroot/stdout.expected
787 e7303626 2020-05-14 stsp
788 e7303626 2020-05-14 stsp got log -r $testroot/repo -l1 -P repo2 | grep '^ [MDmA]' \
789 e7303626 2020-05-14 stsp > $testroot/stdout
790 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
791 49c543a6 2022-03-31 naddy ret=$?
792 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
793 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
794 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
795 e7303626 2020-05-14 stsp return 1
796 e7303626 2020-05-14 stsp fi
797 e7303626 2020-05-14 stsp
798 e7303626 2020-05-14 stsp got log -p -r $testroot/repo -l1 repo2 \
799 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr
800 49c543a6 2022-03-31 naddy ret=$?
801 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
802 e7303626 2020-05-14 stsp echo "log command succeeded unexpectedly" >&2
803 e7303626 2020-05-14 stsp test_done "$testroot" "1"
804 e7303626 2020-05-14 stsp return 1
805 e7303626 2020-05-14 stsp fi
806 e7303626 2020-05-14 stsp local submodule_id=$(got tree -r $testroot/repo -i | \
807 e7303626 2020-05-14 stsp grep 'repo2\$$' | cut -d ' ' -f1)
808 e7303626 2020-05-14 stsp echo "got: object $submodule_id not found" > $testroot/stderr.expected
809 0208f208 2020-05-05 stsp
810 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
811 49c543a6 2022-03-31 naddy ret=$?
812 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
813 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
814 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
815 e7303626 2020-05-14 stsp return 1
816 e7303626 2020-05-14 stsp fi
817 e7303626 2020-05-14 stsp
818 e7303626 2020-05-14 stsp echo "modified foo" > $testroot/repo2/foo
819 e7303626 2020-05-14 stsp (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
820 e7303626 2020-05-14 stsp
821 e7303626 2020-05-14 stsp # Update the repo/repo2 submodule link
822 e7303626 2020-05-14 stsp (cd $testroot/repo && git -C repo2 pull -q)
823 e7303626 2020-05-14 stsp (cd $testroot/repo && git add repo2)
824 e7303626 2020-05-14 stsp git_commit $testroot/repo -m "changed submodule link"
825 e7303626 2020-05-14 stsp
826 e7303626 2020-05-14 stsp # log -P does not show the changed submodule path
827 e7303626 2020-05-14 stsp got log -P -r $testroot/repo -l1 repo2 > $testroot/stdout.full
828 49c543a6 2022-03-31 naddy ret=$?
829 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
830 e7303626 2020-05-14 stsp echo "log command failed unexpectedly" >&2
831 e7303626 2020-05-14 stsp test_done "$testroot" "1"
832 e7303626 2020-05-14 stsp return 1
833 e7303626 2020-05-14 stsp fi
834 e7303626 2020-05-14 stsp grep '^ [MDmA]' $testroot/stdout.full > $testroot/stdout
835 e7303626 2020-05-14 stsp
836 e7303626 2020-05-14 stsp echo -n > $testroot/stdout.expected
837 0208f208 2020-05-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
838 49c543a6 2022-03-31 naddy ret=$?
839 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
840 0208f208 2020-05-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
841 0208f208 2020-05-05 stsp fi
842 0208f208 2020-05-05 stsp test_done "$testroot" "$ret"
843 0208f208 2020-05-05 stsp }
844 0208f208 2020-05-05 stsp
845 7fb414ae 2020-08-08 stsp test_parseargs "$@"
846 e7301579 2019-03-18 stsp run_test test_log_in_repo
847 b70703ad 2019-03-18 stsp run_test test_log_in_bare_repo
848 cbd1af7a 2019-03-18 stsp run_test test_log_in_worktree
849 dfe70b4b 2019-08-27 stsp run_test test_log_in_worktree_with_path_prefix
850 303e2782 2019-08-09 stsp run_test test_log_tag
851 b1ebc001 2019-08-13 stsp run_test test_log_limit
852 c1c775eb 2022-06-08 stsp run_test test_log_oneline
853 2e8c69d1 2020-05-04 stsp run_test test_log_patch_added_file
854 5175b31a 2020-01-04 stsp run_test test_log_nonexistent_path
855 d1fe46f9 2020-04-18 stsp run_test test_log_end_at_commit
856 dbec59df 2020-04-18 stsp run_test test_log_reverse_display
857 50f2fada 2020-04-24 stsp run_test test_log_in_worktree_different_repo
858 0208f208 2020-05-05 stsp run_test test_log_changed_paths
859 e7303626 2020-05-14 stsp run_test test_log_submodule