Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2006 Eric Wong |
| 4 | # |
| 5 | |
Eric Wong | 60d02cc | 2006-07-06 00:14:16 -0700 | [diff] [blame] | 6 | test_description='git-svn basic tests' |
Eric Wong | 7a97de4 | 2006-06-12 05:57:02 -0700 | [diff] [blame] | 7 | GIT_SVN_LC_ALL=$LC_ALL |
Eric Wong | dc62e25 | 2006-06-28 03:07:14 -0700 | [diff] [blame] | 8 | |
| 9 | case "$LC_ALL" in |
| 10 | *.UTF-8) |
| 11 | have_utf8=t |
| 12 | ;; |
| 13 | *) |
| 14 | have_utf8= |
| 15 | ;; |
| 16 | esac |
| 17 | |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 18 | . ./lib-git-svn.sh |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 19 | |
Eric Wong | 60d02cc | 2006-07-06 00:14:16 -0700 | [diff] [blame] | 20 | echo 'define NO_SVN_TESTS to skip git-svn tests' |
| 21 | |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 22 | mkdir import |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 23 | cd import |
| 24 | |
| 25 | echo foo > foo |
Eric Wong | 0e8a002 | 2006-06-15 19:51:05 -0700 | [diff] [blame] | 26 | if test -z "$NO_SYMLINK" |
| 27 | then |
| 28 | ln -s foo foo.link |
| 29 | fi |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 30 | mkdir -p dir/a/b/c/d/e |
| 31 | echo 'deep dir' > dir/a/b/c/d/e/file |
| 32 | mkdir -p bar |
| 33 | echo 'zzz' > bar/zzz |
| 34 | echo '#!/bin/sh' > exec.sh |
| 35 | chmod +x exec.sh |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 36 | svn import -m 'import for git-svn' . "$svnrepo" >/dev/null |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 37 | |
| 38 | cd .. |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 39 | rm -rf import |
| 40 | |
| 41 | test_expect_success \ |
| 42 | 'initialize git-svn' \ |
| 43 | "git-svn init $svnrepo" |
| 44 | |
| 45 | test_expect_success \ |
| 46 | 'import an SVN revision into git' \ |
| 47 | 'git-svn fetch' |
| 48 | |
Eric Wong | a5e0ced | 2006-06-12 15:23:48 -0700 | [diff] [blame] | 49 | test_expect_success "checkout from svn" "svn co $svnrepo $SVN_TREE" |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 50 | |
| 51 | name='try a deep --rmdir with a commit' |
Eric Wong | c7162c1 | 2006-05-23 18:34:24 -0700 | [diff] [blame] | 52 | git checkout -f -b mybranch remotes/git-svn |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 53 | mv dir/a/b/c/d/e/file dir/file |
| 54 | cp dir/file file |
| 55 | git update-index --add --remove dir/a/b/c/d/e/file dir/file file |
| 56 | git commit -m "$name" |
| 57 | |
| 58 | test_expect_success "$name" \ |
Eric Wong | 2beb3cd | 2006-03-01 21:58:31 -0800 | [diff] [blame] | 59 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch && |
Eric Wong | a5e0ced | 2006-06-12 15:23:48 -0700 | [diff] [blame] | 60 | svn up $SVN_TREE && |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 61 | test -d $SVN_TREE/dir && test ! -d $SVN_TREE/dir/a" |
| 62 | |
| 63 | |
| 64 | name='detect node change from file to directory #1' |
| 65 | mkdir dir/new_file |
| 66 | mv dir/file dir/new_file/file |
| 67 | mv dir/new_file dir/file |
| 68 | git update-index --remove dir/file |
| 69 | git update-index --add dir/file/file |
| 70 | git commit -m "$name" |
| 71 | |
Eric Wong | a5e0ced | 2006-06-12 15:23:48 -0700 | [diff] [blame] | 72 | test_expect_failure "$name" \ |
Eric Wong | 2beb3cd | 2006-03-01 21:58:31 -0800 | [diff] [blame] | 73 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch' \ |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 74 | || true |
| 75 | |
| 76 | |
| 77 | name='detect node change from directory to file #1' |
| 78 | rm -rf dir $GIT_DIR/index |
Eric Wong | c7162c1 | 2006-05-23 18:34:24 -0700 | [diff] [blame] | 79 | git checkout -f -b mybranch2 remotes/git-svn |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 80 | mv bar/zzz zzz |
| 81 | rm -rf bar |
| 82 | mv zzz bar |
| 83 | git update-index --remove -- bar/zzz |
| 84 | git update-index --add -- bar |
| 85 | git commit -m "$name" |
| 86 | |
Eric Wong | a5e0ced | 2006-06-12 15:23:48 -0700 | [diff] [blame] | 87 | test_expect_failure "$name" \ |
Eric Wong | 2beb3cd | 2006-03-01 21:58:31 -0800 | [diff] [blame] | 88 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch2' \ |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 89 | || true |
| 90 | |
| 91 | |
| 92 | name='detect node change from file to directory #2' |
| 93 | rm -f $GIT_DIR/index |
Eric Wong | c7162c1 | 2006-05-23 18:34:24 -0700 | [diff] [blame] | 94 | git checkout -f -b mybranch3 remotes/git-svn |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 95 | rm bar/zzz |
| 96 | git-update-index --remove bar/zzz |
| 97 | mkdir bar/zzz |
| 98 | echo yyy > bar/zzz/yyy |
| 99 | git-update-index --add bar/zzz/yyy |
| 100 | git commit -m "$name" |
| 101 | |
Eric Wong | a5e0ced | 2006-06-12 15:23:48 -0700 | [diff] [blame] | 102 | test_expect_failure "$name" \ |
Eric Wong | 2beb3cd | 2006-03-01 21:58:31 -0800 | [diff] [blame] | 103 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch3' \ |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 104 | || true |
| 105 | |
| 106 | |
| 107 | name='detect node change from directory to file #2' |
| 108 | rm -f $GIT_DIR/index |
Eric Wong | c7162c1 | 2006-05-23 18:34:24 -0700 | [diff] [blame] | 109 | git checkout -f -b mybranch4 remotes/git-svn |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 110 | rm -rf dir |
| 111 | git update-index --remove -- dir/file |
| 112 | touch dir |
| 113 | echo asdf > dir |
| 114 | git update-index --add -- dir |
| 115 | git commit -m "$name" |
| 116 | |
Eric Wong | a5e0ced | 2006-06-12 15:23:48 -0700 | [diff] [blame] | 117 | test_expect_failure "$name" \ |
Eric Wong | 2beb3cd | 2006-03-01 21:58:31 -0800 | [diff] [blame] | 118 | 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch4' \ |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 119 | || true |
| 120 | |
| 121 | |
| 122 | name='remove executable bit from a file' |
| 123 | rm -f $GIT_DIR/index |
Eric Wong | c7162c1 | 2006-05-23 18:34:24 -0700 | [diff] [blame] | 124 | git checkout -f -b mybranch5 remotes/git-svn |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 125 | chmod -x exec.sh |
| 126 | git update-index exec.sh |
| 127 | git commit -m "$name" |
| 128 | |
| 129 | test_expect_success "$name" \ |
Eric Wong | 2beb3cd | 2006-03-01 21:58:31 -0800 | [diff] [blame] | 130 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 && |
Eric Wong | a5e0ced | 2006-06-12 15:23:48 -0700 | [diff] [blame] | 131 | svn up $SVN_TREE && |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 132 | test ! -x $SVN_TREE/exec.sh" |
| 133 | |
| 134 | |
| 135 | name='add executable bit back file' |
| 136 | chmod +x exec.sh |
| 137 | git update-index exec.sh |
| 138 | git commit -m "$name" |
| 139 | |
| 140 | test_expect_success "$name" \ |
Eric Wong | 2beb3cd | 2006-03-01 21:58:31 -0800 | [diff] [blame] | 141 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 && |
Eric Wong | a5e0ced | 2006-06-12 15:23:48 -0700 | [diff] [blame] | 142 | svn up $SVN_TREE && |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 143 | test -x $SVN_TREE/exec.sh" |
| 144 | |
| 145 | |
| 146 | |
Eric Wong | 0e8a002 | 2006-06-15 19:51:05 -0700 | [diff] [blame] | 147 | if test -z "$NO_SYMLINK" |
| 148 | then |
| 149 | name='executable file becomes a symlink to bar/zzz (file)' |
| 150 | rm exec.sh |
| 151 | ln -s bar/zzz exec.sh |
| 152 | git update-index exec.sh |
| 153 | git commit -m "$name" |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 154 | |
Eric Wong | 0e8a002 | 2006-06-15 19:51:05 -0700 | [diff] [blame] | 155 | test_expect_success "$name" \ |
| 156 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 && |
| 157 | svn up $SVN_TREE && |
| 158 | test -L $SVN_TREE/exec.sh" |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 159 | |
Eric Wong | 0e8a002 | 2006-06-15 19:51:05 -0700 | [diff] [blame] | 160 | name='new symlink is added to a file that was also just made executable' |
| 161 | chmod +x bar/zzz |
| 162 | ln -s bar/zzz exec-2.sh |
| 163 | git update-index --add bar/zzz exec-2.sh |
| 164 | git commit -m "$name" |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 165 | |
Eric Wong | 0e8a002 | 2006-06-15 19:51:05 -0700 | [diff] [blame] | 166 | test_expect_success "$name" \ |
| 167 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 && |
| 168 | svn up $SVN_TREE && |
| 169 | test -x $SVN_TREE/bar/zzz && |
| 170 | test -L $SVN_TREE/exec-2.sh" |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 171 | |
Eric Wong | 0e8a002 | 2006-06-15 19:51:05 -0700 | [diff] [blame] | 172 | name='modify a symlink to become a file' |
Ramsay Allan Jones | 822a7d5 | 2006-07-30 22:42:25 +0100 | [diff] [blame] | 173 | echo git help > help || true |
Eric Wong | 0e8a002 | 2006-06-15 19:51:05 -0700 | [diff] [blame] | 174 | rm exec-2.sh |
| 175 | cp help exec-2.sh |
| 176 | git update-index exec-2.sh |
| 177 | git commit -m "$name" |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 178 | |
Eric Wong | 0e8a002 | 2006-06-15 19:51:05 -0700 | [diff] [blame] | 179 | test_expect_success "$name" \ |
| 180 | "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 && |
| 181 | svn up $SVN_TREE && |
| 182 | test -f $SVN_TREE/exec-2.sh && |
| 183 | test ! -L $SVN_TREE/exec-2.sh && |
| 184 | diff -u help $SVN_TREE/exec-2.sh" |
| 185 | fi |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 186 | |
| 187 | |
Eric Wong | dc62e25 | 2006-06-28 03:07:14 -0700 | [diff] [blame] | 188 | if test "$have_utf8" = t |
Eric Wong | 7a97de4 | 2006-06-12 05:57:02 -0700 | [diff] [blame] | 189 | then |
| 190 | name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL" |
| 191 | echo '# hello' >> exec-2.sh |
| 192 | git update-index exec-2.sh |
| 193 | git commit -m 'éï∏' |
| 194 | export LC_ALL="$GIT_SVN_LC_ALL" |
| 195 | test_expect_success "$name" "git-svn commit HEAD" |
| 196 | unset LC_ALL |
| 197 | else |
| 198 | echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)" |
| 199 | fi |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 200 | |
| 201 | name='test fetch functionality (svn => git) with alternate GIT_SVN_ID' |
| 202 | GIT_SVN_ID=alt |
| 203 | export GIT_SVN_ID |
| 204 | test_expect_success "$name" \ |
Eric Wong | 2beb3cd | 2006-03-01 21:58:31 -0800 | [diff] [blame] | 205 | "git-svn init $svnrepo && git-svn fetch && |
| 206 | git-rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a && |
| 207 | git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b && |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 208 | diff -u a b" |
| 209 | |
Eric Wong | 0e8a002 | 2006-06-15 19:51:05 -0700 | [diff] [blame] | 210 | if test -n "$NO_SYMLINK" |
| 211 | then |
| 212 | test_done |
| 213 | exit 0 |
| 214 | fi |
| 215 | |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 216 | name='check imported tree checksums expected tree checksums' |
Eric Wong | 86f3637 | 2006-06-15 19:13:56 -0700 | [diff] [blame] | 217 | rm -f expected |
Eric Wong | dc62e25 | 2006-06-28 03:07:14 -0700 | [diff] [blame] | 218 | if test "$have_utf8" = t |
Eric Wong | 86f3637 | 2006-06-15 19:13:56 -0700 | [diff] [blame] | 219 | then |
Ramsay Allan Jones | 822a7d5 | 2006-07-30 22:42:25 +0100 | [diff] [blame] | 220 | echo tree bf522353586b1b883488f2bc73dab0d9f774b9a9 > expected |
Eric Wong | 86f3637 | 2006-06-15 19:13:56 -0700 | [diff] [blame] | 221 | fi |
| 222 | cat >> expected <<\EOF |
Ramsay Allan Jones | 822a7d5 | 2006-07-30 22:42:25 +0100 | [diff] [blame] | 223 | tree 83654bb36f019ae4fe77a0171f81075972087624 |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 224 | tree 031b8d557afc6fea52894eaebb45bec52f1ba6d1 |
| 225 | tree 0b094cbff17168f24c302e297f55bfac65eb8bd3 |
| 226 | tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e |
| 227 | tree 56a30b966619b863674f5978696f4a3594f2fca9 |
| 228 | tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e |
| 229 | tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4 |
| 230 | EOF |
| 231 | test_expect_success "$name" "diff -u a expected" |
| 232 | |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 233 | test_done |