]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9101-git-svn-props.sh
Merge branch 'wb/fsmonitor-bitmap-fix'
[thirdparty/git.git] / t / t9101-git-svn-props.sh
CommitLineData
36f5b1f0
EW
1#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
4#
5
1364ff27 6test_description='git svn property tests'
36f5b1f0
EW
7. ./lib-git-svn.sh
8
9mkdir import
10
11a_crlf=
12a_lf=
13a_cr=
14a_ne_crlf=
15a_ne_lf=
16a_ne_cr=
17a_empty=
18a_empty_lf=
19a_empty_cr=
20a_empty_crlf=
21
22cd import
3c4c7351 23 cat >> kw.c <<\EOF
dc62e25c
EW
24/* Somebody prematurely put a keyword into this file */
25/* $Id$ */
3c4c7351 26EOF
36f5b1f0
EW
27
28 printf "Hello\r\nWorld\r\n" > crlf
e10de5a0 29 a_crlf=$(git hash-object -w crlf)
36f5b1f0 30 printf "Hello\rWorld\r" > cr
e10de5a0 31 a_cr=$(git hash-object -w cr)
36f5b1f0 32 printf "Hello\nWorld\n" > lf
e10de5a0 33 a_lf=$(git hash-object -w lf)
36f5b1f0
EW
34
35 printf "Hello\r\nWorld" > ne_crlf
e10de5a0 36 a_ne_crlf=$(git hash-object -w ne_crlf)
36f5b1f0 37 printf "Hello\nWorld" > ne_lf
e10de5a0 38 a_ne_lf=$(git hash-object -w ne_lf)
36f5b1f0 39 printf "Hello\rWorld" > ne_cr
e10de5a0 40 a_ne_cr=$(git hash-object -w ne_cr)
36f5b1f0
EW
41
42 touch empty
e10de5a0 43 a_empty=$(git hash-object -w empty)
36f5b1f0 44 printf "\n" > empty_lf
e10de5a0 45 a_empty_lf=$(git hash-object -w empty_lf)
36f5b1f0 46 printf "\r" > empty_cr
e10de5a0 47 a_empty_cr=$(git hash-object -w empty_cr)
36f5b1f0 48 printf "\r\n" > empty_crlf
e10de5a0 49 a_empty_crlf=$(git hash-object -w empty_crlf)
36f5b1f0 50
da083d68 51 svn_cmd import --no-auto-props -m 'import for git svn' . "$svnrepo" >/dev/null
36f5b1f0
EW
52cd ..
53
54rm -rf import
f69e836f 55test_expect_success 'checkout working copy from svn' 'svn co "$svnrepo" test_wc'
18a82692
JN
56test_expect_success 'setup some commits to svn' '
57 (
58 cd test_wc &&
42d32870 59 echo Greetings >> kw.c &&
7b3fab87 60 poke kw.c &&
da083d68 61 svn_cmd commit -m "Not yet an Id" &&
42d32870 62 echo Hello world >> kw.c &&
7b3fab87 63 poke kw.c &&
da083d68
ER
64 svn_cmd commit -m "Modified file, but still not yet an Id" &&
65 svn_cmd propset svn:keywords Id kw.c &&
7b3fab87 66 poke kw.c &&
fd4ec4f2 67 svn_cmd commit -m "Propset Id"
18a82692
JN
68 )
69'
42d32870 70
f964732c 71test_expect_success 'initialize git svn' 'git svn init "$svnrepo"'
1364ff27 72test_expect_success 'fetch revisions from svn' 'git svn fetch'
36f5b1f0 73
36f5b1f0 74name='test svn:keywords ignoring'
42d32870 75test_expect_success "$name" \
e1c0c158 76 'git checkout -b mybranch remotes/git-svn &&
42d32870 77 echo Hi again >> kw.c &&
3dff5379 78 git commit -a -m "test keywords ignoring" &&
e1c0c158
JK
79 git svn set-tree remotes/git-svn..mybranch &&
80 git pull . remotes/git-svn'
36f5b1f0
EW
81
82expect='/* $Id$ */'
e10de5a0 83got="$(sed -ne 2p kw.c)"
36f5b1f0
EW
84test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'"
85
18a82692
JN
86test_expect_success "propset CR on crlf files" '
87 (
88 cd test_wc &&
da083d68
ER
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 &&
fd4ec4f2 92 svn_cmd commit -m "propset CR on crlf files"
18a82692
JN
93 )
94'
36f5b1f0 95
42d32870 96test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
1364ff27 97 'git svn fetch &&
e1c0c158 98 git pull . remotes/git-svn &&
da083d68 99 svn_cmd co "$svnrepo" new_wc'
36f5b1f0 100
36f5b1f0
EW
101for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf
102do
103 test_expect_success "Comparing $i" "cmp $i new_wc/$i"
104done
105
106
107cd test_wc
108 printf '$Id$\rHello\rWorld\r' > cr
109 printf '$Id$\rHello\rWorld' > ne_cr
e10de5a0
EP
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)
42d32870 112 test_expect_success 'Set CRLF on cr files' \
da083d68
ER
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"'
36f5b1f0 118cd ..
42d32870 119test_expect_success 'fetch and pull latest from svn' \
e1c0c158 120 'git svn fetch && git pull . remotes/git-svn'
36f5b1f0 121
e10de5a0
EP
122b_cr="$(git hash-object cr)"
123b_ne_cr="$(git hash-object ne_cr)"
36f5b1f0
EW
124
125test_expect_success 'CRLF + $Id$' "test '$a_cr' = '$b_cr'"
126test_expect_success 'CRLF + $Id$ (no newline)' "test '$a_ne_cr' = '$b_ne_cr'"
127
ad2f9085
EW
128cat > show-ignore.expect <<\EOF
129
130# /
131/no-such-file*
132
d05ddec5 133# /deeply/
ad2f9085
EW
134/deeply/no-such-file*
135
d05ddec5 136# /deeply/nested/
ad2f9085
EW
137/deeply/nested/no-such-file*
138
d05ddec5 139# /deeply/nested/directory/
ad2f9085
EW
140/deeply/nested/directory/no-such-file*
141EOF
142
143test_expect_success 'test show-ignore' "
18a82692
JN
144 (
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 '
a7d72544 151no-such-file*
cff4243d 152' . &&
18a82692 153 svn_cmd commit -m 'propset svn:ignore'
fd4ec4f2 154 ) &&
1364ff27 155 git svn show-ignore > show-ignore.got &&
ad2f9085 156 cmp show-ignore.expect show-ignore.got
18a82692 157"
ad2f9085 158
d05ddec5
BS
159cat >create-ignore.expect <<\EOF
160/no-such-file*
161EOF
162
163cat >create-ignore-index.expect <<\EOF
164100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 .gitignore
165100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/.gitignore
166100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/.gitignore
167100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/directory/.gitignore
168EOF
169
170test_expect_success 'test create-ignore' "
e1c0c158 171 git svn fetch && git pull . remotes/git-svn &&
1364ff27 172 git svn create-ignore &&
d05ddec5
BS
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 &&
b00b6ace
MD
177 git ls-files -s >ls_files_result &&
178 grep gitignore ls_files_result | cmp - create-ignore-index.expect
d05ddec5
BS
179 "
180
15153451 181cat >prop.expect <<\EOF
a7d72544 182
15153451
BS
183no-such-file*
184
185EOF
186cat >prop2.expect <<\EOF
1878
188EOF
189
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.
b00b6ace
MD
193test_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 &&
15153451 199 cd deeply &&
b00b6ace
MD
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
207 '
15153451 208
51e057cf
BS
209cat >prop.expect <<\EOF
210Properties on '.':
211 svn:entry:committed-date
212 svn:entry:committed-rev
213 svn:entry:last-author
214 svn:entry:uuid
215 svn:ignore
216EOF
217cat >prop2.expect <<\EOF
218Properties on 'nested/directory/.keep':
219 svn:entry:committed-date
220 svn:entry:committed-rev
221 svn:entry:last-author
222 svn:entry:uuid
223EOF
224
225test_expect_success 'test proplist' "
b00b6ace
MD
226 git svn proplist . >actual &&
227 cmp prop.expect actual &&
228
229 git svn proplist nested/directory/.keep >actual &&
230 cmp prop2.expect actual
51e057cf
BS
231 "
232
36f5b1f0 233test_done