]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9101-git-svn-props.sh
git-svn: implement git svn create-ignore
[thirdparty/git.git] / t / t9101-git-svn-props.sh
CommitLineData
36f5b1f0
EW
1#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
4#
5
6test_description='git-svn property tests'
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
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
52cd ..
53
54rm -rf import
42d32870
EW
55test_expect_success 'checkout working copy from svn' "svn co $svnrepo test_wc"
56test_expect_success 'setup some commits to svn' \
57 'cd test_wc &&
58 echo Greetings >> kw.c &&
7b3fab87 59 poke kw.c &&
42d32870 60 svn commit -m "Not yet an Id" &&
42d32870 61 echo Hello world >> kw.c &&
7b3fab87 62 poke kw.c &&
42d32870 63 svn commit -m "Modified file, but still not yet an Id" &&
42d32870 64 svn propset svn:keywords Id kw.c &&
7b3fab87
MS
65 poke kw.c &&
66 svn commit -m "Propset Id" &&
42d32870
EW
67 cd ..'
68
69test_expect_success 'initialize git-svn' "git-svn init $svnrepo"
70test_expect_success 'fetch revisions from svn' 'git-svn fetch'
36f5b1f0 71
36f5b1f0 72name='test svn:keywords ignoring'
42d32870
EW
73test_expect_success "$name" \
74 'git checkout -b mybranch remotes/git-svn &&
75 echo Hi again >> kw.c &&
3dff5379 76 git commit -a -m "test keywords ignoring" &&
3289e86e 77 git-svn set-tree remotes/git-svn..mybranch &&
42d32870 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 &&
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 &&
7b3fab87 89 svn commit -m "propset CR on crlf files" &&
42d32870 90 cd ..'
36f5b1f0 91
42d32870
EW
92test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
93 "git-svn fetch &&
94 git pull . remotes/git-svn &&
95 svn 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
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
EW
108 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 &&
43853554 113 svn commit -m "propset CRLF on cr files"'
36f5b1f0 114cd ..
42d32870
EW
115test_expect_success 'fetch and pull latest from svn' \
116 'git-svn fetch && git pull . remotes/git-svn'
36f5b1f0
EW
117
118b_cr="`git-hash-object cr`"
119b_ne_cr="`git-hash-object ne_cr`"
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 &&
ad2f9085 143 svn add deeply &&
d99c74e2 144 svn up &&
ad2f9085
EW
145 svn propset -R svn:ignore 'no-such-file*' .
146 svn commit -m 'propset svn:ignore'
147 cd .. &&
148 git-svn show-ignore > show-ignore.got &&
149 cmp show-ignore.expect show-ignore.got
150 "
151
d05ddec5
BS
152cat >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' "
164 git-svn fetch && git pull . remotes/git-svn &&
165 git-svn create-ignore &&
166 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
36f5b1f0 173test_done