t/helper: stop using `the_index`
[git.git] / t / t9116-git-svn-log.sh
blobd74d7b2de68e05cb41d0740f54fa598aaa50fa9a
1 #!/bin/sh
3 # Copyright (c) 2007 Eric Wong
6 test_description='git svn log tests'
8 . ./lib-git-svn.sh
10 test_expect_success 'setup repository and import' '
11 mkdir import &&
13 cd import &&
14 for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3
16 mkdir -p $i &&
17 echo hello >>$i/README ||
18 exit 1
19 done &&
20 svn_cmd import -m test . "$svnrepo"
21 ) &&
22 git svn init "$svnrepo" -T trunk -b branches -t tags &&
23 git svn fetch &&
24 git reset --hard origin/trunk &&
25 echo bye >> README &&
26 git commit -a -m bye &&
27 git svn dcommit &&
28 git reset --hard origin/a &&
29 echo why >> FEEDME &&
30 git update-index --add FEEDME &&
31 git commit -m feedme &&
32 git svn dcommit &&
33 git reset --hard origin/trunk &&
34 echo aye >> README &&
35 git commit -a -m aye &&
36 git svn dcommit &&
37 git reset --hard origin/b &&
38 echo spy >> README &&
39 git commit -a -m spy &&
40 echo try >> README &&
41 git commit -a -m try &&
42 git svn dcommit
45 test_expect_success 'run log' "
46 git reset --hard origin/a &&
47 git svn log -r2 origin/trunk >out &&
48 grep ^r2 out &&
49 git svn log -r4 origin/trunk >out &&
50 grep ^r4 out &&
51 git svn log -r3 >out &&
52 grep ^r3 out
55 test_expect_success 'run log against a from trunk' "
56 git reset --hard origin/trunk &&
57 git svn log -r3 origin/a >out &&
58 grep ^r3 out
61 printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4
63 test_expect_success 'test ascending revision range' "
64 git reset --hard origin/trunk &&
65 git svn log -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' "
69 git reset --hard origin/trunk &&
70 git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
73 test_expect_success 'test ascending revision range with --show-commit (sha1)' "
74 git svn find-rev r1 >expected-range-r1-r2-r4-sha1 &&
75 git svn find-rev r2 >>expected-range-r1-r2-r4-sha1 &&
76 git svn find-rev r4 >>expected-range-r1-r2-r4-sha1 &&
77 git reset --hard origin/trunk &&
78 git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f2 >out &&
79 git rev-parse \$(cat out) >actual &&
80 test_cmp expected-range-r1-r2-r4-sha1 actual
83 printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
85 test_expect_success 'test descending revision range' "
86 git reset --hard origin/trunk &&
87 git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
90 printf 'r1 \nr2 \n' > expected-range-r1-r2
92 test_expect_success 'test ascending revision range with unreachable revision' "
93 git reset --hard origin/trunk &&
94 git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
97 printf 'r2 \nr1 \n' > expected-range-r2-r1
99 test_expect_success 'test descending revision range with unreachable revision' "
100 git reset --hard origin/trunk &&
101 git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
104 printf 'r2 \n' > expected-range-r2
106 test_expect_success 'test ascending revision range with unreachable upper boundary revision and 1 commit' "
107 git reset --hard origin/trunk &&
108 git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
111 test_expect_success 'test descending revision range with unreachable upper boundary revision and 1 commit' "
112 git reset --hard origin/trunk &&
113 git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
116 printf 'r4 \n' > expected-range-r4
118 test_expect_success 'test ascending revision range with unreachable lower boundary revision and 1 commit' "
119 git reset --hard origin/trunk &&
120 git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
123 test_expect_success 'test descending revision range with unreachable lower boundary revision and 1 commit' "
124 git reset --hard origin/trunk &&
125 git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
128 printf -- '------------------------------------------------------------------------\n' > expected-separator
130 test_expect_success 'test ascending revision range with unreachable boundary revisions and no commits' "
131 git reset --hard origin/trunk &&
132 git svn log -r 5:6 | test_cmp expected-separator -
135 test_expect_success 'test descending revision range with unreachable boundary revisions and no commits' "
136 git reset --hard origin/trunk &&
137 git svn log -r 6:5 | test_cmp expected-separator -
140 test_expect_success 'test ascending revision range with unreachable boundary revisions and 1 commit' "
141 git reset --hard origin/trunk &&
142 git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
145 test_expect_success 'test descending revision range with unreachable boundary revisions and 1 commit' "
146 git reset --hard origin/trunk &&
147 git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
150 test_done