3 # Copyright (c) 2006 Eric Wong
8 test_description='git-svn tests'
13 echo "Must be run in contrib/git-svn/t" >&2
20 GIT_SVN_DIR=$GIT_DIR/git-svn
21 SVN_TREE=$GIT_SVN_DIR/tree
23 svnadmin >/dev/null 2>&1
26 test_expect_success 'skipping contrib/git-svn test' :
34 test_expect_success 'skipping contrib/git-svn test' :
43 svnadmin create $svnrepo
44 svnrepo="file://$svnrepo/test-git-svn"
52 mkdir -p dir/a/b/c/d/e
53 echo 'deep dir' > dir/a/b/c/d/e/file
56 echo '#!/bin/sh' > exec.sh
58 svn import -m 'import for git-svn' . $svnrepo >/dev/null
65 'initialize git-svn' \
66 "git-svn init $svnrepo"
69 'import an SVN revision into git' \
73 name='try a deep --rmdir with a commit'
74 git checkout -b mybranch git-svn-HEAD
75 mv dir/a/b/c/d/e/file dir/file
77 git update-index --add --remove dir/a/b/c/d/e/file dir/file file
80 test_expect_success "$name" \
81 "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch &&
82 test -d $SVN_TREE/dir && test ! -d $SVN_TREE/dir/a"
85 name='detect node change from file to directory #1'
87 mv dir/file dir/new_file/file
88 mv dir/new_file dir/file
89 git update-index --remove dir/file
90 git update-index --add dir/file/file
93 test_expect_code 1 "$name" \
94 'git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch' \
98 name='detect node change from directory to file #1'
99 rm -rf dir $GIT_DIR/index
100 git checkout -b mybranch2 git-svn-HEAD
104 git update-index --remove -- bar/zzz
105 git update-index --add -- bar
106 git commit -m "$name"
108 test_expect_code 1 "$name" \
109 'git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch2' \
113 name='detect node change from file to directory #2'
115 git checkout -b mybranch3 git-svn-HEAD
117 git-update-index --remove bar/zzz
119 echo yyy > bar/zzz/yyy
120 git-update-index --add bar/zzz/yyy
121 git commit -m "$name"
123 test_expect_code 1 "$name" \
124 'git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch3' \
128 name='detect node change from directory to file #2'
130 git checkout -b mybranch4 git-svn-HEAD
132 git update-index --remove -- dir/file
135 git update-index --add -- dir
136 git commit -m "$name"
138 test_expect_code 1 "$name" \
139 'git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch4' \
143 name='remove executable bit from a file'
145 git checkout -b mybranch5 git-svn-HEAD
147 git update-index exec.sh
148 git commit -m "$name"
150 test_expect_success "$name" \
151 "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch5 &&
152 test ! -x $SVN_TREE/exec.sh"
155 name='add executable bit back file'
157 git update-index exec.sh
158 git commit -m "$name"
160 test_expect_success "$name" \
161 "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch5 &&
162 test -x $SVN_TREE/exec.sh"
166 name='executable file becomes a symlink to bar/zzz (file)'
168 ln -s bar/zzz exec.sh
169 git update-index exec.sh
170 git commit -m "$name"
172 test_expect_success "$name" \
173 "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch5 &&
174 test -L $SVN_TREE/exec.sh"
178 name='new symlink is added to a file that was also just made executable'
180 ln -s bar/zzz exec-2.sh
181 git update-index --add bar/zzz exec-2.sh
182 git commit -m "$name"
184 test_expect_success "$name" \
185 "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch5 &&
186 test -x $SVN_TREE/bar/zzz &&
187 test -L $SVN_TREE/exec-2.sh"
191 name='modify a symlink to become a file'
192 git help > help || true
195 git update-index exec-2.sh
196 git commit -m "$name"
198 test_expect_success "$name" \
199 "git-svn commit --find-copies-harder --rmdir git-svn-HEAD..mybranch5 &&
200 test -f $SVN_TREE/exec-2.sh &&
201 test ! -L $SVN_TREE/exec-2.sh &&
202 diff -u help $SVN_TREE/exec-2.sh"
206 name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
209 test_expect_success "$name" \
210 "git-svn init $svnrepo && git-svn fetch -v &&
211 git-rev-list --pretty=raw git-svn-HEAD | grep ^tree | uniq > a &&
212 git-rev-list --pretty=raw alt-HEAD | grep ^tree | uniq > b &&