git-svn: ignore expansion of svn:keywords
[git/jrn.git] / contrib / git-svn / t / t0001-contrib-git-svn-props.sh
blob6fa7889e9a691fd0bc0c68618f41045c322b25a3
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 <<''
24 /* Make it look like somebody copied a file from CVS into SVN: */
25 /* $Id: kw.c,v 1.1.1.1 1994/03/06 00:00:00 eric Exp $ */
27 printf "Hello\r\nWorld\r\n" > crlf
28 a_crlf=`git-hash-object -w crlf`
29 printf "Hello\rWorld\r" > cr
30 a_cr=`git-hash-object -w cr`
31 printf "Hello\nWorld\n" > lf
32 a_lf=`git-hash-object -w lf`
34 printf "Hello\r\nWorld" > ne_crlf
35 a_ne_crlf=`git-hash-object -w ne_crlf`
36 printf "Hello\nWorld" > ne_lf
37 a_ne_lf=`git-hash-object -w ne_lf`
38 printf "Hello\rWorld" > ne_cr
39 a_ne_cr=`git-hash-object -w ne_cr`
41 touch empty
42 a_empty=`git-hash-object -w empty`
43 printf "\n" > empty_lf
44 a_empty_lf=`git-hash-object -w empty_lf`
45 printf "\r" > empty_cr
46 a_empty_cr=`git-hash-object -w empty_cr`
47 printf "\r\n" > empty_crlf
48 a_empty_crlf=`git-hash-object -w empty_crlf`
50 svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
51 cd ..
53 rm -rf import
54 svn co "$svnrepo" test_wc
56 cd test_wc
57 echo 'Greetings' >> kw.c
58 svn commit -m 'Not yet an $Id$'
59 svn up
61 echo 'Hello world' >> kw.c
62 svn commit -m 'Modified file, but still not yet an $Id$'
63 svn up
65 svn propset svn:keywords Id kw.c
66 svn commit -m 'Propset $Id$'
67 svn up
68 cd ..
70 git-svn init "$svnrepo"
71 git-svn fetch
73 git checkout -b mybranch remotes/git-svn
74 echo 'Hi again' >> kw.c
75 name='test svn:keywords ignoring'
77 git commit -a -m "$name"
78 git-svn commit remotes/git-svn..mybranch
79 git pull . remotes/git-svn
81 expect='/* $Id$ */'
82 got="`sed -ne 2p kw.c`"
83 test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'"
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
89 svn commit -m 'propset CR on crlf files'
90 svn up
91 cd ..
93 git-svn fetch
94 git pull . remotes/git-svn
96 svn 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 svn propset svn:eol-style CRLF cr
109 svn propset svn:eol-style CRLF ne_cr
110 svn propset svn:keywords Id cr
111 svn propset svn:keywords Id ne_cr
112 svn commit -m 'propset CRLF on cr files'
113 svn up
114 cd ..
116 git-svn fetch
117 git pull . remotes/git-svn
119 b_cr="`git-hash-object cr`"
120 b_ne_cr="`git-hash-object ne_cr`"
122 test_expect_success 'CRLF + $Id$' "test '$a_cr' = '$b_cr'"
123 test_expect_success 'CRLF + $Id$ (no newline)' "test '$a_ne_cr' = '$b_ne_cr'"
125 test_done