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/t9200-git-cvsexportcommit.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 / t9200-git-cvsexportcommit.sh` 344 lines · 10286 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) Robin Rosenberg 4 # 5 test_description='Test export of commits to CVS' 6 7 . ./test-lib.sh 8 9 if ! test_have_prereq PERL; then 10 skip_all='skipping git cvsexportcommit tests, perl not available' 11 test_done 12 fi 13 14 if ! cvs version >/dev/null 2>&1 15 then 16 skip_all='skipping git cvsexportcommit tests, cvs not found' 17 test_done 18 fi 19 20 if ! test_have_prereq NOT_ROOT; then 21 skip_all='When cvs is compiled with CVS_BADROOT commits as root fail' 22 test_done 23 fi 24 25 CVSROOT=$PWD/tmpcvsroot 26 CVSWORK=$PWD/cvswork 27 GIT_DIR=$PWD/.git 28 export CVSROOT CVSWORK GIT_DIR 29 30 rm -rf "$CVSROOT" "$CVSWORK" 31 32 if ! cvs init || ! test -d "$CVSROOT" || ! cvs -Q co -d "$CVSWORK" . 33 then 34 skip_all="cvs repository set-up fails" 35 test_done 36 fi 37 38 test_expect_success 'git setup' ' 39 echo >empty && 40 git add empty && 41 git commit -q -a -m Initial 42 ' 43 44 check_entries () { 45 # $1 == directory, $2 == expected 46 sed -ne '/^\//p' "$1/CVS/Entries" | sort | cut -d/ -f2,3,5 >actual 47 if test -z "$2" 48 then 49 test_must_be_empty actual 50 else 51 printf '%s\n' "$2" | tr '|' '\012' >expected 52 test_cmp expected actual 53 fi 54 } 55 56 test_expect_success 'New file' ' 57 mkdir A B C D E F && 58 echo hello1 >A/newfile1.txt && 59 echo hello2 >B/newfile2.txt && 60 cp "$TEST_DIRECTORY"/test-binary-1.png C/newfile3.png && 61 cp "$TEST_DIRECTORY"/test-binary-1.png D/newfile4.png && 62 git add A/newfile1.txt && 63 git add B/newfile2.txt && 64 git add C/newfile3.png && 65 git add D/newfile4.png && 66 git commit -a -m "Test: New file" && 67 id=$(git rev-list --max-count=1 HEAD) && 68 (cd "$CVSWORK" && 69 git cvsexportcommit -c $id && 70 check_entries A "newfile1.txt/1.1/" && 71 check_entries B "newfile2.txt/1.1/" && 72 check_entries C "newfile3.png/1.1/-kb" && 73 check_entries D "newfile4.png/1.1/-kb" && 74 test_cmp A/newfile1.txt ../A/newfile1.txt && 75 test_cmp B/newfile2.txt ../B/newfile2.txt && 76 test_cmp C/newfile3.png ../C/newfile3.png && 77 test_cmp D/newfile4.png ../D/newfile4.png 78 ) 79 ' 80 81 test_expect_success 'Remove two files, add two and update two' ' 82 echo Hello1 >>A/newfile1.txt && 83 rm -f B/newfile2.txt && 84 rm -f C/newfile3.png && 85 echo Hello5 >E/newfile5.txt && 86 cp "$TEST_DIRECTORY"/test-binary-2.png D/newfile4.png && 87 cp "$TEST_DIRECTORY"/test-binary-1.png F/newfile6.png && 88 git add E/newfile5.txt && 89 git add F/newfile6.png && 90 git commit -a -m "Test: Remove, add and update" && 91 id=$(git rev-list --max-count=1 HEAD) && 92 (cd "$CVSWORK" && 93 git cvsexportcommit -c $id && 94 check_entries A "newfile1.txt/1.2/" && 95 check_entries B "" && 96 check_entries C "" && 97 check_entries D "newfile4.png/1.2/-kb" && 98 check_entries E "newfile5.txt/1.1/" && 99 check_entries F "newfile6.png/1.1/-kb" && 100 test_cmp A/newfile1.txt ../A/newfile1.txt && 101 test_cmp D/newfile4.png ../D/newfile4.png && 102 test_cmp E/newfile5.txt ../E/newfile5.txt && 103 test_cmp F/newfile6.png ../F/newfile6.png 104 ) 105 ' 106 107 # Should fail (but only on the git cvsexportcommit stage) 108 test_expect_success \ 109 'Fail to change binary more than one generation old' \ 110 'cat F/newfile6.png >>D/newfile4.png && 111 git commit -a -m "generatiion 1" && 112 cat F/newfile6.png >>D/newfile4.png && 113 git commit -a -m "generation 2" && 114 id=$(git rev-list --max-count=1 HEAD) && 115 (cd "$CVSWORK" && 116 test_must_fail git cvsexportcommit -c $id 117 )' 118 119 #test_expect_success \ 120 # 'Fail to remove binary file more than one generation old' \ 121 # 'git reset --hard HEAD^ && 122 # cat F/newfile6.png >>D/newfile4.png && 123 # git commit -a -m "generation 2 (again)" && 124 # rm -f D/newfile4.png && 125 # git commit -a -m "generation 3" && 126 # id=$(git rev-list --max-count=1 HEAD) && 127 # (cd "$CVSWORK" && 128 # test_must_fail git cvsexportcommit -c $id 129 # )' 130 131 # We reuse the state from two tests back here 132 133 # This test is here because a patch for only binary files will 134 # fail with gnu patch, so cvsexportcommit must handle that. 135 test_expect_success 'Remove only binary files' ' 136 git reset --hard HEAD^^ && 137 rm -f D/newfile4.png && 138 git commit -a -m "test: remove only a binary file" && 139 id=$(git rev-list --max-count=1 HEAD) && 140 (cd "$CVSWORK" && 141 git cvsexportcommit -c $id && 142 check_entries A "newfile1.txt/1.2/" && 143 check_entries B "" && 144 check_entries C "" && 145 check_entries D "" && 146 check_entries E "newfile5.txt/1.1/" && 147 check_entries F "newfile6.png/1.1/-kb" && 148 test_cmp A/newfile1.txt ../A/newfile1.txt && 149 test_cmp E/newfile5.txt ../E/newfile5.txt && 150 test_cmp F/newfile6.png ../F/newfile6.png 151 ) 152 ' 153 154 test_expect_success 'Remove only a text file' ' 155 rm -f A/newfile1.txt && 156 git commit -a -m "test: remove only a binary file" && 157 id=$(git rev-list --max-count=1 HEAD) && 158 (cd "$CVSWORK" && 159 git cvsexportcommit -c $id && 160 check_entries A "" && 161 check_entries B "" && 162 check_entries C "" && 163 check_entries D "" && 164 check_entries E "newfile5.txt/1.1/" && 165 check_entries F "newfile6.png/1.1/-kb" && 166 test_cmp E/newfile5.txt ../E/newfile5.txt && 167 test_cmp F/newfile6.png ../F/newfile6.png 168 ) 169 ' 170 171 test_expect_success 'New file with spaces in file name' ' 172 mkdir "G g" && 173 echo ok then >"G g/with spaces.txt" && 174 git add "G g/with spaces.txt" && \ 175 cp "$TEST_DIRECTORY"/test-binary-1.png "G g/with spaces.png" && \ 176 git add "G g/with spaces.png" && 177 git commit -a -m "With spaces" && 178 id=$(git rev-list --max-count=1 HEAD) && 179 (cd "$CVSWORK" && 180 git cvsexportcommit -c $id && 181 check_entries "G g" "with spaces.png/1.1/-kb|with spaces.txt/1.1/" 182 ) 183 ' 184 185 test_expect_success 'Update file with spaces in file name' ' 186 echo Ok then >>"G g/with spaces.txt" && 187 cat "$TEST_DIRECTORY"/test-binary-1.png >>"G g/with spaces.png" && \ 188 git add "G g/with spaces.png" && 189 git commit -a -m "Update with spaces" && 190 id=$(git rev-list --max-count=1 HEAD) && 191 (cd "$CVSWORK" && 192 git cvsexportcommit -c $id && 193 check_entries "G g" "with spaces.png/1.2/-kb|with spaces.txt/1.2/" 194 ) 195 ' 196 197 # Some filesystems mangle pathnames with UTF-8 characters -- 198 # check and skip 199 if p="Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" && 200 mkdir -p "tst/$p" && 201 date >"tst/$p/day" && 202 found=$(find tst -type f -print) && 203 test "z$found" = "ztst/$p/day" && 204 rm -fr tst 205 then 206 207 # This test contains UTF-8 characters 208 test_expect_success !MINGW 'File with non-ascii file name' ' 209 mkdir -p Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö && 210 echo Foo >Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt && 211 git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt && 212 cp "$TEST_DIRECTORY"/test-binary-1.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png && 213 git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png && 214 git commit -a -m "Går det så går det" && \ 215 id=$(git rev-list --max-count=1 HEAD) && 216 (cd "$CVSWORK" && 217 git cvsexportcommit -v -c $id && 218 check_entries \ 219 "Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" \ 220 "gårdetsågårdet.png/1.1/-kb|gårdetsågårdet.txt/1.1/" 221 ) 222 ' 223 224 fi 225 226 rm -fr tst 227 228 test_expect_success 'Mismatching patch should fail' ' 229 date >>"E/newfile5.txt" && 230 git add "E/newfile5.txt" && 231 git commit -a -m "Update one" && 232 date >>"E/newfile5.txt" && 233 git add "E/newfile5.txt" && 234 git commit -a -m "Update two" && 235 id=$(git rev-list --max-count=1 HEAD) && 236 (cd "$CVSWORK" && 237 test_must_fail git cvsexportcommit -c $id 238 ) 239 ' 240 241 test_expect_success FILEMODE 'Retain execute bit' ' 242 mkdir G && 243 echo executeon >G/on && 244 chmod +x G/on && 245 echo executeoff >G/off && 246 git add G/on && 247 git add G/off && 248 git commit -a -m "Execute test" && 249 (cd "$CVSWORK" && 250 git cvsexportcommit -c HEAD && 251 test -x G/on && 252 ! test -x G/off 253 ) 254 ' 255 256 test_expect_success '-w option should work with relative GIT_DIR' ' 257 mkdir W && 258 echo foobar >W/file1.txt && 259 echo bazzle >W/file2.txt && 260 git add W/file1.txt && 261 git add W/file2.txt && 262 git commit -m "More updates" && 263 id=$(git rev-list --max-count=1 HEAD) && 264 (cd "$GIT_DIR" && 265 GIT_DIR=. git cvsexportcommit -w "$CVSWORK" -c $id && 266 check_entries "$CVSWORK/W" "file1.txt/1.1/|file2.txt/1.1/" && 267 test_cmp "$CVSWORK/W/file1.txt" ../W/file1.txt && 268 test_cmp "$CVSWORK/W/file2.txt" ../W/file2.txt 269 ) 270 ' 271 272 test_expect_success 'check files before directories' ' 273 274 echo Notes > release-notes && 275 git add release-notes && 276 git commit -m "Add release notes" release-notes && 277 id=$(git rev-parse HEAD) && 278 git cvsexportcommit -w "$CVSWORK" -c $id && 279 280 echo new > DS && 281 echo new > E/DS && 282 echo modified > release-notes && 283 git add DS E/DS release-notes && 284 git commit -m "Add two files with the same basename" && 285 id=$(git rev-parse HEAD) && 286 git cvsexportcommit -w "$CVSWORK" -c $id && 287 check_entries "$CVSWORK/E" "DS/1.1/|newfile5.txt/1.1/" && 288 check_entries "$CVSWORK" "DS/1.1/|release-notes/1.2/" && 289 test_cmp "$CVSWORK/DS" DS && 290 test_cmp "$CVSWORK/E/DS" E/DS && 291 test_cmp "$CVSWORK/release-notes" release-notes 292 293 ' 294 295 test_expect_success 're-commit a removed filename which remains in CVS attic' ' 296 (cd "$CVSWORK" && 297 echo >attic_gremlin && 298 cvs -Q add attic_gremlin && 299 cvs -Q ci -m "added attic_gremlin" && 300 rm attic_gremlin && 301 cvs -Q rm attic_gremlin && 302 cvs -Q ci -m "removed attic_gremlin") && 303 304 echo > attic_gremlin && 305 git add attic_gremlin && 306 git commit -m "Added attic_gremlin" && 307 git cvsexportcommit -w "$CVSWORK" -c HEAD && 308 (cd "$CVSWORK" && cvs -Q update -d) && 309 test_path_is_file "$CVSWORK/attic_gremlin" 310 ' 311 312 # the state of the CVS sandbox may be indeterminate for ' space' 313 # after this test on some platforms / with some versions of CVS 314 # consider adding new tests above this point 315 test_expect_success 'commit a file with leading spaces in the name' ' 316 317 echo space > " space" && 318 git add " space" && 319 git commit -m "Add a file with a leading space" && 320 id=$(git rev-parse HEAD) && 321 git cvsexportcommit -w "$CVSWORK" -c $id && 322 check_entries "$CVSWORK" " space/1.1/|DS/1.1/|attic_gremlin/1.3/|release-notes/1.2/" && 323 test_cmp "$CVSWORK/ space" " space" 324 325 ' 326 327 test_expect_success 'use the same checkout for Git and CVS' ' 328 329 (mkdir shared && 330 cd shared && 331 sane_unset GIT_DIR && 332 cvs co . && 333 git init && 334 git add " space" && 335 git commit -m "fake initial commit" && 336 echo Hello >> " space" && 337 git commit -m "Another change" " space" && 338 git cvsexportcommit -W -p -u -c HEAD && 339 test_grep Hello " space" && 340 git diff-files) 341 342 ' 343 344 test_done