]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9116-git-svn-log.sh
t: use update-ref and show-ref to reading/writing refs
[thirdparty/git.git] / t / t9116-git-svn-log.sh
CommitLineData
6ed77266
EW
1#!/bin/sh
2#
3# Copyright (c) 2007 Eric Wong
4#
5
1364ff27 6test_description='git svn log tests'
6ed77266
EW
7. ./lib-git-svn.sh
8
f69e836f 9test_expect_success 'setup repository and import' '
6ed77266 10 mkdir import &&
18a82692
JN
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 &&
da083d68 19 svn_cmd import -m test . "$svnrepo"
18a82692 20 ) &&
1364ff27
NS
21 git svn init "$svnrepo" -T trunk -b branches -t tags &&
22 git svn fetch &&
fe191fca 23 git reset --hard origin/trunk &&
6ed77266
EW
24 echo bye >> README &&
25 git commit -a -m bye &&
26 git svn dcommit &&
fe191fca 27 git reset --hard origin/a &&
6ed77266
EW
28 echo why >> FEEDME &&
29 git update-index --add FEEDME &&
30 git commit -m feedme &&
31 git svn dcommit &&
fe191fca 32 git reset --hard origin/trunk &&
6ed77266
EW
33 echo aye >> README &&
34 git commit -a -m aye &&
111947ef 35 git svn dcommit &&
fe191fca 36 git reset --hard origin/b &&
111947ef
DK
37 echo spy >> README &&
38 git commit -a -m spy &&
39 echo try >> README &&
40 git commit -a -m try &&
6ed77266 41 git svn dcommit
f69e836f 42 '
6ed77266
EW
43
44test_expect_success 'run log' "
fe191fca 45 git reset --hard origin/a &&
de26f02d
JS
46 git svn log -r2 origin/trunk >out &&
47 grep ^r2 out &&
48 git svn log -r4 origin/trunk >out &&
49 grep ^r4 out &&
50 git svn log -r3 >out &&
51 grep ^r3 out
6ed77266
EW
52 "
53
54test_expect_success 'run log against a from trunk' "
fe191fca 55 git reset --hard origin/trunk &&
de26f02d
JS
56 git svn log -r3 origin/a >out &&
57 grep ^r3 out
6ed77266
EW
58 "
59
60f3ff12 60printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4
fede44b2
DK
61
62test_expect_success 'test ascending revision range' "
fe191fca 63 git reset --hard origin/trunk &&
82ebb0b6 64 git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
fede44b2
DK
65 "
66
9963e025 67test_expect_success 'test ascending revision range with --show-commit' "
fe191fca 68 git reset --hard origin/trunk &&
9963e025
MG
69 git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
70 "
71
72test_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 &&
fe191fca 76 git reset --hard origin/trunk &&
9963e025
MG
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
80 "
81
60f3ff12 82printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
fede44b2
DK
83
84test_expect_success 'test descending revision range' "
fe191fca 85 git reset --hard origin/trunk &&
82ebb0b6 86 git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
fede44b2
DK
87 "
88
111947ef
DK
89printf 'r1 \nr2 \n' > expected-range-r1-r2
90
91test_expect_success 'test ascending revision range with unreachable revision' "
fe191fca 92 git reset --hard origin/trunk &&
82ebb0b6 93 git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
111947ef
DK
94 "
95
96printf 'r2 \nr1 \n' > expected-range-r2-r1
97
98test_expect_success 'test descending revision range with unreachable revision' "
fe191fca 99 git reset --hard origin/trunk &&
82ebb0b6 100 git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
111947ef
DK
101 "
102
103printf 'r2 \n' > expected-range-r2
104
105test_expect_success 'test ascending revision range with unreachable upper boundary revision and 1 commit' "
fe191fca 106 git reset --hard origin/trunk &&
82ebb0b6 107 git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
111947ef
DK
108 "
109
110test_expect_success 'test descending revision range with unreachable upper boundary revision and 1 commit' "
fe191fca 111 git reset --hard origin/trunk &&
82ebb0b6 112 git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
111947ef
DK
113 "
114
115printf 'r4 \n' > expected-range-r4
116
117test_expect_success 'test ascending revision range with unreachable lower boundary revision and 1 commit' "
fe191fca 118 git reset --hard origin/trunk &&
82ebb0b6 119 git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
111947ef
DK
120 "
121
122test_expect_success 'test descending revision range with unreachable lower boundary revision and 1 commit' "
fe191fca 123 git reset --hard origin/trunk &&
82ebb0b6 124 git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
111947ef
DK
125 "
126
127printf -- '------------------------------------------------------------------------\n' > expected-separator
128
129test_expect_success 'test ascending revision range with unreachable boundary revisions and no commits' "
fe191fca 130 git reset --hard origin/trunk &&
82ebb0b6 131 git svn log -r 5:6 | test_cmp expected-separator -
111947ef
DK
132 "
133
134test_expect_success 'test descending revision range with unreachable boundary revisions and no commits' "
fe191fca 135 git reset --hard origin/trunk &&
82ebb0b6 136 git svn log -r 6:5 | test_cmp expected-separator -
111947ef
DK
137 "
138
139test_expect_success 'test ascending revision range with unreachable boundary revisions and 1 commit' "
fe191fca 140 git reset --hard origin/trunk &&
82ebb0b6 141 git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
111947ef
DK
142 "
143
144test_expect_success 'test descending revision range with unreachable boundary revisions and 1 commit' "
fe191fca 145 git reset --hard origin/trunk &&
82ebb0b6 146 git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
111947ef
DK
147 "
148
6ed77266 149test_done