Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2006 Eric Wong |
| 4 | # |
| 5 | |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 6 | test_description='git svn basic tests' |
Ramsay Jones | 952182b | 2008-07-08 23:59:25 +0100 | [diff] [blame] | 7 | GIT_SVN_LC_ALL=${LC_ALL:-$LANG} |
Eric Wong | dc62e25 | 2006-06-28 03:07:14 -0700 | [diff] [blame] | 8 | |
Eric Wong | 36f5b1f | 2006-05-23 19:23:41 -0700 | [diff] [blame] | 9 | . ./lib-git-svn.sh |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 10 | |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 11 | say 'define NO_SVN_TESTS to skip git svn tests' |
Eric Wong | 60d02cc | 2006-07-06 00:14:16 -0700 | [diff] [blame] | 12 | |
Johannes Sixt | 7b7247b | 2009-02-24 21:13:39 +0100 | [diff] [blame] | 13 | case "$GIT_SVN_LC_ALL" in |
| 14 | *.UTF-8) |
| 15 | test_set_prereq UTF8 |
| 16 | ;; |
| 17 | *) |
Ævar Arnfjörð Bjarmason | fadb515 | 2010-06-24 17:44:48 +0000 | [diff] [blame] | 18 | say "# UTF-8 locale not set, some tests skipped ($GIT_SVN_LC_ALL)" |
Johannes Sixt | 7b7247b | 2009-02-24 21:13:39 +0100 | [diff] [blame] | 19 | ;; |
| 20 | esac |
| 21 | |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 22 | test_expect_success \ |
Nanako Shiraishi | f964732 | 2008-09-10 06:25:27 +0900 | [diff] [blame] | 23 | 'initialize git svn' ' |
Eric Wong | 39ed7c1 | 2006-12-26 16:27:37 -0800 | [diff] [blame] | 24 | mkdir import && |
Jonathan Nieder | 18a8269 | 2010-09-06 20:42:54 -0500 | [diff] [blame] | 25 | ( |
| 26 | cd import && |
| 27 | echo foo >foo && |
| 28 | ln -s foo foo.link |
| 29 | mkdir -p dir/a/b/c/d/e && |
| 30 | echo "deep dir" >dir/a/b/c/d/e/file && |
| 31 | mkdir bar && |
| 32 | echo "zzz" >bar/zzz && |
| 33 | echo "#!/bin/sh" >exec.sh && |
| 34 | chmod +x exec.sh && |
| 35 | svn_cmd import -m "import for git svn" . "$svnrepo" >/dev/null |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 36 | ) && |
Eric Wong | 39ed7c1 | 2006-12-26 16:27:37 -0800 | [diff] [blame] | 37 | rm -rf import && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 38 | git svn init "$svnrepo"' |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 39 | |
| 40 | test_expect_success \ |
| 41 | 'import an SVN revision into git' \ |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 42 | 'git svn fetch' |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 43 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 44 | test_expect_success "checkout from svn" 'svn co "$svnrepo" "$SVN_TREE"' |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 45 | |
| 46 | name='try a deep --rmdir with a commit' |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 47 | test_expect_success "$name" ' |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 48 | git checkout -f -b mybranch ${remotes_git_svn} && |
Eric Wong | 39ed7c1 | 2006-12-26 16:27:37 -0800 | [diff] [blame] | 49 | mv dir/a/b/c/d/e/file dir/file && |
| 50 | cp dir/file file && |
| 51 | git update-index --add --remove dir/a/b/c/d/e/file dir/file file && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 52 | git commit -m "$name" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 53 | git svn set-tree --find-copies-harder --rmdir \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 54 | ${remotes_git_svn}..mybranch && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 55 | svn_cmd up "$SVN_TREE" && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 56 | test -d "$SVN_TREE"/dir && test ! -d "$SVN_TREE"/dir/a' |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 57 | |
| 58 | |
| 59 | name='detect node change from file to directory #1' |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 60 | test_expect_success "$name" " |
Eric Wong | 39ed7c1 | 2006-12-26 16:27:37 -0800 | [diff] [blame] | 61 | mkdir dir/new_file && |
| 62 | mv dir/file dir/new_file/file && |
| 63 | mv dir/new_file dir/file && |
| 64 | git update-index --remove dir/file && |
| 65 | git update-index --add dir/file/file && |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 66 | git commit -m '$name' && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 67 | test_must_fail git svn set-tree --find-copies-harder --rmdir \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 68 | ${remotes_git_svn}..mybranch" || true |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 69 | |
| 70 | |
| 71 | name='detect node change from directory to file #1' |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 72 | test_expect_success "$name" ' |
| 73 | rm -rf dir "$GIT_DIR"/index && |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 74 | git checkout -f -b mybranch2 ${remotes_git_svn} && |
Eric Wong | 39ed7c1 | 2006-12-26 16:27:37 -0800 | [diff] [blame] | 75 | mv bar/zzz zzz && |
| 76 | rm -rf bar && |
| 77 | mv zzz bar && |
| 78 | git update-index --remove -- bar/zzz && |
| 79 | git update-index --add -- bar && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 80 | git commit -m "$name" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 81 | test_must_fail git svn set-tree --find-copies-harder --rmdir \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 82 | ${remotes_git_svn}..mybranch2' || true |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 83 | |
| 84 | |
| 85 | name='detect node change from file to directory #2' |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 86 | test_expect_success "$name" ' |
| 87 | rm -f "$GIT_DIR"/index && |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 88 | git checkout -f -b mybranch3 ${remotes_git_svn} && |
Eric Wong | 39ed7c1 | 2006-12-26 16:27:37 -0800 | [diff] [blame] | 89 | rm bar/zzz && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 90 | git update-index --remove bar/zzz && |
Eric Wong | 39ed7c1 | 2006-12-26 16:27:37 -0800 | [diff] [blame] | 91 | mkdir bar/zzz && |
| 92 | echo yyy > bar/zzz/yyy && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 93 | git update-index --add bar/zzz/yyy && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 94 | git commit -m "$name" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 95 | test_must_fail git svn set-tree --find-copies-harder --rmdir \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 96 | ${remotes_git_svn}..mybranch3' || true |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 97 | |
| 98 | |
| 99 | name='detect node change from directory to file #2' |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 100 | test_expect_success "$name" ' |
| 101 | rm -f "$GIT_DIR"/index && |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 102 | git checkout -f -b mybranch4 ${remotes_git_svn} && |
Eric Wong | 39ed7c1 | 2006-12-26 16:27:37 -0800 | [diff] [blame] | 103 | rm -rf dir && |
| 104 | git update-index --remove -- dir/file && |
| 105 | touch dir && |
| 106 | echo asdf > dir && |
| 107 | git update-index --add -- dir && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 108 | git commit -m "$name" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 109 | test_must_fail git svn set-tree --find-copies-harder --rmdir \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 110 | ${remotes_git_svn}..mybranch4' || true |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 111 | |
| 112 | |
| 113 | name='remove executable bit from a file' |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 114 | test_expect_success "$name" ' |
| 115 | rm -f "$GIT_DIR"/index && |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 116 | git checkout -f -b mybranch5 ${remotes_git_svn} && |
Eric Wong | 39ed7c1 | 2006-12-26 16:27:37 -0800 | [diff] [blame] | 117 | chmod -x exec.sh && |
| 118 | git update-index exec.sh && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 119 | git commit -m "$name" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 120 | git svn set-tree --find-copies-harder --rmdir \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 121 | ${remotes_git_svn}..mybranch5 && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 122 | svn_cmd up "$SVN_TREE" && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 123 | test ! -x "$SVN_TREE"/exec.sh' |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 124 | |
| 125 | |
| 126 | name='add executable bit back file' |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 127 | test_expect_success "$name" ' |
Eric Wong | 39ed7c1 | 2006-12-26 16:27:37 -0800 | [diff] [blame] | 128 | chmod +x exec.sh && |
| 129 | git update-index exec.sh && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 130 | git commit -m "$name" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 131 | git svn set-tree --find-copies-harder --rmdir \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 132 | ${remotes_git_svn}..mybranch5 && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 133 | svn_cmd up "$SVN_TREE" && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 134 | test -x "$SVN_TREE"/exec.sh' |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 135 | |
| 136 | |
Eric Wong | 5bd3870 | 2006-12-31 21:49:46 -0800 | [diff] [blame] | 137 | name='executable file becomes a symlink to bar/zzz (file)' |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 138 | test_expect_success "$name" ' |
Eric Wong | 5bd3870 | 2006-12-31 21:49:46 -0800 | [diff] [blame] | 139 | rm exec.sh && |
| 140 | ln -s bar/zzz exec.sh && |
| 141 | git update-index exec.sh && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 142 | git commit -m "$name" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 143 | git svn set-tree --find-copies-harder --rmdir \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 144 | ${remotes_git_svn}..mybranch5 && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 145 | svn_cmd up "$SVN_TREE" && |
Jeff King | afa0876 | 2010-09-21 20:35:59 -0400 | [diff] [blame] | 146 | test -h "$SVN_TREE"/exec.sh' |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 147 | |
Eric Wong | 5bd3870 | 2006-12-31 21:49:46 -0800 | [diff] [blame] | 148 | name='new symlink is added to a file that was also just made executable' |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 149 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 150 | test_expect_success "$name" ' |
Eric Wong | 5bd3870 | 2006-12-31 21:49:46 -0800 | [diff] [blame] | 151 | chmod +x bar/zzz && |
| 152 | ln -s bar/zzz exec-2.sh && |
| 153 | git update-index --add bar/zzz exec-2.sh && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 154 | git commit -m "$name" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 155 | git svn set-tree --find-copies-harder --rmdir \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 156 | ${remotes_git_svn}..mybranch5 && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 157 | svn_cmd up "$SVN_TREE" && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 158 | test -x "$SVN_TREE"/bar/zzz && |
Jeff King | afa0876 | 2010-09-21 20:35:59 -0400 | [diff] [blame] | 159 | test -h "$SVN_TREE"/exec-2.sh' |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 160 | |
Eric Wong | 5bd3870 | 2006-12-31 21:49:46 -0800 | [diff] [blame] | 161 | name='modify a symlink to become a file' |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 162 | test_expect_success "$name" ' |
Eric Wong | 5bd3870 | 2006-12-31 21:49:46 -0800 | [diff] [blame] | 163 | echo git help > help || true && |
| 164 | rm exec-2.sh && |
| 165 | cp help exec-2.sh && |
| 166 | git update-index exec-2.sh && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 167 | git commit -m "$name" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 168 | git svn set-tree --find-copies-harder --rmdir \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 169 | ${remotes_git_svn}..mybranch5 && |
Eygene Ryabinkin | da083d6 | 2009-05-08 12:06:16 +0400 | [diff] [blame] | 170 | svn_cmd up "$SVN_TREE" && |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 171 | test -f "$SVN_TREE"/exec-2.sh && |
Jeff King | afa0876 | 2010-09-21 20:35:59 -0400 | [diff] [blame] | 172 | test ! -h "$SVN_TREE"/exec-2.sh && |
Junio C Hamano | 3af8286 | 2008-05-23 22:28:56 -0700 | [diff] [blame] | 173 | test_cmp help "$SVN_TREE"/exec-2.sh' |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 174 | |
Johannes Sixt | 7b7247b | 2009-02-24 21:13:39 +0100 | [diff] [blame] | 175 | name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL" |
| 176 | LC_ALL="$GIT_SVN_LC_ALL" |
| 177 | export LC_ALL |
| 178 | test_expect_success UTF8 "$name" " |
| 179 | echo '# hello' >> exec-2.sh && |
| 180 | git update-index exec-2.sh && |
| 181 | git commit -m 'éï∏' && |
| 182 | git svn set-tree HEAD" |
| 183 | unset LC_ALL |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 184 | |
| 185 | name='test fetch functionality (svn => git) with alternate GIT_SVN_ID' |
| 186 | GIT_SVN_ID=alt |
| 187 | export GIT_SVN_ID |
| 188 | test_expect_success "$name" \ |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 189 | 'git svn init "$svnrepo" && git svn fetch && |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 190 | git rev-list --pretty=raw ${remotes_git_svn} | grep ^tree | uniq > a && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 191 | git rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b && |
Junio C Hamano | 3af8286 | 2008-05-23 22:28:56 -0700 | [diff] [blame] | 192 | test_cmp a b' |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 193 | |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 194 | name='check imported tree checksums expected tree checksums' |
Eric Wong | 86f3637 | 2006-06-15 19:13:56 -0700 | [diff] [blame] | 195 | rm -f expected |
Johannes Sixt | 7b7247b | 2009-02-24 21:13:39 +0100 | [diff] [blame] | 196 | if test_have_prereq UTF8 |
Eric Wong | 86f3637 | 2006-06-15 19:13:56 -0700 | [diff] [blame] | 197 | then |
Ramsay Allan Jones | 822a7d5 | 2006-07-30 22:42:25 +0100 | [diff] [blame] | 198 | echo tree bf522353586b1b883488f2bc73dab0d9f774b9a9 > expected |
Eric Wong | 86f3637 | 2006-06-15 19:13:56 -0700 | [diff] [blame] | 199 | fi |
| 200 | cat >> expected <<\EOF |
Ramsay Allan Jones | 822a7d5 | 2006-07-30 22:42:25 +0100 | [diff] [blame] | 201 | tree 83654bb36f019ae4fe77a0171f81075972087624 |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 202 | tree 031b8d557afc6fea52894eaebb45bec52f1ba6d1 |
| 203 | tree 0b094cbff17168f24c302e297f55bfac65eb8bd3 |
| 204 | tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e |
| 205 | tree 56a30b966619b863674f5978696f4a3594f2fca9 |
| 206 | tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e |
| 207 | tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4 |
| 208 | EOF |
Eric Wong | e151611 | 2006-11-27 21:46:50 -0800 | [diff] [blame] | 209 | |
Junio C Hamano | 3af8286 | 2008-05-23 22:28:56 -0700 | [diff] [blame] | 210 | test_expect_success "$name" "test_cmp a expected" |
Eric Wong | 42d3287 | 2006-06-13 04:02:23 -0700 | [diff] [blame] | 211 | |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 212 | test_expect_success 'exit if remote refs are ambigious' " |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 213 | git config --add svn-remote.svn.fetch \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 214 | bar:refs/${remotes_git_svn} && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 215 | test_must_fail git svn migrate |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 216 | " |
Eric Wong | e6434f8 | 2007-01-23 16:29:23 -0800 | [diff] [blame] | 217 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 218 | test_expect_success 'exit if init-ing a would clobber a URL' ' |
| 219 | svnadmin create "${PWD}/svnrepo2" && |
| 220 | svn mkdir -m "mkdir bar" "${svnrepo}2/bar" && |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 221 | git config --unset svn-remote.svn.fetch \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 222 | "^bar:refs/${remotes_git_svn}$" && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 223 | test_must_fail git svn init "${svnrepo}2/bar" |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 224 | ' |
Eric Wong | e6434f8 | 2007-01-23 16:29:23 -0800 | [diff] [blame] | 225 | |
| 226 | test_expect_success \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 227 | 'init allows us to connect to another directory in the same repo' ' |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 228 | git svn init --minimize-url -i bar "$svnrepo/bar" && |
Eric Wong | ccb6b6f | 2007-02-13 17:38:58 -0800 | [diff] [blame] | 229 | git config --get svn-remote.svn.fetch \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 230 | "^bar:refs/remotes/bar$" && |
Eric Wong | ccb6b6f | 2007-02-13 17:38:58 -0800 | [diff] [blame] | 231 | git config --get svn-remote.svn.fetch \ |
Nanako Shiraishi | 16805d3 | 2008-09-08 19:02:05 +0900 | [diff] [blame] | 232 | "^:refs/${remotes_git_svn}$" |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 233 | ' |
Eric Wong | b805b44 | 2007-01-22 13:52:04 -0800 | [diff] [blame] | 234 | |
Thomas Rast | 5eec27e | 2009-05-29 17:09:42 +0200 | [diff] [blame] | 235 | test_expect_success 'dcommit $rev does not clobber current branch' ' |
| 236 | git svn fetch -i bar && |
| 237 | git checkout -b my-bar refs/remotes/bar && |
| 238 | echo 1 > foo && |
| 239 | git add foo && |
| 240 | git commit -m "change 1" && |
| 241 | echo 2 > foo && |
| 242 | git add foo && |
| 243 | git commit -m "change 2" && |
| 244 | old_head=$(git rev-parse HEAD) && |
| 245 | git svn dcommit -i bar HEAD^ && |
| 246 | test $old_head = $(git rev-parse HEAD) && |
| 247 | test refs/heads/my-bar = $(git symbolic-ref HEAD) && |
| 248 | git log refs/remotes/bar | grep "change 1" && |
| 249 | ! git log refs/remotes/bar | grep "change 2" && |
| 250 | git checkout master && |
| 251 | git branch -D my-bar |
| 252 | ' |
| 253 | |
Eric Wong | d3a840d | 2007-01-26 01:32:45 -0800 | [diff] [blame] | 254 | test_expect_success 'able to dcommit to a subdirectory' " |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 255 | git svn fetch -i bar && |
Eric Wong | d3a840d | 2007-01-26 01:32:45 -0800 | [diff] [blame] | 256 | git checkout -b my-bar refs/remotes/bar && |
| 257 | echo abc > d && |
| 258 | git update-index --add d && |
| 259 | git commit -m '/bar/d should be in the log' && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 260 | git svn dcommit -i bar && |
Eric Wong | d3a840d | 2007-01-26 01:32:45 -0800 | [diff] [blame] | 261 | test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" && |
| 262 | mkdir newdir && |
| 263 | echo new > newdir/dir && |
| 264 | git update-index --add newdir/dir && |
| 265 | git commit -m 'add a new directory' && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 266 | git svn dcommit -i bar && |
Eric Wong | d3a840d | 2007-01-26 01:32:45 -0800 | [diff] [blame] | 267 | test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" && |
| 268 | echo foo >> newdir/dir && |
| 269 | git update-index newdir/dir && |
| 270 | git commit -m 'modify a file in new directory' && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 271 | git svn dcommit -i bar && |
Eric Wong | d3a840d | 2007-01-26 01:32:45 -0800 | [diff] [blame] | 272 | test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" |
| 273 | " |
| 274 | |
David D. Kilzer | 181264a | 2010-08-02 12:58:19 -0700 | [diff] [blame] | 275 | test_expect_success 'dcommit should not fail with a touched file' ' |
| 276 | test_commit "commit-new-file-foo2" foo2 && |
| 277 | test-chmtime =-60 foo && |
| 278 | git svn dcommit |
| 279 | ' |
| 280 | |
| 281 | test_expect_success 'rebase should not fail with a touched file' ' |
| 282 | test-chmtime =-60 foo && |
| 283 | git svn rebase |
| 284 | ' |
| 285 | |
Eric Wong | d3a840d | 2007-01-26 01:32:45 -0800 | [diff] [blame] | 286 | test_expect_success 'able to set-tree to a subdirectory' " |
| 287 | echo cba > d && |
| 288 | git update-index d && |
| 289 | git commit -m 'update /bar/d' && |
Nanako Shiraishi | 1364ff2 | 2008-09-08 19:02:08 +0900 | [diff] [blame] | 290 | git svn set-tree -i bar HEAD && |
Eric Wong | d3a840d | 2007-01-26 01:32:45 -0800 | [diff] [blame] | 291 | test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\" |
| 292 | " |
| 293 | |
Deskin Miller | 6e5121f | 2008-11-06 00:07:39 -0500 | [diff] [blame] | 294 | test_expect_success 'git-svn works in a bare repository' ' |
| 295 | mkdir bare-repo && |
| 296 | ( cd bare-repo && |
| 297 | git init --bare && |
| 298 | GIT_DIR=. git svn init "$svnrepo" && |
| 299 | git svn fetch ) && |
| 300 | rm -rf bare-repo |
| 301 | ' |
| 302 | |
Eric Wong | 96a40b2 | 2006-02-20 10:57:29 -0800 | [diff] [blame] | 303 | test_done |