blob: 1e31d6ea7253ee4216347fd707d1408f97af32fa [file] [log] [blame]
Eric Wong36f5b1f2006-05-23 19:23:41 -07001#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
4#
5
Nanako Shiraishi1364ff22008-09-08 19:02:08 +09006test_description='git svn property tests'
Eric Wong36f5b1f2006-05-23 19:23:41 -07007. ./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
Eric Wong3c4c7352006-05-29 19:03:45 -070023 cat >> kw.c <<\EOF
Eric Wongdc62e252006-06-28 03:07:14 -070024/* Somebody prematurely put a keyword into this file */
25/* $Id$ */
Eric Wong3c4c7352006-05-29 19:03:45 -070026EOF
Eric Wong36f5b1f2006-05-23 19:23:41 -070027
28 printf "Hello\r\nWorld\r\n" > crlf
Nanako Shiraishida06a802008-09-10 06:25:28 +090029 a_crlf=`git hash-object -w crlf`
Eric Wong36f5b1f2006-05-23 19:23:41 -070030 printf "Hello\rWorld\r" > cr
Nanako Shiraishida06a802008-09-10 06:25:28 +090031 a_cr=`git hash-object -w cr`
Eric Wong36f5b1f2006-05-23 19:23:41 -070032 printf "Hello\nWorld\n" > lf
Nanako Shiraishida06a802008-09-10 06:25:28 +090033 a_lf=`git hash-object -w lf`
Eric Wong36f5b1f2006-05-23 19:23:41 -070034
35 printf "Hello\r\nWorld" > ne_crlf
Nanako Shiraishida06a802008-09-10 06:25:28 +090036 a_ne_crlf=`git hash-object -w ne_crlf`
Eric Wong36f5b1f2006-05-23 19:23:41 -070037 printf "Hello\nWorld" > ne_lf
Nanako Shiraishida06a802008-09-10 06:25:28 +090038 a_ne_lf=`git hash-object -w ne_lf`
Eric Wong36f5b1f2006-05-23 19:23:41 -070039 printf "Hello\rWorld" > ne_cr
Nanako Shiraishida06a802008-09-10 06:25:28 +090040 a_ne_cr=`git hash-object -w ne_cr`
Eric Wong36f5b1f2006-05-23 19:23:41 -070041
42 touch empty
Nanako Shiraishida06a802008-09-10 06:25:28 +090043 a_empty=`git hash-object -w empty`
Eric Wong36f5b1f2006-05-23 19:23:41 -070044 printf "\n" > empty_lf
Nanako Shiraishida06a802008-09-10 06:25:28 +090045 a_empty_lf=`git hash-object -w empty_lf`
Eric Wong36f5b1f2006-05-23 19:23:41 -070046 printf "\r" > empty_cr
Nanako Shiraishida06a802008-09-10 06:25:28 +090047 a_empty_cr=`git hash-object -w empty_cr`
Eric Wong36f5b1f2006-05-23 19:23:41 -070048 printf "\r\n" > empty_crlf
Nanako Shiraishida06a802008-09-10 06:25:28 +090049 a_empty_crlf=`git hash-object -w empty_crlf`
Eric Wong36f5b1f2006-05-23 19:23:41 -070050
Nanako Shiraishif9647322008-09-10 06:25:27 +090051 svn import --no-auto-props -m 'import for git svn' . "$svnrepo" >/dev/null
Eric Wong36f5b1f2006-05-23 19:23:41 -070052cd ..
53
54rm -rf import
Bryan Donlanf69e8362008-05-04 01:37:59 -040055test_expect_success 'checkout working copy from svn' 'svn co "$svnrepo" test_wc'
Eric Wong42d32872006-06-13 04:02:23 -070056test_expect_success 'setup some commits to svn' \
57 'cd test_wc &&
58 echo Greetings >> kw.c &&
Michael Spang7b3fab82007-02-12 19:33:37 -050059 poke kw.c &&
Eric Wong42d32872006-06-13 04:02:23 -070060 svn commit -m "Not yet an Id" &&
Eric Wong42d32872006-06-13 04:02:23 -070061 echo Hello world >> kw.c &&
Michael Spang7b3fab82007-02-12 19:33:37 -050062 poke kw.c &&
Eric Wong42d32872006-06-13 04:02:23 -070063 svn commit -m "Modified file, but still not yet an Id" &&
Eric Wong42d32872006-06-13 04:02:23 -070064 svn propset svn:keywords Id kw.c &&
Michael Spang7b3fab82007-02-12 19:33:37 -050065 poke kw.c &&
66 svn commit -m "Propset Id" &&
Eric Wong42d32872006-06-13 04:02:23 -070067 cd ..'
Eric Wong36f5b1f2006-05-23 19:23:41 -070068
Nanako Shiraishif9647322008-09-10 06:25:27 +090069test_expect_success 'initialize git svn' 'git svn init "$svnrepo"'
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090070test_expect_success 'fetch revisions from svn' 'git svn fetch'
Eric Wong36f5b1f2006-05-23 19:23:41 -070071
Eric Wong36f5b1f2006-05-23 19:23:41 -070072name='test svn:keywords ignoring'
Eric Wong42d32872006-06-13 04:02:23 -070073test_expect_success "$name" \
Nanako Shiraishi16805d32008-09-08 19:02:05 +090074 'git checkout -b mybranch ${remotes_git_svn} &&
Eric Wong42d32872006-06-13 04:02:23 -070075 echo Hi again >> kw.c &&
Pavel Roskin3dff5372007-02-03 23:49:16 -050076 git commit -a -m "test keywords ignoring" &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090077 git svn set-tree ${remotes_git_svn}..mybranch &&
Nanako Shiraishi16805d32008-09-08 19:02:05 +090078 git pull . ${remotes_git_svn}'
Eric Wong36f5b1f2006-05-23 19:23:41 -070079
80expect='/* $Id$ */'
81got="`sed -ne 2p kw.c`"
82test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'"
83
Eric Wong42d32872006-06-13 04:02:23 -070084test_expect_success "propset CR on crlf files" \
85 'cd test_wc &&
86 svn propset svn:eol-style CR empty &&
87 svn propset svn:eol-style CR crlf &&
88 svn propset svn:eol-style CR ne_crlf &&
Michael Spang7b3fab82007-02-12 19:33:37 -050089 svn commit -m "propset CR on crlf files" &&
Eric Wong42d32872006-06-13 04:02:23 -070090 cd ..'
Eric Wong36f5b1f2006-05-23 19:23:41 -070091
Eric Wong42d32872006-06-13 04:02:23 -070092test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
Nanako Shiraishi1364ff22008-09-08 19:02:08 +090093 'git svn fetch &&
Nanako Shiraishi16805d32008-09-08 19:02:05 +090094 git pull . ${remotes_git_svn} &&
Bryan Donlanf69e8362008-05-04 01:37:59 -040095 svn co "$svnrepo" new_wc'
Eric Wong36f5b1f2006-05-23 19:23:41 -070096
Eric Wong36f5b1f2006-05-23 19:23:41 -070097for 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
Nanako Shiraishida06a802008-09-10 06:25:28 +0900106 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`
Eric Wong42d32872006-06-13 04:02:23 -0700108 test_expect_success 'Set CRLF on cr files' \
109 'svn propset svn:eol-style CRLF cr &&
110 svn propset svn:eol-style CRLF ne_cr &&
111 svn propset svn:keywords Id cr &&
112 svn propset svn:keywords Id ne_cr &&
Eric Wong43853552006-12-31 21:49:47 -0800113 svn commit -m "propset CRLF on cr files"'
Eric Wong36f5b1f2006-05-23 19:23:41 -0700114cd ..
Eric Wong42d32872006-06-13 04:02:23 -0700115test_expect_success 'fetch and pull latest from svn' \
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900116 'git svn fetch && git pull . ${remotes_git_svn}'
Eric Wong36f5b1f2006-05-23 19:23:41 -0700117
Nanako Shiraishida06a802008-09-10 06:25:28 +0900118b_cr="`git hash-object cr`"
119b_ne_cr="`git hash-object ne_cr`"
Eric Wong36f5b1f2006-05-23 19:23:41 -0700120
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
Eric Wongad2f9082007-01-11 17:55:50 -0800124cat > show-ignore.expect <<\EOF
125
126# /
127/no-such-file*
128
Benoit Sigoured05ddec2007-10-16 16:36:49 +0200129# /deeply/
Eric Wongad2f9082007-01-11 17:55:50 -0800130/deeply/no-such-file*
131
Benoit Sigoured05ddec2007-10-16 16:36:49 +0200132# /deeply/nested/
Eric Wongad2f9082007-01-11 17:55:50 -0800133/deeply/nested/no-such-file*
134
Benoit Sigoured05ddec2007-10-16 16:36:49 +0200135# /deeply/nested/directory/
Eric Wongad2f9082007-01-11 17:55:50 -0800136/deeply/nested/directory/no-such-file*
137EOF
138
139test_expect_success 'test show-ignore' "
140 cd test_wc &&
141 mkdir -p deeply/nested/directory &&
Benoit Sigoured05ddec2007-10-16 16:36:49 +0200142 touch deeply/nested/directory/.keep &&
Eric Wongad2f9082007-01-11 17:55:50 -0800143 svn add deeply &&
Sam Vilaind99c74e2007-09-21 14:02:34 +1200144 svn up &&
Eric Wongad2f9082007-01-11 17:55:50 -0800145 svn propset -R svn:ignore 'no-such-file*' .
146 svn commit -m 'propset svn:ignore'
147 cd .. &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900148 git svn show-ignore > show-ignore.got &&
Eric Wongad2f9082007-01-11 17:55:50 -0800149 cmp show-ignore.expect show-ignore.got
150 "
151
Benoit Sigoured05ddec2007-10-16 16:36:49 +0200152cat >create-ignore.expect <<\EOF
153/no-such-file*
154EOF
155
156cat >create-ignore-index.expect <<\EOF
157100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 .gitignore
158100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/.gitignore
159100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/.gitignore
160100644 8c52e5dfcd0a8b6b6bcfe6b41b89bcbf493718a5 0 deeply/nested/directory/.gitignore
161EOF
162
163test_expect_success 'test create-ignore' "
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900164 git svn fetch && git pull . ${remotes_git_svn} &&
165 git svn create-ignore &&
Benoit Sigoured05ddec2007-10-16 16:36:49 +0200166 cmp ./.gitignore create-ignore.expect &&
167 cmp ./deeply/.gitignore create-ignore.expect &&
168 cmp ./deeply/nested/.gitignore create-ignore.expect &&
169 cmp ./deeply/nested/directory/.gitignore create-ignore.expect &&
170 git ls-files -s | grep gitignore | cmp - create-ignore-index.expect
171 "
172
Benoit Sigoure15153452007-10-16 16:36:50 +0200173cat >prop.expect <<\EOF
174no-such-file*
175
176EOF
177cat >prop2.expect <<\EOF
1788
179EOF
180
181# This test can be improved: since all the svn:ignore contain the same
182# pattern, it can pass even though the propget did not execute on the
183# right directory.
184test_expect_success 'test propget' "
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900185 git svn propget svn:ignore . | cmp - prop.expect &&
Benoit Sigoure15153452007-10-16 16:36:50 +0200186 cd deeply &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900187 git svn propget svn:ignore . | cmp - ../prop.expect &&
188 git svn propget svn:entry:committed-rev nested/directory/.keep \
Benoit Sigoure15153452007-10-16 16:36:50 +0200189 | cmp - ../prop2.expect &&
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900190 git svn propget svn:ignore .. | cmp - ../prop.expect &&
191 git svn propget svn:ignore nested/ | cmp - ../prop.expect &&
192 git svn propget svn:ignore ./nested | cmp - ../prop.expect &&
193 git svn propget svn:ignore .././deeply/nested | cmp - ../prop.expect
Benoit Sigoure15153452007-10-16 16:36:50 +0200194 "
195
Benoit Sigoure51e057c2007-10-16 16:36:51 +0200196cat >prop.expect <<\EOF
197Properties on '.':
198 svn:entry:committed-date
199 svn:entry:committed-rev
200 svn:entry:last-author
201 svn:entry:uuid
202 svn:ignore
203EOF
204cat >prop2.expect <<\EOF
205Properties on 'nested/directory/.keep':
206 svn:entry:committed-date
207 svn:entry:committed-rev
208 svn:entry:last-author
209 svn:entry:uuid
210EOF
211
212test_expect_success 'test proplist' "
Nanako Shiraishi1364ff22008-09-08 19:02:08 +0900213 git svn proplist . | cmp - prop.expect &&
214 git svn proplist nested/directory/.keep | cmp - prop2.expect
Benoit Sigoure51e057c2007-10-16 16:36:51 +0200215 "
216
Eric Wong36f5b1f2006-05-23 19:23:41 -0700217test_done