Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2007 Johannes E. Schindelin |
| 4 | # |
| 5 | |
Nanako Shiraishi | eaa2a6f | 2008-09-10 06:25:25 +0900 | [diff] [blame] | 6 | test_description='git fast-export' |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 7 | . ./test-lib.sh |
| 8 | |
| 9 | test_expect_success 'setup' ' |
| 10 | |
Elijah Newren | ebeec7d | 2009-03-25 17:53:23 -0600 | [diff] [blame] | 11 | echo break it > file0 && |
| 12 | git add file0 && |
| 13 | test_tick && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 14 | echo Wohlauf > file && |
| 15 | git add file && |
| 16 | test_tick && |
| 17 | git commit -m initial && |
| 18 | echo die Luft > file && |
| 19 | echo geht frisch > file2 && |
| 20 | git add file file2 && |
| 21 | test_tick && |
| 22 | git commit -m second && |
| 23 | echo und > file2 && |
| 24 | test_tick && |
| 25 | git commit -m third file2 && |
| 26 | test_tick && |
| 27 | git tag rein && |
| 28 | git checkout -b wer HEAD^ && |
Jonathan Nieder | a48fcd8 | 2010-10-30 20:46:54 -0500 | [diff] [blame] | 29 | echo lange > file2 && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 30 | test_tick && |
| 31 | git commit -m sitzt file2 && |
| 32 | test_tick && |
| 33 | git tag -a -m valentin muss && |
| 34 | git merge -s ours master |
| 35 | |
| 36 | ' |
| 37 | |
| 38 | test_expect_success 'fast-export | fast-import' ' |
| 39 | |
| 40 | MASTER=$(git rev-parse --verify master) && |
| 41 | REIN=$(git rev-parse --verify rein) && |
| 42 | WER=$(git rev-parse --verify wer) && |
| 43 | MUSS=$(git rev-parse --verify muss) && |
| 44 | mkdir new && |
| 45 | git --git-dir=new/.git init && |
| 46 | git fast-export --all | |
| 47 | (cd new && |
| 48 | git fast-import && |
| 49 | test $MASTER = $(git rev-parse --verify refs/heads/master) && |
| 50 | test $REIN = $(git rev-parse --verify refs/tags/rein) && |
| 51 | test $WER = $(git rev-parse --verify refs/heads/wer) && |
| 52 | test $MUSS = $(git rev-parse --verify refs/tags/muss)) |
| 53 | |
| 54 | ' |
| 55 | |
| 56 | test_expect_success 'fast-export master~2..master' ' |
| 57 | |
| 58 | git fast-export master~2..master | |
| 59 | sed "s/master/partial/" | |
| 60 | (cd new && |
| 61 | git fast-import && |
| 62 | test $MASTER != $(git rev-parse --verify refs/heads/partial) && |
Elijah Newren | ebeec7d | 2009-03-25 17:53:23 -0600 | [diff] [blame] | 63 | git diff --exit-code master partial && |
| 64 | git diff --exit-code master^ partial^ && |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 65 | test_must_fail git rev-parse partial~2) |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 66 | |
| 67 | ' |
| 68 | |
| 69 | test_expect_success 'iso-8859-1' ' |
| 70 | |
Brandon Casey | e0d44c5 | 2009-05-18 18:44:44 -0500 | [diff] [blame] | 71 | git config i18n.commitencoding ISO8859-1 && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 72 | # use author and committer name in ISO-8859-1 to match it. |
Junio C Hamano | bfdbee9 | 2008-08-08 02:26:28 -0700 | [diff] [blame] | 73 | . "$TEST_DIRECTORY"/t3901-8859-1.txt && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 74 | test_tick && |
| 75 | echo rosten >file && |
| 76 | git commit -s -m den file && |
| 77 | git fast-export wer^..wer | |
| 78 | sed "s/wer/i18n/" | |
| 79 | (cd new && |
| 80 | git fast-import && |
| 81 | git cat-file commit i18n | grep "Áéí óú") |
| 82 | |
| 83 | ' |
Pieter de Bie | df6a7ff | 2008-06-11 13:17:04 +0200 | [diff] [blame] | 84 | test_expect_success 'import/export-marks' ' |
| 85 | |
| 86 | git checkout -b marks master && |
| 87 | git fast-export --export-marks=tmp-marks HEAD && |
| 88 | test -s tmp-marks && |
Stefano Lattarini | 3fb0459 | 2012-04-11 13:24:01 +0200 | [diff] [blame] | 89 | test_line_count = 3 tmp-marks && |
Pieter de Bie | df6a7ff | 2008-06-11 13:17:04 +0200 | [diff] [blame] | 90 | test $( |
| 91 | git fast-export --import-marks=tmp-marks\ |
| 92 | --export-marks=tmp-marks HEAD | |
| 93 | grep ^commit | |
| 94 | wc -l) \ |
| 95 | -eq 0 && |
| 96 | echo change > file && |
| 97 | git commit -m "last commit" file && |
| 98 | test $( |
| 99 | git fast-export --import-marks=tmp-marks \ |
| 100 | --export-marks=tmp-marks HEAD | |
| 101 | grep ^commit\ | |
| 102 | wc -l) \ |
| 103 | -eq 1 && |
Stefano Lattarini | 3fb0459 | 2012-04-11 13:24:01 +0200 | [diff] [blame] | 104 | test_line_count = 4 tmp-marks |
Pieter de Bie | df6a7ff | 2008-06-11 13:17:04 +0200 | [diff] [blame] | 105 | |
| 106 | ' |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 107 | |
| 108 | cat > signed-tag-import << EOF |
| 109 | tag sign-your-name |
| 110 | from $(git rev-parse HEAD) |
| 111 | tagger C O Mitter <committer@example.com> 1112911993 -0700 |
| 112 | data 210 |
| 113 | A message for a sign |
| 114 | -----BEGIN PGP SIGNATURE----- |
| 115 | Version: GnuPG v1.4.5 (GNU/Linux) |
| 116 | |
| 117 | fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign |
| 118 | aturefakedsignaturefake= |
| 119 | =/59v |
| 120 | -----END PGP SIGNATURE----- |
| 121 | EOF |
| 122 | |
| 123 | test_expect_success 'set up faked signed tag' ' |
| 124 | |
| 125 | cat signed-tag-import | git fast-import |
| 126 | |
| 127 | ' |
| 128 | |
| 129 | test_expect_success 'signed-tags=abort' ' |
| 130 | |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 131 | test_must_fail git fast-export --signed-tags=abort sign-your-name |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 132 | |
| 133 | ' |
| 134 | |
Johannes Schindelin | ee4bc37 | 2007-12-03 22:44:39 +0000 | [diff] [blame] | 135 | test_expect_success 'signed-tags=verbatim' ' |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 136 | |
Johannes Schindelin | ee4bc37 | 2007-12-03 22:44:39 +0000 | [diff] [blame] | 137 | git fast-export --signed-tags=verbatim sign-your-name > output && |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 138 | grep PGP output |
| 139 | |
| 140 | ' |
| 141 | |
| 142 | test_expect_success 'signed-tags=strip' ' |
| 143 | |
| 144 | git fast-export --signed-tags=strip sign-your-name > output && |
| 145 | ! grep PGP output |
| 146 | |
| 147 | ' |
| 148 | |
John Keeping | cd16c59 | 2013-04-14 11:57:06 +0100 | [diff] [blame] | 149 | test_expect_success 'signed-tags=warn-strip' ' |
| 150 | git fast-export --signed-tags=warn-strip sign-your-name >output 2>err && |
| 151 | ! grep PGP output && |
| 152 | test -s err |
| 153 | ' |
| 154 | |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 155 | test_expect_success 'setup submodule' ' |
| 156 | |
| 157 | git checkout -f master && |
| 158 | mkdir sub && |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 159 | ( |
| 160 | cd sub && |
| 161 | git init && |
| 162 | echo test file > file && |
| 163 | git add file && |
| 164 | git commit -m sub_initial |
| 165 | ) && |
Elia Pinto | c7b793a | 2016-01-12 11:49:36 +0000 | [diff] [blame] | 166 | git submodule add "$(pwd)/sub" sub && |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 167 | git commit -m initial && |
| 168 | test_tick && |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 169 | ( |
| 170 | cd sub && |
| 171 | echo more data >> file && |
| 172 | git add file && |
| 173 | git commit -m sub_second |
| 174 | ) && |
Alexander Gavrilov | 03db452 | 2008-07-19 16:21:24 +0400 | [diff] [blame] | 175 | git add sub && |
| 176 | git commit -m second |
| 177 | |
| 178 | ' |
| 179 | |
| 180 | test_expect_success 'submodule fast-export | fast-import' ' |
| 181 | |
| 182 | SUBENT1=$(git ls-tree master^ sub) && |
| 183 | SUBENT2=$(git ls-tree master sub) && |
| 184 | rm -rf new && |
| 185 | mkdir new && |
| 186 | git --git-dir=new/.git init && |
| 187 | git fast-export --signed-tags=strip --all | |
| 188 | (cd new && |
| 189 | git fast-import && |
| 190 | test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" && |
| 191 | test "$SUBENT2" = "$(git ls-tree refs/heads/master sub)" && |
| 192 | git checkout master && |
| 193 | git submodule init && |
| 194 | git submodule update && |
| 195 | cmp sub/file ../sub/file) |
| 196 | |
| 197 | ' |
| 198 | |
Junio C Hamano | 91e80b9 | 2009-02-18 11:17:27 -0800 | [diff] [blame] | 199 | GIT_AUTHOR_NAME='A U Thor'; export GIT_AUTHOR_NAME |
| 200 | GIT_COMMITTER_NAME='C O Mitter'; export GIT_COMMITTER_NAME |
Alexander Gavrilov | ae7c5dc | 2008-07-27 00:52:54 +0400 | [diff] [blame] | 201 | |
| 202 | test_expect_success 'setup copies' ' |
| 203 | |
| 204 | git config --unset i18n.commitencoding && |
| 205 | git checkout -b copy rein && |
| 206 | git mv file file3 && |
| 207 | git commit -m move1 && |
| 208 | test_tick && |
| 209 | cp file2 file4 && |
| 210 | git add file4 && |
| 211 | git mv file2 file5 && |
| 212 | git commit -m copy1 && |
| 213 | test_tick && |
| 214 | cp file3 file6 && |
| 215 | git add file6 && |
| 216 | git commit -m copy2 && |
| 217 | test_tick && |
| 218 | echo more text >> file6 && |
| 219 | echo even more text >> file6 && |
| 220 | git add file6 && |
| 221 | git commit -m modify && |
| 222 | test_tick && |
| 223 | cp file6 file7 && |
| 224 | echo test >> file7 && |
| 225 | git add file7 && |
| 226 | git commit -m copy_modify |
| 227 | |
| 228 | ' |
| 229 | |
| 230 | test_expect_success 'fast-export -C -C | fast-import' ' |
| 231 | |
| 232 | ENTRY=$(git rev-parse --verify copy) && |
| 233 | rm -rf new && |
| 234 | mkdir new && |
| 235 | git --git-dir=new/.git init && |
| 236 | git fast-export -C -C --signed-tags=strip --all > output && |
Jeff King | 6280dfd | 2011-08-05 16:36:22 -0600 | [diff] [blame] | 237 | grep "^C file6 file7\$" output && |
Alexander Gavrilov | ae7c5dc | 2008-07-27 00:52:54 +0400 | [diff] [blame] | 238 | cat output | |
| 239 | (cd new && |
| 240 | git fast-import && |
| 241 | test $ENTRY = $(git rev-parse --verify refs/heads/copy)) |
| 242 | |
| 243 | ' |
| 244 | |
Johannes Schindelin | 2075ffb | 2008-11-23 12:55:54 +0100 | [diff] [blame] | 245 | test_expect_success 'fast-export | fast-import when master is tagged' ' |
Miklos Vajna | 283b953 | 2008-11-22 19:22:48 +0100 | [diff] [blame] | 246 | |
| 247 | git tag -m msg last && |
| 248 | git fast-export -C -C --signed-tags=strip --all > output && |
| 249 | test $(grep -c "^tag " output) = 3 |
| 250 | |
| 251 | ' |
| 252 | |
Johannes Schindelin | 4e46a8d | 2008-12-20 01:00:27 +0100 | [diff] [blame] | 253 | cat > tag-content << EOF |
| 254 | object $(git rev-parse HEAD) |
| 255 | type commit |
| 256 | tag rosten |
| 257 | EOF |
| 258 | |
| 259 | test_expect_success 'cope with tagger-less tags' ' |
| 260 | |
| 261 | TAG=$(git hash-object -t tag -w tag-content) && |
| 262 | git update-ref refs/tags/sonnenschein $TAG && |
| 263 | git fast-export -C -C --signed-tags=strip --all > output && |
| 264 | test $(grep -c "^tag " output) = 4 && |
| 265 | ! grep "Unspecified Tagger" output && |
| 266 | git fast-export -C -C --signed-tags=strip --all \ |
| 267 | --fake-missing-tagger > output && |
| 268 | test $(grep -c "^tag " output) = 4 && |
| 269 | grep "Unspecified Tagger" output |
| 270 | |
| 271 | ' |
| 272 | |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 273 | test_expect_success 'setup for limiting exports by PATH' ' |
| 274 | mkdir limit-by-paths && |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 275 | ( |
| 276 | cd limit-by-paths && |
| 277 | git init && |
| 278 | echo hi > there && |
| 279 | git add there && |
| 280 | git commit -m "First file" && |
| 281 | echo foo > bar && |
| 282 | git add bar && |
| 283 | git commit -m "Second file" && |
| 284 | git tag -a -m msg mytag && |
| 285 | echo morefoo >> bar && |
| 286 | git add bar && |
| 287 | git commit -m "Change to second file" |
| 288 | ) |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 289 | ' |
| 290 | |
| 291 | cat > limit-by-paths/expected << EOF |
| 292 | blob |
| 293 | mark :1 |
| 294 | data 3 |
| 295 | hi |
| 296 | |
| 297 | reset refs/tags/mytag |
| 298 | commit refs/tags/mytag |
| 299 | mark :2 |
| 300 | author A U Thor <author@example.com> 1112912713 -0700 |
| 301 | committer C O Mitter <committer@example.com> 1112912713 -0700 |
| 302 | data 11 |
| 303 | First file |
| 304 | M 100644 :1 there |
| 305 | |
| 306 | EOF |
| 307 | |
| 308 | test_expect_success 'dropping tag of filtered out object' ' |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 309 | ( |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 310 | cd limit-by-paths && |
| 311 | git fast-export --tag-of-filtered-object=drop mytag -- there > output && |
Felipe Contreras | 9ff10fc | 2012-11-28 23:11:09 +0100 | [diff] [blame] | 312 | test_cmp expected output |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 313 | ) |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 314 | ' |
| 315 | |
| 316 | cat >> limit-by-paths/expected << EOF |
| 317 | tag mytag |
| 318 | from :2 |
| 319 | tagger C O Mitter <committer@example.com> 1112912713 -0700 |
| 320 | data 4 |
| 321 | msg |
| 322 | |
| 323 | EOF |
| 324 | |
| 325 | test_expect_success 'rewriting tag of filtered out object' ' |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 326 | ( |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 327 | cd limit-by-paths && |
| 328 | git fast-export --tag-of-filtered-object=rewrite mytag -- there > output && |
Felipe Contreras | 9ff10fc | 2012-11-28 23:11:09 +0100 | [diff] [blame] | 329 | test_cmp expected output |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 330 | ) |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 331 | ' |
| 332 | |
| 333 | cat > limit-by-paths/expected << EOF |
| 334 | blob |
| 335 | mark :1 |
| 336 | data 4 |
| 337 | foo |
| 338 | |
| 339 | blob |
| 340 | mark :2 |
| 341 | data 3 |
| 342 | hi |
| 343 | |
| 344 | reset refs/heads/master |
| 345 | commit refs/heads/master |
| 346 | mark :3 |
| 347 | author A U Thor <author@example.com> 1112912713 -0700 |
| 348 | committer C O Mitter <committer@example.com> 1112912713 -0700 |
| 349 | data 12 |
| 350 | Second file |
| 351 | M 100644 :1 bar |
| 352 | M 100644 :2 there |
| 353 | |
| 354 | EOF |
| 355 | |
| 356 | test_expect_failure 'no exact-ref revisions included' ' |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 357 | ( |
| 358 | cd limit-by-paths && |
| 359 | git fast-export master~2..master~1 > output && |
Felipe Contreras | 9ff10fc | 2012-11-28 23:11:09 +0100 | [diff] [blame] | 360 | test_cmp expected output |
Junio C Hamano | 4c367c6 | 2010-03-28 17:42:11 -0700 | [diff] [blame] | 361 | ) |
Elijah Newren | 25e0ca5 | 2009-06-25 22:48:32 -0600 | [diff] [blame] | 362 | ' |
| 363 | |
Elijah Newren | 4087a02 | 2010-07-17 11:00:50 -0600 | [diff] [blame] | 364 | test_expect_success 'path limiting with import-marks does not lose unmodified files' ' |
| 365 | git checkout -b simple marks~2 && |
| 366 | git fast-export --export-marks=marks simple -- file > /dev/null && |
| 367 | echo more content >> file && |
| 368 | test_tick && |
| 369 | git commit -mnext file && |
| 370 | git fast-export --import-marks=marks simple -- file file0 | grep file0 |
| 371 | ' |
| 372 | |
Elijah Newren | 7f40ab0 | 2010-07-17 11:00:51 -0600 | [diff] [blame] | 373 | test_expect_success 'full-tree re-shows unmodified files' ' |
| 374 | git checkout -f simple && |
| 375 | test $(git fast-export --full-tree simple | grep -c file0) -eq 3 |
| 376 | ' |
| 377 | |
Erik Faye-Lund | 41a5c70 | 2009-03-23 12:53:06 +0000 | [diff] [blame] | 378 | test_expect_success 'set-up a few more tags for tag export tests' ' |
| 379 | git checkout -f master && |
Elia Pinto | c7b793a | 2016-01-12 11:49:36 +0000 | [diff] [blame] | 380 | HEAD_TREE=$(git show -s --pretty=raw HEAD | grep tree | sed "s/tree //") && |
Erik Faye-Lund | 41a5c70 | 2009-03-23 12:53:06 +0000 | [diff] [blame] | 381 | git tag tree_tag -m "tagging a tree" $HEAD_TREE && |
| 382 | git tag -a tree_tag-obj -m "tagging a tree" $HEAD_TREE && |
| 383 | git tag tag-obj_tag -m "tagging a tag" tree_tag-obj && |
| 384 | git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj |
| 385 | ' |
| 386 | |
Elijah Newren | 02c48cd | 2009-06-25 22:48:28 -0600 | [diff] [blame] | 387 | test_expect_success 'tree_tag' ' |
| 388 | mkdir result && |
| 389 | (cd result && git init) && |
| 390 | git fast-export tree_tag > fe-stream && |
| 391 | (cd result && git fast-import < ../fe-stream) |
| 392 | ' |
| 393 | |
Erik Faye-Lund | 41a5c70 | 2009-03-23 12:53:06 +0000 | [diff] [blame] | 394 | # NEEDSWORK: not just check return status, but validate the output |
Erik Faye-Lund | c0582c5 | 2009-03-23 12:53:08 +0000 | [diff] [blame] | 395 | test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj' |
Erik Faye-Lund | 1982467 | 2009-03-23 12:53:09 +0000 | [diff] [blame] | 396 | test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' |
| 397 | test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' |
Erik Faye-Lund | 41a5c70 | 2009-03-23 12:53:06 +0000 | [diff] [blame] | 398 | |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 399 | test_expect_success 'directory becomes symlink' ' |
Elijah Newren | f15652d | 2010-07-09 07:10:51 -0600 | [diff] [blame] | 400 | git init dirtosymlink && |
| 401 | git init result && |
| 402 | ( |
| 403 | cd dirtosymlink && |
| 404 | mkdir foo && |
| 405 | mkdir bar && |
| 406 | echo hello > foo/world && |
| 407 | echo hello > bar/world && |
| 408 | git add foo/world bar/world && |
| 409 | git commit -q -mone && |
| 410 | git rm -r foo && |
Johannes Sixt | 889c6f0 | 2013-06-07 22:53:28 +0200 | [diff] [blame] | 411 | test_ln_s_add bar foo && |
Elijah Newren | f15652d | 2010-07-09 07:10:51 -0600 | [diff] [blame] | 412 | git commit -q -mtwo |
| 413 | ) && |
| 414 | ( |
| 415 | cd dirtosymlink && |
| 416 | git fast-export master -- foo | |
| 417 | (cd ../result && git fast-import --quiet) |
| 418 | ) && |
| 419 | (cd result && git show master:foo) |
| 420 | ' |
| 421 | |
Jeff King | 6280dfd | 2011-08-05 16:36:22 -0600 | [diff] [blame] | 422 | test_expect_success 'fast-export quotes pathnames' ' |
| 423 | git init crazy-paths && |
| 424 | (cd crazy-paths && |
Elia Pinto | c7b793a | 2016-01-12 11:49:36 +0000 | [diff] [blame] | 425 | blob=$(echo foo | git hash-object -w --stdin) && |
Jeff King | 6280dfd | 2011-08-05 16:36:22 -0600 | [diff] [blame] | 426 | git update-index --add \ |
| 427 | --cacheinfo 100644 $blob "$(printf "path with\\nnewline")" \ |
| 428 | --cacheinfo 100644 $blob "path with \"quote\"" \ |
| 429 | --cacheinfo 100644 $blob "path with \\backslash" \ |
| 430 | --cacheinfo 100644 $blob "path with space" && |
| 431 | git commit -m addition && |
Jeff King | 94221d2 | 2013-10-28 21:23:03 -0400 | [diff] [blame] | 432 | git ls-files -z -s | perl -0pe "s{\\t}{$&subdir/}" >index && |
Jeff King | 6280dfd | 2011-08-05 16:36:22 -0600 | [diff] [blame] | 433 | git read-tree --empty && |
| 434 | git update-index -z --index-info <index && |
| 435 | git commit -m rename && |
| 436 | git read-tree --empty && |
| 437 | git commit -m deletion && |
Jay Soffian | ff59f6d | 2012-06-27 17:58:01 -0400 | [diff] [blame] | 438 | git fast-export -M HEAD >export.out && |
Jeff King | 6280dfd | 2011-08-05 16:36:22 -0600 | [diff] [blame] | 439 | git rev-list HEAD >expect && |
| 440 | git init result && |
| 441 | cd result && |
| 442 | git fast-import <../export.out && |
| 443 | git rev-list HEAD >actual && |
| 444 | test_cmp ../expect actual |
| 445 | ) |
| 446 | ' |
| 447 | |
Felipe Contreras | 5d3698f | 2012-11-24 04:17:01 +0100 | [diff] [blame] | 448 | test_expect_success 'test bidirectionality' ' |
| 449 | >marks-cur && |
| 450 | >marks-new && |
| 451 | git init marks-test && |
| 452 | git fast-export --export-marks=marks-cur --import-marks=marks-cur --branches | \ |
| 453 | git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks=marks-new && |
| 454 | (cd marks-test && |
| 455 | git reset --hard && |
| 456 | echo Wohlauf > file && |
| 457 | git commit -a -m "back in time") && |
| 458 | git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks=marks-new --branches | \ |
| 459 | git fast-import --export-marks=marks-cur --import-marks=marks-cur |
| 460 | ' |
| 461 | |
Felipe Contreras | 49266e8 | 2012-11-28 23:23:59 +0100 | [diff] [blame] | 462 | cat > expected << EOF |
| 463 | blob |
| 464 | mark :13 |
| 465 | data 5 |
| 466 | bump |
| 467 | |
| 468 | commit refs/heads/master |
| 469 | mark :14 |
| 470 | author A U Thor <author@example.com> 1112912773 -0700 |
| 471 | committer C O Mitter <committer@example.com> 1112912773 -0700 |
| 472 | data 5 |
| 473 | bump |
| 474 | from :12 |
| 475 | M 100644 :13 file |
| 476 | |
| 477 | EOF |
| 478 | |
| 479 | test_expect_success 'avoid uninteresting refs' ' |
| 480 | > tmp-marks && |
| 481 | git fast-export --import-marks=tmp-marks \ |
| 482 | --export-marks=tmp-marks master > /dev/null && |
| 483 | git tag v1.0 && |
| 484 | git branch uninteresting && |
| 485 | echo bump > file && |
| 486 | git commit -a -m bump && |
| 487 | git fast-export --import-marks=tmp-marks \ |
| 488 | --export-marks=tmp-marks ^uninteresting ^v1.0 master > actual && |
| 489 | test_cmp expected actual |
| 490 | ' |
| 491 | |
Felipe Contreras | f28e7c9 | 2012-11-28 23:24:00 +0100 | [diff] [blame] | 492 | cat > expected << EOF |
| 493 | reset refs/heads/master |
| 494 | from :14 |
| 495 | |
| 496 | EOF |
| 497 | |
| 498 | test_expect_success 'refs are updated even if no commits need to be exported' ' |
| 499 | > tmp-marks && |
| 500 | git fast-export --import-marks=tmp-marks \ |
| 501 | --export-marks=tmp-marks master > /dev/null && |
| 502 | git fast-export --import-marks=tmp-marks \ |
| 503 | --export-marks=tmp-marks master > actual && |
| 504 | test_cmp expected actual |
| 505 | ' |
| 506 | |
Felipe Contreras | 03e9010 | 2014-04-20 13:59:24 -0500 | [diff] [blame] | 507 | test_expect_success 'use refspec' ' |
| 508 | git fast-export --refspec refs/heads/master:refs/heads/foobar master | \ |
| 509 | grep "^commit " | sort | uniq > actual && |
| 510 | echo "commit refs/heads/foobar" > expected && |
| 511 | test_cmp expected actual |
| 512 | ' |
| 513 | |
Felipe Contreras | 60ed264 | 2014-04-20 13:59:28 -0500 | [diff] [blame] | 514 | test_expect_success 'delete refspec' ' |
| 515 | git branch to-delete && |
| 516 | git fast-export --refspec :refs/heads/to-delete to-delete ^to-delete > actual && |
| 517 | cat > expected <<-EOF && |
| 518 | reset refs/heads/to-delete |
| 519 | from 0000000000000000000000000000000000000000 |
| 520 | |
| 521 | EOF |
| 522 | test_cmp expected actual |
| 523 | ' |
| 524 | |
Johannes Schindelin | f2dc849 | 2007-12-02 14:14:13 +0000 | [diff] [blame] | 525 | test_done |