Git 2.11.3
[alt-git.git] / t / t9116-git-svn-log.sh
blob45773ee560dab10a6dbec4bf19a82bbdae3fe7c4
1 #!/bin/sh
3 # Copyright (c) 2007 Eric Wong
6 test_description='git svn log tests'
7 . ./lib-git-svn.sh
9 test_expect_success 'setup repository and import' '
10 mkdir import &&
12 cd import &&
13 for i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3
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 origin/trunk &&
24 echo bye >> README &&
25 git commit -a -m bye &&
26 git svn dcommit &&
27 git reset --hard origin/a &&
28 echo why >> FEEDME &&
29 git update-index --add FEEDME &&
30 git commit -m feedme &&
31 git svn dcommit &&
32 git reset --hard origin/trunk &&
33 echo aye >> README &&
34 git commit -a -m aye &&
35 git svn dcommit &&
36 git reset --hard origin/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
44 test_expect_success 'run log' "
45 git reset --hard origin/a &&
46 git svn log -r2 origin/trunk | grep ^r2 &&
47 git svn log -r4 origin/trunk | grep ^r4 &&
48 git svn log -r3 | grep ^r3
51 test_expect_success 'run log against a from trunk' "
52 git reset --hard origin/trunk &&
53 git svn log -r3 origin/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 origin/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 origin/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 origin/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 origin/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 origin/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 origin/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 origin/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 origin/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 origin/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 origin/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 origin/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 origin/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 origin/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 origin/trunk &&
142 git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
145 test_done