Merge branch 'xx/trivial' into maint
[git/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
da06a803 29 a_crlf=`git hash-object -w crlf`
36f5b1f0 30 printf "Hello\rWorld\r" > cr
da06a803 31 a_cr=`git hash-object -w cr`
36f5b1f0 32 printf "Hello\nWorld\n" > lf
da06a803 33 a_lf=`git hash-object -w lf`
36f5b1f0
EW
34
35 printf "Hello\r\nWorld" > ne_crlf
da06a803 36 a_ne_crlf=`git hash-object -w ne_crlf`
36f5b1f0 37 printf "Hello\nWorld" > ne_lf
da06a803 38 a_ne_lf=`git hash-object -w ne_lf`
36f5b1f0 39 printf "Hello\rWorld" > ne_cr
da06a803 40 a_ne_cr=`git hash-object -w ne_cr`
36f5b1f0
EW
41
42 touch empty
da06a803 43 a_empty=`git hash-object -w empty`
36f5b1f0 44 printf "\n" > empty_lf
da06a803 45 a_empty_lf=`git hash-object -w empty_lf`
36f5b1f0 46 printf "\r" > empty_cr
da06a803 47 a_empty_cr=`git hash-object -w empty_cr`
36f5b1f0 48 printf "\r\n" > empty_crlf
da06a803 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'
42d32870
EW
56test_expect_success 'setup some commits to svn' \
57 'cd test_wc &&
58 echo Greetings >> kw.c &&
7b3fab87 59 poke kw.c &&
da083d68 60 svn_cmd commit -m "Not yet an Id" &&
42d32870 61 echo Hello world >> kw.c &&
7b3fab87 62 poke kw.c &&
da083d68
ER
63 svn_cmd commit -m "Modified file, but still not yet an Id" &&
64 svn_cmd propset svn:keywords Id kw.c &&
7b3fab87 65 poke kw.c &&
da083d68 66 svn_cmd commit -m "Propset Id" &&
42d32870
EW
67 cd ..'
68
f964732c 69test_expect_success 'initialize git svn' 'git svn init "$svnrepo"'
1364ff27 70test_expect_success 'fetch revisions from svn' 'git svn fetch'
36f5b1f0 71
36f5b1f0 72name='test svn:keywords ignoring'
42d32870 73test_expect_success "$name" \
16805d3e 74 'git checkout -b mybranch ${remotes_git_svn} &&
42d32870 75 echo Hi again >> kw.c &&
3dff5379 76 git commit -a -m "test keywords ignoring" &&
1364ff27 77 git svn set-tree ${remotes_git_svn}..mybranch &&
16805d3e 78 git pull . ${remotes_git_svn}'
36f5b1f0
EW
79
80expect='/* $Id$ */'
81got="`sed -ne 2p kw.c`"
82test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'"
83
42d32870
EW
84test_expect_success "propset CR on crlf files" \
85 'cd test_wc &&
da083d68
ER
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" &&
42d32870 90 cd ..'
36f5b1f0 91
42d32870 92test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
1364ff27 93 'git svn fetch &&
16805d3e 94 git pull . ${remotes_git_svn} &&
da083d68 95 svn_cmd co "$svnrepo" new_wc'
36f5b1f0 96
36f5b1f0
EW
97for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf
98do
99 test_expect_success "Comparing $i" "cmp $i new_wc/$i"
100done
101
102
103cd test_wc
104 printf '$Id$\rHello\rWorld\r' > cr
105 printf '$Id$\rHello\rWorld' > ne_cr
da06a803
NS
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`
42d32870 108 test_expect_success 'Set CRLF on cr files' \
da083d68
ER
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"'
36f5b1f0 114cd ..
42d32870 115test_expect_success 'fetch and pull latest from svn' \
1364ff27 116 'git svn fetch && git pull . ${remotes_git_svn}'
36f5b1f0 117
da06a803
NS
118b_cr="`git hash-object cr`"
119b_ne_cr="`git hash-object ne_cr`"
36f5b1f0
EW
120
121test_expect_success 'CRLF + $Id$' "test '$a_cr' = '$b_cr'"
122test_expect_success 'CRLF + $Id$ (no newline)' "test '$a_ne_cr' = '$b_ne_cr'"
123
ad2f9085
EW
124cat > show-ignore.expect <<\EOF
125
126# /
127/no-such-file*
128
d05ddec5 129# /deeply/
ad2f9085
EW
130/deeply/no-such-file*
131
d05ddec5 132# /deeply/nested/
ad2f9085
EW
133/deeply/nested/no-such-file*
134
d05ddec5 135# /deeply/nested/directory/
ad2f9085
EW
136/deeply/nested/directory/no-such-file*
137EOF
138
139test_expect_success 'test show-ignore' "
140 cd test_wc &&
141 mkdir -p deeply/nested/directory &&
d05ddec5 142 touch deeply/nested/directory/.keep &&
da083d68
ER
143 svn_cmd add deeply &&
144 svn_cmd up &&
a7d72544
MH
145 svn_cmd propset -R svn:ignore '
146no-such-file*
147' .
da083d68 148 svn_cmd commit -m 'propset svn:ignore'
ad2f9085 149 cd .. &&
1364ff27 150 git svn show-ignore > show-ignore.got &&
ad2f9085
EW
151 cmp show-ignore.expect show-ignore.got
152 "
153
d05ddec5
BS
154cat >create-ignore.expect <<\EOF
155/no-such-file*
156EOF
157
158cat >create-ignore-index.expect <<\EOF
159100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 .gitignore
160100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/.gitignore
161100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/.gitignore
162100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/directory/.gitignore
163EOF
164
165test_expect_success 'test create-ignore' "
1364ff27
NS
166 git svn fetch && git pull . ${remotes_git_svn} &&
167 git svn create-ignore &&
d05ddec5
BS
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
173 "
174
15153451 175cat >prop.expect <<\EOF
a7d72544 176
15153451
BS
177no-such-file*
178
179EOF
180cat >prop2.expect <<\EOF
1818
182EOF
183
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.
187test_expect_success 'test propget' "
1364ff27 188 git svn propget svn:ignore . | cmp - prop.expect &&
15153451 189 cd deeply &&
1364ff27
NS
190 git svn propget svn:ignore . | cmp - ../prop.expect &&
191 git svn propget svn:entry:committed-rev nested/directory/.keep \
15153451 192 | cmp - ../prop2.expect &&
1364ff27
NS
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
15153451
BS
197 "
198
51e057cf
BS
199cat >prop.expect <<\EOF
200Properties on '.':
201 svn:entry:committed-date
202 svn:entry:committed-rev
203 svn:entry:last-author
204 svn:entry:uuid
205 svn:ignore
206EOF
207cat >prop2.expect <<\EOF
208Properties on 'nested/directory/.keep':
209 svn:entry:committed-date
210 svn:entry:committed-rev
211 svn:entry:last-author
212 svn:entry:uuid
213EOF
214
215test_expect_success 'test proplist' "
1364ff27
NS
216 git svn proplist . | cmp - prop.expect &&
217 git svn proplist nested/directory/.keep | cmp - prop2.expect
51e057cf
BS
218 "
219
36f5b1f0 220test_done