3 5aa81393 2020-01-06 stsp # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
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.
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.
17 cbd1af7a 2019-03-18 stsp . ./common.sh
19 e7301579 2019-03-18 stsp function 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`
23 e7301579 2019-03-18 stsp echo "commit $head_rev (master)" > $testroot/stdout.expected
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
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"
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
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"
49 e7301579 2019-03-18 stsp test_done "$testroot" "0"
52 b70703ad 2019-03-18 stsp function 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`
56 b70703ad 2019-03-18 stsp echo "commit $head_rev (master)" > $testroot/stdout.expected
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
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"
70 b70703ad 2019-03-18 stsp test_done "$testroot" "0"
73 cbd1af7a 2019-03-18 stsp function test_log_in_worktree {
74 f43793a4 2020-01-27 stsp local testroot=`test_init log_in_worktree 1`
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`
83 cbd1af7a 2019-03-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
85 cbd1af7a 2019-03-18 stsp if [ "$ret" != "0" ]; then
86 cbd1af7a 2019-03-18 stsp test_done "$testroot" "$ret"
90 f43793a4 2020-01-27 stsp echo "commit $head_commit (master)" > $testroot/stdout.expected
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
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"
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
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"
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
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"
128 cbd1af7a 2019-03-18 stsp test_done "$testroot" "0"
131 dfe70b4b 2019-08-27 stsp function 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`
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`
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"
142 0cfcb52d 2019-08-27 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
144 0cfcb52d 2019-08-27 stsp if [ "$ret" != "0" ]; then
145 0cfcb52d 2019-08-27 stsp test_done "$testroot" "$ret"
149 0cfcb52d 2019-08-27 stsp echo "commit $zeta_rev" > $testroot/stdout.expected
150 0cfcb52d 2019-08-27 stsp echo "commit $head_rev" >> $testroot/stdout.expected
152 0cfcb52d 2019-08-27 stsp for p in "" "." zeta; do
153 0cfcb52d 2019-08-27 stsp (cd $testroot/wt && got log $p | \
154 0cfcb52d 2019-08-27 stsp grep ^commit > $testroot/stdout)
155 0cfcb52d 2019-08-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
157 0cfcb52d 2019-08-27 stsp if [ "$ret" != "0" ]; then
158 0cfcb52d 2019-08-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
159 0cfcb52d 2019-08-27 stsp test_done "$testroot" "$ret"
164 0cfcb52d 2019-08-27 stsp test_done "$testroot" "0"
167 303e2782 2019-08-09 stsp function test_log_tag {
168 303e2782 2019-08-09 stsp local testroot=`test_init log_tag`
169 303e2782 2019-08-09 stsp local commit_id=`git_show_head $testroot/repo`
170 303e2782 2019-08-09 stsp local tag="1.0.0"
171 5a8ddf14 2019-08-13 stsp local tag2="2.0.0"
173 303e2782 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
175 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
176 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
180 303e2782 2019-08-09 stsp (cd $testroot/repo && git tag -a -m "test" $tag)
182 a436ad14 2019-08-13 stsp echo "commit $commit_id (master, tags/$tag)" > $testroot/stdout.expected
183 303e2782 2019-08-09 stsp (cd $testroot/wt && got log -l1 -c $tag | grep ^commit \
184 303e2782 2019-08-09 stsp > $testroot/stdout)
185 303e2782 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
187 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
188 303e2782 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
189 5a8ddf14 2019-08-13 stsp test_done "$testroot" "$ret"
193 992eb9d8 2020-02-07 tracey # test a "lightweight" tag
194 5a8ddf14 2019-08-13 stsp (cd $testroot/repo && git tag $tag2)
196 5a8ddf14 2019-08-13 stsp echo "commit $commit_id (master, tags/$tag, tags/$tag2)" \
197 5a8ddf14 2019-08-13 stsp > $testroot/stdout.expected
198 5a8ddf14 2019-08-13 stsp (cd $testroot/wt && got log -l1 -c $tag2 | grep ^commit \
199 5a8ddf14 2019-08-13 stsp > $testroot/stdout)
200 5a8ddf14 2019-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
202 5a8ddf14 2019-08-13 stsp if [ "$ret" != "0" ]; then
203 5a8ddf14 2019-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
205 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
208 b1ebc001 2019-08-13 stsp function test_log_limit {
209 b1ebc001 2019-08-13 stsp local testroot=`test_init log_limit`
210 b1ebc001 2019-08-13 stsp local commit_id0=`git_show_head $testroot/repo`
212 b1ebc001 2019-08-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
214 b1ebc001 2019-08-13 stsp if [ "$ret" != "0" ]; then
215 b1ebc001 2019-08-13 stsp test_done "$testroot" "$ret"
219 b1ebc001 2019-08-13 stsp echo "modified alpha" > $testroot/wt/alpha
220 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
221 b1ebc001 2019-08-13 stsp local commit_id1=`git_show_head $testroot/repo`
223 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got rm beta >/dev/null)
224 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
225 b1ebc001 2019-08-13 stsp local commit_id2=`git_show_head $testroot/repo`
227 b1ebc001 2019-08-13 stsp echo "new file" > $testroot/wt/new
228 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got add new >/dev/null)
229 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
230 b1ebc001 2019-08-13 stsp local commit_id3=`git_show_head $testroot/repo`
232 b1ebc001 2019-08-13 stsp # -l1 should print the first commit only
233 b1ebc001 2019-08-13 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
234 b1ebc001 2019-08-13 stsp (cd $testroot/wt && got log -l1 | grep ^commit > $testroot/stdout)
235 b1ebc001 2019-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
237 b1ebc001 2019-08-13 stsp if [ "$ret" != "0" ]; then
238 b1ebc001 2019-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
239 b1ebc001 2019-08-13 stsp test_done "$testroot" "$ret"
243 b1ebc001 2019-08-13 stsp # env var can be used to set a log limit without -l option
244 b1ebc001 2019-08-13 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
245 b1ebc001 2019-08-13 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
246 b1ebc001 2019-08-13 stsp (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=2 got log | \
247 b1ebc001 2019-08-13 stsp grep ^commit > $testroot/stdout)
248 b1ebc001 2019-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
250 b1ebc001 2019-08-13 stsp if [ "$ret" != "0" ]; then
251 b1ebc001 2019-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
252 b1ebc001 2019-08-13 stsp test_done "$testroot" "$ret"
256 b1ebc001 2019-08-13 stsp # non-numeric env var is ignored
257 b1ebc001 2019-08-13 stsp (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=foobar got log | \
258 b1ebc001 2019-08-13 stsp grep ^commit > $testroot/stdout)
259 b1ebc001 2019-08-13 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
260 b1ebc001 2019-08-13 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
261 b1ebc001 2019-08-13 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
262 b1ebc001 2019-08-13 stsp echo "commit $commit_id0" >> $testroot/stdout.expected
263 b1ebc001 2019-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
265 b1ebc001 2019-08-13 stsp if [ "$ret" != "0" ]; then
266 b1ebc001 2019-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
267 b1ebc001 2019-08-13 stsp test_done "$testroot" "$ret"
271 b1ebc001 2019-08-13 stsp # -l option takes precedence over env var
272 b1ebc001 2019-08-13 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
273 b1ebc001 2019-08-13 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
274 b1ebc001 2019-08-13 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
275 b1ebc001 2019-08-13 stsp echo "commit $commit_id0" >> $testroot/stdout.expected
276 b1ebc001 2019-08-13 stsp (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=1 got log -l0 | \
277 b1ebc001 2019-08-13 stsp grep ^commit > $testroot/stdout)
278 b1ebc001 2019-08-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
280 b1ebc001 2019-08-13 stsp if [ "$ret" != "0" ]; then
281 b1ebc001 2019-08-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
283 b1ebc001 2019-08-13 stsp test_done "$testroot" "0"
286 2e8c69d1 2020-05-04 stsp function test_log_patch_added_file {
287 2e8c69d1 2020-05-04 stsp local testroot=`test_init log_patch_added_file`
288 2e8c69d1 2020-05-04 stsp local commit_id0=`git_show_head $testroot/repo`
290 2e8c69d1 2020-05-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
292 2e8c69d1 2020-05-04 stsp if [ "$ret" != "0" ]; then
293 2e8c69d1 2020-05-04 stsp test_done "$testroot" "$ret"
297 2e8c69d1 2020-05-04 stsp echo "new file" > $testroot/wt/new
298 2e8c69d1 2020-05-04 stsp (cd $testroot/wt && got add new >/dev/null)
299 2e8c69d1 2020-05-04 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
300 2e8c69d1 2020-05-04 stsp local commit_id1=`git_show_head $testroot/repo`
302 2e8c69d1 2020-05-04 stsp echo "commit $commit_id1 (master)" > $testroot/stdout.expected
303 2e8c69d1 2020-05-04 stsp # This used to fail with 'got: no such entry found in tree'
304 2e8c69d1 2020-05-04 stsp (cd $testroot/wt && got log -l1 -p new > $testroot/stdout.patch)
306 2e8c69d1 2020-05-04 stsp if [ "$ret" != "0" ]; then
307 2e8c69d1 2020-05-04 stsp echo "got log command failed unexpectedly" >&2
308 2e8c69d1 2020-05-04 stsp test_done "$testroot" "$ret"
311 2e8c69d1 2020-05-04 stsp grep ^commit $testroot/stdout.patch > $testroot/stdout
312 2e8c69d1 2020-05-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
314 2e8c69d1 2020-05-04 stsp if [ "$ret" != "0" ]; then
315 2e8c69d1 2020-05-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
317 2e8c69d1 2020-05-04 stsp test_done "$testroot" "$ret"
320 5175b31a 2020-01-04 stsp function test_log_nonexistent_path {
321 5175b31a 2020-01-04 stsp local testroot=`test_init log_nonexistent_path`
322 5175b31a 2020-01-04 stsp local head_rev=`git_show_head $testroot/repo`
324 5175b31a 2020-01-04 stsp echo "commit $head_rev (master)" > $testroot/stdout.expected
326 5175b31a 2020-01-04 stsp (cd $testroot/repo && got log this/does/not/exist \
327 5175b31a 2020-01-04 stsp > $testroot/stdout 2> $testroot/stderr)
329 5175b31a 2020-01-04 stsp if [ "$ret" == "0" ]; then
330 5175b31a 2020-01-04 stsp echo "log command succeeded unexpectedly" >&2
331 5175b31a 2020-01-04 stsp test_done "$testroot" "1"
335 5175b31a 2020-01-04 stsp echo -n > $testroot/stdout.expected
336 5175b31a 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
338 5175b31a 2020-01-04 stsp if [ "$ret" != "0" ]; then
339 5175b31a 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
340 5175b31a 2020-01-04 stsp test_done "$testroot" "$ret"
344 5175b31a 2020-01-04 stsp echo "got: this/does/not/exist: no such entry found in tree" \
345 5175b31a 2020-01-04 stsp > $testroot/stderr.expected
346 5175b31a 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
348 5175b31a 2020-01-04 stsp if [ "$ret" != "0" ]; then
349 5175b31a 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
351 5175b31a 2020-01-04 stsp test_done "$testroot" "$ret"
354 d1fe46f9 2020-04-18 stsp function test_log_end_at_commit {
355 d1fe46f9 2020-04-18 stsp local testroot=`test_init log_end_at_commit`
356 d1fe46f9 2020-04-18 stsp local commit_id0=`git_show_head $testroot/repo`
358 d1fe46f9 2020-04-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
360 d1fe46f9 2020-04-18 stsp if [ "$ret" != "0" ]; then
361 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
365 d1fe46f9 2020-04-18 stsp echo "modified alpha" > $testroot/wt/alpha
366 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
367 d1fe46f9 2020-04-18 stsp local commit_id1=`git_show_head $testroot/repo`
369 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got rm beta >/dev/null)
370 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
371 d1fe46f9 2020-04-18 stsp local commit_id2=`git_show_head $testroot/repo`
373 d1fe46f9 2020-04-18 stsp echo "new file" > $testroot/wt/new
374 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got add new >/dev/null)
375 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
376 d1fe46f9 2020-04-18 stsp local commit_id3=`git_show_head $testroot/repo`
378 d1fe46f9 2020-04-18 stsp # Print commit 3 only
379 d1fe46f9 2020-04-18 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
380 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -x $commit_id3 | grep ^commit \
381 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
382 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
384 d1fe46f9 2020-04-18 stsp if [ "$ret" != "0" ]; then
385 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
386 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
390 d1fe46f9 2020-04-18 stsp # Print commit 3 up to commit 1 inclusive
391 d1fe46f9 2020-04-18 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
392 d1fe46f9 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
393 d1fe46f9 2020-04-18 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
394 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -c $commit_id3 -x $commit_id1 | \
395 d1fe46f9 2020-04-18 stsp grep ^commit > $testroot/stdout)
396 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
404 d1fe46f9 2020-04-18 stsp # Create commits on an unrelated branch
405 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got br foo > /dev/null)
406 d1fe46f9 2020-04-18 stsp echo bar >> $testroot/wt/alpha
407 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got commit -m "change on branch foo" >/dev/null)
408 d1fe46f9 2020-04-18 stsp local commit_id4=`git_show_branch_head $testroot/repo foo`
410 d1fe46f9 2020-04-18 stsp # Print commit 4 only (in work tree)
411 d1fe46f9 2020-04-18 stsp echo "commit $commit_id4 (foo)" > $testroot/stdout.expected
412 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -x foo | grep ^commit \
413 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
414 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
416 d1fe46f9 2020-04-18 stsp if [ "$ret" != "0" ]; then
417 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
418 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
422 d1fe46f9 2020-04-18 stsp # Print commit 4 only (in repository)
423 d1fe46f9 2020-04-18 stsp echo "commit $commit_id4 (foo)" > $testroot/stdout.expected
424 d1fe46f9 2020-04-18 stsp (cd $testroot/repo && got log -c foo -x foo | grep ^commit \
425 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
426 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
428 d1fe46f9 2020-04-18 stsp if [ "$ret" != "0" ]; then
429 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
430 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
434 d1fe46f9 2020-04-18 stsp # Repository's HEAD is on master branch so -x foo without an explicit
435 d1fe46f9 2020-04-18 stsp # '-c foo' start commit has no effect there
436 d1fe46f9 2020-04-18 stsp echo "commit $commit_id3 (master)" > $testroot/stdout.expected
437 d1fe46f9 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
438 d1fe46f9 2020-04-18 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
439 d1fe46f9 2020-04-18 stsp echo "commit $commit_id0" >> $testroot/stdout.expected
440 d1fe46f9 2020-04-18 stsp (cd $testroot/repo && got log -x foo | grep ^commit \
441 d1fe46f9 2020-04-18 stsp > $testroot/stdout)
442 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
444 d1fe46f9 2020-04-18 stsp if [ "$ret" != "0" ]; then
445 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
446 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
450 d1fe46f9 2020-04-18 stsp # got will refuse -x with a non-existent commit
451 d1fe46f9 2020-04-18 stsp (cd $testroot/wt && got log -x nonexistent \
452 d1fe46f9 2020-04-18 stsp > $testroot/stdout 2> $testroot/stderr)
454 d1fe46f9 2020-04-18 stsp if [ "$ret" == "0" ]; then
455 d1fe46f9 2020-04-18 stsp echo "log command succeeded unexpectedly" >&2
456 d1fe46f9 2020-04-18 stsp test_done "$testroot" "1"
459 d1fe46f9 2020-04-18 stsp echo -n > $testroot/stdout.expected
460 d1fe46f9 2020-04-18 stsp echo "got: nonexistent: bad object id string" \
461 d1fe46f9 2020-04-18 stsp > $testroot/stderr.expected
462 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stderr.expected $testroot/stderr
464 d1fe46f9 2020-04-18 stsp if [ "$ret" != "0" ]; then
465 d1fe46f9 2020-04-18 stsp diff -u $testroot/stderr.expected $testroot/stderr
466 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
469 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
471 d1fe46f9 2020-04-18 stsp if [ "$ret" != "0" ]; then
472 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
473 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
477 d1fe46f9 2020-04-18 stsp # try the same with the hash of an empty string which is very
478 d1fe46f9 2020-04-18 stsp # unlikely to match any object
479 b90c3048 2020-04-19 stsp local empty_sha1=da39a3ee5e6b4b0d3255bfef95601890afd80709
480 b90c3048 2020-04-19 stsp (cd $testroot/wt && got log -x $empty_sha1 \
481 d1fe46f9 2020-04-18 stsp > $testroot/stdout 2> $testroot/stderr)
483 d1fe46f9 2020-04-18 stsp if [ "$ret" == "0" ]; then
484 d1fe46f9 2020-04-18 stsp echo "log command succeeded unexpectedly" >&2
485 d1fe46f9 2020-04-18 stsp test_done "$testroot" "1"
488 d1fe46f9 2020-04-18 stsp echo -n > $testroot/stdout.expected
489 b90c3048 2020-04-19 stsp echo "got: $empty_sha1: object not found" > $testroot/stderr.expected
490 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stderr.expected $testroot/stderr
492 d1fe46f9 2020-04-18 stsp if [ "$ret" != "0" ]; then
493 d1fe46f9 2020-04-18 stsp diff -u $testroot/stderr.expected $testroot/stderr
494 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
497 d1fe46f9 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
499 d1fe46f9 2020-04-18 stsp if [ "$ret" != "0" ]; then
500 d1fe46f9 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
501 d1fe46f9 2020-04-18 stsp test_done "$testroot" "$ret"
505 d1fe46f9 2020-04-18 stsp test_done "$testroot" "0"
508 dbec59df 2020-04-18 stsp function test_log_reverse_display {
509 dbec59df 2020-04-18 stsp local testroot=`test_init log_reverse_display`
510 dbec59df 2020-04-18 stsp local commit_id0=`git_show_head $testroot/repo`
512 dbec59df 2020-04-18 stsp got checkout $testroot/repo $testroot/wt > /dev/null
514 dbec59df 2020-04-18 stsp if [ "$ret" != "0" ]; then
515 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
519 dbec59df 2020-04-18 stsp echo "modified alpha" > $testroot/wt/alpha
520 dbec59df 2020-04-18 stsp (cd $testroot/wt && got commit -m 'commit1' > /dev/null)
521 dbec59df 2020-04-18 stsp local commit_id1=`git_show_head $testroot/repo`
523 dbec59df 2020-04-18 stsp (cd $testroot/wt && got rm beta >/dev/null)
524 dbec59df 2020-04-18 stsp (cd $testroot/wt && got commit -m 'commit2' > /dev/null)
525 dbec59df 2020-04-18 stsp local commit_id2=`git_show_head $testroot/repo`
527 dbec59df 2020-04-18 stsp echo "new file" > $testroot/wt/new
528 dbec59df 2020-04-18 stsp (cd $testroot/wt && got add new >/dev/null)
529 dbec59df 2020-04-18 stsp (cd $testroot/wt && got commit -m 'commit3' > /dev/null)
530 dbec59df 2020-04-18 stsp local commit_id3=`git_show_head $testroot/repo`
532 dbec59df 2020-04-18 stsp # -R alone should display all commits in reverse
533 dbec59df 2020-04-18 stsp echo "commit $commit_id0" > $testroot/stdout.expected
534 dbec59df 2020-04-18 stsp echo "commit $commit_id1" >> $testroot/stdout.expected
535 dbec59df 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
536 dbec59df 2020-04-18 stsp echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
537 dbec59df 2020-04-18 stsp (cd $testroot/wt && got log -R | grep ^commit > $testroot/stdout)
538 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
540 dbec59df 2020-04-18 stsp if [ "$ret" != "0" ]; then
541 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
542 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
546 dbec59df 2020-04-18 stsp # -R takes effect after the -l commit traversal limit
547 dbec59df 2020-04-18 stsp echo "commit $commit_id2" > $testroot/stdout.expected
548 dbec59df 2020-04-18 stsp echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
549 dbec59df 2020-04-18 stsp (cd $testroot/wt && got log -R -l2 | grep ^commit > $testroot/stdout)
550 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
552 dbec59df 2020-04-18 stsp if [ "$ret" != "0" ]; then
553 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
554 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
558 dbec59df 2020-04-18 stsp # -R works with commit ranges specified via -c and -x
559 dbec59df 2020-04-18 stsp echo "commit $commit_id1" > $testroot/stdout.expected
560 dbec59df 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
561 dbec59df 2020-04-18 stsp echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
562 dbec59df 2020-04-18 stsp (cd $testroot/wt && got log -R -c $commit_id3 -x $commit_id1 | \
563 dbec59df 2020-04-18 stsp grep ^commit > $testroot/stdout)
564 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
566 dbec59df 2020-04-18 stsp if [ "$ret" != "0" ]; then
567 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
568 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
571 dbec59df 2020-04-18 stsp # commit matching with -s applies before -R
572 dbec59df 2020-04-18 stsp echo "commit $commit_id1" > $testroot/stdout.expected
573 dbec59df 2020-04-18 stsp echo "commit $commit_id2" >> $testroot/stdout.expected
574 dbec59df 2020-04-18 stsp (cd $testroot/wt && got log -R -s 'commit[12]' | \
575 dbec59df 2020-04-18 stsp grep ^commit > $testroot/stdout)
576 dbec59df 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
578 dbec59df 2020-04-18 stsp if [ "$ret" != "0" ]; then
579 dbec59df 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
581 dbec59df 2020-04-18 stsp test_done "$testroot" "$ret"
584 50f2fada 2020-04-24 stsp function test_log_in_worktree_different_repo {
585 50f2fada 2020-04-24 stsp local testroot=`test_init log_in_worktree_different_repo 1`
587 50f2fada 2020-04-24 stsp make_test_tree $testroot/repo
588 50f2fada 2020-04-24 stsp mkdir -p $testroot/repo/epsilon/d
589 50f2fada 2020-04-24 stsp echo foo > $testroot/repo/epsilon/d/foo
590 50f2fada 2020-04-24 stsp (cd $testroot/repo && git add .)
591 50f2fada 2020-04-24 stsp git_commit $testroot/repo -m "adding the test tree"
592 50f2fada 2020-04-24 stsp local head_commit=`git_show_head $testroot/repo`
594 50f2fada 2020-04-24 stsp got init $testroot/other-repo
595 50f2fada 2020-04-24 stsp mkdir -p $testroot/tree
596 50f2fada 2020-04-24 stsp make_test_tree $testroot/tree
597 50f2fada 2020-04-24 stsp got import -mm -b foo -r $testroot/other-repo $testroot/tree >/dev/null
598 50f2fada 2020-04-24 stsp got checkout -b foo $testroot/other-repo $testroot/wt > /dev/null
600 50f2fada 2020-04-24 stsp if [ "$ret" != "0" ]; then
601 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
605 50f2fada 2020-04-24 stsp echo "commit $head_commit (master)" > $testroot/stdout.expected
607 50f2fada 2020-04-24 stsp # 'got log' used to fail with "reference refs/heads/foo not found"
608 50f2fada 2020-04-24 stsp # even though that reference belongs to an unrelated repository
609 50f2fada 2020-04-24 stsp # found via a worktree via the current working directory
610 50f2fada 2020-04-24 stsp for p in "" alpha epsilon; do
611 50f2fada 2020-04-24 stsp (cd $testroot/wt && got log -r $testroot/repo $p | \
612 50f2fada 2020-04-24 stsp grep ^commit > $testroot/stdout)
613 50f2fada 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
615 50f2fada 2020-04-24 stsp if [ "$ret" != "0" ]; then
616 50f2fada 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
617 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
622 50f2fada 2020-04-24 stsp for p in "" epsilon/zeta; do
623 50f2fada 2020-04-24 stsp (cd $testroot/wt/epsilon && got log -r $testroot/repo $p | \
624 50f2fada 2020-04-24 stsp grep ^commit > $testroot/stdout)
625 50f2fada 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
627 50f2fada 2020-04-24 stsp if [ "$ret" != "0" ]; then
628 50f2fada 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
629 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
634 50f2fada 2020-04-24 stsp for p in "" foo; do
635 50f2fada 2020-04-24 stsp (cd $testroot/wt/epsilon && got log -r $testroot/repo epsilon/d/$p | \
636 50f2fada 2020-04-24 stsp grep ^commit > $testroot/stdout)
637 50f2fada 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
639 50f2fada 2020-04-24 stsp if [ "$ret" != "0" ]; then
640 50f2fada 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
641 50f2fada 2020-04-24 stsp test_done "$testroot" "$ret"
646 50f2fada 2020-04-24 stsp test_done "$testroot" "0"
649 0208f208 2020-05-05 stsp function test_log_changed_paths {
650 0208f208 2020-05-05 stsp local testroot=`test_init log_changed_paths`
651 0208f208 2020-05-05 stsp local commit_id0=`git_show_head $testroot/repo`
653 0208f208 2020-05-05 stsp got checkout $testroot/repo $testroot/wt > /dev/null
655 0208f208 2020-05-05 stsp if [ "$ret" != "0" ]; then
656 0208f208 2020-05-05 stsp test_done "$testroot" "$ret"
660 0208f208 2020-05-05 stsp echo "modified alpha" > $testroot/wt/alpha
661 0208f208 2020-05-05 stsp (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
662 0208f208 2020-05-05 stsp local commit_id1=`git_show_head $testroot/repo`
664 0208f208 2020-05-05 stsp (cd $testroot/wt && got rm beta >/dev/null)
665 0208f208 2020-05-05 stsp (cd $testroot/wt && chmod +x epsilon/zeta >/dev/null)
666 0208f208 2020-05-05 stsp (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
667 0208f208 2020-05-05 stsp local commit_id2=`git_show_head $testroot/repo`
669 0208f208 2020-05-05 stsp echo "new file" > $testroot/wt/new
670 0208f208 2020-05-05 stsp (cd $testroot/wt && got add new >/dev/null)
671 0208f208 2020-05-05 stsp (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
672 0208f208 2020-05-05 stsp local commit_id3=`git_show_head $testroot/repo`
674 0208f208 2020-05-05 stsp (cd $testroot/wt && got log -P | grep '^ [MDmA]' > $testroot/stdout)
676 0208f208 2020-05-05 stsp echo " A new" > $testroot/stdout.expected
677 0208f208 2020-05-05 stsp echo " D beta" >> $testroot/stdout.expected
678 0208f208 2020-05-05 stsp echo " m epsilon/zeta" >> $testroot/stdout.expected
679 0208f208 2020-05-05 stsp echo " M alpha" >> $testroot/stdout.expected
680 0208f208 2020-05-05 stsp echo " A alpha" >> $testroot/stdout.expected
681 0208f208 2020-05-05 stsp echo " A beta" >> $testroot/stdout.expected
682 0208f208 2020-05-05 stsp echo " A epsilon/zeta" >> $testroot/stdout.expected
683 0208f208 2020-05-05 stsp echo " A gamma/delta" >> $testroot/stdout.expected
685 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
687 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
688 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
690 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
693 e7303626 2020-05-14 stsp function test_log_submodule {
694 e7303626 2020-05-14 stsp local testroot=`test_init log_submodule`
696 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
698 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
699 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
700 e7303626 2020-05-14 stsp local head_commit=`git_show_head $testroot/repo`
702 e7303626 2020-05-14 stsp echo "commit $head_commit (master)" > $testroot/stdout.expected
704 e7303626 2020-05-14 stsp got log -r $testroot/repo -l1 repo2 | grep ^commit > $testroot/stdout
705 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
707 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
708 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
709 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
713 e7303626 2020-05-14 stsp echo " A .gitmodules" > $testroot/stdout.expected
715 e7303626 2020-05-14 stsp got log -r $testroot/repo -l1 -P repo2 | grep '^ [MDmA]' \
716 e7303626 2020-05-14 stsp > $testroot/stdout
717 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
719 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
720 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
721 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
725 e7303626 2020-05-14 stsp got log -p -r $testroot/repo -l1 repo2 \
726 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr
728 e7303626 2020-05-14 stsp if [ "$ret" == "0" ]; then
729 e7303626 2020-05-14 stsp echo "log command succeeded unexpectedly" >&2
730 e7303626 2020-05-14 stsp test_done "$testroot" "1"
733 e7303626 2020-05-14 stsp local submodule_id=$(got tree -r $testroot/repo -i | \
734 e7303626 2020-05-14 stsp grep 'repo2\$$' | cut -d ' ' -f1)
735 e7303626 2020-05-14 stsp echo "got: object $submodule_id not found" > $testroot/stderr.expected
737 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
739 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
740 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
741 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
745 e7303626 2020-05-14 stsp echo "modified foo" > $testroot/repo2/foo
746 e7303626 2020-05-14 stsp (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
748 e7303626 2020-05-14 stsp # Update the repo/repo2 submodule link
749 e7303626 2020-05-14 stsp (cd $testroot/repo && git -C repo2 pull -q)
750 e7303626 2020-05-14 stsp (cd $testroot/repo && git add repo2)
751 e7303626 2020-05-14 stsp git_commit $testroot/repo -m "changed submodule link"
753 e7303626 2020-05-14 stsp # log -P does not show the changed submodule path
754 e7303626 2020-05-14 stsp got log -P -r $testroot/repo -l1 repo2 > $testroot/stdout.full
756 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
757 e7303626 2020-05-14 stsp echo "log command failed unexpectedly" >&2
758 e7303626 2020-05-14 stsp test_done "$testroot" "1"
761 e7303626 2020-05-14 stsp grep '^ [MDmA]' $testroot/stdout.full > $testroot/stdout
763 e7303626 2020-05-14 stsp echo -n > $testroot/stdout.expected
764 0208f208 2020-05-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
766 0208f208 2020-05-05 stsp if [ "$ret" != "0" ]; then
767 0208f208 2020-05-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
769 0208f208 2020-05-05 stsp test_done "$testroot" "$ret"
772 e7301579 2019-03-18 stsp run_test test_log_in_repo
773 b70703ad 2019-03-18 stsp run_test test_log_in_bare_repo
774 cbd1af7a 2019-03-18 stsp run_test test_log_in_worktree
775 dfe70b4b 2019-08-27 stsp run_test test_log_in_worktree_with_path_prefix
776 303e2782 2019-08-09 stsp run_test test_log_tag
777 b1ebc001 2019-08-13 stsp run_test test_log_limit
778 2e8c69d1 2020-05-04 stsp run_test test_log_patch_added_file
779 5175b31a 2020-01-04 stsp run_test test_log_nonexistent_path
780 d1fe46f9 2020-04-18 stsp run_test test_log_end_at_commit
781 dbec59df 2020-04-18 stsp run_test test_log_reverse_display
782 50f2fada 2020-04-24 stsp run_test test_log_in_worktree_different_repo
783 0208f208 2020-05-05 stsp run_test test_log_changed_paths
784 e7303626 2020-05-14 stsp run_test test_log_submodule