]>
Commit | Line | Data |
---|---|---|
f2dc849e JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Johannes E. Schindelin | |
4 | # | |
5 | ||
eaa2a6fc | 6 | test_description='git fast-export' |
f2dc849e JS |
7 | . ./test-lib.sh |
8 | ||
9 | test_expect_success 'setup' ' | |
10 | ||
ebeec7db EN |
11 | echo break it > file0 && |
12 | git add file0 && | |
13 | test_tick && | |
f2dc849e JS |
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^ && | |
a48fcd83 | 29 | echo lange > file2 && |
f2dc849e JS |
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 && | |
a4d4e32a | 46 | git fast-export --all >actual && |
f2dc849e JS |
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) && | |
a4d4e32a | 52 | test $MUSS = $(git rev-parse --verify refs/tags/muss)) <actual |
f2dc849e JS |
53 | |
54 | ' | |
55 | ||
af2abd87 EN |
56 | test_expect_success 'fast-export ^muss^{commit} muss' ' |
57 | git fast-export --tag-of-filtered-object=rewrite ^muss^{commit} muss >actual && | |
58 | cat >expected <<-EOF && | |
59 | tag muss | |
60 | from $(git rev-parse --verify muss^{commit}) | |
61 | $(git cat-file tag muss | grep tagger) | |
62 | data 9 | |
63 | valentin | |
64 | ||
65 | EOF | |
66 | test_cmp expected actual | |
67 | ' | |
68 | ||
a1638cfe EN |
69 | test_expect_success 'fast-export --mark-tags ^muss^{commit} muss' ' |
70 | git fast-export --mark-tags --tag-of-filtered-object=rewrite ^muss^{commit} muss >actual && | |
71 | cat >expected <<-EOF && | |
72 | tag muss | |
73 | mark :1 | |
74 | from $(git rev-parse --verify muss^{commit}) | |
75 | $(git cat-file tag muss | grep tagger) | |
76 | data 9 | |
77 | valentin | |
78 | ||
79 | EOF | |
80 | test_cmp expected actual | |
81 | ' | |
82 | ||
f2dc849e JS |
83 | test_expect_success 'fast-export master~2..master' ' |
84 | ||
a4d4e32a PK |
85 | git fast-export master~2..master >actual && |
86 | sed "s/master/partial/" actual | | |
f2dc849e JS |
87 | (cd new && |
88 | git fast-import && | |
89 | test $MASTER != $(git rev-parse --verify refs/heads/partial) && | |
ebeec7db EN |
90 | git diff --exit-code master partial && |
91 | git diff --exit-code master^ partial^ && | |
d492b31c | 92 | test_must_fail git rev-parse partial~2) |
f2dc849e JS |
93 | |
94 | ' | |
95 | ||
530ca19c EN |
96 | test_expect_success 'fast-export --reference-excluded-parents master~2..master' ' |
97 | ||
98 | git fast-export --reference-excluded-parents master~2..master >actual && | |
99 | grep commit.refs/heads/master actual >commit-count && | |
100 | test_line_count = 2 commit-count && | |
101 | sed "s/master/rewrite/" actual | | |
102 | (cd new && | |
103 | git fast-import && | |
104 | test $MASTER = $(git rev-parse --verify refs/heads/rewrite)) | |
105 | ' | |
106 | ||
a965bb31 EN |
107 | test_expect_success 'fast-export --show-original-ids' ' |
108 | ||
109 | git fast-export --show-original-ids master >output && | |
110 | grep ^original-oid output| sed -e s/^original-oid.// | sort >actual && | |
111 | git rev-list --objects master muss >objects-and-names && | |
112 | awk "{print \$1}" objects-and-names | sort >commits-trees-blobs && | |
113 | comm -23 actual commits-trees-blobs >unfound && | |
114 | test_must_be_empty unfound | |
115 | ' | |
116 | ||
117 | test_expect_success 'fast-export --show-original-ids | git fast-import' ' | |
118 | ||
119 | git fast-export --show-original-ids master muss | git fast-import --quiet && | |
120 | test $MASTER = $(git rev-parse --verify refs/heads/master) && | |
121 | test $MUSS = $(git rev-parse --verify refs/tags/muss) | |
122 | ' | |
123 | ||
e80001f8 | 124 | test_expect_success 'reencoding iso-8859-7' ' |
f2dc849e | 125 | |
32615ce7 EN |
126 | test_when_finished "git reset --hard HEAD~1" && |
127 | test_config i18n.commitencoding iso-8859-7 && | |
f2dc849e JS |
128 | test_tick && |
129 | echo rosten >file && | |
32615ce7 | 130 | git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file && |
e80001f8 | 131 | git fast-export --reencode=yes wer^..wer >iso-8859-7.fi && |
32615ce7 | 132 | sed "s/wer/i18n/" iso-8859-7.fi | |
f2dc849e JS |
133 | (cd new && |
134 | git fast-import && | |
831279d3 | 135 | # The commit object, if not re-encoded, would be 200 bytes plus hash. |
32615ce7 EN |
136 | # Removing the "encoding iso-8859-7\n" header drops 20 bytes. |
137 | # Re-encoding the Pi character from \xF0 (\360) in iso-8859-7 | |
138 | # to \xCF\x80 (\317\200) in UTF-8 adds a byte. Check for | |
139 | # the expected size. | |
831279d3 | 140 | test $(($(test_oid hexsz) + 181)) -eq "$(git cat-file -s i18n)" && |
32615ce7 | 141 | # ...and for the expected translation of bytes. |
a4d4e32a | 142 | git cat-file commit i18n >actual && |
32615ce7 EN |
143 | grep $(printf "\317\200") actual && |
144 | # Also make sure the commit does not have the "encoding" header | |
145 | ! grep ^encoding actual) | |
df6a7ff7 | 146 | ' |
32615ce7 | 147 | |
e80001f8 EN |
148 | test_expect_success 'aborting on iso-8859-7' ' |
149 | ||
150 | test_when_finished "git reset --hard HEAD~1" && | |
151 | test_config i18n.commitencoding iso-8859-7 && | |
152 | echo rosten >file && | |
153 | git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file && | |
154 | test_must_fail git fast-export --reencode=abort wer^..wer >iso-8859-7.fi | |
155 | ' | |
156 | ||
157 | test_expect_success 'preserving iso-8859-7' ' | |
158 | ||
159 | test_when_finished "git reset --hard HEAD~1" && | |
160 | test_config i18n.commitencoding iso-8859-7 && | |
161 | echo rosten >file && | |
162 | git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file && | |
163 | git fast-export --reencode=no wer^..wer >iso-8859-7.fi && | |
164 | sed "s/wer/i18n-no-recoding/" iso-8859-7.fi | | |
165 | (cd new && | |
166 | git fast-import && | |
831279d3 | 167 | # The commit object, if not re-encoded, is 200 bytes plus hash. |
e80001f8 EN |
168 | # Removing the "encoding iso-8859-7\n" header would drops 20 |
169 | # bytes. Re-encoding the Pi character from \xF0 (\360) in | |
170 | # iso-8859-7 to \xCF\x80 (\317\200) in UTF-8 adds a byte. | |
171 | # Check for the expected size... | |
831279d3 | 172 | test $(($(test_oid hexsz) + 200)) -eq "$(git cat-file -s i18n-no-recoding)" && |
e80001f8 EN |
173 | # ...as well as the expected byte. |
174 | git cat-file commit i18n-no-recoding >actual && | |
175 | grep $(printf "\360") actual && | |
176 | # Also make sure the commit has the "encoding" header | |
177 | grep ^encoding actual) | |
178 | ' | |
179 | ||
ccbfc96d EN |
180 | test_expect_success 'encoding preserved if reencoding fails' ' |
181 | ||
182 | test_when_finished "git reset --hard HEAD~1" && | |
183 | test_config i18n.commitencoding iso-8859-7 && | |
184 | echo rosten >file && | |
185 | git commit -s -F "$TEST_DIRECTORY/t9350/broken-iso-8859-7-commit-message.txt" file && | |
e80001f8 | 186 | git fast-export --reencode=yes wer^..wer >iso-8859-7.fi && |
ccbfc96d EN |
187 | sed "s/wer/i18n-invalid/" iso-8859-7.fi | |
188 | (cd new && | |
189 | git fast-import && | |
190 | git cat-file commit i18n-invalid >actual && | |
191 | # Make sure the commit still has the encoding header | |
192 | grep ^encoding actual && | |
193 | # Verify that the commit has the expected size; i.e. | |
194 | # that no bytes were re-encoded to a different encoding. | |
831279d3 | 195 | test $(($(test_oid hexsz) + 212)) -eq "$(git cat-file -s i18n-invalid)" && |
ccbfc96d EN |
196 | # ...and check for the original special bytes |
197 | grep $(printf "\360") actual && | |
198 | grep $(printf "\377") actual) | |
199 | ' | |
200 | ||
df6a7ff7 PB |
201 | test_expect_success 'import/export-marks' ' |
202 | ||
203 | git checkout -b marks master && | |
204 | git fast-export --export-marks=tmp-marks HEAD && | |
205 | test -s tmp-marks && | |
3fb0459b | 206 | test_line_count = 3 tmp-marks && |
a4d4e32a PK |
207 | git fast-export --import-marks=tmp-marks \ |
208 | --export-marks=tmp-marks HEAD >actual && | |
209 | test $(grep ^commit actual | wc -l) -eq 0 && | |
df6a7ff7 PB |
210 | echo change > file && |
211 | git commit -m "last commit" file && | |
a4d4e32a PK |
212 | git fast-export --import-marks=tmp-marks \ |
213 | --export-marks=tmp-marks HEAD >actual && | |
214 | test $(grep ^commit\ actual | wc -l) -eq 1 && | |
3fb0459b | 215 | test_line_count = 4 tmp-marks |
df6a7ff7 | 216 | |
f2dc849e JS |
217 | ' |
218 | ||
219 | cat > signed-tag-import << EOF | |
220 | tag sign-your-name | |
221 | from $(git rev-parse HEAD) | |
222 | tagger C O Mitter <committer@example.com> 1112911993 -0700 | |
223 | data 210 | |
224 | A message for a sign | |
225 | -----BEGIN PGP SIGNATURE----- | |
226 | Version: GnuPG v1.4.5 (GNU/Linux) | |
227 | ||
228 | fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign | |
229 | aturefakedsignaturefake= | |
230 | =/59v | |
231 | -----END PGP SIGNATURE----- | |
232 | EOF | |
233 | ||
234 | test_expect_success 'set up faked signed tag' ' | |
235 | ||
236 | cat signed-tag-import | git fast-import | |
237 | ||
238 | ' | |
239 | ||
240 | test_expect_success 'signed-tags=abort' ' | |
241 | ||
d492b31c | 242 | test_must_fail git fast-export --signed-tags=abort sign-your-name |
f2dc849e JS |
243 | |
244 | ' | |
245 | ||
ee4bc371 | 246 | test_expect_success 'signed-tags=verbatim' ' |
f2dc849e | 247 | |
ee4bc371 | 248 | git fast-export --signed-tags=verbatim sign-your-name > output && |
f2dc849e JS |
249 | grep PGP output |
250 | ||
251 | ' | |
252 | ||
253 | test_expect_success 'signed-tags=strip' ' | |
254 | ||
255 | git fast-export --signed-tags=strip sign-your-name > output && | |
256 | ! grep PGP output | |
257 | ||
258 | ' | |
259 | ||
cd16c59b JK |
260 | test_expect_success 'signed-tags=warn-strip' ' |
261 | git fast-export --signed-tags=warn-strip sign-your-name >output 2>err && | |
262 | ! grep PGP output && | |
263 | test -s err | |
264 | ' | |
265 | ||
03db4525 AG |
266 | test_expect_success 'setup submodule' ' |
267 | ||
f4a32a55 | 268 | test_config_global protocol.file.allow always && |
03db4525 AG |
269 | git checkout -f master && |
270 | mkdir sub && | |
4c367c6a JH |
271 | ( |
272 | cd sub && | |
273 | git init && | |
274 | echo test file > file && | |
275 | git add file && | |
276 | git commit -m sub_initial | |
277 | ) && | |
c7b793a1 | 278 | git submodule add "$(pwd)/sub" sub && |
03db4525 AG |
279 | git commit -m initial && |
280 | test_tick && | |
4c367c6a JH |
281 | ( |
282 | cd sub && | |
283 | echo more data >> file && | |
284 | git add file && | |
285 | git commit -m sub_second | |
286 | ) && | |
03db4525 AG |
287 | git add sub && |
288 | git commit -m second | |
289 | ||
290 | ' | |
291 | ||
292 | test_expect_success 'submodule fast-export | fast-import' ' | |
293 | ||
f4a32a55 | 294 | test_config_global protocol.file.allow always && |
03db4525 AG |
295 | SUBENT1=$(git ls-tree master^ sub) && |
296 | SUBENT2=$(git ls-tree master sub) && | |
297 | rm -rf new && | |
298 | mkdir new && | |
299 | git --git-dir=new/.git init && | |
a4d4e32a | 300 | git fast-export --signed-tags=strip --all >actual && |
03db4525 AG |
301 | (cd new && |
302 | git fast-import && | |
303 | test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" && | |
304 | test "$SUBENT2" = "$(git ls-tree refs/heads/master sub)" && | |
305 | git checkout master && | |
306 | git submodule init && | |
307 | git submodule update && | |
a4d4e32a | 308 | cmp sub/file ../sub/file) <actual |
03db4525 AG |
309 | |
310 | ' | |
311 | ||
91e80b98 JH |
312 | GIT_AUTHOR_NAME='A U Thor'; export GIT_AUTHOR_NAME |
313 | GIT_COMMITTER_NAME='C O Mitter'; export GIT_COMMITTER_NAME | |
ae7c5dce AG |
314 | |
315 | test_expect_success 'setup copies' ' | |
316 | ||
ae7c5dce AG |
317 | git checkout -b copy rein && |
318 | git mv file file3 && | |
319 | git commit -m move1 && | |
320 | test_tick && | |
321 | cp file2 file4 && | |
322 | git add file4 && | |
323 | git mv file2 file5 && | |
324 | git commit -m copy1 && | |
325 | test_tick && | |
326 | cp file3 file6 && | |
327 | git add file6 && | |
328 | git commit -m copy2 && | |
329 | test_tick && | |
330 | echo more text >> file6 && | |
331 | echo even more text >> file6 && | |
332 | git add file6 && | |
333 | git commit -m modify && | |
334 | test_tick && | |
335 | cp file6 file7 && | |
336 | echo test >> file7 && | |
337 | git add file7 && | |
338 | git commit -m copy_modify | |
339 | ||
340 | ' | |
341 | ||
342 | test_expect_success 'fast-export -C -C | fast-import' ' | |
343 | ||
344 | ENTRY=$(git rev-parse --verify copy) && | |
345 | rm -rf new && | |
346 | mkdir new && | |
347 | git --git-dir=new/.git init && | |
348 | git fast-export -C -C --signed-tags=strip --all > output && | |
b3e8ca89 | 349 | grep "^C file2 file4\$" output && |
ae7c5dce AG |
350 | cat output | |
351 | (cd new && | |
352 | git fast-import && | |
353 | test $ENTRY = $(git rev-parse --verify refs/heads/copy)) | |
354 | ||
355 | ' | |
356 | ||
2075ffb5 | 357 | test_expect_success 'fast-export | fast-import when master is tagged' ' |
283b9532 MV |
358 | |
359 | git tag -m msg last && | |
360 | git fast-export -C -C --signed-tags=strip --all > output && | |
361 | test $(grep -c "^tag " output) = 3 | |
362 | ||
363 | ' | |
364 | ||
4e46a8d6 JS |
365 | cat > tag-content << EOF |
366 | object $(git rev-parse HEAD) | |
367 | type commit | |
368 | tag rosten | |
369 | EOF | |
370 | ||
371 | test_expect_success 'cope with tagger-less tags' ' | |
372 | ||
373 | TAG=$(git hash-object -t tag -w tag-content) && | |
374 | git update-ref refs/tags/sonnenschein $TAG && | |
375 | git fast-export -C -C --signed-tags=strip --all > output && | |
376 | test $(grep -c "^tag " output) = 4 && | |
377 | ! grep "Unspecified Tagger" output && | |
378 | git fast-export -C -C --signed-tags=strip --all \ | |
379 | --fake-missing-tagger > output && | |
380 | test $(grep -c "^tag " output) = 4 && | |
381 | grep "Unspecified Tagger" output | |
382 | ||
383 | ' | |
384 | ||
25e0ca5d EN |
385 | test_expect_success 'setup for limiting exports by PATH' ' |
386 | mkdir limit-by-paths && | |
4c367c6a JH |
387 | ( |
388 | cd limit-by-paths && | |
389 | git init && | |
390 | echo hi > there && | |
391 | git add there && | |
392 | git commit -m "First file" && | |
393 | echo foo > bar && | |
394 | git add bar && | |
395 | git commit -m "Second file" && | |
396 | git tag -a -m msg mytag && | |
397 | echo morefoo >> bar && | |
398 | git add bar && | |
399 | git commit -m "Change to second file" | |
400 | ) | |
25e0ca5d EN |
401 | ' |
402 | ||
403 | cat > limit-by-paths/expected << EOF | |
404 | blob | |
405 | mark :1 | |
406 | data 3 | |
407 | hi | |
408 | ||
409 | reset refs/tags/mytag | |
410 | commit refs/tags/mytag | |
411 | mark :2 | |
412 | author A U Thor <author@example.com> 1112912713 -0700 | |
413 | committer C O Mitter <committer@example.com> 1112912713 -0700 | |
414 | data 11 | |
415 | First file | |
416 | M 100644 :1 there | |
417 | ||
418 | EOF | |
419 | ||
420 | test_expect_success 'dropping tag of filtered out object' ' | |
4c367c6a | 421 | ( |
25e0ca5d EN |
422 | cd limit-by-paths && |
423 | git fast-export --tag-of-filtered-object=drop mytag -- there > output && | |
9ff10fc8 | 424 | test_cmp expected output |
4c367c6a | 425 | ) |
25e0ca5d EN |
426 | ' |
427 | ||
428 | cat >> limit-by-paths/expected << EOF | |
429 | tag mytag | |
430 | from :2 | |
431 | tagger C O Mitter <committer@example.com> 1112912713 -0700 | |
432 | data 4 | |
433 | msg | |
434 | ||
435 | EOF | |
436 | ||
437 | test_expect_success 'rewriting tag of filtered out object' ' | |
4c367c6a | 438 | ( |
25e0ca5d EN |
439 | cd limit-by-paths && |
440 | git fast-export --tag-of-filtered-object=rewrite mytag -- there > output && | |
9ff10fc8 | 441 | test_cmp expected output |
4c367c6a | 442 | ) |
25e0ca5d EN |
443 | ' |
444 | ||
1f30c904 EN |
445 | test_expect_success 'rewrite tag predating pathspecs to nothing' ' |
446 | test_create_repo rewrite_tag_predating_pathspecs && | |
447 | ( | |
448 | cd rewrite_tag_predating_pathspecs && | |
449 | ||
450 | test_commit initial && | |
451 | ||
452 | git tag -a -m "Some old tag" v0.0.0.0.0.0.1 && | |
453 | ||
454 | test_commit bar && | |
455 | ||
456 | git fast-export --tag-of-filtered-object=rewrite --all -- bar.t >output && | |
457 | grep from.$ZERO_OID output | |
458 | ) | |
459 | ' | |
460 | ||
25e0ca5d EN |
461 | cat > limit-by-paths/expected << EOF |
462 | blob | |
463 | mark :1 | |
464 | data 4 | |
465 | foo | |
466 | ||
467 | blob | |
468 | mark :2 | |
469 | data 3 | |
470 | hi | |
471 | ||
472 | reset refs/heads/master | |
473 | commit refs/heads/master | |
474 | mark :3 | |
475 | author A U Thor <author@example.com> 1112912713 -0700 | |
476 | committer C O Mitter <committer@example.com> 1112912713 -0700 | |
477 | data 12 | |
478 | Second file | |
479 | M 100644 :1 bar | |
480 | M 100644 :2 there | |
481 | ||
482 | EOF | |
483 | ||
484 | test_expect_failure 'no exact-ref revisions included' ' | |
4c367c6a JH |
485 | ( |
486 | cd limit-by-paths && | |
487 | git fast-export master~2..master~1 > output && | |
9ff10fc8 | 488 | test_cmp expected output |
4c367c6a | 489 | ) |
25e0ca5d EN |
490 | ' |
491 | ||
4087a02e EN |
492 | test_expect_success 'path limiting with import-marks does not lose unmodified files' ' |
493 | git checkout -b simple marks~2 && | |
494 | git fast-export --export-marks=marks simple -- file > /dev/null && | |
495 | echo more content >> file && | |
496 | test_tick && | |
497 | git commit -mnext file && | |
a4d4e32a PK |
498 | git fast-export --import-marks=marks simple -- file file0 >actual && |
499 | grep file0 actual | |
4087a02e EN |
500 | ' |
501 | ||
cd13762d EN |
502 | test_expect_success 'avoid corrupt stream with non-existent mark' ' |
503 | test_create_repo avoid_non_existent_mark && | |
504 | ( | |
505 | cd avoid_non_existent_mark && | |
506 | ||
507 | test_commit important-path && | |
508 | ||
509 | test_commit ignored && | |
510 | ||
511 | git branch A && | |
512 | git branch B && | |
513 | ||
514 | echo foo >>important-path.t && | |
515 | git add important-path.t && | |
516 | test_commit more changes && | |
517 | ||
518 | git fast-export --all -- important-path.t | git fast-import --force | |
519 | ) | |
520 | ' | |
521 | ||
7f40ab09 EN |
522 | test_expect_success 'full-tree re-shows unmodified files' ' |
523 | git checkout -f simple && | |
a4d4e32a PK |
524 | git fast-export --full-tree simple >actual && |
525 | test $(grep -c file0 actual) -eq 3 | |
7f40ab09 EN |
526 | ' |
527 | ||
41a5c70f EFL |
528 | test_expect_success 'set-up a few more tags for tag export tests' ' |
529 | git checkout -f master && | |
c7b793a1 | 530 | HEAD_TREE=$(git show -s --pretty=raw HEAD | grep tree | sed "s/tree //") && |
41a5c70f EFL |
531 | git tag tree_tag -m "tagging a tree" $HEAD_TREE && |
532 | git tag -a tree_tag-obj -m "tagging a tree" $HEAD_TREE && | |
533 | git tag tag-obj_tag -m "tagging a tag" tree_tag-obj && | |
534 | git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj | |
535 | ' | |
536 | ||
02c48cd6 EN |
537 | test_expect_success 'tree_tag' ' |
538 | mkdir result && | |
539 | (cd result && git init) && | |
540 | git fast-export tree_tag > fe-stream && | |
541 | (cd result && git fast-import < ../fe-stream) | |
542 | ' | |
543 | ||
41a5c70f | 544 | # NEEDSWORK: not just check return status, but validate the output |
8d7d33c1 | 545 | # Note that these tests DO NOTHING other than print a warning that |
7a40cf15 | 546 | # they are omitting the one tag we asked them to export (because the |
8d7d33c1 EN |
547 | # tags resolve to a tree). They exist just to make sure we do not |
548 | # abort but instead just warn. | |
c0582c53 | 549 | test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj' |
1982467d EFL |
550 | test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' |
551 | test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' | |
41a5c70f | 552 | |
8d7d33c1 EN |
553 | test_expect_success 'handling tags of blobs' ' |
554 | git tag -a -m "Tag of a blob" blobtag $(git rev-parse master:file) && | |
555 | git fast-export blobtag >actual && | |
556 | cat >expect <<-EOF && | |
557 | blob | |
558 | mark :1 | |
559 | data 9 | |
560 | die Luft | |
561 | ||
562 | tag blobtag | |
563 | from :1 | |
564 | tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
565 | data 14 | |
566 | Tag of a blob | |
567 | ||
568 | EOF | |
569 | test_cmp expect actual | |
570 | ' | |
571 | ||
941790d7 | 572 | test_expect_success 'handling nested tags' ' |
8d7d33c1 EN |
573 | git tag -a -m "This is a nested tag" nested muss && |
574 | git fast-export --mark-tags nested >output && | |
575 | grep "^from $ZERO_OID$" output && | |
576 | grep "^tag nested$" output >tag_lines && | |
577 | test_line_count = 2 tag_lines | |
578 | ' | |
579 | ||
889c6f0e | 580 | test_expect_success 'directory becomes symlink' ' |
f15652d9 EN |
581 | git init dirtosymlink && |
582 | git init result && | |
583 | ( | |
584 | cd dirtosymlink && | |
585 | mkdir foo && | |
586 | mkdir bar && | |
587 | echo hello > foo/world && | |
588 | echo hello > bar/world && | |
589 | git add foo/world bar/world && | |
590 | git commit -q -mone && | |
591 | git rm -r foo && | |
889c6f0e | 592 | test_ln_s_add bar foo && |
f15652d9 EN |
593 | git commit -q -mtwo |
594 | ) && | |
595 | ( | |
596 | cd dirtosymlink && | |
597 | git fast-export master -- foo | | |
598 | (cd ../result && git fast-import --quiet) | |
599 | ) && | |
600 | (cd result && git show master:foo) | |
601 | ' | |
602 | ||
6280dfdc JK |
603 | test_expect_success 'fast-export quotes pathnames' ' |
604 | git init crazy-paths && | |
e1d911dd | 605 | test_config -C crazy-paths core.protectNTFS false && |
6280dfdc | 606 | (cd crazy-paths && |
c7b793a1 | 607 | blob=$(echo foo | git hash-object -w --stdin) && |
35edce20 | 608 | git -c core.protectNTFS=false update-index --add \ |
6280dfdc JK |
609 | --cacheinfo 100644 $blob "$(printf "path with\\nnewline")" \ |
610 | --cacheinfo 100644 $blob "path with \"quote\"" \ | |
611 | --cacheinfo 100644 $blob "path with \\backslash" \ | |
612 | --cacheinfo 100644 $blob "path with space" && | |
613 | git commit -m addition && | |
94221d22 | 614 | git ls-files -z -s | perl -0pe "s{\\t}{$&subdir/}" >index && |
6280dfdc JK |
615 | git read-tree --empty && |
616 | git update-index -z --index-info <index && | |
617 | git commit -m rename && | |
618 | git read-tree --empty && | |
619 | git commit -m deletion && | |
ff59f6da | 620 | git fast-export -M HEAD >export.out && |
6280dfdc JK |
621 | git rev-list HEAD >expect && |
622 | git init result && | |
623 | cd result && | |
624 | git fast-import <../export.out && | |
625 | git rev-list HEAD >actual && | |
626 | test_cmp ../expect actual | |
627 | ) | |
628 | ' | |
629 | ||
5d3698ff | 630 | test_expect_success 'test bidirectionality' ' |
5d3698ff | 631 | git init marks-test && |
208d6924 EN |
632 | git fast-export --export-marks=marks-cur --import-marks-if-exists=marks-cur --branches | \ |
633 | git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks-if-exists=marks-new && | |
5d3698ff FC |
634 | (cd marks-test && |
635 | git reset --hard && | |
636 | echo Wohlauf > file && | |
637 | git commit -a -m "back in time") && | |
208d6924 EN |
638 | git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks-if-exists=marks-new --branches | \ |
639 | git fast-import --export-marks=marks-cur --import-marks-if-exists=marks-cur | |
5d3698ff FC |
640 | ' |
641 | ||
49266e8a FC |
642 | cat > expected << EOF |
643 | blob | |
644 | mark :13 | |
645 | data 5 | |
646 | bump | |
647 | ||
648 | commit refs/heads/master | |
649 | mark :14 | |
650 | author A U Thor <author@example.com> 1112912773 -0700 | |
651 | committer C O Mitter <committer@example.com> 1112912773 -0700 | |
652 | data 5 | |
653 | bump | |
654 | from :12 | |
655 | M 100644 :13 file | |
656 | ||
657 | EOF | |
658 | ||
659 | test_expect_success 'avoid uninteresting refs' ' | |
660 | > tmp-marks && | |
661 | git fast-export --import-marks=tmp-marks \ | |
662 | --export-marks=tmp-marks master > /dev/null && | |
663 | git tag v1.0 && | |
664 | git branch uninteresting && | |
665 | echo bump > file && | |
666 | git commit -a -m bump && | |
667 | git fast-export --import-marks=tmp-marks \ | |
668 | --export-marks=tmp-marks ^uninteresting ^v1.0 master > actual && | |
669 | test_cmp expected actual | |
670 | ' | |
671 | ||
f28e7c90 FC |
672 | cat > expected << EOF |
673 | reset refs/heads/master | |
674 | from :14 | |
675 | ||
676 | EOF | |
677 | ||
678 | test_expect_success 'refs are updated even if no commits need to be exported' ' | |
679 | > tmp-marks && | |
680 | git fast-export --import-marks=tmp-marks \ | |
681 | --export-marks=tmp-marks master > /dev/null && | |
682 | git fast-export --import-marks=tmp-marks \ | |
683 | --export-marks=tmp-marks master > actual && | |
684 | test_cmp expected actual | |
685 | ' | |
686 | ||
03e9010c | 687 | test_expect_success 'use refspec' ' |
a4d4e32a PK |
688 | git fast-export --refspec refs/heads/master:refs/heads/foobar master >actual2 && |
689 | grep "^commit " actual2 | sort | uniq >actual && | |
03e9010c FC |
690 | echo "commit refs/heads/foobar" > expected && |
691 | test_cmp expected actual | |
692 | ' | |
693 | ||
fdf31b63 | 694 | test_expect_success 'delete ref because entire history excluded' ' |
60ed2643 | 695 | git branch to-delete && |
fdf31b63 EN |
696 | git fast-export to-delete ^to-delete >actual && |
697 | cat >expected <<-EOF && | |
698 | reset refs/heads/to-delete | |
831279d3 | 699 | from $ZERO_OID |
fdf31b63 EN |
700 | |
701 | EOF | |
702 | test_cmp expected actual | |
703 | ' | |
704 | ||
705 | test_expect_success 'delete refspec' ' | |
706 | git fast-export --refspec :refs/heads/to-delete >actual && | |
707 | cat >expected <<-EOF && | |
60ed2643 | 708 | reset refs/heads/to-delete |
831279d3 | 709 | from $ZERO_OID |
60ed2643 FC |
710 | |
711 | EOF | |
712 | test_cmp expected actual | |
713 | ' | |
714 | ||
b3e8ca89 JT |
715 | test_expect_success 'when using -C, do not declare copy when source of copy is also modified' ' |
716 | test_create_repo src && | |
717 | echo a_line >src/file.txt && | |
718 | git -C src add file.txt && | |
719 | git -C src commit -m 1st_commit && | |
720 | ||
721 | cp src/file.txt src/file2.txt && | |
722 | echo another_line >>src/file.txt && | |
723 | git -C src add file.txt file2.txt && | |
724 | git -C src commit -m 2nd_commit && | |
725 | ||
726 | test_create_repo dst && | |
a4d4e32a PK |
727 | git -C src fast-export --all -C >actual && |
728 | git -C dst fast-import <actual && | |
b3e8ca89 JT |
729 | git -C src show >expected && |
730 | git -C dst show >actual && | |
731 | test_cmp expected actual | |
732 | ' | |
733 | ||
be011bbe MÅ |
734 | test_expect_success 'merge commit gets exported with --import-marks' ' |
735 | test_create_repo merging && | |
736 | ( | |
737 | cd merging && | |
738 | test_commit initial && | |
739 | git checkout -b topic && | |
740 | test_commit on-topic && | |
741 | git checkout master && | |
742 | test_commit on-master && | |
743 | test_tick && | |
744 | git merge --no-ff -m Yeah topic && | |
745 | ||
746 | echo ":1 $(git rev-parse HEAD^^)" >marks && | |
747 | git fast-export --import-marks=marks master >out && | |
748 | grep Yeah out | |
749 | ) | |
750 | ' | |
751 | ||
f2dc849e | 752 | test_done |