Merge branch 'mg/status-b'
[git/dscho.git] / t / t9101-git-svn-props.sh
blob929499e996bc33d96ebab0b01ebcac8240e689b7
1 #!/bin/sh
3 # Copyright (c) 2006 Eric Wong
6 test_description='git svn property tests'
7 . ./lib-git-svn.sh
9 mkdir import
11 a_crlf=
12 a_lf=
13 a_cr=
14 a_ne_crlf=
15 a_ne_lf=
16 a_ne_cr=
17 a_empty=
18 a_empty_lf=
19 a_empty_cr=
20 a_empty_crlf=
22 cd import
23 cat >> kw.c <<\EOF
24 /* Somebody prematurely put a keyword into this file */
25 /* $Id$ */
26 EOF
28 printf "Hello\r\nWorld\r\n" > crlf
29 a_crlf=`git hash-object -w crlf`
30 printf "Hello\rWorld\r" > cr
31 a_cr=`git hash-object -w cr`
32 printf "Hello\nWorld\n" > lf
33 a_lf=`git hash-object -w lf`
35 printf "Hello\r\nWorld" > ne_crlf
36 a_ne_crlf=`git hash-object -w ne_crlf`
37 printf "Hello\nWorld" > ne_lf
38 a_ne_lf=`git hash-object -w ne_lf`
39 printf "Hello\rWorld" > ne_cr
40 a_ne_cr=`git hash-object -w ne_cr`
42 touch empty
43 a_empty=`git hash-object -w empty`
44 printf "\n" > empty_lf
45 a_empty_lf=`git hash-object -w empty_lf`
46 printf "\r" > empty_cr
47 a_empty_cr=`git hash-object -w empty_cr`
48 printf "\r\n" > empty_crlf
49 a_empty_crlf=`git hash-object -w empty_crlf`
51 svn_cmd import --no-auto-props -m 'import for git svn' . "$svnrepo" >/dev/null
52 cd ..
54 rm -rf import
55 test_expect_success 'checkout working copy from svn' 'svn co "$svnrepo" test_wc'
56 test_expect_success 'setup some commits to svn' \
57 'cd test_wc &&
58 echo Greetings >> kw.c &&
59 poke kw.c &&
60 svn_cmd commit -m "Not yet an Id" &&
61 echo Hello world >> kw.c &&
62 poke kw.c &&
63 svn_cmd commit -m "Modified file, but still not yet an Id" &&
64 svn_cmd propset svn:keywords Id kw.c &&
65 poke kw.c &&
66 svn_cmd commit -m "Propset Id" &&
67 cd ..'
69 test_expect_success 'initialize git svn' 'git svn init "$svnrepo"'
70 test_expect_success 'fetch revisions from svn' 'git svn fetch'
72 name='test svn:keywords ignoring'
73 test_expect_success "$name" \
74 'git checkout -b mybranch ${remotes_git_svn} &&
75 echo Hi again >> kw.c &&
76 git commit -a -m "test keywords ignoring" &&
77 git svn set-tree ${remotes_git_svn}..mybranch &&
78 git pull . ${remotes_git_svn}'
80 expect='/* $Id$ */'
81 got="`sed -ne 2p kw.c`"
82 test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'"
84 test_expect_success "propset CR on crlf files" \
85 'cd test_wc &&
86 svn_cmd propset svn:eol-style CR empty &&
87 svn_cmd propset svn:eol-style CR crlf &&
88 svn_cmd propset svn:eol-style CR ne_crlf &&
89 svn_cmd commit -m "propset CR on crlf files" &&
90 cd ..'
92 test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
93 'git svn fetch &&
94 git pull . ${remotes_git_svn} &&
95 svn_cmd co "$svnrepo" new_wc'
97 for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf
99 test_expect_success "Comparing $i" "cmp $i new_wc/$i"
100 done
103 cd test_wc
104 printf '$Id$\rHello\rWorld\r' > cr
105 printf '$Id$\rHello\rWorld' > ne_cr
106 a_cr=`printf '$Id$\r\nHello\r\nWorld\r\n' | git hash-object --stdin`
107 a_ne_cr=`printf '$Id$\r\nHello\r\nWorld' | git hash-object --stdin`
108 test_expect_success 'Set CRLF on cr files' \
109 'svn_cmd propset svn:eol-style CRLF cr &&
110 svn_cmd propset svn:eol-style CRLF ne_cr &&
111 svn_cmd propset svn:keywords Id cr &&
112 svn_cmd propset svn:keywords Id ne_cr &&
113 svn_cmd commit -m "propset CRLF on cr files"'
114 cd ..
115 test_expect_success 'fetch and pull latest from svn' \
116 'git svn fetch && git pull . ${remotes_git_svn}'
118 b_cr="`git hash-object cr`"
119 b_ne_cr="`git hash-object ne_cr`"
121 test_expect_success 'CRLF + $Id$' "test '$a_cr' = '$b_cr'"
122 test_expect_success 'CRLF + $Id$ (no newline)' "test '$a_ne_cr' = '$b_ne_cr'"
124 cat > show-ignore.expect <<\EOF
127 /no-such-file*
129 # /deeply/
130 /deeply/no-such-file*
132 # /deeply/nested/
133 /deeply/nested/no-such-file*
135 # /deeply/nested/directory/
136 /deeply/nested/directory/no-such-file*
139 test_expect_success 'test show-ignore' "
140 cd test_wc &&
141 mkdir -p deeply/nested/directory &&
142 touch deeply/nested/directory/.keep &&
143 svn_cmd add deeply &&
144 svn_cmd up &&
145 svn_cmd propset -R svn:ignore '
146 no-such-file*
148 svn_cmd commit -m 'propset svn:ignore'
149 cd .. &&
150 git svn show-ignore > show-ignore.got &&
151 cmp show-ignore.expect show-ignore.got
154 cat >create-ignore.expect <<\EOF
155 /no-such-file*
158 cat >create-ignore-index.expect <<\EOF
159 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 .gitignore
160 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/.gitignore
161 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/.gitignore
162 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/directory/.gitignore
165 test_expect_success 'test create-ignore' "
166 git svn fetch && git pull . ${remotes_git_svn} &&
167 git svn create-ignore &&
168 cmp ./.gitignore create-ignore.expect &&
169 cmp ./deeply/.gitignore create-ignore.expect &&
170 cmp ./deeply/nested/.gitignore create-ignore.expect &&
171 cmp ./deeply/nested/directory/.gitignore create-ignore.expect &&
172 git ls-files -s | grep gitignore | cmp - create-ignore-index.expect
175 cat >prop.expect <<\EOF
177 no-such-file*
180 cat >prop2.expect <<\EOF
184 # This test can be improved: since all the svn:ignore contain the same
185 # pattern, it can pass even though the propget did not execute on the
186 # right directory.
187 test_expect_success 'test propget' "
188 git svn propget svn:ignore . | cmp - prop.expect &&
189 cd deeply &&
190 git svn propget svn:ignore . | cmp - ../prop.expect &&
191 git svn propget svn:entry:committed-rev nested/directory/.keep \
192 | cmp - ../prop2.expect &&
193 git svn propget svn:ignore .. | cmp - ../prop.expect &&
194 git svn propget svn:ignore nested/ | cmp - ../prop.expect &&
195 git svn propget svn:ignore ./nested | cmp - ../prop.expect &&
196 git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect
199 cat >prop.expect <<\EOF
200 Properties on '.':
201 svn:entry:committed-date
202 svn:entry:committed-rev
203 svn:entry:last-author
204 svn:entry:uuid
205 svn:ignore
207 cat >prop2.expect <<\EOF
208 Properties on 'nested/directory/.keep':
209 svn:entry:committed-date
210 svn:entry:committed-rev
211 svn:entry:last-author
212 svn:entry:uuid
215 test_expect_success 'test proplist' "
216 git svn proplist . | cmp - prop.expect &&
217 git svn proplist nested/directory/.keep | cmp - prop2.expect
220 test_done