3 # Copyright (c) 2006 Eric Wong
6 test_description='git-svn tests'
15 mkdir -p dir/a/b/c/d/e
16 echo 'deep dir' > dir/a/b/c/d/e/file
19 echo '#!/bin/sh' > exec.sh
21 svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
27 'initialize git-svn' \
28 "git-svn init $svnrepo"
31 'import an SVN revision into git' \
35 name='try a deep --rmdir with a commit'
36 git checkout -f -b mybranch remotes/git-svn
37 mv dir/a/b/c/d/e/file dir/file
39 git update-index --add --remove dir/a/b/c/d/e/file dir/file file
42 test_expect_success "$name" \
43 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch &&
44 test -d $SVN_TREE/dir && test ! -d $SVN_TREE/dir/a"
47 name='detect node change from file to directory #1'
49 mv dir/file dir/new_file/file
50 mv dir/new_file dir/file
51 git update-index --remove dir/file
52 git update-index --add dir/file/file
55 test_expect_code 1 "$name" \
56 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch' \
60 name='detect node change from directory to file #1'
61 rm -rf dir $GIT_DIR/index
62 git checkout -f -b mybranch2 remotes/git-svn
66 git update-index --remove -- bar/zzz
67 git update-index --add -- bar
70 test_expect_code 1 "$name" \
71 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch2' \
75 name='detect node change from file to directory #2'
77 git checkout -f -b mybranch3 remotes/git-svn
79 git-update-index --remove bar/zzz
81 echo yyy > bar/zzz/yyy
82 git-update-index --add bar/zzz/yyy
85 test_expect_code 1 "$name" \
86 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch3' \
90 name='detect node change from directory to file #2'
92 git checkout -f -b mybranch4 remotes/git-svn
94 git update-index --remove -- dir/file
97 git update-index --add -- dir
100 test_expect_code 1 "$name" \
101 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch4' \
105 name='remove executable bit from a file'
107 git checkout -f -b mybranch5 remotes/git-svn
109 git update-index exec.sh
110 git commit -m "$name"
112 test_expect_success "$name" \
113 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
114 test ! -x $SVN_TREE/exec.sh"
117 name='add executable bit back file'
119 git update-index exec.sh
120 git commit -m "$name"
122 test_expect_success "$name" \
123 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
124 test -x $SVN_TREE/exec.sh"
128 name='executable file becomes a symlink to bar/zzz (file)'
130 ln -s bar/zzz exec.sh
131 git update-index exec.sh
132 git commit -m "$name"
134 test_expect_success "$name" \
135 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
136 test -L $SVN_TREE/exec.sh"
140 name='new symlink is added to a file that was also just made executable'
142 ln -s bar/zzz exec-2.sh
143 git update-index --add bar/zzz exec-2.sh
144 git commit -m "$name"
146 test_expect_success "$name" \
147 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
148 test -x $SVN_TREE/bar/zzz &&
149 test -L $SVN_TREE/exec-2.sh"
153 name='modify a symlink to become a file'
154 git help > help || true
157 git update-index exec-2.sh
158 git commit -m "$name"
160 test_expect_success "$name" \
161 "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
162 test -f $SVN_TREE/exec-2.sh &&
163 test ! -L $SVN_TREE/exec-2.sh &&
164 diff -u help $SVN_TREE/exec-2.sh"
167 if test -n "$GIT_SVN_LC_ALL" && echo $GIT_SVN_LC_ALL | grep -q '\.UTF-8$'
169 name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL"
170 echo '# hello' >> exec-2.sh
171 git update-index exec-2.sh
173 export LC_ALL="$GIT_SVN_LC_ALL"
174 test_expect_success "$name" "git-svn commit HEAD"
177 echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)"
180 name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
183 test_expect_success "$name" \
184 "git-svn init $svnrepo && git-svn fetch &&
185 git-rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a &&
186 git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&