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