midx: honor the MIDX_PROGRESS flag in verify_midx_file
[git.git] / t / t9101-git-svn-props.sh
blobc26c4b0927916fca6902eb54600a13aee5e7dea9
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' '
58 cd test_wc &&
59 echo Greetings >> kw.c &&
60 poke kw.c &&
61 svn_cmd commit -m "Not yet an Id" &&
62 echo Hello world >> kw.c &&
63 poke kw.c &&
64 svn_cmd commit -m "Modified file, but still not yet an Id" &&
65 svn_cmd propset svn:keywords Id kw.c &&
66 poke kw.c &&
67 svn_cmd commit -m "Propset Id"
71 test_expect_success 'initialize git svn' 'git svn init "$svnrepo"'
72 test_expect_success 'fetch revisions from svn' 'git svn fetch'
74 name='test svn:keywords ignoring'
75 test_expect_success "$name" \
76 'git checkout -b mybranch remotes/git-svn &&
77 echo Hi again >> kw.c &&
78 git commit -a -m "test keywords ignoring" &&
79 git svn set-tree remotes/git-svn..mybranch &&
80 git pull . remotes/git-svn'
82 expect='/* $Id$ */'
83 got="$(sed -ne 2p kw.c)"
84 test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'"
86 test_expect_success "propset CR on crlf files" '
88 cd test_wc &&
89 svn_cmd propset svn:eol-style CR empty &&
90 svn_cmd propset svn:eol-style CR crlf &&
91 svn_cmd propset svn:eol-style CR ne_crlf &&
92 svn_cmd commit -m "propset CR on crlf files"
96 test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
97 'git svn fetch &&
98 git pull . remotes/git-svn &&
99 svn_cmd co "$svnrepo" new_wc'
101 for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf
103 test_expect_success "Comparing $i" "cmp $i new_wc/$i"
104 done
107 cd test_wc
108 printf '$Id$\rHello\rWorld\r' > cr
109 printf '$Id$\rHello\rWorld' > ne_cr
110 a_cr=$(printf '$Id$\r\nHello\r\nWorld\r\n' | git hash-object --stdin)
111 a_ne_cr=$(printf '$Id$\r\nHello\r\nWorld' | git hash-object --stdin)
112 test_expect_success 'Set CRLF on cr files' \
113 'svn_cmd propset svn:eol-style CRLF cr &&
114 svn_cmd propset svn:eol-style CRLF ne_cr &&
115 svn_cmd propset svn:keywords Id cr &&
116 svn_cmd propset svn:keywords Id ne_cr &&
117 svn_cmd commit -m "propset CRLF on cr files"'
118 cd ..
119 test_expect_success 'fetch and pull latest from svn' \
120 'git svn fetch && git pull . remotes/git-svn'
122 b_cr="$(git hash-object cr)"
123 b_ne_cr="$(git hash-object ne_cr)"
125 test_expect_success 'CRLF + $Id$' "test '$a_cr' = '$b_cr'"
126 test_expect_success 'CRLF + $Id$ (no newline)' "test '$a_ne_cr' = '$b_ne_cr'"
128 cat > show-ignore.expect <<\EOF
131 /no-such-file*
133 # /deeply/
134 /deeply/no-such-file*
136 # /deeply/nested/
137 /deeply/nested/no-such-file*
139 # /deeply/nested/directory/
140 /deeply/nested/directory/no-such-file*
143 test_expect_success 'test show-ignore' "
145 cd test_wc &&
146 mkdir -p deeply/nested/directory &&
147 touch deeply/nested/directory/.keep &&
148 svn_cmd add deeply &&
149 svn_cmd up &&
150 svn_cmd propset -R svn:ignore '
151 no-such-file*
152 ' . &&
153 svn_cmd commit -m 'propset svn:ignore'
154 ) &&
155 git svn show-ignore > show-ignore.got &&
156 cmp show-ignore.expect show-ignore.got
159 cat >create-ignore.expect <<\EOF
160 /no-such-file*
163 cat >create-ignore-index.expect <<\EOF
164 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 .gitignore
165 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/.gitignore
166 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/.gitignore
167 100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/directory/.gitignore
170 test_expect_success 'test create-ignore' "
171 git svn fetch && git pull . remotes/git-svn &&
172 git svn create-ignore &&
173 cmp ./.gitignore create-ignore.expect &&
174 cmp ./deeply/.gitignore create-ignore.expect &&
175 cmp ./deeply/nested/.gitignore create-ignore.expect &&
176 cmp ./deeply/nested/directory/.gitignore create-ignore.expect &&
177 git ls-files -s >ls_files_result &&
178 grep gitignore ls_files_result | cmp - create-ignore-index.expect
181 cat >prop.expect <<\EOF
183 no-such-file*
186 cat >prop2.expect <<\EOF
190 # This test can be improved: since all the svn:ignore contain the same
191 # pattern, it can pass even though the propget did not execute on the
192 # right directory.
193 test_expect_success 'test propget' '
194 test_propget () {
195 git svn propget $1 $2 >actual &&
196 cmp $3 actual
197 } &&
198 test_propget svn:ignore . prop.expect &&
199 cd deeply &&
200 test_propget svn:ignore . ../prop.expect &&
201 test_propget svn:entry:committed-rev nested/directory/.keep \
202 ../prop2.expect &&
203 test_propget svn:ignore .. ../prop.expect &&
204 test_propget svn:ignore nested/ ../prop.expect &&
205 test_propget svn:ignore ./nested ../prop.expect &&
206 test_propget svn:ignore .././deeply/nested ../prop.expect
209 cat >prop.expect <<\EOF
210 Properties on '.':
211 svn:entry:committed-date
212 svn:entry:committed-rev
213 svn:entry:last-author
214 svn:entry:uuid
215 svn:ignore
217 cat >prop2.expect <<\EOF
218 Properties on 'nested/directory/.keep':
219 svn:entry:committed-date
220 svn:entry:committed-rev
221 svn:entry:last-author
222 svn:entry:uuid
225 test_expect_success 'test proplist' "
226 git svn proplist . >actual &&
227 cmp prop.expect actual &&
229 git svn proplist nested/directory/.keep >actual &&
230 cmp prop2.expect actual
233 test_done