3 # Copyright (c) 2007 Eric Wong
6 test_description
='git svn log tests'
9 test_expect_success
'setup repository and import' '
13 for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3
16 echo hello >>$i/README ||
19 svn_cmd import -m test . "$svnrepo"
21 git svn init "$svnrepo" -T trunk -b branches -t tags &&
23 git reset --hard origin/trunk &&
25 git commit -a -m bye &&
27 git reset --hard origin/a &&
29 git update-index --add FEEDME &&
30 git commit -m feedme &&
32 git reset --hard origin/trunk &&
34 git commit -a -m aye &&
36 git reset --hard origin/b &&
38 git commit -a -m spy &&
40 git commit -a -m try &&
44 test_expect_success
'run log' "
45 git reset --hard origin/a &&
46 git svn log -r2 origin/trunk >out &&
48 git svn log -r4 origin/trunk >out &&
50 git svn log -r3 >out &&
54 test_expect_success
'run log against a from trunk' "
55 git reset --hard origin/trunk &&
56 git svn log -r3 origin/a >out &&
60 printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4
62 test_expect_success
'test ascending revision range' "
63 git reset --hard origin/trunk &&
64 git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
67 test_expect_success
'test ascending revision range with --show-commit' "
68 git reset --hard origin/trunk &&
69 git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
72 test_expect_success
'test ascending revision range with --show-commit (sha1)' "
73 git svn find-rev r1 >expected-range-r1-r2-r4-sha1 &&
74 git svn find-rev r2 >>expected-range-r1-r2-r4-sha1 &&
75 git svn find-rev r4 >>expected-range-r1-r2-r4-sha1 &&
76 git reset --hard origin/trunk &&
77 git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f2 >out &&
78 git rev-parse \$(cat out) >actual &&
79 test_cmp expected-range-r1-r2-r4-sha1 actual
82 printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
84 test_expect_success
'test descending revision range' "
85 git reset --hard origin/trunk &&
86 git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
89 printf 'r1 \nr2 \n' > expected-range-r1-r2
91 test_expect_success
'test ascending revision range with unreachable revision' "
92 git reset --hard origin/trunk &&
93 git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
96 printf 'r2 \nr1 \n' > expected-range-r2-r1
98 test_expect_success
'test descending revision range with unreachable revision' "
99 git reset --hard origin/trunk &&
100 git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
103 printf 'r2 \n' > expected-range-r2
105 test_expect_success
'test ascending revision range with unreachable upper boundary revision and 1 commit' "
106 git reset --hard origin/trunk &&
107 git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
110 test_expect_success
'test descending revision range with unreachable upper boundary revision and 1 commit' "
111 git reset --hard origin/trunk &&
112 git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
115 printf 'r4 \n' > expected-range-r4
117 test_expect_success
'test ascending revision range with unreachable lower boundary revision and 1 commit' "
118 git reset --hard origin/trunk &&
119 git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
122 test_expect_success
'test descending revision range with unreachable lower boundary revision and 1 commit' "
123 git reset --hard origin/trunk &&
124 git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
127 printf -- '------------------------------------------------------------------------\n' > expected-separator
129 test_expect_success
'test ascending revision range with unreachable boundary revisions and no commits' "
130 git reset --hard origin/trunk &&
131 git svn log -r 5:6 | test_cmp expected-separator -
134 test_expect_success
'test descending revision range with unreachable boundary revisions and no commits' "
135 git reset --hard origin/trunk &&
136 git svn log -r 6:5 | test_cmp expected-separator -
139 test_expect_success
'test ascending revision range with unreachable boundary revisions and 1 commit' "
140 git reset --hard origin/trunk &&
141 git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
144 test_expect_success
'test descending revision range with unreachable boundary revisions and 1 commit' "
145 git reset --hard origin/trunk &&
146 git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -