]>
Commit | Line | Data |
---|---|---|
36f5b1f0 EW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Eric Wong | |
4 | # | |
5 | ||
1364ff27 | 6 | test_description='git svn property tests' |
7a98d9ab | 7 | |
36f5b1f0 EW |
8 | . ./lib-git-svn.sh |
9 | ||
10 | mkdir import | |
11 | ||
12 | a_crlf= | |
13 | a_lf= | |
14 | a_cr= | |
15 | a_ne_crlf= | |
16 | a_ne_lf= | |
17 | a_ne_cr= | |
18 | a_empty= | |
19 | a_empty_lf= | |
20 | a_empty_cr= | |
21 | a_empty_crlf= | |
22 | ||
23 | cd import | |
09bf1225 | 24 | cat >>kw.c <<\EOF |
dc62e25c EW |
25 | /* Somebody prematurely put a keyword into this file */ |
26 | /* $Id$ */ | |
3c4c7351 | 27 | EOF |
36f5b1f0 | 28 | |
09bf1225 | 29 | printf "Hello\r\nWorld\r\n" >crlf |
e10de5a0 | 30 | a_crlf=$(git hash-object -w crlf) |
09bf1225 | 31 | printf "Hello\rWorld\r" >cr |
e10de5a0 | 32 | a_cr=$(git hash-object -w cr) |
09bf1225 | 33 | printf "Hello\nWorld\n" >lf |
e10de5a0 | 34 | a_lf=$(git hash-object -w lf) |
36f5b1f0 | 35 | |
09bf1225 | 36 | printf "Hello\r\nWorld" >ne_crlf |
e10de5a0 | 37 | a_ne_crlf=$(git hash-object -w ne_crlf) |
09bf1225 | 38 | printf "Hello\nWorld" >ne_lf |
e10de5a0 | 39 | a_ne_lf=$(git hash-object -w ne_lf) |
09bf1225 | 40 | printf "Hello\rWorld" >ne_cr |
e10de5a0 | 41 | a_ne_cr=$(git hash-object -w ne_cr) |
36f5b1f0 EW |
42 | |
43 | touch empty | |
e10de5a0 | 44 | a_empty=$(git hash-object -w empty) |
09bf1225 | 45 | printf "\n" >empty_lf |
e10de5a0 | 46 | a_empty_lf=$(git hash-object -w empty_lf) |
09bf1225 | 47 | printf "\r" >empty_cr |
e10de5a0 | 48 | a_empty_cr=$(git hash-object -w empty_cr) |
09bf1225 | 49 | printf "\r\n" >empty_crlf |
e10de5a0 | 50 | a_empty_crlf=$(git hash-object -w empty_crlf) |
36f5b1f0 | 51 | |
da083d68 | 52 | svn_cmd import --no-auto-props -m 'import for git svn' . "$svnrepo" >/dev/null |
36f5b1f0 EW |
53 | cd .. |
54 | ||
55 | rm -rf import | |
f69e836f | 56 | test_expect_success 'checkout working copy from svn' 'svn co "$svnrepo" test_wc' |
18a82692 JN |
57 | test_expect_success 'setup some commits to svn' ' |
58 | ( | |
59 | cd test_wc && | |
09bf1225 | 60 | echo Greetings >>kw.c && |
7b3fab87 | 61 | poke kw.c && |
da083d68 | 62 | svn_cmd commit -m "Not yet an Id" && |
09bf1225 | 63 | echo Hello world >>kw.c && |
7b3fab87 | 64 | poke kw.c && |
da083d68 ER |
65 | svn_cmd commit -m "Modified file, but still not yet an Id" && |
66 | svn_cmd propset svn:keywords Id kw.c && | |
7b3fab87 | 67 | poke kw.c && |
fd4ec4f2 | 68 | svn_cmd commit -m "Propset Id" |
18a82692 JN |
69 | ) |
70 | ' | |
42d32870 | 71 | |
f964732c | 72 | test_expect_success 'initialize git svn' 'git svn init "$svnrepo"' |
1364ff27 | 73 | test_expect_success 'fetch revisions from svn' 'git svn fetch' |
36f5b1f0 | 74 | |
36f5b1f0 | 75 | name='test svn:keywords ignoring' |
42d32870 | 76 | test_expect_success "$name" \ |
e1c0c158 | 77 | 'git checkout -b mybranch remotes/git-svn && |
09bf1225 | 78 | echo Hi again >>kw.c && |
3dff5379 | 79 | git commit -a -m "test keywords ignoring" && |
e1c0c158 JK |
80 | git svn set-tree remotes/git-svn..mybranch && |
81 | git pull . remotes/git-svn' | |
36f5b1f0 EW |
82 | |
83 | expect='/* $Id$ */' | |
e10de5a0 | 84 | got="$(sed -ne 2p kw.c)" |
36f5b1f0 EW |
85 | test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'" |
86 | ||
18a82692 JN |
87 | test_expect_success "propset CR on crlf files" ' |
88 | ( | |
89 | cd test_wc && | |
da083d68 ER |
90 | svn_cmd propset svn:eol-style CR empty && |
91 | svn_cmd propset svn:eol-style CR crlf && | |
92 | svn_cmd propset svn:eol-style CR ne_crlf && | |
fd4ec4f2 | 93 | svn_cmd commit -m "propset CR on crlf files" |
18a82692 JN |
94 | ) |
95 | ' | |
36f5b1f0 | 96 | |
42d32870 | 97 | test_expect_success 'fetch and pull latest from svn and checkout a new wc' \ |
1364ff27 | 98 | 'git svn fetch && |
e1c0c158 | 99 | git pull . remotes/git-svn && |
da083d68 | 100 | svn_cmd co "$svnrepo" new_wc' |
36f5b1f0 | 101 | |
36f5b1f0 EW |
102 | for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf |
103 | do | |
104 | test_expect_success "Comparing $i" "cmp $i new_wc/$i" | |
105 | done | |
106 | ||
107 | ||
108 | cd test_wc | |
09bf1225 SK |
109 | printf '$Id$\rHello\rWorld\r' >cr |
110 | printf '$Id$\rHello\rWorld' >ne_cr | |
e10de5a0 EP |
111 | a_cr=$(printf '$Id$\r\nHello\r\nWorld\r\n' | git hash-object --stdin) |
112 | a_ne_cr=$(printf '$Id$\r\nHello\r\nWorld' | git hash-object --stdin) | |
42d32870 | 113 | test_expect_success 'Set CRLF on cr files' \ |
da083d68 ER |
114 | 'svn_cmd propset svn:eol-style CRLF cr && |
115 | svn_cmd propset svn:eol-style CRLF ne_cr && | |
116 | svn_cmd propset svn:keywords Id cr && | |
117 | svn_cmd propset svn:keywords Id ne_cr && | |
118 | svn_cmd commit -m "propset CRLF on cr files"' | |
36f5b1f0 | 119 | cd .. |
42d32870 | 120 | test_expect_success 'fetch and pull latest from svn' \ |
e1c0c158 | 121 | 'git svn fetch && git pull . remotes/git-svn' |
36f5b1f0 | 122 | |
e10de5a0 EP |
123 | b_cr="$(git hash-object cr)" |
124 | b_ne_cr="$(git hash-object ne_cr)" | |
36f5b1f0 EW |
125 | |
126 | test_expect_success 'CRLF + $Id$' "test '$a_cr' = '$b_cr'" | |
127 | test_expect_success 'CRLF + $Id$ (no newline)' "test '$a_ne_cr' = '$b_ne_cr'" | |
128 | ||
09bf1225 | 129 | cat >show-ignore.expect <<\EOF |
ad2f9085 EW |
130 | |
131 | # / | |
132 | /no-such-file* | |
133 | ||
d05ddec5 | 134 | # /deeply/ |
ad2f9085 EW |
135 | /deeply/no-such-file* |
136 | ||
d05ddec5 | 137 | # /deeply/nested/ |
ad2f9085 EW |
138 | /deeply/nested/no-such-file* |
139 | ||
d05ddec5 | 140 | # /deeply/nested/directory/ |
ad2f9085 EW |
141 | /deeply/nested/directory/no-such-file* |
142 | EOF | |
143 | ||
144 | test_expect_success 'test show-ignore' " | |
18a82692 JN |
145 | ( |
146 | cd test_wc && | |
147 | mkdir -p deeply/nested/directory && | |
148 | touch deeply/nested/directory/.keep && | |
149 | svn_cmd add deeply && | |
150 | svn_cmd up && | |
151 | svn_cmd propset -R svn:ignore ' | |
a7d72544 | 152 | no-such-file* |
cff4243d | 153 | ' . && |
18a82692 | 154 | svn_cmd commit -m 'propset svn:ignore' |
fd4ec4f2 | 155 | ) && |
09bf1225 | 156 | git svn show-ignore >show-ignore.got && |
ad2f9085 | 157 | cmp show-ignore.expect show-ignore.got |
18a82692 | 158 | " |
ad2f9085 | 159 | |
d05ddec5 BS |
160 | cat >create-ignore.expect <<\EOF |
161 | /no-such-file* | |
162 | EOF | |
163 | ||
3e04b6e1 | 164 | expectoid=$(git hash-object create-ignore.expect) |
165 | ||
166 | cat >create-ignore-index.expect <<EOF | |
167 | 100644 $expectoid 0 .gitignore | |
168 | 100644 $expectoid 0 deeply/.gitignore | |
169 | 100644 $expectoid 0 deeply/nested/.gitignore | |
170 | 100644 $expectoid 0 deeply/nested/directory/.gitignore | |
d05ddec5 BS |
171 | EOF |
172 | ||
173 | test_expect_success 'test create-ignore' " | |
e1c0c158 | 174 | git svn fetch && git pull . remotes/git-svn && |
1364ff27 | 175 | git svn create-ignore && |
d05ddec5 BS |
176 | cmp ./.gitignore create-ignore.expect && |
177 | cmp ./deeply/.gitignore create-ignore.expect && | |
178 | cmp ./deeply/nested/.gitignore create-ignore.expect && | |
179 | cmp ./deeply/nested/directory/.gitignore create-ignore.expect && | |
b00b6ace MD |
180 | git ls-files -s >ls_files_result && |
181 | grep gitignore ls_files_result | cmp - create-ignore-index.expect | |
d05ddec5 BS |
182 | " |
183 | ||
15153451 | 184 | cat >prop.expect <<\EOF |
a7d72544 | 185 | |
15153451 BS |
186 | no-such-file* |
187 | ||
188 | EOF | |
189 | cat >prop2.expect <<\EOF | |
190 | 8 | |
191 | EOF | |
192 | ||
193 | # This test can be improved: since all the svn:ignore contain the same | |
194 | # pattern, it can pass even though the propget did not execute on the | |
195 | # right directory. | |
b00b6ace MD |
196 | test_expect_success 'test propget' ' |
197 | test_propget () { | |
198 | git svn propget $1 $2 >actual && | |
199 | cmp $3 actual | |
200 | } && | |
201 | test_propget svn:ignore . prop.expect && | |
15153451 | 202 | cd deeply && |
b00b6ace MD |
203 | test_propget svn:ignore . ../prop.expect && |
204 | test_propget svn:entry:committed-rev nested/directory/.keep \ | |
205 | ../prop2.expect && | |
206 | test_propget svn:ignore .. ../prop.expect && | |
207 | test_propget svn:ignore nested/ ../prop.expect && | |
208 | test_propget svn:ignore ./nested ../prop.expect && | |
209 | test_propget svn:ignore .././deeply/nested ../prop.expect | |
210 | ' | |
15153451 | 211 | |
51e057cf BS |
212 | cat >prop.expect <<\EOF |
213 | Properties on '.': | |
214 | svn:entry:committed-date | |
215 | svn:entry:committed-rev | |
216 | svn:entry:last-author | |
217 | svn:entry:uuid | |
218 | svn:ignore | |
219 | EOF | |
220 | cat >prop2.expect <<\EOF | |
221 | Properties on 'nested/directory/.keep': | |
222 | svn:entry:committed-date | |
223 | svn:entry:committed-rev | |
224 | svn:entry:last-author | |
225 | svn:entry:uuid | |
226 | EOF | |
227 | ||
228 | test_expect_success 'test proplist' " | |
b00b6ace MD |
229 | git svn proplist . >actual && |
230 | cmp prop.expect actual && | |
231 | ||
232 | git svn proplist nested/directory/.keep >actual && | |
233 | cmp prop2.expect actual | |
51e057cf BS |
234 | " |
235 | ||
36f5b1f0 | 236 | test_done |