|
| 1 | +#!/bin/sh |
| 2 | +test_description='git svn globbing refspecs with prefixed globs' |
| 3 | +. ./lib-git-svn.sh |
| 4 | + |
| 5 | +test_expect_success 'prepare test refspec prefixed globbing' ' |
| 6 | + cat >expect.end <<EOF |
| 7 | +the end |
| 8 | +hi |
| 9 | +start a new branch |
| 10 | +initial |
| 11 | +EOF |
| 12 | + ' |
| 13 | + |
| 14 | +test_expect_success 'test refspec prefixed globbing' ' |
| 15 | + mkdir -p trunk/src/a trunk/src/b trunk/doc && |
| 16 | + echo "hello world" >trunk/src/a/readme && |
| 17 | + echo "goodbye world" >trunk/src/b/readme && |
| 18 | + svn_cmd import -m "initial" trunk "$svnrepo"/trunk && |
| 19 | + svn_cmd co "$svnrepo" tmp && |
| 20 | + ( |
| 21 | + cd tmp && |
| 22 | + mkdir branches tags && |
| 23 | + svn_cmd add branches tags && |
| 24 | + svn_cmd cp trunk branches/b_start && |
| 25 | + svn_cmd commit -m "start a new branch" && |
| 26 | + svn_cmd up && |
| 27 | + echo "hi" >>branches/b_start/src/b/readme && |
| 28 | + poke branches/b_start/src/b/readme && |
| 29 | + echo "hey" >>branches/b_start/src/a/readme && |
| 30 | + poke branches/b_start/src/a/readme && |
| 31 | + svn_cmd commit -m "hi" && |
| 32 | + svn_cmd up && |
| 33 | + svn_cmd cp branches/b_start tags/t_end && |
| 34 | + echo "bye" >>tags/t_end/src/b/readme && |
| 35 | + poke tags/t_end/src/b/readme && |
| 36 | + echo "aye" >>tags/t_end/src/a/readme && |
| 37 | + poke tags/t_end/src/a/readme && |
| 38 | + svn_cmd commit -m "the end" && |
| 39 | + echo "byebye" >>tags/t_end/src/b/readme && |
| 40 | + poke tags/t_end/src/b/readme && |
| 41 | + svn_cmd commit -m "nothing to see here" |
| 42 | + ) && |
| 43 | + git config --add svn-remote.svn.url "$svnrepo" && |
| 44 | + git config --add svn-remote.svn.fetch \ |
| 45 | + "trunk/src/a:refs/remotes/trunk" && |
| 46 | + git config --add svn-remote.svn.branches \ |
| 47 | + "branches/b_*/src/a:refs/remotes/branches/b_*" && |
| 48 | + git config --add svn-remote.svn.tags\ |
| 49 | + "tags/t_*/src/a:refs/remotes/tags/t_*" && |
| 50 | + git svn multi-fetch && |
| 51 | + git log --pretty=oneline refs/remotes/tags/t_end | \ |
| 52 | + sed -e "s/^.\{41\}//" >output.end && |
| 53 | + test_cmp expect.end output.end && |
| 54 | + test "$(git rev-parse refs/remotes/tags/t_end~1)" = \ |
| 55 | + "$(git rev-parse refs/remotes/branches/b_start)" && |
| 56 | + test "$(git rev-parse refs/remotes/branches/b_start~2)" = \ |
| 57 | + "$(git rev-parse refs/remotes/trunk)" && |
| 58 | + test_must_fail git rev-parse refs/remotes/tags/t_end@3 |
| 59 | + ' |
| 60 | + |
| 61 | +test_expect_success 'prepare test left-hand-side only prefixed globbing' ' |
| 62 | + echo try to try >expect.two && |
| 63 | + echo nothing to see here >>expect.two && |
| 64 | + cat expect.end >>expect.two |
| 65 | + ' |
| 66 | + |
| 67 | +test_expect_success 'test left-hand-side only prefixed globbing' ' |
| 68 | + git config --add svn-remote.two.url "$svnrepo" && |
| 69 | + git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk && |
| 70 | + git config --add svn-remote.two.branches \ |
| 71 | + "branches/b_*:refs/remotes/two/branches/*" && |
| 72 | + git config --add svn-remote.two.tags \ |
| 73 | + "tags/t_*:refs/remotes/two/tags/*" && |
| 74 | + ( |
| 75 | + cd tmp && |
| 76 | + echo "try try" >>tags/t_end/src/b/readme && |
| 77 | + poke tags/t_end/src/b/readme && |
| 78 | + svn_cmd commit -m "try to try" |
| 79 | + ) && |
| 80 | + git svn fetch two && |
| 81 | + test $(git rev-list refs/remotes/two/tags/t_end | wc -l) -eq 6 && |
| 82 | + test $(git rev-list refs/remotes/two/branches/b_start | wc -l) -eq 3 && |
| 83 | + test $(git rev-parse refs/remotes/two/branches/b_start~2) = \ |
| 84 | + $(git rev-parse refs/remotes/two/trunk) && |
| 85 | + test $(git rev-parse refs/remotes/two/tags/t_end~3) = \ |
| 86 | + $(git rev-parse refs/remotes/two/branches/b_start) && |
| 87 | + git log --pretty=oneline refs/remotes/two/tags/t_end | \ |
| 88 | + sed -e "s/^.\{41\}//" >output.two && |
| 89 | + test_cmp expect.two output.two |
| 90 | + ' |
| 91 | + |
| 92 | +test_expect_success 'prepare test prefixed globs match just prefix' ' |
| 93 | + cat >expect.three <<EOF |
| 94 | +Tag commit to t_ |
| 95 | +Branch commit to b_ |
| 96 | +initial |
| 97 | +EOF |
| 98 | + ' |
| 99 | + |
| 100 | +test_expect_success 'test prefixed globs match just prefix' ' |
| 101 | + git config --add svn-remote.three.url "$svnrepo" && |
| 102 | + git config --add svn-remote.three.fetch \ |
| 103 | + trunk:refs/remotes/three/trunk && |
| 104 | + git config --add svn-remote.three.branches \ |
| 105 | + "branches/b_*:refs/remotes/three/branches/*" && |
| 106 | + git config --add svn-remote.three.tags \ |
| 107 | + "tags/t_*:refs/remotes/three/tags/*" && |
| 108 | + ( |
| 109 | + cd tmp && |
| 110 | + svn_cmd cp trunk branches/b_ && |
| 111 | + echo "Branch commit to b_" >>branches/b_/src/a/readme && |
| 112 | + poke branches/b_/src/a/readme && |
| 113 | + svn_cmd commit -m "Branch commit to b_" && |
| 114 | + svn_cmd up && svn_cmd cp branches/b_ tags/t_ && |
| 115 | + echo "Tag commit to t_" >>tags/t_/src/a/readme && |
| 116 | + poke tags/t_/src/a/readme && |
| 117 | + svn_cmd commit -m "Tag commit to t_" && |
| 118 | + svn_cmd up |
| 119 | + ) && |
| 120 | + git svn fetch three && |
| 121 | + test $(git rev-list refs/remotes/three/branches/b_ | wc -l) -eq 2 && |
| 122 | + test $(git rev-list refs/remotes/three/tags/t_ | wc -l) -eq 3 && |
| 123 | + test $(git rev-parse refs/remotes/three/branches/b_~1) = \ |
| 124 | + $(git rev-parse refs/remotes/three/trunk) && |
| 125 | + test $(git rev-parse refs/remotes/three/tags/t_~1) = \ |
| 126 | + $(git rev-parse refs/remotes/three/branches/b_) && |
| 127 | + git log --pretty=oneline refs/remotes/three/tags/t_ | \ |
| 128 | + sed -e "s/^.\{41\}//" >output.three && |
| 129 | + test_cmp expect.three output.three |
| 130 | + ' |
| 131 | + |
| 132 | +test_expect_success 'prepare test disallow prefixed multi-globs' " |
| 133 | +cat >expect.four <<EOF |
| 134 | +Only one set of wildcards (e.g. '*' or '*/*/*') is supported: branches/b_*/t/* |
| 135 | +
|
| 136 | +EOF |
| 137 | + " |
| 138 | + |
| 139 | +test_expect_success 'test disallow prefixed multi-globs' ' |
| 140 | + git config --add svn-remote.four.url "$svnrepo" && |
| 141 | + git config --add svn-remote.four.fetch \ |
| 142 | + trunk:refs/remotes/four/trunk && |
| 143 | + git config --add svn-remote.four.branches \ |
| 144 | + "branches/b_*/t/*:refs/remotes/four/branches/*" && |
| 145 | + git config --add svn-remote.four.tags \ |
| 146 | + "tags/t_*/*:refs/remotes/four/tags/*" && |
| 147 | + ( |
| 148 | + cd tmp && |
| 149 | + echo "try try" >>tags/t_end/src/b/readme && |
| 150 | + poke tags/t_end/src/b/readme && |
| 151 | + svn_cmd commit -m "try to try" |
| 152 | + ) && |
| 153 | + test_must_fail git svn fetch four 2>stderr.four && |
| 154 | + test_cmp expect.four stderr.four && |
| 155 | + git config --unset svn-remote.four.branches && |
| 156 | + git config --unset svn-remote.four.tags |
| 157 | + ' |
| 158 | + |
| 159 | +test_expect_success 'prepare test globbing in the middle of the word' ' |
| 160 | + cat >expect.five <<EOF |
| 161 | +Tag commit to fghij |
| 162 | +Branch commit to abcde |
| 163 | +initial |
| 164 | +EOF |
| 165 | + ' |
| 166 | + |
| 167 | +test_expect_success 'test globbing in the middle of the word' ' |
| 168 | + git config --add svn-remote.five.url "$svnrepo" && |
| 169 | + git config --add svn-remote.five.fetch \ |
| 170 | + trunk:refs/remotes/five/trunk && |
| 171 | + git config --add svn-remote.five.branches \ |
| 172 | + "branches/a*e:refs/remotes/five/branches/*" && |
| 173 | + git config --add svn-remote.five.tags \ |
| 174 | + "tags/f*j:refs/remotes/five/tags/*" && |
| 175 | + ( |
| 176 | + cd tmp && |
| 177 | + svn_cmd cp trunk branches/abcde && |
| 178 | + echo "Branch commit to abcde" >>branches/abcde/src/a/readme && |
| 179 | + poke branches/b_/src/a/readme && |
| 180 | + svn_cmd commit -m "Branch commit to abcde" && |
| 181 | + svn_cmd up && |
| 182 | + svn_cmd cp branches/abcde tags/fghij && |
| 183 | + echo "Tag commit to fghij" >>tags/fghij/src/a/readme && |
| 184 | + poke tags/fghij/src/a/readme && |
| 185 | + svn_cmd commit -m "Tag commit to fghij" && |
| 186 | + svn_cmd up |
| 187 | + ) && |
| 188 | + git svn fetch five && |
| 189 | + test $(git rev-list refs/remotes/five/branches/abcde | wc -l) -eq 2 && |
| 190 | + test $(git rev-list refs/remotes/five/tags/fghij | wc -l) -eq 3 && |
| 191 | + test $(git rev-parse refs/remotes/five/branches/abcde~1) = \ |
| 192 | + $(git rev-parse refs/remotes/five/trunk) && |
| 193 | + test $(git rev-parse refs/remotes/five/tags/fghij~1) = \ |
| 194 | + $(git rev-parse refs/remotes/five/branches/abcde) && |
| 195 | + git log --pretty=oneline refs/remotes/five/tags/fghij | \ |
| 196 | + sed -e "s/^.\{41\}//" >output.five && |
| 197 | + test_cmp expect.five output.five |
| 198 | + ' |
| 199 | + |
| 200 | +test_expect_success 'prepare test disallow multiple asterisks in one word' " |
| 201 | + echo \"Only one '*' is allowed in a pattern: 'a*c*e'\" >expect.six && |
| 202 | + echo \"\" >>expect.six |
| 203 | + " |
| 204 | + |
| 205 | +test_expect_success 'test disallow multiple asterisks in one word' ' |
| 206 | + git config --add svn-remote.six.url "$svnrepo" && |
| 207 | + git config --add svn-remote.six.fetch \ |
| 208 | + trunk:refs/remotes/six/trunk && |
| 209 | + git config --add svn-remote.six.branches \ |
| 210 | + "branches/a*c*e:refs/remotes/six/branches/*" && |
| 211 | + git config --add svn-remote.six.tags \ |
| 212 | + "tags/f*h*j:refs/remotes/six/tags/*" && |
| 213 | + ( |
| 214 | + cd tmp && |
| 215 | + echo "try try" >>tags/fghij/src/b/readme && |
| 216 | + poke tags/fghij/src/b/readme && |
| 217 | + svn_cmd commit -m "try to try" |
| 218 | + ) && |
| 219 | + test_must_fail git svn fetch six 2>stderr.six && |
| 220 | + test_cmp expect.six stderr.six |
| 221 | + ' |
| 222 | + |
| 223 | +test_done |
0 commit comments