3 # Copyright (c) 2006 Eric Wong
6 test_description='git-svn tests'
14 mkdir -p dir/a/b/c/d/e
15 echo 'deep dir' > dir/a/b/c/d/e/file
18 echo '#!/bin/sh' > exec.sh
20 svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
26 'initialize git-svn' \
27 "git-svn init $svnrepo"
30 'import an SVN revision into git' \
34 name='try a deep --rmdir with a commit'
35 git checkout -b mybranch remotes/git-svn
36 mv dir/a/b/c/d/e/file dir/file
38 git update-index --add --remove dir/a/b/c/d/e/file dir/file file
41 test_expect_success "$name" \
42 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch &&
43 test -d $SVN_TREE/dir && test ! -d $SVN_TREE/dir/a"
46 name='detect node change from file to directory #1'
48 mv dir/file dir/new_file/file
49 mv dir/new_file dir/file
50 git update-index --remove dir/file
51 git update-index --add dir/file/file
54 test_expect_code 1 "$name" \
55 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch' \
59 name='detect node change from directory to file #1'
60 rm -rf dir $GIT_DIR/index
61 git checkout -b mybranch2 remotes/git-svn
65 git update-index --remove -- bar/zzz
66 git update-index --add -- bar
69 test_expect_code 1 "$name" \
70 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch2' \
74 name='detect node change from file to directory #2'
76 git checkout -b mybranch3 remotes/git-svn
78 git-update-index --remove bar/zzz
80 echo yyy > bar/zzz/yyy
81 git-update-index --add bar/zzz/yyy
84 test_expect_code 1 "$name" \
85 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch3' \
89 name='detect node change from directory to file #2'
91 git checkout -b mybranch4 remotes/git-svn
93 git update-index --remove -- dir/file
96 git update-index --add -- dir
99 test_expect_code 1 "$name" \
100 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch4' \
104 name='remove executable bit from a file'
106 git checkout -b mybranch5 remotes/git-svn
108 git update-index exec.sh
109 git commit -m "$name"
111 test_expect_success "$name" \
112 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
113 test ! -x $SVN_TREE/exec.sh"
116 name='add executable bit back file'
118 git update-index exec.sh
119 git commit -m "$name"
121 test_expect_success "$name" \
122 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
123 test -x $SVN_TREE/exec.sh"
127 name='executable file becomes a symlink to bar/zzz (file)'
129 ln -s bar/zzz exec.sh
130 git update-index exec.sh
131 git commit -m "$name"
133 test_expect_success "$name" \
134 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
135 test -L $SVN_TREE/exec.sh"
139 name='new symlink is added to a file that was also just made executable'
141 ln -s bar/zzz exec-2.sh
142 git update-index --add bar/zzz exec-2.sh
143 git commit -m "$name"
145 test_expect_success "$name" \
146 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
147 test -x $SVN_TREE/bar/zzz &&
148 test -L $SVN_TREE/exec-2.sh"
152 name='modify a symlink to become a file'
153 git help > help || true
156 git update-index exec-2.sh
157 git commit -m "$name"
159 test_expect_success "$name" \
160 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
161 test -f $SVN_TREE/exec-2.sh &&
162 test ! -L $SVN_TREE/exec-2.sh &&
163 diff -u help $SVN_TREE/exec-2.sh"
167 name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
170 test_expect_success "$name" \
171 "git-svn init $svnrepo && git-svn fetch &&
172 git-rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a &&
173 git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&