]>
Commit | Line | Data |
---|---|---|
36f5b1f0 EW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Eric Wong | |
4 | # | |
5 | ||
6 | test_description='git-svn property tests' | |
7 | . ./lib-git-svn.sh | |
8 | ||
9 | mkdir import | |
10 | ||
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= | |
21 | ||
22 | cd import | |
3c4c7351 | 23 | cat >> kw.c <<\EOF |
36f5b1f0 EW |
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 $ */ | |
3c4c7351 | 26 | EOF |
36f5b1f0 EW |
27 | |
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` | |
34 | ||
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` | |
41 | ||
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` | |
50 | ||
51 | svn import -m 'import for git-svn' . "$svnrepo" >/dev/null | |
52 | cd .. | |
53 | ||
54 | rm -rf import | |
55 | svn co "$svnrepo" test_wc | |
56 | ||
57 | cd test_wc | |
58 | echo 'Greetings' >> kw.c | |
59 | svn commit -m 'Not yet an $Id$' | |
60 | svn up | |
61 | ||
62 | echo 'Hello world' >> kw.c | |
63 | svn commit -m 'Modified file, but still not yet an $Id$' | |
64 | svn up | |
65 | ||
66 | svn propset svn:keywords Id kw.c | |
67 | svn commit -m 'Propset $Id$' | |
68 | svn up | |
69 | cd .. | |
70 | ||
71 | git-svn init "$svnrepo" | |
72 | git-svn fetch | |
73 | ||
74 | git checkout -b mybranch remotes/git-svn | |
75 | echo 'Hi again' >> kw.c | |
76 | name='test svn:keywords ignoring' | |
77 | ||
78 | git commit -a -m "$name" | |
79 | git-svn commit remotes/git-svn..mybranch | |
80 | git pull . remotes/git-svn | |
81 | ||
82 | expect='/* $Id$ */' | |
83 | got="`sed -ne 2p kw.c`" | |
84 | test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'" | |
85 | ||
86 | cd test_wc | |
87 | svn propset svn:eol-style CR empty | |
88 | svn propset svn:eol-style CR crlf | |
89 | svn propset svn:eol-style CR ne_crlf | |
90 | svn commit -m 'propset CR on crlf files' | |
91 | svn up | |
92 | cd .. | |
93 | ||
94 | git-svn fetch | |
95 | git pull . remotes/git-svn | |
96 | ||
97 | svn co "$svnrepo" new_wc | |
98 | for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf | |
99 | do | |
100 | test_expect_success "Comparing $i" "cmp $i new_wc/$i" | |
101 | done | |
102 | ||
103 | ||
104 | cd test_wc | |
105 | printf '$Id$\rHello\rWorld\r' > cr | |
106 | printf '$Id$\rHello\rWorld' > ne_cr | |
107 | a_cr=`printf '$Id$\r\nHello\r\nWorld\r\n' | git-hash-object --stdin` | |
108 | a_ne_cr=`printf '$Id$\r\nHello\r\nWorld' | git-hash-object --stdin` | |
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 | |
113 | svn commit -m 'propset CRLF on cr files' | |
114 | svn up | |
115 | cd .. | |
116 | ||
117 | git-svn fetch | |
118 | git pull . remotes/git-svn | |
119 | ||
120 | b_cr="`git-hash-object cr`" | |
121 | b_ne_cr="`git-hash-object ne_cr`" | |
122 | ||
123 | test_expect_success 'CRLF + $Id$' "test '$a_cr' = '$b_cr'" | |
124 | test_expect_success 'CRLF + $Id$ (no newline)' "test '$a_ne_cr' = '$b_ne_cr'" | |
125 | ||
126 | test_done |