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 trunk &&
25 git commit -a -m bye &&
29 git update-index --add FEEDME &&
30 git commit -m feedme &&
32 git reset --hard trunk &&
34 git commit -a -m aye &&
38 git commit -a -m spy &&
40 git commit -a -m try &&
44 test_expect_success
'run log' "
46 git svn log -r2 trunk | grep ^r2 &&
47 git svn log -r4 trunk | grep ^r4 &&
48 git svn log -r3 | grep ^r3
51 test_expect_success
'run log against a from trunk' "
52 git reset --hard trunk &&
53 git svn log -r3 a | grep ^r3
56 printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4
58 test_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 -
63 test_expect_success
'test ascending revision range with --show-commit' "
64 git reset --hard trunk &&
65 git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
68 test_expect_success
'test ascending revision range with --show-commit (sha1)' "
69 git svn find-rev r1 >expected-range-r1-r2-r4-sha1 &&
70 git svn find-rev r2 >>expected-range-r1-r2-r4-sha1 &&
71 git svn find-rev r4 >>expected-range-r1-r2-r4-sha1 &&
72 git reset --hard trunk &&
73 git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f2 >out &&
74 git rev-parse \$(cat out) >actual &&
75 test_cmp expected-range-r1-r2-r4-sha1 actual
78 printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
80 test_expect_success
'test descending revision range' "
81 git reset --hard trunk &&
82 git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
85 printf 'r1 \nr2 \n' > expected-range-r1-r2
87 test_expect_success
'test ascending revision range with unreachable revision' "
88 git reset --hard trunk &&
89 git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
92 printf 'r2 \nr1 \n' > expected-range-r2-r1
94 test_expect_success
'test descending revision range with unreachable revision' "
95 git reset --hard trunk &&
96 git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
99 printf 'r2 \n' > expected-range-r2
101 test_expect_success
'test ascending revision range with unreachable upper boundary revision and 1 commit' "
102 git reset --hard trunk &&
103 git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
106 test_expect_success
'test descending revision range with unreachable upper boundary revision and 1 commit' "
107 git reset --hard trunk &&
108 git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
111 printf 'r4 \n' > expected-range-r4
113 test_expect_success
'test ascending revision range with unreachable lower boundary revision and 1 commit' "
114 git reset --hard trunk &&
115 git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
118 test_expect_success
'test descending revision range with unreachable lower boundary revision and 1 commit' "
119 git reset --hard trunk &&
120 git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
123 printf -- '------------------------------------------------------------------------\n' > expected-separator
125 test_expect_success
'test ascending revision range with unreachable boundary revisions and no commits' "
126 git reset --hard trunk &&
127 git svn log -r 5:6 | test_cmp expected-separator -
130 test_expect_success
'test descending revision range with unreachable boundary revisions and no commits' "
131 git reset --hard trunk &&
132 git svn log -r 6:5 | test_cmp expected-separator -
135 test_expect_success
'test ascending revision range with unreachable boundary revisions and 1 commit' "
136 git reset --hard trunk &&
137 git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
140 test_expect_success
'test descending revision range with unreachable boundary revisions and 1 commit' "
141 git reset --hard trunk &&
142 git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -