Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t9104-git-svn-follow-parent.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t9104-git-svn-follow-parent.sh` 230 lines ยท 7850 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) 2006 Eric Wong 4 # 5 6 test_description='git svn fetching' 7 8 . ./lib-git-svn.sh 9 10 test_expect_success 'initialize repo' ' 11 mkdir import && 12 ( 13 cd import && 14 mkdir -p trunk && 15 echo hello >trunk/readme && 16 svn_cmd import -m "initial" . "$svnrepo" 17 ) && 18 svn_cmd co "$svnrepo" wc && 19 ( 20 cd wc && 21 echo world >>trunk/readme && 22 poke trunk/readme && 23 svn_cmd commit -m "another commit" && 24 svn_cmd up && 25 svn_cmd mv trunk thunk && 26 echo goodbye >>thunk/readme && 27 poke thunk/readme && 28 svn_cmd commit -m "bye now" 29 ) 30 ' 31 32 test_expect_success 'init and fetch a moved directory' ' 33 git svn init --minimize-url -i thunk "$svnrepo"/thunk && 34 git svn fetch -i thunk && 35 test "$(git rev-parse --verify refs/remotes/thunk@2)" \ 36 = "$(git rev-parse --verify refs/remotes/thunk~1)" && 37 git cat-file blob refs/remotes/thunk:readme >actual && 38 test "$(sed -n -e "3p" actual)" = goodbye && 39 test -z "$(git config --get svn-remote.svn.fetch \ 40 "^trunk:refs/remotes/thunk@2$")" 41 ' 42 43 test_expect_success 'init and fetch from one svn-remote' ' 44 git config svn-remote.svn.url "$svnrepo" && 45 git config --add svn-remote.svn.fetch \ 46 trunk:refs/remotes/svn/trunk && 47 git config --add svn-remote.svn.fetch \ 48 thunk:refs/remotes/svn/thunk && 49 git svn fetch -i svn/thunk && 50 test "$(git rev-parse --verify refs/remotes/svn/trunk)" \ 51 = "$(git rev-parse --verify refs/remotes/svn/thunk~1)" && 52 git cat-file blob refs/remotes/svn/thunk:readme >actual && 53 test "$(sed -n -e "3p" actual)" = goodbye 54 ' 55 56 test_expect_success 'follow deleted parent' ' 57 (svn_cmd cp -m "resurrecting trunk as junk" \ 58 "$svnrepo"/trunk@2 "$svnrepo"/junk || 59 svn cp -m "resurrecting trunk as junk" \ 60 -r2 "$svnrepo"/trunk "$svnrepo"/junk) && 61 git config --add svn-remote.svn.fetch \ 62 junk:refs/remotes/svn/junk && 63 git svn fetch -i svn/thunk && 64 git svn fetch -i svn/junk && 65 test -z "$(git diff svn/junk svn/trunk)" && 66 test "$(git merge-base svn/junk svn/trunk)" \ 67 = "$(git rev-parse svn/trunk)" 68 ' 69 70 test_expect_success 'follow larger parent' ' 71 mkdir -p import/trunk/thunk/bump/thud && 72 echo hi > import/trunk/thunk/bump/thud/file && 73 svn import -m "import a larger parent" import "$svnrepo"/larger-parent && 74 svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger && 75 git svn init --minimize-url -i larger \ 76 "$svnrepo"/larger-parent/trunk/thunk/bump/thud && 77 git svn fetch -i larger && 78 git svn init --minimize-url -i larger-parent \ 79 "$svnrepo"/another-larger/trunk/thunk/bump/thud && 80 git svn fetch -i larger-parent && 81 git rev-parse --verify refs/remotes/larger && 82 git rev-parse --verify \ 83 refs/remotes/larger-parent && 84 test "$(git merge-base \ 85 refs/remotes/larger-parent \ 86 refs/remotes/larger)" = \ 87 "$(git rev-parse refs/remotes/larger)" 88 ' 89 90 test_expect_success 'follow higher-level parent' ' 91 svn mkdir -m "follow higher-level parent" "$svnrepo"/blob && 92 svn co "$svnrepo"/blob blob && 93 ( 94 cd blob && 95 echo hi > hi && 96 svn add hi && 97 svn commit -m "hihi" 98 ) && 99 svn mkdir -m "new glob at top level" "$svnrepo"/glob && 100 svn mv -m "move blob down a level" "$svnrepo"/blob "$svnrepo"/glob/blob && 101 git svn init --minimize-url -i blob "$svnrepo"/glob/blob && 102 git svn fetch -i blob 103 ' 104 105 test_expect_success 'follow deleted directory' ' 106 svn_cmd mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye && 107 svn_cmd rm -m "remove glob" "$svnrepo"/glob && 108 git svn init --minimize-url -i glob "$svnrepo"/glob && 109 git svn fetch -i glob && 110 test "$(git cat-file blob refs/remotes/glob:blob/bye)" = hi && 111 git ls-tree refs/remotes/glob >actual && 112 test_line_count = 1 actual 113 ' 114 115 # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn) 116 # in trunk/subversion/bindings/swig/perl 117 test_expect_success 'follow-parent avoids deleting relevant info' ' 118 mkdir -p import/trunk/subversion/bindings/swig/perl/t && 119 for i in a b c ; do \ 120 echo $i > import/trunk/subversion/bindings/swig/perl/$i.pm && 121 echo _$i > import/trunk/subversion/bindings/swig/perl/t/$i.t || return 1 122 done && 123 echo "bad delete test" > \ 124 import/trunk/subversion/bindings/swig/perl/t/larger-parent && 125 echo "bad delete test 2" > \ 126 import/trunk/subversion/bindings/swig/perl/another-larger && 127 ( 128 cd import && 129 svn import -m "r9270 test" . "$svnrepo"/r9270 130 ) && 131 svn_cmd co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 && 132 ( 133 cd r9270 && 134 svn mkdir native && 135 svn mv t native/t && 136 for i in a b c 137 do 138 svn mv $i.pm native/$i.pm || return 1 139 done && 140 echo z >>native/t/c.t && 141 poke native/t/c.t && 142 svn commit -m "reorg test" 143 ) && 144 git svn init --minimize-url -i r9270-t \ 145 "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t && 146 git svn fetch -i r9270-t && 147 test $(git rev-list r9270-t | wc -l) -eq 2 && 148 test "$(git ls-tree --name-only r9270-t~1)" = \ 149 "$(git ls-tree --name-only r9270-t)" 150 ' 151 152 test_expect_success "track initial change if it was only made to parent" ' 153 svn_cmd cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk && 154 git svn init --minimize-url -i r9270-d \ 155 "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t && 156 git svn fetch -i r9270-d && 157 test $(git rev-list r9270-d | wc -l) -eq 3 && 158 test "$(git ls-tree --name-only r9270-t)" = \ 159 "$(git ls-tree --name-only r9270-d)" && 160 test "$(git rev-parse r9270-t)" = \ 161 "$(git rev-parse r9270-d~1)" 162 ' 163 164 test_expect_success "follow-parent is atomic" ' 165 record_size=$(($(test_oid rawsz) + 4)) && 166 ( 167 cd wc && 168 svn_cmd up && 169 svn_cmd mkdir stunk && 170 echo "trunk stunk" > stunk/readme && 171 svn_cmd add stunk/readme && 172 svn_cmd ci -m "trunk stunk" && 173 echo "stunk like junk" >> stunk/readme && 174 svn_cmd ci -m "really stunk" && 175 echo "stink stank stunk" >> stunk/readme && 176 svn_cmd ci -m "even the grinch agrees" 177 ) && 178 svn_cmd copy -m "stunk flunked" "$svnrepo"/stunk "$svnrepo"/flunk && 179 { svn cp -m "early stunk flunked too" \ 180 "$svnrepo"/stunk@17 "$svnrepo"/flunked || 181 svn_cmd cp -m "early stunk flunked too" \ 182 -r17 "$svnrepo"/stunk "$svnrepo"/flunked; } && 183 git svn init --minimize-url -i stunk "$svnrepo"/stunk && 184 git svn fetch -i stunk && 185 git update-ref refs/remotes/flunk@18 refs/remotes/stunk~2 && 186 git update-ref -d refs/remotes/stunk && 187 git config --unset svn-remote.svn.fetch stunk && 188 mkdir -p "$GIT_DIR"/svn/refs/remotes/flunk@18 && 189 rev_map=$(cd "$GIT_DIR"/svn/refs/remotes/stunk && ls .rev_map*) && 190 dd if="$GIT_DIR"/svn/refs/remotes/stunk/$rev_map \ 191 of="$GIT_DIR"/svn/refs/remotes/flunk@18/$rev_map bs=$record_size count=1 && 192 rm -rf "$GIT_DIR"/svn/refs/remotes/stunk && 193 git svn init --minimize-url -i flunk "$svnrepo"/flunk && 194 git svn fetch -i flunk && 195 git svn init --minimize-url -i stunk "$svnrepo"/stunk && 196 git svn fetch -i stunk && 197 git svn init --minimize-url -i flunked "$svnrepo"/flunked && 198 git svn fetch -i flunked && 199 test "$(git rev-parse --verify refs/remotes/flunk@18)" \ 200 = "$(git rev-parse --verify refs/remotes/stunk)" && 201 test "$(git rev-parse --verify refs/remotes/flunk~1)" \ 202 = "$(git rev-parse --verify refs/remotes/stunk)" && 203 test "$(git rev-parse --verify refs/remotes/flunked~1)" \ 204 = "$(git rev-parse --verify refs/remotes/stunk~1)" 205 ' 206 207 test_expect_success "track multi-parent paths" ' 208 svn_cmd cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob && 209 git svn multi-fetch && 210 git cat-file commit refs/remotes/glob >actual && 211 grep "^parent " actual >actual2 && 212 test_line_count = 2 actual2 213 ' 214 215 test_expect_success "multi-fetch continues to work" " 216 git svn multi-fetch 217 " 218 219 test_expect_success "multi-fetch works off a 'clean' repository" ' 220 rm -rf "$GIT_DIR/svn" && 221 git for-each-ref --format="option no-deref%0adelete %(refname)" refs/remotes | 222 git update-ref --stdin && 223 git reflog expire --all --expire=all && 224 mkdir "$GIT_DIR/svn" && 225 git svn multi-fetch 226 ' 227 228 test_debug 'gitk --all &' 229 230 test_done