1#!/bin/sh
2#
3# Copyright (c) 2007 Eric Wong
4#
5
6test_description='git svn log tests'
7. ./lib-git-svn.sh
8
9test_expect_success 'setup repository and import' '
10 mkdir import &&
11 (
12 cd import &&
13 for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3
14 do
15 mkdir -p $i &&
16 echo hello >>$i/README ||
17 exit 1
18 done &&
19 svn_cmd import -m test . "$svnrepo"
20 ) &&
21 git svn init "$svnrepo" -T trunk -b branches -t tags &&
22 git svn fetch &&
23 git reset --hard trunk &&
24 echo bye >> README &&
25 git commit -a -m bye &&
26 git svn dcommit &&
27 git reset --hard a &&
28 echo why >> FEEDME &&
29 git update-index --add FEEDME &&
30 git commit -m feedme &&
31 git svn dcommit &&
32 git reset --hard trunk &&
33 echo aye >> README &&
34 git commit -a -m aye &&
35 git svn dcommit &&
36 git reset --hard b &&
37 echo spy >> README &&
38 git commit -a -m spy &&
39 echo try >> README &&
40 git commit -a -m try &&
41 git svn dcommit
42 '
43
44test_expect_success 'run log' "
45 git reset --hard a &&
46 git svn log -r2 trunk | grep ^r2 &&
47 git svn log -r4 trunk | grep ^r4 &&
48 git svn log -r3 | grep ^r3
49 "
50
51test_expect_success 'run log against a from trunk' "
52 git reset --hard trunk &&
53 git svn log -r3 a | grep ^r3
54 "
55
56printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4
57
58test_expect_success 'test ascending revision range' "
59 git reset --hard trunk &&
60 git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
61 "
62
63printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
64
65test_expect_success 'test descending revision range' "
66 git reset --hard trunk &&
67 git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
68 "
69
70printf 'r1 \nr2 \n' > expected-range-r1-r2
71
72test_expect_success 'test ascending revision range with unreachable revision' "
73 git reset --hard trunk &&
74 git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
75 "
76
77printf 'r2 \nr1 \n' > expected-range-r2-r1
78
79test_expect_success 'test descending revision range with unreachable revision' "
80 git reset --hard trunk &&
81 git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
82 "
83
84printf 'r2 \n' > expected-range-r2
85
86test_expect_success 'test ascending revision range with unreachable upper boundary revision and 1 commit' "
87 git reset --hard trunk &&
88 git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
89 "
90
91test_expect_success 'test descending revision range with unreachable upper boundary revision and 1 commit' "
92 git reset --hard trunk &&
93 git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
94 "
95
96printf 'r4 \n' > expected-range-r4
97
98test_expect_success 'test ascending revision range with unreachable lower boundary revision and 1 commit' "
99 git reset --hard trunk &&
100 git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
101 "
102
103test_expect_success 'test descending revision range with unreachable lower boundary revision and 1 commit' "
104 git reset --hard trunk &&
105 git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
106 "
107
108printf -- '------------------------------------------------------------------------\n' > expected-separator
109
110test_expect_success 'test ascending revision range with unreachable boundary revisions and no commits' "
111 git reset --hard trunk &&
112 git svn log -r 5:6 | test_cmp expected-separator -
113 "
114
115test_expect_success 'test descending revision range with unreachable boundary revisions and no commits' "
116 git reset --hard trunk &&
117 git svn log -r 6:5 | test_cmp expected-separator -
118 "
119
120test_expect_success 'test ascending revision range with unreachable boundary revisions and 1 commit' "
121 git reset --hard trunk &&
122 git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
123 "
124
125test_expect_success 'test descending revision range with unreachable boundary revisions and 1 commit' "
126 git reset --hard trunk &&
127 git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
128 "
129
130test_done