]>
Commit | Line | Data |
---|---|---|
50aee995 SP |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Shawn Pearce | |
4 | # | |
5 | ||
eaa2a6fc | 6 | test_description='test git fast-import utility' |
50aee995 | 7 | . ./test-lib.sh |
bfdbee98 | 8 | . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash |
50aee995 | 9 | |
4de0bbd8 JN |
10 | # Print $1 bytes from stdin to stdout. |
11 | # | |
12 | # This could be written as "head -c $1", but IRIX "head" does not | |
13 | # support the -c option. | |
14 | head_c () { | |
94221d22 | 15 | perl -e ' |
4de0bbd8 JN |
16 | my $len = $ARGV[1]; |
17 | while ($len > 0) { | |
18 | my $s; | |
19 | my $nread = sysread(STDIN, $s, $len); | |
20 | die "cannot read: $!" unless defined($nread); | |
21 | print $s; | |
22 | $len -= $nread; | |
23 | } | |
24 | ' - "$1" | |
25 | } | |
26 | ||
05880b02 JS |
27 | verify_packs () { |
28 | for p in .git/objects/pack/*.pack | |
29 | do | |
30 | git verify-pack "$@" "$p" || return | |
31 | done | |
32 | } | |
33 | ||
8232dc42 SP |
34 | file2_data='file2 |
35 | second line of EOF' | |
36 | ||
37 | file3_data='EOF | |
38 | in 3rd file | |
39 | END' | |
40 | ||
41 | file4_data=abcd | |
42 | file4_len=4 | |
43 | ||
b715cfbb SP |
44 | file5_data='an inline file. |
45 | we should see it later.' | |
46 | ||
47 | file6_data='#!/bin/sh | |
48 | echo "$@"' | |
49 | ||
85c62395 DB |
50 | >empty |
51 | ||
50aee995 SP |
52 | ### |
53 | ### series A | |
54 | ### | |
55 | ||
56 | test_tick | |
85c62395 DB |
57 | |
58 | test_expect_success 'empty stream succeeds' ' | |
59 | git fast-import </dev/null | |
60 | ' | |
61 | ||
50aee995 SP |
62 | cat >input <<INPUT_END |
63 | blob | |
64 | mark :2 | |
65 | data <<EOF | |
8232dc42 | 66 | $file2_data |
50aee995 SP |
67 | EOF |
68 | ||
69 | blob | |
70 | mark :3 | |
71 | data <<END | |
8232dc42 | 72 | $file3_data |
50aee995 SP |
73 | END |
74 | ||
75 | blob | |
76 | mark :4 | |
8232dc42 SP |
77 | data $file4_len |
78 | $file4_data | |
50aee995 SP |
79 | commit refs/heads/master |
80 | mark :5 | |
81 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
82 | data <<COMMIT | |
83 | initial | |
84 | COMMIT | |
85 | ||
86 | M 644 :2 file2 | |
87 | M 644 :3 file3 | |
88 | M 755 :4 file4 | |
89 | ||
88fbf67b JH |
90 | tag series-A |
91 | from :5 | |
92 | data <<EOF | |
93 | An annotated tag without a tagger | |
94 | EOF | |
95 | ||
2efe38e7 DI |
96 | tag series-A-blob |
97 | from :3 | |
98 | data <<EOF | |
99 | An annotated tag that annotates a blob. | |
100 | EOF | |
101 | ||
50aee995 SP |
102 | INPUT_END |
103 | test_expect_success \ | |
104 | 'A: create pack from stdin' \ | |
eaa2a6fc | 105 | 'git fast-import --export-marks=marks.out <input && |
5be60078 | 106 | git whatchanged master' |
05880b02 JS |
107 | |
108 | test_expect_success 'A: verify pack' ' | |
109 | verify_packs | |
110 | ' | |
50aee995 SP |
111 | |
112 | cat >expect <<EOF | |
113 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
114 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
115 | ||
116 | initial | |
117 | EOF | |
118 | test_expect_success \ | |
119 | 'A: verify commit' \ | |
5be60078 | 120 | 'git cat-file commit master | sed 1d >actual && |
3af82863 | 121 | test_cmp expect actual' |
50aee995 SP |
122 | |
123 | cat >expect <<EOF | |
124 | 100644 blob file2 | |
125 | 100644 blob file3 | |
126 | 100755 blob file4 | |
127 | EOF | |
128 | test_expect_success \ | |
129 | 'A: verify tree' \ | |
5be60078 | 130 | 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
3af82863 | 131 | test_cmp expect actual' |
50aee995 | 132 | |
8232dc42 | 133 | echo "$file2_data" >expect |
50aee995 SP |
134 | test_expect_success \ |
135 | 'A: verify file2' \ | |
3af82863 | 136 | 'git cat-file blob master:file2 >actual && test_cmp expect actual' |
50aee995 | 137 | |
8232dc42 | 138 | echo "$file3_data" >expect |
50aee995 SP |
139 | test_expect_success \ |
140 | 'A: verify file3' \ | |
3af82863 | 141 | 'git cat-file blob master:file3 >actual && test_cmp expect actual' |
50aee995 | 142 | |
8232dc42 | 143 | printf "$file4_data" >expect |
50aee995 SP |
144 | test_expect_success \ |
145 | 'A: verify file4' \ | |
3af82863 | 146 | 'git cat-file blob master:file4 >actual && test_cmp expect actual' |
50aee995 | 147 | |
88fbf67b JH |
148 | cat >expect <<EOF |
149 | object $(git rev-parse refs/heads/master) | |
150 | type commit | |
151 | tag series-A | |
152 | ||
153 | An annotated tag without a tagger | |
154 | EOF | |
155 | test_expect_success 'A: verify tag/series-A' ' | |
156 | git cat-file tag tags/series-A >actual && | |
157 | test_cmp expect actual | |
158 | ' | |
159 | ||
2efe38e7 DI |
160 | cat >expect <<EOF |
161 | object $(git rev-parse refs/heads/master:file3) | |
162 | type blob | |
163 | tag series-A-blob | |
164 | ||
165 | An annotated tag that annotates a blob. | |
166 | EOF | |
167 | test_expect_success 'A: verify tag/series-A-blob' ' | |
168 | git cat-file tag tags/series-A-blob >actual && | |
169 | test_cmp expect actual | |
170 | ' | |
171 | ||
50aee995 | 172 | cat >expect <<EOF |
5be60078 JH |
173 | :2 `git rev-parse --verify master:file2` |
174 | :3 `git rev-parse --verify master:file3` | |
175 | :4 `git rev-parse --verify master:file4` | |
176 | :5 `git rev-parse --verify master^0` | |
50aee995 SP |
177 | EOF |
178 | test_expect_success \ | |
179 | 'A: verify marks output' \ | |
3af82863 | 180 | 'test_cmp expect marks.out' |
50aee995 | 181 | |
e8438420 SP |
182 | test_expect_success \ |
183 | 'A: verify marks import' \ | |
eaa2a6fc | 184 | 'git fast-import \ |
e8438420 SP |
185 | --import-marks=marks.out \ |
186 | --export-marks=marks.new \ | |
187 | </dev/null && | |
3af82863 | 188 | test_cmp expect marks.new' |
e8438420 | 189 | |
2efe38e7 | 190 | test_tick |
6c447f63 | 191 | new_blob=$(echo testing | git hash-object --stdin) |
2efe38e7 DI |
192 | cat >input <<INPUT_END |
193 | tag series-A-blob-2 | |
194 | from $(git rev-parse refs/heads/master:file3) | |
195 | data <<EOF | |
196 | Tag blob by sha1. | |
197 | EOF | |
6c447f63 DI |
198 | |
199 | blob | |
200 | mark :6 | |
201 | data <<EOF | |
202 | testing | |
203 | EOF | |
204 | ||
205 | commit refs/heads/new_blob | |
206 | committer <> 0 +0000 | |
207 | data 0 | |
208 | M 644 :6 new_blob | |
209 | #pretend we got sha1 from fast-import | |
210 | ls "new_blob" | |
211 | ||
212 | tag series-A-blob-3 | |
213 | from $new_blob | |
214 | data <<EOF | |
215 | Tag new_blob. | |
216 | EOF | |
2efe38e7 DI |
217 | INPUT_END |
218 | ||
219 | cat >expect <<EOF | |
220 | object $(git rev-parse refs/heads/master:file3) | |
221 | type blob | |
222 | tag series-A-blob-2 | |
223 | ||
224 | Tag blob by sha1. | |
6c447f63 DI |
225 | object $new_blob |
226 | type blob | |
227 | tag series-A-blob-3 | |
228 | ||
229 | Tag new_blob. | |
2efe38e7 DI |
230 | EOF |
231 | ||
232 | test_expect_success \ | |
233 | 'A: tag blob by sha1' \ | |
234 | 'git fast-import <input && | |
235 | git cat-file tag tags/series-A-blob-2 >actual && | |
6c447f63 | 236 | git cat-file tag tags/series-A-blob-3 >>actual && |
2efe38e7 DI |
237 | test_cmp expect actual' |
238 | ||
aac65ed1 SP |
239 | test_tick |
240 | cat >input <<INPUT_END | |
241 | commit refs/heads/verify--import-marks | |
242 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
243 | data <<COMMIT | |
244 | recreate from :5 | |
245 | COMMIT | |
246 | ||
247 | from :5 | |
248 | M 755 :2 copy-of-file2 | |
249 | ||
250 | INPUT_END | |
251 | test_expect_success \ | |
252 | 'A: verify marks import does not crash' \ | |
eaa2a6fc | 253 | 'git fast-import --import-marks=marks.out <input && |
5be60078 | 254 | git whatchanged verify--import-marks' |
05880b02 JS |
255 | |
256 | test_expect_success 'A: verify pack' ' | |
257 | verify_packs | |
258 | ' | |
259 | ||
aac65ed1 SP |
260 | cat >expect <<EOF |
261 | :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2 | |
262 | EOF | |
5be60078 | 263 | git diff-tree -M -r master verify--import-marks >actual |
aac65ed1 SP |
264 | test_expect_success \ |
265 | 'A: verify diff' \ | |
266 | 'compare_diff_raw expect actual && | |
5be60078 JH |
267 | test `git rev-parse --verify master:file2` \ |
268 | = `git rev-parse --verify verify--import-marks:copy-of-file2`' | |
aac65ed1 | 269 | |
7e7db5e4 RH |
270 | test_tick |
271 | mt=$(git hash-object --stdin < /dev/null) | |
272 | : >input.blob | |
273 | : >marks.exp | |
274 | : >tree.exp | |
275 | ||
276 | cat >input.commit <<EOF | |
277 | commit refs/heads/verify--dump-marks | |
278 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
279 | data <<COMMIT | |
280 | test the sparse array dumping routines with exponentially growing marks | |
281 | COMMIT | |
282 | EOF | |
283 | ||
284 | i=0 | |
285 | l=4 | |
286 | m=6 | |
287 | n=7 | |
288 | while test "$i" -lt 27; do | |
289 | cat >>input.blob <<EOF | |
290 | blob | |
291 | mark :$l | |
292 | data 0 | |
293 | blob | |
294 | mark :$m | |
295 | data 0 | |
296 | blob | |
297 | mark :$n | |
298 | data 0 | |
299 | EOF | |
300 | echo "M 100644 :$l l$i" >>input.commit | |
301 | echo "M 100644 :$m m$i" >>input.commit | |
302 | echo "M 100644 :$n n$i" >>input.commit | |
303 | ||
304 | echo ":$l $mt" >>marks.exp | |
305 | echo ":$m $mt" >>marks.exp | |
306 | echo ":$n $mt" >>marks.exp | |
307 | ||
308 | printf "100644 blob $mt\tl$i\n" >>tree.exp | |
309 | printf "100644 blob $mt\tm$i\n" >>tree.exp | |
310 | printf "100644 blob $mt\tn$i\n" >>tree.exp | |
311 | ||
312 | l=$(($l + $l)) | |
313 | m=$(($m + $m)) | |
314 | n=$(($l + $n)) | |
315 | ||
316 | i=$((1 + $i)) | |
317 | done | |
318 | ||
319 | sort tree.exp > tree.exp_s | |
320 | ||
321 | test_expect_success 'A: export marks with large values' ' | |
322 | cat input.blob input.commit | git fast-import --export-marks=marks.large && | |
323 | git ls-tree refs/heads/verify--dump-marks >tree.out && | |
324 | test_cmp tree.exp_s tree.out && | |
325 | test_cmp marks.exp marks.large' | |
326 | ||
50aee995 SP |
327 | ### |
328 | ### series B | |
329 | ### | |
330 | ||
331 | test_tick | |
332 | cat >input <<INPUT_END | |
333 | commit refs/heads/branch | |
334 | mark :1 | |
335 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
336 | data <<COMMIT | |
337 | corrupt | |
338 | COMMIT | |
339 | ||
340 | from refs/heads/master | |
341 | M 755 0000000000000000000000000000000000000001 zero1 | |
342 | ||
343 | INPUT_END | |
41ac414e | 344 | test_expect_success 'B: fail on invalid blob sha1' ' |
eaa2a6fc | 345 | test_must_fail git fast-import <input |
41ac414e | 346 | ' |
50aee995 SP |
347 | rm -f .git/objects/pack_* .git/objects/index_* |
348 | ||
ea08a6fd SP |
349 | cat >input <<INPUT_END |
350 | commit TEMP_TAG | |
351 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
352 | data <<COMMIT | |
353 | tag base | |
354 | COMMIT | |
355 | ||
356 | from refs/heads/master | |
357 | ||
358 | INPUT_END | |
359 | test_expect_success \ | |
360 | 'B: accept branch name "TEMP_TAG"' \ | |
eaa2a6fc | 361 | 'git fast-import <input && |
ea08a6fd SP |
362 | test -f .git/TEMP_TAG && |
363 | test `git rev-parse master` = `git rev-parse TEMP_TAG^`' | |
364 | rm -f .git/TEMP_TAG | |
365 | ||
4cedb78c DI |
366 | git gc 2>/dev/null >/dev/null |
367 | git prune 2>/dev/null >/dev/null | |
368 | ||
369 | cat >input <<INPUT_END | |
370 | commit refs/heads/empty-committer-1 | |
371 | committer <> $GIT_COMMITTER_DATE | |
372 | data <<COMMIT | |
373 | empty commit | |
374 | COMMIT | |
375 | INPUT_END | |
376 | test_expect_success 'B: accept empty committer' ' | |
377 | git fast-import <input && | |
378 | out=$(git fsck) && | |
379 | echo "$out" && | |
380 | test -z "$out" | |
381 | ' | |
382 | git update-ref -d refs/heads/empty-committer-1 || true | |
383 | ||
384 | git gc 2>/dev/null >/dev/null | |
385 | git prune 2>/dev/null >/dev/null | |
386 | ||
387 | cat >input <<INPUT_END | |
388 | commit refs/heads/empty-committer-2 | |
389 | committer <a@b.com> $GIT_COMMITTER_DATE | |
390 | data <<COMMIT | |
391 | empty commit | |
392 | COMMIT | |
393 | INPUT_END | |
17fb0072 | 394 | test_expect_success 'B: accept and fixup committer with no name' ' |
4cedb78c DI |
395 | git fast-import <input && |
396 | out=$(git fsck) && | |
397 | echo "$out" && | |
398 | test -z "$out" | |
399 | ' | |
400 | git update-ref -d refs/heads/empty-committer-2 || true | |
401 | ||
402 | git gc 2>/dev/null >/dev/null | |
403 | git prune 2>/dev/null >/dev/null | |
404 | ||
405 | cat >input <<INPUT_END | |
406 | commit refs/heads/invalid-committer | |
407 | committer Name email> $GIT_COMMITTER_DATE | |
408 | data <<COMMIT | |
409 | empty commit | |
410 | COMMIT | |
411 | INPUT_END | |
4b4963c0 | 412 | test_expect_success 'B: fail on invalid committer (1)' ' |
4cedb78c DI |
413 | test_must_fail git fast-import <input |
414 | ' | |
415 | git update-ref -d refs/heads/invalid-committer || true | |
416 | ||
417 | cat >input <<INPUT_END | |
418 | commit refs/heads/invalid-committer | |
419 | committer Name <e<mail> $GIT_COMMITTER_DATE | |
420 | data <<COMMIT | |
421 | empty commit | |
422 | COMMIT | |
423 | INPUT_END | |
4b4963c0 | 424 | test_expect_success 'B: fail on invalid committer (2)' ' |
4cedb78c DI |
425 | test_must_fail git fast-import <input |
426 | ' | |
427 | git update-ref -d refs/heads/invalid-committer || true | |
428 | ||
429 | cat >input <<INPUT_END | |
430 | commit refs/heads/invalid-committer | |
431 | committer Name <email>> $GIT_COMMITTER_DATE | |
432 | data <<COMMIT | |
433 | empty commit | |
434 | COMMIT | |
435 | INPUT_END | |
4b4963c0 | 436 | test_expect_success 'B: fail on invalid committer (3)' ' |
4cedb78c DI |
437 | test_must_fail git fast-import <input |
438 | ' | |
439 | git update-ref -d refs/heads/invalid-committer || true | |
440 | ||
441 | cat >input <<INPUT_END | |
442 | commit refs/heads/invalid-committer | |
443 | committer Name <email $GIT_COMMITTER_DATE | |
444 | data <<COMMIT | |
445 | empty commit | |
446 | COMMIT | |
447 | INPUT_END | |
4b4963c0 | 448 | test_expect_success 'B: fail on invalid committer (4)' ' |
4cedb78c DI |
449 | test_must_fail git fast-import <input |
450 | ' | |
451 | git update-ref -d refs/heads/invalid-committer || true | |
452 | ||
453 | cat >input <<INPUT_END | |
454 | commit refs/heads/invalid-committer | |
455 | committer Name<email> $GIT_COMMITTER_DATE | |
456 | data <<COMMIT | |
457 | empty commit | |
458 | COMMIT | |
459 | INPUT_END | |
4b4963c0 | 460 | test_expect_success 'B: fail on invalid committer (5)' ' |
4cedb78c DI |
461 | test_must_fail git fast-import <input |
462 | ' | |
463 | git update-ref -d refs/heads/invalid-committer || true | |
464 | ||
50aee995 SP |
465 | ### |
466 | ### series C | |
467 | ### | |
468 | ||
eaa2a6fc | 469 | newf=`echo hi newf | git hash-object -w --stdin` |
5be60078 | 470 | oldf=`git rev-parse --verify master:file2` |
50aee995 SP |
471 | test_tick |
472 | cat >input <<INPUT_END | |
473 | commit refs/heads/branch | |
474 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
475 | data <<COMMIT | |
476 | second | |
477 | COMMIT | |
478 | ||
479 | from refs/heads/master | |
480 | M 644 $oldf file2/oldf | |
481 | M 755 $newf file2/newf | |
482 | D file3 | |
483 | ||
484 | INPUT_END | |
485 | test_expect_success \ | |
486 | 'C: incremental import create pack from stdin' \ | |
eaa2a6fc | 487 | 'git fast-import <input && |
5be60078 | 488 | git whatchanged branch' |
05880b02 JS |
489 | |
490 | test_expect_success 'C: verify pack' ' | |
491 | verify_packs | |
492 | ' | |
493 | ||
50aee995 SP |
494 | test_expect_success \ |
495 | 'C: validate reuse existing blob' \ | |
a48fcd83 | 496 | 'test $newf = `git rev-parse --verify branch:file2/newf` && |
5be60078 | 497 | test $oldf = `git rev-parse --verify branch:file2/oldf`' |
50aee995 SP |
498 | |
499 | cat >expect <<EOF | |
5be60078 | 500 | parent `git rev-parse --verify master^0` |
50aee995 SP |
501 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
502 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
503 | ||
504 | second | |
505 | EOF | |
506 | test_expect_success \ | |
507 | 'C: verify commit' \ | |
5be60078 | 508 | 'git cat-file commit branch | sed 1d >actual && |
3af82863 | 509 | test_cmp expect actual' |
50aee995 SP |
510 | |
511 | cat >expect <<EOF | |
512 | :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf | |
513 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf | |
514 | :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3 | |
515 | EOF | |
5be60078 | 516 | git diff-tree -M -r master branch >actual |
50aee995 SP |
517 | test_expect_success \ |
518 | 'C: validate rename result' \ | |
519 | 'compare_diff_raw expect actual' | |
520 | ||
b715cfbb SP |
521 | ### |
522 | ### series D | |
523 | ### | |
524 | ||
525 | test_tick | |
526 | cat >input <<INPUT_END | |
527 | commit refs/heads/branch | |
528 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
529 | data <<COMMIT | |
530 | third | |
531 | COMMIT | |
532 | ||
533 | from refs/heads/branch^0 | |
534 | M 644 inline newdir/interesting | |
535 | data <<EOF | |
536 | $file5_data | |
537 | EOF | |
538 | ||
539 | M 755 inline newdir/exec.sh | |
540 | data <<EOF | |
541 | $file6_data | |
542 | EOF | |
543 | ||
544 | INPUT_END | |
545 | test_expect_success \ | |
546 | 'D: inline data in commit' \ | |
eaa2a6fc | 547 | 'git fast-import <input && |
5be60078 | 548 | git whatchanged branch' |
05880b02 JS |
549 | |
550 | test_expect_success 'D: verify pack' ' | |
551 | verify_packs | |
552 | ' | |
b715cfbb SP |
553 | |
554 | cat >expect <<EOF | |
2c0ab4d4 JH |
555 | :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh |
556 | :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting | |
b715cfbb | 557 | EOF |
5be60078 | 558 | git diff-tree -M -r branch^ branch >actual |
b715cfbb SP |
559 | test_expect_success \ |
560 | 'D: validate new files added' \ | |
561 | 'compare_diff_raw expect actual' | |
562 | ||
563 | echo "$file5_data" >expect | |
564 | test_expect_success \ | |
565 | 'D: verify file5' \ | |
5be60078 | 566 | 'git cat-file blob branch:newdir/interesting >actual && |
3af82863 | 567 | test_cmp expect actual' |
b715cfbb SP |
568 | |
569 | echo "$file6_data" >expect | |
570 | test_expect_success \ | |
571 | 'D: verify file6' \ | |
5be60078 | 572 | 'git cat-file blob branch:newdir/exec.sh >actual && |
3af82863 | 573 | test_cmp expect actual' |
b715cfbb | 574 | |
63e0c8b3 SP |
575 | ### |
576 | ### series E | |
577 | ### | |
578 | ||
579 | cat >input <<INPUT_END | |
580 | commit refs/heads/branch | |
581 | author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500 | |
582 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500 | |
583 | data <<COMMIT | |
584 | RFC 2822 type date | |
585 | COMMIT | |
586 | ||
587 | from refs/heads/branch^0 | |
588 | ||
589 | INPUT_END | |
41ac414e | 590 | test_expect_success 'E: rfc2822 date, --date-format=raw' ' |
eaa2a6fc | 591 | test_must_fail git fast-import --date-format=raw <input |
41ac414e | 592 | ' |
63e0c8b3 SP |
593 | test_expect_success \ |
594 | 'E: rfc2822 date, --date-format=rfc2822' \ | |
eaa2a6fc | 595 | 'git fast-import --date-format=rfc2822 <input' |
05880b02 JS |
596 | |
597 | test_expect_success 'E: verify pack' ' | |
598 | verify_packs | |
599 | ' | |
63e0c8b3 SP |
600 | |
601 | cat >expect <<EOF | |
602 | author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500 | |
603 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500 | |
604 | ||
605 | RFC 2822 type date | |
606 | EOF | |
607 | test_expect_success \ | |
608 | 'E: verify commit' \ | |
5be60078 | 609 | 'git cat-file commit branch | sed 1,2d >actual && |
3af82863 | 610 | test_cmp expect actual' |
63e0c8b3 | 611 | |
7073e69e SP |
612 | ### |
613 | ### series F | |
614 | ### | |
615 | ||
5be60078 | 616 | old_branch=`git rev-parse --verify branch^0` |
7073e69e SP |
617 | test_tick |
618 | cat >input <<INPUT_END | |
619 | commit refs/heads/branch | |
620 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
621 | data <<COMMIT | |
622 | losing things already? | |
623 | COMMIT | |
624 | ||
625 | from refs/heads/branch~1 | |
626 | ||
627 | reset refs/heads/other | |
628 | from refs/heads/branch | |
629 | ||
630 | INPUT_END | |
631 | test_expect_success \ | |
632 | 'F: non-fast-forward update skips' \ | |
eaa2a6fc | 633 | 'if git fast-import <input |
7073e69e SP |
634 | then |
635 | echo BAD gfi did not fail | |
636 | return 1 | |
637 | else | |
5be60078 | 638 | if test $old_branch = `git rev-parse --verify branch^0` |
7073e69e SP |
639 | then |
640 | : branch unaffected and failure returned | |
641 | return 0 | |
642 | else | |
643 | echo BAD gfi changed branch $old_branch | |
644 | return 1 | |
645 | fi | |
646 | fi | |
647 | ' | |
05880b02 JS |
648 | |
649 | test_expect_success 'F: verify pack' ' | |
650 | verify_packs | |
651 | ' | |
7073e69e SP |
652 | |
653 | cat >expect <<EOF | |
5be60078 JH |
654 | tree `git rev-parse branch~1^{tree}` |
655 | parent `git rev-parse branch~1` | |
7073e69e SP |
656 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
657 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
658 | ||
659 | losing things already? | |
660 | EOF | |
661 | test_expect_success \ | |
662 | 'F: verify other commit' \ | |
5be60078 | 663 | 'git cat-file commit other >actual && |
3af82863 | 664 | test_cmp expect actual' |
7073e69e SP |
665 | |
666 | ### | |
667 | ### series G | |
668 | ### | |
669 | ||
5be60078 | 670 | old_branch=`git rev-parse --verify branch^0` |
7073e69e SP |
671 | test_tick |
672 | cat >input <<INPUT_END | |
673 | commit refs/heads/branch | |
674 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
675 | data <<COMMIT | |
676 | losing things already? | |
677 | COMMIT | |
678 | ||
679 | from refs/heads/branch~1 | |
680 | ||
681 | INPUT_END | |
682 | test_expect_success \ | |
683 | 'G: non-fast-forward update forced' \ | |
eaa2a6fc | 684 | 'git fast-import --force <input' |
05880b02 JS |
685 | |
686 | test_expect_success 'G: verify pack' ' | |
687 | verify_packs | |
688 | ' | |
689 | ||
7073e69e SP |
690 | test_expect_success \ |
691 | 'G: branch changed, but logged' \ | |
5be60078 JH |
692 | 'test $old_branch != `git rev-parse --verify branch^0` && |
693 | test $old_branch = `git rev-parse --verify branch@{1}`' | |
7073e69e | 694 | |
825769a8 SP |
695 | ### |
696 | ### series H | |
697 | ### | |
698 | ||
699 | test_tick | |
700 | cat >input <<INPUT_END | |
701 | commit refs/heads/H | |
702 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
703 | data <<COMMIT | |
704 | third | |
705 | COMMIT | |
706 | ||
707 | from refs/heads/branch^0 | |
708 | M 644 inline i-will-die | |
709 | data <<EOF | |
710 | this file will never exist. | |
711 | EOF | |
712 | ||
713 | deleteall | |
714 | M 644 inline h/e/l/lo | |
715 | data <<EOF | |
716 | $file5_data | |
717 | EOF | |
718 | ||
719 | INPUT_END | |
720 | test_expect_success \ | |
721 | 'H: deletall, add 1' \ | |
eaa2a6fc | 722 | 'git fast-import <input && |
5be60078 | 723 | git whatchanged H' |
05880b02 JS |
724 | |
725 | test_expect_success 'H: verify pack' ' | |
726 | verify_packs | |
727 | ' | |
825769a8 SP |
728 | |
729 | cat >expect <<EOF | |
730 | :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf | |
731 | :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf | |
732 | :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4 | |
733 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo | |
734 | :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh | |
735 | EOF | |
5be60078 | 736 | git diff-tree -M -r H^ H >actual |
825769a8 SP |
737 | test_expect_success \ |
738 | 'H: validate old files removed, new files added' \ | |
739 | 'compare_diff_raw expect actual' | |
740 | ||
741 | echo "$file5_data" >expect | |
742 | test_expect_success \ | |
743 | 'H: verify file' \ | |
5be60078 | 744 | 'git cat-file blob H:h/e/l/lo >actual && |
3af82863 | 745 | test_cmp expect actual' |
825769a8 | 746 | |
bdf1c06d SP |
747 | ### |
748 | ### series I | |
749 | ### | |
750 | ||
751 | cat >input <<INPUT_END | |
752 | commit refs/heads/export-boundary | |
753 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
754 | data <<COMMIT | |
755 | we have a border. its only 40 characters wide. | |
756 | COMMIT | |
757 | ||
758 | from refs/heads/branch | |
759 | ||
760 | INPUT_END | |
761 | test_expect_success \ | |
762 | 'I: export-pack-edges' \ | |
eaa2a6fc | 763 | 'git fast-import --export-pack-edges=edges.list <input' |
bdf1c06d SP |
764 | |
765 | cat >expect <<EOF | |
5be60078 | 766 | .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary` |
bdf1c06d SP |
767 | EOF |
768 | test_expect_success \ | |
769 | 'I: verify edge list' \ | |
770 | 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual && | |
3af82863 | 771 | test_cmp expect actual' |
bdf1c06d | 772 | |
ea5e370a SP |
773 | ### |
774 | ### series J | |
775 | ### | |
776 | ||
777 | cat >input <<INPUT_END | |
778 | commit refs/heads/J | |
779 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
780 | data <<COMMIT | |
781 | create J | |
782 | COMMIT | |
783 | ||
784 | from refs/heads/branch | |
785 | ||
786 | reset refs/heads/J | |
787 | ||
788 | commit refs/heads/J | |
789 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
790 | data <<COMMIT | |
791 | initialize J | |
792 | COMMIT | |
793 | ||
794 | INPUT_END | |
795 | test_expect_success \ | |
796 | 'J: reset existing branch creates empty commit' \ | |
eaa2a6fc | 797 | 'git fast-import <input' |
ea5e370a SP |
798 | test_expect_success \ |
799 | 'J: branch has 1 commit, empty tree' \ | |
5be60078 | 800 | 'test 1 = `git rev-list J | wc -l` && |
ea5e370a SP |
801 | test 0 = `git ls-tree J | wc -l`' |
802 | ||
2c9c8ee2 DI |
803 | cat >input <<INPUT_END |
804 | reset refs/heads/J2 | |
805 | ||
806 | tag wrong_tag | |
807 | from refs/heads/J2 | |
808 | data <<EOF | |
809 | Tag branch that was reset. | |
810 | EOF | |
811 | INPUT_END | |
812 | test_expect_success \ | |
813 | 'J: tag must fail on empty branch' \ | |
814 | 'test_must_fail git fast-import <input' | |
ea5e370a SP |
815 | ### |
816 | ### series K | |
817 | ### | |
818 | ||
819 | cat >input <<INPUT_END | |
820 | commit refs/heads/K | |
821 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
822 | data <<COMMIT | |
823 | create K | |
824 | COMMIT | |
825 | ||
826 | from refs/heads/branch | |
827 | ||
828 | commit refs/heads/K | |
829 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
830 | data <<COMMIT | |
831 | redo K | |
832 | COMMIT | |
833 | ||
834 | from refs/heads/branch^1 | |
835 | ||
836 | INPUT_END | |
837 | test_expect_success \ | |
838 | 'K: reinit branch with from' \ | |
eaa2a6fc | 839 | 'git fast-import <input' |
ea5e370a SP |
840 | test_expect_success \ |
841 | 'K: verify K^1 = branch^1' \ | |
5be60078 JH |
842 | 'test `git rev-parse --verify branch^1` \ |
843 | = `git rev-parse --verify K^1`' | |
ea5e370a | 844 | |
e7411303 JK |
845 | ### |
846 | ### series L | |
847 | ### | |
848 | ||
849 | cat >input <<INPUT_END | |
850 | blob | |
851 | mark :1 | |
852 | data <<EOF | |
853 | some data | |
854 | EOF | |
855 | ||
856 | blob | |
857 | mark :2 | |
858 | data <<EOF | |
859 | other data | |
860 | EOF | |
861 | ||
862 | commit refs/heads/L | |
863 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
864 | data <<COMMIT | |
865 | create L | |
866 | COMMIT | |
867 | ||
868 | M 644 :1 b. | |
869 | M 644 :1 b/other | |
870 | M 644 :1 ba | |
871 | ||
872 | commit refs/heads/L | |
873 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
874 | data <<COMMIT | |
875 | update L | |
876 | COMMIT | |
877 | ||
878 | M 644 :2 b. | |
879 | M 644 :2 b/other | |
880 | M 644 :2 ba | |
881 | INPUT_END | |
882 | ||
883 | cat >expect <<EXPECT_END | |
884 | :100644 100644 4268632... 55d3a52... M b. | |
885 | :040000 040000 0ae5cac... 443c768... M b | |
886 | :100644 100644 4268632... 55d3a52... M ba | |
887 | EXPECT_END | |
888 | ||
889 | test_expect_success \ | |
890 | 'L: verify internal tree sorting' \ | |
eaa2a6fc | 891 | 'git fast-import <input && |
82cb8afa | 892 | git diff-tree --abbrev --raw L^ L >output && |
3af82863 | 893 | test_cmp expect output' |
e7411303 | 894 | |
9a0edb79 DI |
895 | cat >input <<INPUT_END |
896 | blob | |
897 | mark :1 | |
898 | data <<EOF | |
899 | the data | |
900 | EOF | |
901 | ||
902 | commit refs/heads/L2 | |
903 | committer C O Mitter <committer@example.com> 1112912473 -0700 | |
904 | data <<COMMIT | |
905 | init L2 | |
906 | COMMIT | |
907 | M 644 :1 a/b/c | |
908 | M 644 :1 a/b/d | |
909 | M 644 :1 a/e/f | |
910 | ||
911 | commit refs/heads/L2 | |
912 | committer C O Mitter <committer@example.com> 1112912473 -0700 | |
913 | data <<COMMIT | |
914 | update L2 | |
915 | COMMIT | |
916 | C a g | |
917 | C a/e g/b | |
918 | M 644 :1 g/b/h | |
919 | INPUT_END | |
920 | ||
921 | cat <<EOF >expect | |
922 | g/b/f | |
923 | g/b/h | |
924 | EOF | |
925 | ||
8fb3ad76 | 926 | test_expect_success \ |
9a0edb79 DI |
927 | 'L: nested tree copy does not corrupt deltas' \ |
928 | 'git fast-import <input && | |
929 | git ls-tree L2 g/b/ >tmp && | |
930 | cat tmp | cut -f 2 >actual && | |
931 | test_cmp expect actual && | |
932 | git fsck `git rev-parse L2`' | |
933 | ||
934 | git update-ref -d refs/heads/L2 | |
935 | ||
f39a946a SP |
936 | ### |
937 | ### series M | |
938 | ### | |
939 | ||
940 | test_tick | |
941 | cat >input <<INPUT_END | |
942 | commit refs/heads/M1 | |
943 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
944 | data <<COMMIT | |
945 | file rename | |
946 | COMMIT | |
947 | ||
948 | from refs/heads/branch^0 | |
949 | R file2/newf file2/n.e.w.f | |
950 | ||
951 | INPUT_END | |
952 | ||
953 | cat >expect <<EOF | |
954 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f | |
955 | EOF | |
956 | test_expect_success \ | |
957 | 'M: rename file in same subdirectory' \ | |
eaa2a6fc | 958 | 'git fast-import <input && |
f39a946a SP |
959 | git diff-tree -M -r M1^ M1 >actual && |
960 | compare_diff_raw expect actual' | |
961 | ||
962 | cat >input <<INPUT_END | |
963 | commit refs/heads/M2 | |
964 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
965 | data <<COMMIT | |
966 | file rename | |
967 | COMMIT | |
968 | ||
969 | from refs/heads/branch^0 | |
970 | R file2/newf i/am/new/to/you | |
971 | ||
972 | INPUT_END | |
973 | ||
974 | cat >expect <<EOF | |
975 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you | |
976 | EOF | |
977 | test_expect_success \ | |
978 | 'M: rename file to new subdirectory' \ | |
eaa2a6fc | 979 | 'git fast-import <input && |
f39a946a SP |
980 | git diff-tree -M -r M2^ M2 >actual && |
981 | compare_diff_raw expect actual' | |
982 | ||
983 | cat >input <<INPUT_END | |
984 | commit refs/heads/M3 | |
985 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
986 | data <<COMMIT | |
987 | file rename | |
988 | COMMIT | |
989 | ||
990 | from refs/heads/M2^0 | |
991 | R i other/sub | |
992 | ||
993 | INPUT_END | |
994 | ||
995 | cat >expect <<EOF | |
996 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you | |
997 | EOF | |
998 | test_expect_success \ | |
999 | 'M: rename subdirectory to new subdirectory' \ | |
eaa2a6fc | 1000 | 'git fast-import <input && |
f39a946a SP |
1001 | git diff-tree -M -r M3^ M3 >actual && |
1002 | compare_diff_raw expect actual' | |
1003 | ||
aca70610 JK |
1004 | cat >input <<INPUT_END |
1005 | commit refs/heads/M4 | |
1006 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1007 | data <<COMMIT | |
1008 | rename root | |
1009 | COMMIT | |
1010 | ||
1011 | from refs/heads/M2^0 | |
1012 | R "" sub | |
1013 | ||
1014 | INPUT_END | |
1015 | ||
1016 | cat >expect <<EOF | |
1017 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf | |
1018 | :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4 | |
1019 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you | |
1020 | :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh | |
1021 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting | |
1022 | EOF | |
62bfa11c | 1023 | test_expect_success \ |
aca70610 JK |
1024 | 'M: rename root to subdirectory' \ |
1025 | 'git fast-import <input && | |
1026 | git diff-tree -M -r M4^ M4 >actual && | |
1027 | cat actual && | |
1028 | compare_diff_raw expect actual' | |
1029 | ||
b6f3481b SP |
1030 | ### |
1031 | ### series N | |
1032 | ### | |
1033 | ||
1034 | test_tick | |
1035 | cat >input <<INPUT_END | |
1036 | commit refs/heads/N1 | |
1037 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1038 | data <<COMMIT | |
1039 | file copy | |
1040 | COMMIT | |
1041 | ||
1042 | from refs/heads/branch^0 | |
1043 | C file2/newf file2/n.e.w.f | |
1044 | ||
1045 | INPUT_END | |
1046 | ||
1047 | cat >expect <<EOF | |
1048 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f | |
1049 | EOF | |
1050 | test_expect_success \ | |
1051 | 'N: copy file in same subdirectory' \ | |
eaa2a6fc | 1052 | 'git fast-import <input && |
b6f3481b SP |
1053 | git diff-tree -C --find-copies-harder -r N1^ N1 >actual && |
1054 | compare_diff_raw expect actual' | |
1055 | ||
1056 | cat >input <<INPUT_END | |
1057 | commit refs/heads/N2 | |
1058 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1059 | data <<COMMIT | |
1060 | clean directory copy | |
1061 | COMMIT | |
1062 | ||
1063 | from refs/heads/branch^0 | |
1064 | C file2 file3 | |
1065 | ||
1066 | commit refs/heads/N2 | |
1067 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1068 | data <<COMMIT | |
1069 | modify directory copy | |
1070 | COMMIT | |
1071 | ||
1072 | M 644 inline file3/file5 | |
1073 | data <<EOF | |
1074 | $file5_data | |
1075 | EOF | |
1076 | ||
1077 | INPUT_END | |
1078 | ||
1079 | cat >expect <<EOF | |
1080 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5 | |
1081 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf | |
1082 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf | |
1083 | EOF | |
1084 | test_expect_success \ | |
1085 | 'N: copy then modify subdirectory' \ | |
eaa2a6fc | 1086 | 'git fast-import <input && |
b6f3481b SP |
1087 | git diff-tree -C --find-copies-harder -r N2^^ N2 >actual && |
1088 | compare_diff_raw expect actual' | |
1089 | ||
1090 | cat >input <<INPUT_END | |
1091 | commit refs/heads/N3 | |
1092 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1093 | data <<COMMIT | |
1094 | dirty directory copy | |
1095 | COMMIT | |
1096 | ||
1097 | from refs/heads/branch^0 | |
1098 | M 644 inline file2/file5 | |
1099 | data <<EOF | |
1100 | $file5_data | |
1101 | EOF | |
1102 | ||
1103 | C file2 file3 | |
1104 | D file2/file5 | |
1105 | ||
1106 | INPUT_END | |
1107 | ||
1108 | test_expect_success \ | |
1109 | 'N: copy dirty subdirectory' \ | |
eaa2a6fc NS |
1110 | 'git fast-import <input && |
1111 | test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`' | |
b6f3481b | 1112 | |
334fba65 JN |
1113 | test_expect_success \ |
1114 | 'N: copy directory by id' \ | |
1115 | 'cat >expect <<-\EOF && | |
1116 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf | |
1117 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf | |
1118 | EOF | |
1119 | subdir=$(git rev-parse refs/heads/branch^0:file2) && | |
1120 | cat >input <<-INPUT_END && | |
1121 | commit refs/heads/N4 | |
1122 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1123 | data <<COMMIT | |
1124 | copy by tree hash | |
1125 | COMMIT | |
1126 | ||
1127 | from refs/heads/branch^0 | |
1128 | M 040000 $subdir file3 | |
1129 | INPUT_END | |
1130 | git fast-import <input && | |
1131 | git diff-tree -C --find-copies-harder -r N4^ N4 >actual && | |
1132 | compare_diff_raw expect actual' | |
1133 | ||
8dc6a373 | 1134 | test_expect_success PIPE 'N: read and copy directory' ' |
99094a7a | 1135 | cat >expect <<-\EOF && |
8dc6a373 DB |
1136 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf |
1137 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf | |
1138 | EOF | |
1139 | git update-ref -d refs/heads/N4 && | |
1140 | rm -f backflow && | |
1141 | mkfifo backflow && | |
1142 | ( | |
1143 | exec <backflow && | |
1144 | cat <<-EOF && | |
1145 | commit refs/heads/N4 | |
1146 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1147 | data <<COMMIT | |
1148 | copy by tree hash, part 2 | |
1149 | COMMIT | |
1150 | ||
1151 | from refs/heads/branch^0 | |
1152 | ls "file2" | |
1153 | EOF | |
1154 | read mode type tree filename && | |
1155 | echo "M 040000 $tree file3" | |
1156 | ) | | |
1157 | git fast-import --cat-blob-fd=3 3>backflow && | |
1158 | git diff-tree -C --find-copies-harder -r N4^ N4 >actual && | |
1159 | compare_diff_raw expect actual | |
1160 | ' | |
1161 | ||
1162 | test_expect_success PIPE 'N: empty directory reads as missing' ' | |
1163 | cat <<-\EOF >expect && | |
1164 | OBJNAME | |
1165 | :000000 100644 OBJNAME OBJNAME A unrelated | |
1166 | EOF | |
1167 | echo "missing src" >expect.response && | |
1168 | git update-ref -d refs/heads/read-empty && | |
1169 | rm -f backflow && | |
1170 | mkfifo backflow && | |
1171 | ( | |
1172 | exec <backflow && | |
1173 | cat <<-EOF && | |
1174 | commit refs/heads/read-empty | |
1175 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1176 | data <<COMMIT | |
1177 | read "empty" (missing) directory | |
1178 | COMMIT | |
1179 | ||
1180 | M 100644 inline src/greeting | |
1181 | data <<BLOB | |
1182 | hello | |
1183 | BLOB | |
1184 | C src/greeting dst1/non-greeting | |
1185 | C src/greeting unrelated | |
1186 | # leave behind "empty" src directory | |
1187 | D src/greeting | |
1188 | ls "src" | |
1189 | EOF | |
1190 | read -r line && | |
1191 | printf "%s\n" "$line" >response && | |
1192 | cat <<-\EOF | |
1193 | D dst1 | |
1194 | D dst2 | |
1195 | EOF | |
1196 | ) | | |
1197 | git fast-import --cat-blob-fd=3 3>backflow && | |
1198 | test_cmp expect.response response && | |
1199 | git rev-list read-empty | | |
1200 | git diff-tree -r --root --stdin | | |
1201 | sed "s/$_x40/OBJNAME/g" >actual && | |
1202 | test_cmp expect actual | |
1203 | ' | |
1204 | ||
2794ad52 DB |
1205 | test_expect_success \ |
1206 | 'N: copy root directory by tree hash' \ | |
1207 | 'cat >expect <<-\EOF && | |
1208 | :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf | |
1209 | :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf | |
1210 | EOF | |
1211 | root=$(git rev-parse refs/heads/branch^0^{tree}) && | |
1212 | cat >input <<-INPUT_END && | |
1213 | commit refs/heads/N6 | |
1214 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1215 | data <<COMMIT | |
1216 | copy root directory by tree hash | |
1217 | COMMIT | |
1218 | ||
1219 | from refs/heads/branch^0 | |
1220 | M 040000 $root "" | |
1221 | INPUT_END | |
1222 | git fast-import <input && | |
1223 | git diff-tree -C --find-copies-harder -r N4 N6 >actual && | |
1224 | compare_diff_raw expect actual' | |
1225 | ||
e0eb6b97 | 1226 | test_expect_success \ |
aca70610 JK |
1227 | 'N: copy root by path' \ |
1228 | 'cat >expect <<-\EOF && | |
1229 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf | |
1230 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf | |
1231 | :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4 | |
1232 | :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh | |
1233 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting | |
1234 | EOF | |
1235 | cat >input <<-INPUT_END && | |
1236 | commit refs/heads/N-copy-root-path | |
1237 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1238 | data <<COMMIT | |
1239 | copy root directory by (empty) path | |
1240 | COMMIT | |
1241 | ||
1242 | from refs/heads/branch^0 | |
1243 | C "" oldroot | |
1244 | INPUT_END | |
1245 | git fast-import <input && | |
1246 | git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual && | |
1247 | compare_diff_raw expect actual' | |
1248 | ||
8fe533f6 JN |
1249 | test_expect_success \ |
1250 | 'N: delete directory by copying' \ | |
1251 | 'cat >expect <<-\EOF && | |
1252 | OBJID | |
1253 | :100644 000000 OBJID OBJID D foo/bar/qux | |
1254 | OBJID | |
1255 | :000000 100644 OBJID OBJID A foo/bar/baz | |
1256 | :000000 100644 OBJID OBJID A foo/bar/qux | |
1257 | EOF | |
1258 | empty_tree=$(git mktree </dev/null) && | |
1259 | cat >input <<-INPUT_END && | |
1260 | commit refs/heads/N-delete | |
1261 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1262 | data <<COMMIT | |
1263 | collect data to be deleted | |
1264 | COMMIT | |
1265 | ||
1266 | deleteall | |
1267 | M 100644 inline foo/bar/baz | |
1268 | data <<DATA_END | |
1269 | hello | |
1270 | DATA_END | |
1271 | C "foo/bar/baz" "foo/bar/qux" | |
1272 | C "foo/bar/baz" "foo/bar/quux/1" | |
1273 | C "foo/bar/baz" "foo/bar/quuux" | |
1274 | M 040000 $empty_tree foo/bar/quux | |
1275 | M 040000 $empty_tree foo/bar/quuux | |
1276 | ||
1277 | commit refs/heads/N-delete | |
1278 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1279 | data <<COMMIT | |
1280 | delete subdirectory | |
1281 | COMMIT | |
1282 | ||
1283 | M 040000 $empty_tree foo/bar/qux | |
1284 | INPUT_END | |
1285 | git fast-import <input && | |
1286 | git rev-list N-delete | | |
1287 | git diff-tree -r --stdin --root --always | | |
1288 | sed -e "s/$_x40/OBJID/g" >actual && | |
1289 | test_cmp expect actual' | |
1290 | ||
334fba65 JN |
1291 | test_expect_success \ |
1292 | 'N: modify copied tree' \ | |
1293 | 'cat >expect <<-\EOF && | |
1294 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5 | |
1295 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf | |
1296 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf | |
1297 | EOF | |
1298 | subdir=$(git rev-parse refs/heads/branch^0:file2) && | |
1299 | cat >input <<-INPUT_END && | |
1300 | commit refs/heads/N5 | |
1301 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1302 | data <<COMMIT | |
1303 | copy by tree hash | |
1304 | COMMIT | |
1305 | ||
1306 | from refs/heads/branch^0 | |
1307 | M 040000 $subdir file3 | |
1308 | ||
1309 | commit refs/heads/N5 | |
1310 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1311 | data <<COMMIT | |
1312 | modify directory copy | |
1313 | COMMIT | |
1314 | ||
1315 | M 644 inline file3/file5 | |
1316 | data <<EOF | |
1317 | $file5_data | |
1318 | EOF | |
1319 | INPUT_END | |
1320 | git fast-import <input && | |
1321 | git diff-tree -C --find-copies-harder -r N5^^ N5 >actual && | |
1322 | compare_diff_raw expect actual' | |
1323 | ||
34215783 JN |
1324 | test_expect_success \ |
1325 | 'N: reject foo/ syntax' \ | |
1326 | 'subdir=$(git rev-parse refs/heads/branch^0:file2) && | |
1327 | test_must_fail git fast-import <<-INPUT_END | |
1328 | commit refs/heads/N5B | |
1329 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1330 | data <<COMMIT | |
1331 | copy with invalid syntax | |
1332 | COMMIT | |
1333 | ||
1334 | from refs/heads/branch^0 | |
1335 | M 040000 $subdir file3/ | |
1336 | INPUT_END' | |
1337 | ||
178e1dea JN |
1338 | test_expect_success \ |
1339 | 'N: reject foo/ syntax in copy source' \ | |
1340 | 'test_must_fail git fast-import <<-INPUT_END | |
1341 | commit refs/heads/N5C | |
1342 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1343 | data <<COMMIT | |
1344 | copy with invalid syntax | |
1345 | COMMIT | |
1346 | ||
1347 | from refs/heads/branch^0 | |
1348 | C file2/ file3 | |
1349 | INPUT_END' | |
1350 | ||
1351 | test_expect_success \ | |
1352 | 'N: reject foo/ syntax in rename source' \ | |
1353 | 'test_must_fail git fast-import <<-INPUT_END | |
1354 | commit refs/heads/N5D | |
1355 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1356 | data <<COMMIT | |
1357 | rename with invalid syntax | |
1358 | COMMIT | |
1359 | ||
1360 | from refs/heads/branch^0 | |
1361 | R file2/ file3 | |
1362 | INPUT_END' | |
1363 | ||
1364 | test_expect_success \ | |
1365 | 'N: reject foo/ syntax in ls argument' \ | |
1366 | 'test_must_fail git fast-import <<-INPUT_END | |
1367 | commit refs/heads/N5E | |
1368 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1369 | data <<COMMIT | |
1370 | copy with invalid syntax | |
1371 | COMMIT | |
1372 | ||
1373 | from refs/heads/branch^0 | |
1374 | ls "file2/" | |
1375 | INPUT_END' | |
1376 | ||
5edde510 JN |
1377 | test_expect_success \ |
1378 | 'N: copy to root by id and modify' \ | |
1379 | 'echo "hello, world" >expect.foo && | |
1380 | echo hello >expect.bar && | |
1381 | git fast-import <<-SETUP_END && | |
1382 | commit refs/heads/N7 | |
1383 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1384 | data <<COMMIT | |
1385 | hello, tree | |
1386 | COMMIT | |
1387 | ||
1388 | deleteall | |
1389 | M 644 inline foo/bar | |
1390 | data <<EOF | |
1391 | hello | |
1392 | EOF | |
1393 | SETUP_END | |
1394 | ||
1395 | tree=$(git rev-parse --verify N7:) && | |
1396 | git fast-import <<-INPUT_END && | |
1397 | commit refs/heads/N8 | |
1398 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1399 | data <<COMMIT | |
1400 | copy to root by id and modify | |
1401 | COMMIT | |
1402 | ||
1403 | M 040000 $tree "" | |
1404 | M 644 inline foo/foo | |
1405 | data <<EOF | |
1406 | hello, world | |
1407 | EOF | |
1408 | INPUT_END | |
1409 | git show N8:foo/foo >actual.foo && | |
1410 | git show N8:foo/bar >actual.bar && | |
1411 | test_cmp expect.foo actual.foo && | |
1412 | test_cmp expect.bar actual.bar' | |
1413 | ||
34215783 JN |
1414 | test_expect_success \ |
1415 | 'N: extract subtree' \ | |
1416 | 'branch=$(git rev-parse --verify refs/heads/branch^{tree}) && | |
1417 | cat >input <<-INPUT_END && | |
1418 | commit refs/heads/N9 | |
1419 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1420 | data <<COMMIT | |
1421 | extract subtree branch:newdir | |
1422 | COMMIT | |
1423 | ||
1424 | M 040000 $branch "" | |
971728c8 | 1425 | C "newdir" "" |
34215783 JN |
1426 | INPUT_END |
1427 | git fast-import <input && | |
1428 | git diff --exit-code branch:newdir N9' | |
1429 | ||
971728c8 JN |
1430 | test_expect_success \ |
1431 | 'N: modify subtree, extract it, and modify again' \ | |
1432 | 'echo hello >expect.baz && | |
1433 | echo hello, world >expect.qux && | |
1434 | git fast-import <<-SETUP_END && | |
1435 | commit refs/heads/N10 | |
1436 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1437 | data <<COMMIT | |
1438 | hello, tree | |
1439 | COMMIT | |
1440 | ||
1441 | deleteall | |
1442 | M 644 inline foo/bar/baz | |
1443 | data <<EOF | |
1444 | hello | |
1445 | EOF | |
1446 | SETUP_END | |
1447 | ||
1448 | tree=$(git rev-parse --verify N10:) && | |
1449 | git fast-import <<-INPUT_END && | |
1450 | commit refs/heads/N11 | |
1451 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1452 | data <<COMMIT | |
1453 | copy to root by id and modify | |
1454 | COMMIT | |
1455 | ||
1456 | M 040000 $tree "" | |
1457 | M 100644 inline foo/bar/qux | |
1458 | data <<EOF | |
1459 | hello, world | |
1460 | EOF | |
1461 | R "foo" "" | |
1462 | C "bar/qux" "bar/quux" | |
1463 | INPUT_END | |
1464 | git show N11:bar/baz >actual.baz && | |
1465 | git show N11:bar/qux >actual.qux && | |
1466 | git show N11:bar/quux >actual.quux && | |
1467 | test_cmp expect.baz actual.baz && | |
1468 | test_cmp expect.qux actual.qux && | |
1469 | test_cmp expect.qux actual.quux' | |
1470 | ||
401d53fa SP |
1471 | ### |
1472 | ### series O | |
1473 | ### | |
1474 | ||
1475 | cat >input <<INPUT_END | |
1476 | #we will | |
1477 | commit refs/heads/O1 | |
1478 | # -- ignore all of this text | |
1479 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1480 | # $GIT_COMMITTER_NAME has inserted here for his benefit. | |
1481 | data <<COMMIT | |
1482 | dirty directory copy | |
1483 | COMMIT | |
1484 | ||
1485 | # don't forget the import blank line! | |
1486 | # | |
1487 | # yes, we started from our usual base of branch^0. | |
1488 | # i like branch^0. | |
1489 | from refs/heads/branch^0 | |
1490 | # and we need to reuse file2/file5 from N3 above. | |
1491 | M 644 inline file2/file5 | |
1492 | # otherwise the tree will be different | |
1493 | data <<EOF | |
1494 | $file5_data | |
1495 | EOF | |
1496 | ||
1497 | # don't forget to copy file2 to file3 | |
1498 | C file2 file3 | |
1499 | # | |
1500 | # or to delete file5 from file2. | |
1501 | D file2/file5 | |
1502 | # are we done yet? | |
1503 | ||
1504 | INPUT_END | |
1505 | ||
1506 | test_expect_success \ | |
1507 | 'O: comments are all skipped' \ | |
eaa2a6fc NS |
1508 | 'git fast-import <input && |
1509 | test `git rev-parse N3` = `git rev-parse O1`' | |
401d53fa | 1510 | |
2c570cde SP |
1511 | cat >input <<INPUT_END |
1512 | commit refs/heads/O2 | |
1513 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1514 | data <<COMMIT | |
1515 | dirty directory copy | |
1516 | COMMIT | |
1517 | from refs/heads/branch^0 | |
1518 | M 644 inline file2/file5 | |
1519 | data <<EOF | |
1520 | $file5_data | |
1521 | EOF | |
1522 | C file2 file3 | |
1523 | D file2/file5 | |
1524 | ||
1525 | INPUT_END | |
1526 | ||
1527 | test_expect_success \ | |
1528 | 'O: blank lines not necessary after data commands' \ | |
eaa2a6fc NS |
1529 | 'git fast-import <input && |
1530 | test `git rev-parse N3` = `git rev-parse O2`' | |
2c570cde | 1531 | |
1fdb649c SP |
1532 | test_expect_success \ |
1533 | 'O: repack before next test' \ | |
1534 | 'git repack -a -d' | |
1535 | ||
1536 | cat >input <<INPUT_END | |
1537 | commit refs/heads/O3 | |
1538 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1539 | data <<COMMIT | |
1540 | zstring | |
1541 | COMMIT | |
1542 | commit refs/heads/O3 | |
1543 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1544 | data <<COMMIT | |
1545 | zof | |
1546 | COMMIT | |
1547 | checkpoint | |
1548 | commit refs/heads/O3 | |
1549 | mark :5 | |
1550 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1551 | data <<COMMIT | |
1552 | zempty | |
1553 | COMMIT | |
1554 | checkpoint | |
1555 | commit refs/heads/O3 | |
1556 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1557 | data <<COMMIT | |
1558 | zcommits | |
1559 | COMMIT | |
1560 | reset refs/tags/O3-2nd | |
1561 | from :5 | |
655e8515 AS |
1562 | reset refs/tags/O3-3rd |
1563 | from :5 | |
1fdb649c SP |
1564 | INPUT_END |
1565 | ||
1566 | cat >expect <<INPUT_END | |
1567 | string | |
1568 | of | |
1569 | empty | |
1570 | commits | |
1571 | INPUT_END | |
1572 | test_expect_success \ | |
1573 | 'O: blank lines not necessary after other commands' \ | |
eaa2a6fc | 1574 | 'git fast-import <input && |
1fdb649c SP |
1575 | test 8 = `find .git/objects/pack -type f | wc -l` && |
1576 | test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` && | |
1577 | git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual && | |
3af82863 | 1578 | test_cmp expect actual' |
1fdb649c | 1579 | |
ac053c02 SP |
1580 | cat >input <<INPUT_END |
1581 | commit refs/heads/O4 | |
1582 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1583 | data <<COMMIT | |
1584 | zstring | |
1585 | COMMIT | |
1586 | commit refs/heads/O4 | |
1587 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1588 | data <<COMMIT | |
1589 | zof | |
1590 | COMMIT | |
1591 | progress Two commits down, 2 to go! | |
1592 | commit refs/heads/O4 | |
1593 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1594 | data <<COMMIT | |
1595 | zempty | |
1596 | COMMIT | |
1597 | progress Three commits down, 1 to go! | |
1598 | commit refs/heads/O4 | |
1599 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1600 | data <<COMMIT | |
1601 | zcommits | |
1602 | COMMIT | |
1603 | progress I'm done! | |
1604 | INPUT_END | |
1605 | test_expect_success \ | |
1606 | 'O: progress outputs as requested by input' \ | |
eaa2a6fc | 1607 | 'git fast-import <input >actual && |
ac053c02 | 1608 | grep "progress " <input >expect && |
3af82863 | 1609 | test_cmp expect actual' |
ac053c02 | 1610 | |
03db4525 AG |
1611 | ### |
1612 | ### series P (gitlinks) | |
1613 | ### | |
1614 | ||
1615 | cat >input <<INPUT_END | |
1616 | blob | |
1617 | mark :1 | |
1618 | data 10 | |
1619 | test file | |
1620 | ||
1621 | reset refs/heads/sub | |
1622 | commit refs/heads/sub | |
1623 | mark :2 | |
1624 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1625 | data 12 | |
1626 | sub_initial | |
1627 | M 100644 :1 file | |
1628 | ||
1629 | blob | |
1630 | mark :3 | |
1631 | data <<DATAEND | |
1632 | [submodule "sub"] | |
1633 | path = sub | |
1634 | url = "`pwd`/sub" | |
1635 | DATAEND | |
1636 | ||
1637 | commit refs/heads/subuse1 | |
1638 | mark :4 | |
1639 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1640 | data 8 | |
1641 | initial | |
1642 | from refs/heads/master | |
1643 | M 100644 :3 .gitmodules | |
1644 | M 160000 :2 sub | |
1645 | ||
1646 | blob | |
1647 | mark :5 | |
1648 | data 20 | |
1649 | test file | |
1650 | more data | |
1651 | ||
1652 | commit refs/heads/sub | |
1653 | mark :6 | |
1654 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1655 | data 11 | |
1656 | sub_second | |
1657 | from :2 | |
1658 | M 100644 :5 file | |
1659 | ||
1660 | commit refs/heads/subuse1 | |
1661 | mark :7 | |
1662 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1663 | data 7 | |
1664 | second | |
1665 | from :4 | |
1666 | M 160000 :6 sub | |
1667 | ||
1668 | INPUT_END | |
1669 | ||
1670 | test_expect_success \ | |
cb8ad289 | 1671 | 'P: superproject & submodule mix' \ |
eaa2a6fc | 1672 | 'git fast-import <input && |
03db4525 | 1673 | git checkout subuse1 && |
fd4ec4f2 | 1674 | rm -rf sub && mkdir sub && (cd sub && |
03db4525 | 1675 | git init && |
8ee5d731 | 1676 | git fetch --update-head-ok .. refs/heads/sub:refs/heads/master && |
fd4ec4f2 | 1677 | git checkout master) && |
03db4525 AG |
1678 | git submodule init && |
1679 | git submodule update' | |
1680 | ||
eaa2a6fc NS |
1681 | SUBLAST=$(git rev-parse --verify sub) |
1682 | SUBPREV=$(git rev-parse --verify sub^) | |
03db4525 AG |
1683 | |
1684 | cat >input <<INPUT_END | |
1685 | blob | |
1686 | mark :1 | |
1687 | data <<DATAEND | |
1688 | [submodule "sub"] | |
1689 | path = sub | |
1690 | url = "`pwd`/sub" | |
1691 | DATAEND | |
1692 | ||
1693 | commit refs/heads/subuse2 | |
1694 | mark :2 | |
1695 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1696 | data 8 | |
1697 | initial | |
1698 | from refs/heads/master | |
1699 | M 100644 :1 .gitmodules | |
1700 | M 160000 $SUBPREV sub | |
1701 | ||
1702 | commit refs/heads/subuse2 | |
1703 | mark :3 | |
1704 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1705 | data 7 | |
1706 | second | |
1707 | from :2 | |
1708 | M 160000 $SUBLAST sub | |
1709 | ||
1710 | INPUT_END | |
1711 | ||
1712 | test_expect_success \ | |
1713 | 'P: verbatim SHA gitlinks' \ | |
1714 | 'git branch -D sub && | |
1715 | git gc && git prune && | |
eaa2a6fc NS |
1716 | git fast-import <input && |
1717 | test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)' | |
03db4525 AG |
1718 | |
1719 | test_tick | |
1720 | cat >input <<INPUT_END | |
1721 | commit refs/heads/subuse3 | |
1722 | mark :1 | |
1723 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1724 | data <<COMMIT | |
1725 | corrupt | |
1726 | COMMIT | |
1727 | ||
1728 | from refs/heads/subuse2 | |
1729 | M 160000 inline sub | |
1730 | data <<DATA | |
1731 | $SUBPREV | |
1732 | DATA | |
1733 | ||
1734 | INPUT_END | |
1735 | ||
1736 | test_expect_success 'P: fail on inline gitlink' ' | |
eaa2a6fc | 1737 | test_must_fail git fast-import <input' |
03db4525 AG |
1738 | |
1739 | test_tick | |
1740 | cat >input <<INPUT_END | |
1741 | blob | |
1742 | mark :1 | |
1743 | data <<DATA | |
1744 | $SUBPREV | |
1745 | DATA | |
1746 | ||
1747 | commit refs/heads/subuse3 | |
1748 | mark :2 | |
1749 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1750 | data <<COMMIT | |
1751 | corrupt | |
1752 | COMMIT | |
1753 | ||
1754 | from refs/heads/subuse2 | |
1755 | M 160000 :1 sub | |
1756 | ||
1757 | INPUT_END | |
1758 | ||
1759 | test_expect_success 'P: fail on blob mark in gitlink' ' | |
eaa2a6fc | 1760 | test_must_fail git fast-import <input' |
03db4525 | 1761 | |
a8dd2e7d JH |
1762 | ### |
1763 | ### series Q (notes) | |
1764 | ### | |
1765 | ||
2a113aee JH |
1766 | note1_data="The first note for the first commit" |
1767 | note2_data="The first note for the second commit" | |
1768 | note3_data="The first note for the third commit" | |
1769 | note1b_data="The second note for the first commit" | |
1770 | note1c_data="The third note for the first commit" | |
1771 | note2b_data="The second note for the second commit" | |
a8dd2e7d JH |
1772 | |
1773 | test_tick | |
1774 | cat >input <<INPUT_END | |
1775 | blob | |
1776 | mark :2 | |
1777 | data <<EOF | |
1778 | $file2_data | |
1779 | EOF | |
1780 | ||
1781 | commit refs/heads/notes-test | |
1782 | mark :3 | |
1783 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1784 | data <<COMMIT | |
1785 | first (:3) | |
1786 | COMMIT | |
1787 | ||
1788 | M 644 :2 file2 | |
1789 | ||
1790 | blob | |
1791 | mark :4 | |
1792 | data $file4_len | |
1793 | $file4_data | |
1794 | commit refs/heads/notes-test | |
1795 | mark :5 | |
1796 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1797 | data <<COMMIT | |
1798 | second (:5) | |
1799 | COMMIT | |
1800 | ||
1801 | M 644 :4 file4 | |
1802 | ||
1803 | commit refs/heads/notes-test | |
1804 | mark :6 | |
1805 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1806 | data <<COMMIT | |
1807 | third (:6) | |
1808 | COMMIT | |
1809 | ||
1810 | M 644 inline file5 | |
1811 | data <<EOF | |
1812 | $file5_data | |
1813 | EOF | |
1814 | ||
1815 | M 755 inline file6 | |
1816 | data <<EOF | |
1817 | $file6_data | |
1818 | EOF | |
1819 | ||
1820 | blob | |
1821 | mark :7 | |
1822 | data <<EOF | |
1823 | $note1_data | |
1824 | EOF | |
1825 | ||
1826 | blob | |
1827 | mark :8 | |
1828 | data <<EOF | |
1829 | $note2_data | |
1830 | EOF | |
1831 | ||
1832 | commit refs/notes/foobar | |
1833 | mark :9 | |
1834 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1835 | data <<COMMIT | |
1836 | notes (:9) | |
1837 | COMMIT | |
1838 | ||
1839 | N :7 :3 | |
1840 | N :8 :5 | |
1841 | N inline :6 | |
1842 | data <<EOF | |
1843 | $note3_data | |
1844 | EOF | |
1845 | ||
2a113aee JH |
1846 | commit refs/notes/foobar |
1847 | mark :10 | |
1848 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1849 | data <<COMMIT | |
1850 | notes (:10) | |
1851 | COMMIT | |
1852 | ||
1853 | N inline :3 | |
1854 | data <<EOF | |
1855 | $note1b_data | |
1856 | EOF | |
1857 | ||
1858 | commit refs/notes/foobar2 | |
1859 | mark :11 | |
1860 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1861 | data <<COMMIT | |
1862 | notes (:11) | |
1863 | COMMIT | |
1864 | ||
1865 | N inline :3 | |
1866 | data <<EOF | |
1867 | $note1c_data | |
1868 | EOF | |
1869 | ||
1870 | commit refs/notes/foobar | |
1871 | mark :12 | |
1872 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1873 | data <<COMMIT | |
1874 | notes (:12) | |
1875 | COMMIT | |
1876 | ||
1877 | deleteall | |
1878 | N inline :5 | |
1879 | data <<EOF | |
1880 | $note2b_data | |
1881 | EOF | |
1882 | ||
a8dd2e7d | 1883 | INPUT_END |
2a113aee | 1884 | |
a8dd2e7d JH |
1885 | test_expect_success \ |
1886 | 'Q: commit notes' \ | |
1887 | 'git fast-import <input && | |
1888 | git whatchanged notes-test' | |
05880b02 JS |
1889 | |
1890 | test_expect_success 'Q: verify pack' ' | |
1891 | verify_packs | |
1892 | ' | |
a8dd2e7d JH |
1893 | |
1894 | commit1=$(git rev-parse notes-test~2) | |
1895 | commit2=$(git rev-parse notes-test^) | |
1896 | commit3=$(git rev-parse notes-test) | |
1897 | ||
1898 | cat >expect <<EOF | |
1899 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1900 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1901 | ||
1902 | first (:3) | |
1903 | EOF | |
1904 | test_expect_success \ | |
1905 | 'Q: verify first commit' \ | |
1906 | 'git cat-file commit notes-test~2 | sed 1d >actual && | |
1907 | test_cmp expect actual' | |
1908 | ||
1909 | cat >expect <<EOF | |
1910 | parent $commit1 | |
1911 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1912 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1913 | ||
1914 | second (:5) | |
1915 | EOF | |
1916 | test_expect_success \ | |
1917 | 'Q: verify second commit' \ | |
1918 | 'git cat-file commit notes-test^ | sed 1d >actual && | |
1919 | test_cmp expect actual' | |
1920 | ||
1921 | cat >expect <<EOF | |
1922 | parent $commit2 | |
1923 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1924 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1925 | ||
1926 | third (:6) | |
1927 | EOF | |
1928 | test_expect_success \ | |
1929 | 'Q: verify third commit' \ | |
1930 | 'git cat-file commit notes-test | sed 1d >actual && | |
1931 | test_cmp expect actual' | |
1932 | ||
1933 | cat >expect <<EOF | |
1934 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1935 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1936 | ||
1937 | notes (:9) | |
1938 | EOF | |
1939 | test_expect_success \ | |
2a113aee JH |
1940 | 'Q: verify first notes commit' \ |
1941 | 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual && | |
a8dd2e7d JH |
1942 | test_cmp expect actual' |
1943 | ||
1944 | cat >expect.unsorted <<EOF | |
1945 | 100644 blob $commit1 | |
1946 | 100644 blob $commit2 | |
1947 | 100644 blob $commit3 | |
1948 | EOF | |
1949 | cat expect.unsorted | sort >expect | |
1950 | test_expect_success \ | |
2a113aee JH |
1951 | 'Q: verify first notes tree' \ |
1952 | 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual && | |
a8dd2e7d JH |
1953 | test_cmp expect actual' |
1954 | ||
1955 | echo "$note1_data" >expect | |
1956 | test_expect_success \ | |
2a113aee JH |
1957 | 'Q: verify first note for first commit' \ |
1958 | 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual' | |
a8dd2e7d JH |
1959 | |
1960 | echo "$note2_data" >expect | |
1961 | test_expect_success \ | |
2a113aee JH |
1962 | 'Q: verify first note for second commit' \ |
1963 | 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual' | |
1964 | ||
1965 | echo "$note3_data" >expect | |
1966 | test_expect_success \ | |
1967 | 'Q: verify first note for third commit' \ | |
1968 | 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual' | |
1969 | ||
1970 | cat >expect <<EOF | |
1971 | parent `git rev-parse --verify refs/notes/foobar~2` | |
1972 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1973 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1974 | ||
1975 | notes (:10) | |
1976 | EOF | |
1977 | test_expect_success \ | |
1978 | 'Q: verify second notes commit' \ | |
1979 | 'git cat-file commit refs/notes/foobar^ | sed 1d >actual && | |
1980 | test_cmp expect actual' | |
1981 | ||
1982 | cat >expect.unsorted <<EOF | |
1983 | 100644 blob $commit1 | |
1984 | 100644 blob $commit2 | |
1985 | 100644 blob $commit3 | |
1986 | EOF | |
1987 | cat expect.unsorted | sort >expect | |
1988 | test_expect_success \ | |
1989 | 'Q: verify second notes tree' \ | |
1990 | 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual && | |
1991 | test_cmp expect actual' | |
1992 | ||
1993 | echo "$note1b_data" >expect | |
1994 | test_expect_success \ | |
1995 | 'Q: verify second note for first commit' \ | |
1996 | 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual' | |
1997 | ||
1998 | echo "$note2_data" >expect | |
1999 | test_expect_success \ | |
2000 | 'Q: verify first note for second commit' \ | |
2001 | 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual' | |
a8dd2e7d JH |
2002 | |
2003 | echo "$note3_data" >expect | |
2004 | test_expect_success \ | |
2a113aee JH |
2005 | 'Q: verify first note for third commit' \ |
2006 | 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual' | |
2007 | ||
2008 | cat >expect <<EOF | |
2009 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2010 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2011 | ||
2012 | notes (:11) | |
2013 | EOF | |
2014 | test_expect_success \ | |
2015 | 'Q: verify third notes commit' \ | |
2016 | 'git cat-file commit refs/notes/foobar2 | sed 1d >actual && | |
2017 | test_cmp expect actual' | |
2018 | ||
2019 | cat >expect.unsorted <<EOF | |
2020 | 100644 blob $commit1 | |
2021 | EOF | |
2022 | cat expect.unsorted | sort >expect | |
2023 | test_expect_success \ | |
2024 | 'Q: verify third notes tree' \ | |
2025 | 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual && | |
2026 | test_cmp expect actual' | |
2027 | ||
2028 | echo "$note1c_data" >expect | |
2029 | test_expect_success \ | |
2030 | 'Q: verify third note for first commit' \ | |
2031 | 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual' | |
2032 | ||
2033 | cat >expect <<EOF | |
2034 | parent `git rev-parse --verify refs/notes/foobar^` | |
2035 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2036 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2037 | ||
2038 | notes (:12) | |
2039 | EOF | |
2040 | test_expect_success \ | |
2041 | 'Q: verify fourth notes commit' \ | |
2042 | 'git cat-file commit refs/notes/foobar | sed 1d >actual && | |
2043 | test_cmp expect actual' | |
2044 | ||
2045 | cat >expect.unsorted <<EOF | |
2046 | 100644 blob $commit2 | |
2047 | EOF | |
2048 | cat expect.unsorted | sort >expect | |
2049 | test_expect_success \ | |
2050 | 'Q: verify fourth notes tree' \ | |
2051 | 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual && | |
2052 | test_cmp expect actual' | |
2053 | ||
2054 | echo "$note2b_data" >expect | |
2055 | test_expect_success \ | |
2056 | 'Q: verify second note for second commit' \ | |
2057 | 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual' | |
a8dd2e7d | 2058 | |
0bc69881 DI |
2059 | cat >input <<EOF |
2060 | reset refs/heads/Q0 | |
2061 | ||
2062 | commit refs/heads/note-Q0 | |
2063 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2064 | data <<COMMIT | |
2065 | Note for an empty branch. | |
2066 | COMMIT | |
2067 | ||
2068 | N inline refs/heads/Q0 | |
2069 | data <<NOTE | |
2070 | some note | |
2071 | NOTE | |
2072 | EOF | |
2073 | test_expect_success \ | |
2074 | 'Q: deny note on empty branch' \ | |
2075 | 'test_must_fail git fast-import <input' | |
f963bd5d | 2076 | ### |
2792f26c | 2077 | ### series R (feature and option) |
f963bd5d SR |
2078 | ### |
2079 | ||
2080 | cat >input <<EOF | |
2081 | feature no-such-feature-exists | |
2082 | EOF | |
2083 | ||
2084 | test_expect_success 'R: abort on unsupported feature' ' | |
2085 | test_must_fail git fast-import <input | |
2086 | ' | |
2087 | ||
2088 | cat >input <<EOF | |
2089 | feature date-format=now | |
2090 | EOF | |
2091 | ||
2092 | test_expect_success 'R: supported feature is accepted' ' | |
2093 | git fast-import <input | |
2094 | ' | |
2095 | ||
2096 | cat >input << EOF | |
2097 | blob | |
2098 | data 3 | |
2099 | hi | |
2100 | feature date-format=now | |
2101 | EOF | |
2102 | ||
2103 | test_expect_success 'R: abort on receiving feature after data command' ' | |
2104 | test_must_fail git fast-import <input | |
2105 | ' | |
2106 | ||
081751c8 SR |
2107 | cat >input << EOF |
2108 | feature import-marks=git.marks | |
2109 | feature import-marks=git2.marks | |
2110 | EOF | |
2111 | ||
2112 | test_expect_success 'R: only one import-marks feature allowed per stream' ' | |
2113 | test_must_fail git fast-import <input | |
2114 | ' | |
2115 | ||
f963bd5d SR |
2116 | cat >input << EOF |
2117 | feature export-marks=git.marks | |
2118 | blob | |
2119 | mark :1 | |
2120 | data 3 | |
2121 | hi | |
2122 | ||
2123 | EOF | |
2124 | ||
2125 | test_expect_success \ | |
2126 | 'R: export-marks feature results in a marks file being created' \ | |
2127 | 'cat input | git fast-import && | |
2128 | grep :1 git.marks' | |
2129 | ||
2130 | test_expect_success \ | |
8d8136c3 | 2131 | 'R: export-marks options can be overridden by commandline options' \ |
f963bd5d SR |
2132 | 'cat input | git fast-import --export-marks=other.marks && |
2133 | grep :1 other.marks' | |
2134 | ||
dded4f12 RR |
2135 | test_expect_success 'R: catch typo in marks file name' ' |
2136 | test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null && | |
2137 | echo "feature import-marks=nonexistent.marks" | | |
2138 | test_must_fail git fast-import | |
2139 | ' | |
2140 | ||
2141 | test_expect_success 'R: import and output marks can be the same file' ' | |
2142 | rm -f io.marks && | |
2143 | blob=$(echo hi | git hash-object --stdin) && | |
2144 | cat >expect <<-EOF && | |
2145 | :1 $blob | |
2146 | :2 $blob | |
2147 | EOF | |
2148 | git fast-import --export-marks=io.marks <<-\EOF && | |
2149 | blob | |
2150 | mark :1 | |
2151 | data 3 | |
2152 | hi | |
2153 | ||
2154 | EOF | |
2155 | git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF && | |
2156 | blob | |
2157 | mark :2 | |
2158 | data 3 | |
2159 | hi | |
2160 | ||
2161 | EOF | |
2162 | test_cmp expect io.marks | |
2163 | ' | |
2164 | ||
2165 | test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' ' | |
2166 | rm -f io.marks && | |
2167 | test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF | |
2168 | blob | |
2169 | mark :1 | |
2170 | data 3 | |
2171 | hi | |
2172 | ||
2173 | EOF | |
2174 | ' | |
2175 | ||
2176 | test_expect_success 'R: --import-marks-if-exists' ' | |
2177 | rm -f io.marks && | |
2178 | blob=$(echo hi | git hash-object --stdin) && | |
2179 | echo ":1 $blob" >expect && | |
2180 | git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF && | |
2181 | blob | |
2182 | mark :1 | |
2183 | data 3 | |
2184 | hi | |
2185 | ||
2186 | EOF | |
2187 | test_cmp expect io.marks | |
2188 | ' | |
2189 | ||
3beb4fc4 DI |
2190 | test_expect_success 'R: feature import-marks-if-exists' ' |
2191 | rm -f io.marks && | |
2192 | >expect && | |
2193 | ||
2194 | git fast-import --export-marks=io.marks <<-\EOF && | |
2195 | feature import-marks-if-exists=not_io.marks | |
2196 | EOF | |
2197 | test_cmp expect io.marks && | |
2198 | ||
2199 | blob=$(echo hi | git hash-object --stdin) && | |
2200 | ||
2201 | echo ":1 $blob" >io.marks && | |
2202 | echo ":1 $blob" >expect && | |
2203 | echo ":2 $blob" >>expect && | |
2204 | ||
2205 | git fast-import --export-marks=io.marks <<-\EOF && | |
2206 | feature import-marks-if-exists=io.marks | |
2207 | blob | |
2208 | mark :2 | |
2209 | data 3 | |
2210 | hi | |
2211 | ||
2212 | EOF | |
2213 | test_cmp expect io.marks && | |
2214 | ||
2215 | echo ":3 $blob" >>expect && | |
2216 | ||
2217 | git fast-import --import-marks=io.marks \ | |
2218 | --export-marks=io.marks <<-\EOF && | |
2219 | feature import-marks-if-exists=not_io.marks | |
2220 | blob | |
2221 | mark :3 | |
2222 | data 3 | |
2223 | hi | |
2224 | ||
2225 | EOF | |
2226 | test_cmp expect io.marks && | |
2227 | ||
2228 | >expect && | |
2229 | ||
2230 | git fast-import --import-marks-if-exists=not_io.marks \ | |
8fb26872 | 2231 | --export-marks=io.marks <<-\EOF && |
3beb4fc4 DI |
2232 | feature import-marks-if-exists=io.marks |
2233 | EOF | |
2234 | test_cmp expect io.marks | |
2235 | ' | |
2236 | ||
f963bd5d SR |
2237 | cat >input << EOF |
2238 | feature import-marks=marks.out | |
2239 | feature export-marks=marks.new | |
2240 | EOF | |
2241 | ||
2242 | test_expect_success \ | |
2243 | 'R: import to output marks works without any content' \ | |
2244 | 'cat input | git fast-import && | |
2245 | test_cmp marks.out marks.new' | |
2246 | ||
2247 | cat >input <<EOF | |
7be8b3ba | 2248 | feature import-marks=nonexistent.marks |
f963bd5d SR |
2249 | feature export-marks=marks.new |
2250 | EOF | |
2251 | ||
2252 | test_expect_success \ | |
2253 | 'R: import marks prefers commandline marks file over the stream' \ | |
2254 | 'cat input | git fast-import --import-marks=marks.out && | |
2255 | test_cmp marks.out marks.new' | |
2256 | ||
081751c8 SR |
2257 | |
2258 | cat >input <<EOF | |
7be8b3ba | 2259 | feature import-marks=nonexistent.marks |
081751c8 SR |
2260 | feature export-marks=combined.marks |
2261 | EOF | |
2262 | ||
2263 | test_expect_success 'R: multiple --import-marks= should be honoured' ' | |
2264 | head -n2 marks.out > one.marks && | |
2265 | tail -n +3 marks.out > two.marks && | |
2266 | git fast-import --import-marks=one.marks --import-marks=two.marks <input && | |
2267 | test_cmp marks.out combined.marks | |
2268 | ' | |
2269 | ||
bc3c79ae SR |
2270 | cat >input <<EOF |
2271 | feature relative-marks | |
2272 | feature import-marks=relative.in | |
2273 | feature export-marks=relative.out | |
2274 | EOF | |
2275 | ||
2276 | test_expect_success 'R: feature relative-marks should be honoured' ' | |
2277 | mkdir -p .git/info/fast-import/ && | |
2278 | cp marks.new .git/info/fast-import/relative.in && | |
2279 | git fast-import <input && | |
2280 | test_cmp marks.new .git/info/fast-import/relative.out | |
2281 | ' | |
2282 | ||
2283 | cat >input <<EOF | |
2284 | feature relative-marks | |
2285 | feature import-marks=relative.in | |
2286 | feature no-relative-marks | |
2287 | feature export-marks=non-relative.out | |
2288 | EOF | |
2289 | ||
2290 | test_expect_success 'R: feature no-relative-marks should be honoured' ' | |
2291 | git fast-import <input && | |
2292 | test_cmp marks.new non-relative.out | |
2293 | ' | |
2294 | ||
8dc6a373 DB |
2295 | test_expect_success 'R: feature ls supported' ' |
2296 | echo "feature ls" | | |
2297 | git fast-import | |
2298 | ' | |
2299 | ||
85c62395 DB |
2300 | test_expect_success 'R: feature cat-blob supported' ' |
2301 | echo "feature cat-blob" | | |
2302 | git fast-import | |
2303 | ' | |
2304 | ||
2305 | test_expect_success 'R: cat-blob-fd must be a nonnegative integer' ' | |
2306 | test_must_fail git fast-import --cat-blob-fd=-1 </dev/null | |
2307 | ' | |
2308 | ||
f57a8715 | 2309 | test_expect_success !MINGW 'R: print old blob' ' |
85c62395 DB |
2310 | blob=$(echo "yes it can" | git hash-object -w --stdin) && |
2311 | cat >expect <<-EOF && | |
2312 | ${blob} blob 11 | |
2313 | yes it can | |
2314 | ||
2315 | EOF | |
2316 | echo "cat-blob $blob" | | |
2317 | git fast-import --cat-blob-fd=6 6>actual && | |
2318 | test_cmp expect actual | |
2319 | ' | |
2320 | ||
f57a8715 | 2321 | test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' ' |
85c62395 DB |
2322 | echo hello >greeting && |
2323 | blob=$(git hash-object -w greeting) && | |
2324 | cat >expect <<-EOF && | |
2325 | ${blob} blob 6 | |
2326 | hello | |
2327 | ||
2328 | EOF | |
2329 | git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF && | |
2330 | cat-blob $blob | |
2331 | EOF | |
2332 | test_cmp expect actual.3 && | |
2333 | test_cmp empty actual.1 && | |
2334 | git fast-import 3>actual.3 >actual.1 <<-EOF && | |
2335 | option cat-blob-fd=3 | |
2336 | cat-blob $blob | |
2337 | EOF | |
2338 | test_cmp empty actual.3 && | |
2339 | test_cmp expect actual.1 | |
2340 | ' | |
2341 | ||
28c7b1f7 MH |
2342 | test_expect_success !MINGW 'R: print mark for new blob' ' |
2343 | echo "effluentish" | git hash-object --stdin >expect && | |
2344 | git fast-import --cat-blob-fd=6 6>actual <<-\EOF && | |
2345 | blob | |
2346 | mark :1 | |
2347 | data <<BLOB_END | |
2348 | effluentish | |
2349 | BLOB_END | |
2350 | get-mark :1 | |
2351 | EOF | |
2352 | test_cmp expect actual | |
2353 | ' | |
2354 | ||
f57a8715 | 2355 | test_expect_success !MINGW 'R: print new blob' ' |
85c62395 DB |
2356 | blob=$(echo "yep yep yep" | git hash-object --stdin) && |
2357 | cat >expect <<-EOF && | |
2358 | ${blob} blob 12 | |
2359 | yep yep yep | |
2360 | ||
2361 | EOF | |
2362 | git fast-import --cat-blob-fd=6 6>actual <<-\EOF && | |
2363 | blob | |
2364 | mark :1 | |
2365 | data <<BLOB_END | |
2366 | yep yep yep | |
2367 | BLOB_END | |
2368 | cat-blob :1 | |
2369 | EOF | |
2370 | test_cmp expect actual | |
2371 | ' | |
2372 | ||
f57a8715 | 2373 | test_expect_success !MINGW 'R: print new blob by sha1' ' |
85c62395 DB |
2374 | blob=$(echo "a new blob named by sha1" | git hash-object --stdin) && |
2375 | cat >expect <<-EOF && | |
2376 | ${blob} blob 25 | |
2377 | a new blob named by sha1 | |
2378 | ||
2379 | EOF | |
2380 | git fast-import --cat-blob-fd=6 6>actual <<-EOF && | |
2381 | blob | |
2382 | data <<BLOB_END | |
2383 | a new blob named by sha1 | |
2384 | BLOB_END | |
2385 | cat-blob $blob | |
2386 | EOF | |
2387 | test_cmp expect actual | |
2388 | ' | |
2389 | ||
2390 | test_expect_success 'setup: big file' ' | |
2391 | ( | |
2392 | echo "the quick brown fox jumps over the lazy dog" >big && | |
2393 | for i in 1 2 3 | |
2394 | do | |
2395 | cat big big big big >bigger && | |
2396 | cat bigger bigger bigger bigger >big || | |
2397 | exit | |
2398 | done | |
2399 | ) | |
2400 | ' | |
2401 | ||
2402 | test_expect_success 'R: print two blobs to stdout' ' | |
2403 | blob1=$(git hash-object big) && | |
2404 | blob1_len=$(wc -c <big) && | |
2405 | blob2=$(echo hello | git hash-object --stdin) && | |
2406 | { | |
2407 | echo ${blob1} blob $blob1_len && | |
2408 | cat big && | |
2409 | cat <<-EOF | |
2410 | ||
2411 | ${blob2} blob 6 | |
2412 | hello | |
2413 | ||
2414 | EOF | |
2415 | } >expect && | |
2416 | { | |
2417 | cat <<-\END_PART1 && | |
2418 | blob | |
2419 | mark :1 | |
2420 | data <<data_end | |
2421 | END_PART1 | |
2422 | cat big && | |
2423 | cat <<-\EOF | |
2424 | data_end | |
2425 | blob | |
2426 | mark :2 | |
2427 | data <<data_end | |
2428 | hello | |
2429 | data_end | |
2430 | cat-blob :1 | |
2431 | cat-blob :2 | |
2432 | EOF | |
2433 | } | | |
2434 | git fast-import >actual && | |
2435 | test_cmp expect actual | |
2436 | ' | |
2437 | ||
85c62395 DB |
2438 | test_expect_success PIPE 'R: copy using cat-file' ' |
2439 | expect_id=$(git hash-object big) && | |
2440 | expect_len=$(wc -c <big) && | |
2441 | echo $expect_id blob $expect_len >expect.response && | |
2442 | ||
2443 | rm -f blobs && | |
2444 | cat >frontend <<-\FRONTEND_END && | |
2445 | #!/bin/sh | |
85c62395 DB |
2446 | FRONTEND_END |
2447 | ||
2448 | mkfifo blobs && | |
2449 | ( | |
2450 | export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE && | |
4de0bbd8 JN |
2451 | cat <<-\EOF && |
2452 | feature cat-blob | |
2453 | blob | |
2454 | mark :1 | |
2455 | data <<BLOB | |
2456 | EOF | |
2457 | cat big && | |
2458 | cat <<-\EOF && | |
2459 | BLOB | |
2460 | cat-blob :1 | |
2461 | EOF | |
2462 | ||
2463 | read blob_id type size <&3 && | |
2464 | echo "$blob_id $type $size" >response && | |
2465 | head_c $size >blob <&3 && | |
2466 | read newline <&3 && | |
2467 | ||
2468 | cat <<-EOF && | |
2469 | commit refs/heads/copied | |
2470 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2471 | data <<COMMIT | |
2472 | copy big file as file3 | |
2473 | COMMIT | |
2474 | M 644 inline file3 | |
2475 | data <<BLOB | |
2476 | EOF | |
2477 | cat blob && | |
2478 | echo BLOB | |
2479 | ) 3<blobs | | |
2480 | git fast-import --cat-blob-fd=3 3>blobs && | |
85c62395 DB |
2481 | git show copied:file3 >actual && |
2482 | test_cmp expect.response response && | |
2483 | test_cmp big actual | |
2484 | ' | |
2485 | ||
777f80d7 JN |
2486 | test_expect_success PIPE 'R: print blob mid-commit' ' |
2487 | rm -f blobs && | |
2488 | echo "A blob from _before_ the commit." >expect && | |
2489 | mkfifo blobs && | |
2490 | ( | |
2491 | exec 3<blobs && | |
2492 | cat <<-EOF && | |
2493 | feature cat-blob | |
2494 | blob | |
2495 | mark :1 | |
2496 | data <<BLOB | |
2497 | A blob from _before_ the commit. | |
2498 | BLOB | |
2499 | commit refs/heads/temporary | |
2500 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2501 | data <<COMMIT | |
2502 | Empty commit | |
2503 | COMMIT | |
2504 | cat-blob :1 | |
2505 | EOF | |
2506 | ||
2507 | read blob_id type size <&3 && | |
4de0bbd8 | 2508 | head_c $size >actual <&3 && |
777f80d7 JN |
2509 | read newline <&3 && |
2510 | ||
2511 | echo | |
2512 | ) | | |
2513 | git fast-import --cat-blob-fd=3 3>blobs && | |
2514 | test_cmp expect actual | |
2515 | ' | |
2516 | ||
2517 | test_expect_success PIPE 'R: print staged blob within commit' ' | |
2518 | rm -f blobs && | |
2519 | echo "A blob from _within_ the commit." >expect && | |
2520 | mkfifo blobs && | |
2521 | ( | |
2522 | exec 3<blobs && | |
2523 | cat <<-EOF && | |
2524 | feature cat-blob | |
2525 | commit refs/heads/within | |
2526 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2527 | data <<COMMIT | |
2528 | Empty commit | |
2529 | COMMIT | |
2530 | M 644 inline within | |
2531 | data <<BLOB | |
2532 | A blob from _within_ the commit. | |
2533 | BLOB | |
2534 | EOF | |
2535 | ||
2536 | to_get=$( | |
2537 | echo "A blob from _within_ the commit." | | |
2538 | git hash-object --stdin | |
2539 | ) && | |
2540 | echo "cat-blob $to_get" && | |
2541 | ||
2542 | read blob_id type size <&3 && | |
4de0bbd8 | 2543 | head_c $size >actual <&3 && |
777f80d7 JN |
2544 | read newline <&3 && |
2545 | ||
2546 | echo deleteall | |
2547 | ) | | |
2548 | git fast-import --cat-blob-fd=3 3>blobs && | |
2549 | test_cmp expect actual | |
2550 | ' | |
2551 | ||
2792f26c SR |
2552 | cat >input << EOF |
2553 | option git quiet | |
2554 | blob | |
2555 | data 3 | |
2556 | hi | |
2557 | ||
2558 | EOF | |
2559 | ||
2792f26c SR |
2560 | test_expect_success 'R: quiet option results in no stats being output' ' |
2561 | cat input | git fast-import 2> output && | |
2562 | test_cmp empty output | |
2563 | ' | |
2564 | ||
be56862f SR |
2565 | test_expect_success 'R: feature done means terminating "done" is mandatory' ' |
2566 | echo feature done | test_must_fail git fast-import && | |
2567 | test_must_fail git fast-import --done </dev/null | |
2568 | ' | |
2569 | ||
2570 | test_expect_success 'R: terminating "done" with trailing gibberish is ok' ' | |
2571 | git fast-import <<-\EOF && | |
2572 | feature done | |
2573 | done | |
2574 | trailing gibberish | |
2575 | EOF | |
2576 | git fast-import <<-\EOF | |
2577 | done | |
2578 | more trailing gibberish | |
2579 | EOF | |
2580 | ' | |
2581 | ||
2582 | test_expect_success 'R: terminating "done" within commit' ' | |
2583 | cat >expect <<-\EOF && | |
2584 | OBJID | |
2585 | :000000 100644 OBJID OBJID A hello.c | |
2586 | :000000 100644 OBJID OBJID A hello2.c | |
2587 | EOF | |
2588 | git fast-import <<-EOF && | |
2589 | commit refs/heads/done-ends | |
2590 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2591 | data <<EOT | |
2592 | Commit terminated by "done" command | |
2593 | EOT | |
2594 | M 100644 inline hello.c | |
2595 | data <<EOT | |
2596 | Hello, world. | |
2597 | EOT | |
2598 | C hello.c hello2.c | |
2599 | done | |
2600 | EOF | |
2601 | git rev-list done-ends | | |
2602 | git diff-tree -r --stdin --root --always | | |
2603 | sed -e "s/$_x40/OBJID/g" >actual && | |
2604 | test_cmp expect actual | |
2605 | ' | |
2606 | ||
2792f26c SR |
2607 | cat >input <<EOF |
2608 | option git non-existing-option | |
2609 | EOF | |
2610 | ||
2611 | test_expect_success 'R: die on unknown option' ' | |
2612 | test_must_fail git fast-import <input | |
2613 | ' | |
2614 | ||
2615 | test_expect_success 'R: unknown commandline options are rejected' '\ | |
2616 | test_must_fail git fast-import --non-existing-option < /dev/null | |
2617 | ' | |
2618 | ||
a9ff277e JN |
2619 | test_expect_success 'R: die on invalid option argument' ' |
2620 | echo "option git active-branches=-5" | | |
2621 | test_must_fail git fast-import && | |
2622 | echo "option git depth=" | | |
2623 | test_must_fail git fast-import && | |
2624 | test_must_fail git fast-import --depth="5 elephants" </dev/null | |
2625 | ' | |
2626 | ||
2792f26c SR |
2627 | cat >input <<EOF |
2628 | option non-existing-vcs non-existing-option | |
2629 | EOF | |
2630 | ||
2631 | test_expect_success 'R: ignore non-git options' ' | |
2632 | git fast-import <input | |
2633 | ' | |
2634 | ||
5eef828b SP |
2635 | ## |
2636 | ## R: very large blobs | |
2637 | ## | |
2638 | blobsize=$((2*1024*1024 + 53)) | |
2639 | test-genrandom bar $blobsize >expect | |
2640 | cat >input <<INPUT_END | |
2641 | commit refs/heads/big-file | |
2642 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2643 | data <<COMMIT | |
2644 | R - big file | |
2645 | COMMIT | |
2646 | ||
2647 | M 644 inline big1 | |
2648 | data $blobsize | |
2649 | INPUT_END | |
2650 | cat expect >>input | |
2651 | cat >>input <<INPUT_END | |
2652 | M 644 inline big2 | |
2653 | data $blobsize | |
2654 | INPUT_END | |
2655 | cat expect >>input | |
2656 | echo >>input | |
2657 | ||
2658 | test_expect_success \ | |
2659 | 'R: blob bigger than threshold' \ | |
2660 | 'test_create_repo R && | |
2661 | git --git-dir=R/.git fast-import --big-file-threshold=1 <input' | |
05880b02 JS |
2662 | |
2663 | test_expect_success 'R: verify created pack' ' | |
2664 | ( | |
2665 | cd R && | |
2666 | verify_packs -v > ../verify | |
2667 | ) | |
2668 | ' | |
2669 | ||
5eef828b SP |
2670 | test_expect_success \ |
2671 | 'R: verify written objects' \ | |
2672 | 'git --git-dir=R/.git cat-file blob big-file:big1 >actual && | |
f9f3851b | 2673 | test_cmp_bin expect actual && |
5eef828b SP |
2674 | a=$(git --git-dir=R/.git rev-parse big-file:big1) && |
2675 | b=$(git --git-dir=R/.git rev-parse big-file:big2) && | |
2676 | test $a = $b' | |
2677 | test_expect_success \ | |
2678 | 'R: blob appears only once' \ | |
2679 | 'n=$(grep $a verify | wc -l) && | |
2680 | test 1 = $n' | |
2681 | ||
06454cb9 PW |
2682 | ### |
2683 | ### series S | |
2684 | ### | |
2685 | # | |
2686 | # Make sure missing spaces and EOLs after mark references | |
2687 | # cause errors. | |
2688 | # | |
2689 | # Setup: | |
2690 | # | |
2691 | # 1--2--4 | |
2692 | # \ / | |
2693 | # -3- | |
2694 | # | |
2695 | # commit marks: 301, 302, 303, 304 | |
2696 | # blob marks: 403, 404, resp. | |
2697 | # note mark: 202 | |
2698 | # | |
2699 | # The error message when a space is missing not at the | |
2700 | # end of the line is: | |
2701 | # | |
2702 | # Missing space after .. | |
2703 | # | |
2704 | # or when extra characters come after the mark at the end | |
2705 | # of the line: | |
2706 | # | |
2707 | # Garbage after .. | |
2708 | # | |
2709 | # or when the dataref is neither "inline " or a known SHA1, | |
2710 | # | |
2711 | # Invalid dataref .. | |
2712 | # | |
2713 | test_tick | |
2714 | ||
2715 | cat >input <<INPUT_END | |
2716 | commit refs/heads/S | |
2717 | mark :301 | |
2718 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2719 | data <<COMMIT | |
2720 | commit 1 | |
2721 | COMMIT | |
2722 | M 100644 inline hello.c | |
2723 | data <<BLOB | |
2724 | blob 1 | |
2725 | BLOB | |
2726 | ||
2727 | commit refs/heads/S | |
2728 | mark :302 | |
2729 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2730 | data <<COMMIT | |
2731 | commit 2 | |
2732 | COMMIT | |
2733 | from :301 | |
2734 | M 100644 inline hello.c | |
2735 | data <<BLOB | |
2736 | blob 2 | |
2737 | BLOB | |
2738 | ||
2739 | blob | |
2740 | mark :403 | |
2741 | data <<BLOB | |
2742 | blob 3 | |
2743 | BLOB | |
2744 | ||
2745 | blob | |
2746 | mark :202 | |
2747 | data <<BLOB | |
2748 | note 2 | |
2749 | BLOB | |
2750 | INPUT_END | |
2751 | ||
2752 | test_expect_success 'S: initialize for S tests' ' | |
2753 | git fast-import --export-marks=marks <input | |
2754 | ' | |
2755 | ||
2756 | # | |
2757 | # filemodify, three datarefs | |
2758 | # | |
2759 | test_expect_success 'S: filemodify with garbage after mark must fail' ' | |
2760 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && | |
2761 | commit refs/heads/S | |
2762 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2763 | data <<COMMIT | |
2764 | commit N | |
2765 | COMMIT | |
2766 | M 100644 :403x hello.c | |
2767 | EOF | |
2768 | cat err && | |
2769 | test_i18ngrep "space after mark" err | |
2770 | ' | |
2771 | ||
2772 | # inline is misspelled; fast-import thinks it is some unknown dataref | |
2773 | test_expect_success 'S: filemodify with garbage after inline must fail' ' | |
2774 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && | |
2775 | commit refs/heads/S | |
2776 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2777 | data <<COMMIT | |
2778 | commit N | |
2779 | COMMIT | |
2780 | M 100644 inlineX hello.c | |
2781 | data <<BLOB | |
2782 | inline | |
2783 | BLOB | |
2784 | EOF | |
2785 | cat err && | |
2786 | test_i18ngrep "nvalid dataref" err | |
2787 | ' | |
2788 | ||
2789 | test_expect_success 'S: filemodify with garbage after sha1 must fail' ' | |
2790 | sha1=$(grep :403 marks | cut -d\ -f2) && | |
2791 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && | |
2792 | commit refs/heads/S | |
2793 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2794 | data <<COMMIT | |
2795 | commit N | |
2796 | COMMIT | |
2797 | M 100644 ${sha1}x hello.c | |
2798 | EOF | |
2799 | cat err && | |
2800 | test_i18ngrep "space after SHA1" err | |
2801 | ' | |
2802 | ||
2803 | # | |
2804 | # notemodify, three ways to say dataref | |
2805 | # | |
2806 | test_expect_success 'S: notemodify with garabge after mark dataref must fail' ' | |
2807 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && | |
2808 | commit refs/heads/S | |
2809 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2810 | data <<COMMIT | |
2811 | commit S note dataref markref | |
2812 | COMMIT | |
2813 | N :202x :302 | |
2814 | EOF | |
2815 | cat err && | |
2816 | test_i18ngrep "space after mark" err | |
2817 | ' | |
2818 | ||
2819 | test_expect_success 'S: notemodify with garbage after inline dataref must fail' ' | |
2820 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && | |
2821 | commit refs/heads/S | |
2822 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2823 | data <<COMMIT | |
2824 | commit S note dataref inline | |
2825 | COMMIT | |
2826 | N inlineX :302 | |
2827 | data <<BLOB | |
2828 | note blob | |
2829 | BLOB | |
2830 | EOF | |
2831 | cat err && | |
2832 | test_i18ngrep "nvalid dataref" err | |
2833 | ' | |
2834 | ||
2835 | test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' ' | |
2836 | sha1=$(grep :202 marks | cut -d\ -f2) && | |
2837 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && | |
2838 | commit refs/heads/S | |
2839 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2840 | data <<COMMIT | |
2841 | commit S note dataref sha1 | |
2842 | COMMIT | |
2843 | N ${sha1}x :302 | |
2844 | EOF | |
2845 | cat err && | |
2846 | test_i18ngrep "space after SHA1" err | |
2847 | ' | |
2848 | ||
2849 | # | |
a8a5406a | 2850 | # notemodify, mark in commit-ish |
06454cb9 | 2851 | # |
634c42da | 2852 | test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' ' |
06454cb9 PW |
2853 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && |
2854 | commit refs/heads/Snotes | |
2855 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2856 | data <<COMMIT | |
a8a5406a | 2857 | commit S note commit-ish |
06454cb9 PW |
2858 | COMMIT |
2859 | N :202 :302x | |
2860 | EOF | |
2861 | cat err && | |
2862 | test_i18ngrep "after mark" err | |
2863 | ' | |
2864 | ||
2865 | # | |
2866 | # from | |
2867 | # | |
2868 | test_expect_success 'S: from with garbage after mark must fail' ' | |
0a5e3c50 JK |
2869 | test_must_fail \ |
2870 | git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err && | |
06454cb9 PW |
2871 | commit refs/heads/S2 |
2872 | mark :303 | |
2873 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2874 | data <<COMMIT | |
2875 | commit 3 | |
2876 | COMMIT | |
2877 | from :301x | |
2878 | M 100644 :403 hello.c | |
2879 | EOF | |
2880 | ||
06454cb9 PW |
2881 | |
2882 | # go create the commit, need it for merge test | |
2883 | git fast-import --import-marks=marks --export-marks=marks <<-EOF && | |
2884 | commit refs/heads/S2 | |
2885 | mark :303 | |
2886 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2887 | data <<COMMIT | |
2888 | commit 3 | |
2889 | COMMIT | |
2890 | from :301 | |
2891 | M 100644 :403 hello.c | |
2892 | EOF | |
2893 | ||
2894 | # now evaluate the error | |
2895 | cat err && | |
2896 | test_i18ngrep "after mark" err | |
2897 | ' | |
2898 | ||
2899 | ||
2900 | # | |
2901 | # merge | |
2902 | # | |
2903 | test_expect_success 'S: merge with garbage after mark must fail' ' | |
2904 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && | |
2905 | commit refs/heads/S | |
2906 | mark :304 | |
2907 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2908 | data <<COMMIT | |
2909 | merge 4 | |
2910 | COMMIT | |
2911 | from :302 | |
2912 | merge :303x | |
2913 | M 100644 :403 hello.c | |
2914 | EOF | |
2915 | cat err && | |
2916 | test_i18ngrep "after mark" err | |
2917 | ' | |
2918 | ||
2919 | # | |
2920 | # tag, from markref | |
2921 | # | |
2922 | test_expect_success 'S: tag with garbage after mark must fail' ' | |
2923 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && | |
2924 | tag refs/tags/Stag | |
2925 | from :302x | |
2926 | tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
2927 | data <<TAG | |
2928 | tag S | |
2929 | TAG | |
2930 | EOF | |
2931 | cat err && | |
2932 | test_i18ngrep "after mark" err | |
2933 | ' | |
2934 | ||
2935 | # | |
2936 | # cat-blob markref | |
2937 | # | |
2938 | test_expect_success 'S: cat-blob with garbage after mark must fail' ' | |
2939 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && | |
2940 | cat-blob :403x | |
2941 | EOF | |
2942 | cat err && | |
2943 | test_i18ngrep "after mark" err | |
2944 | ' | |
2945 | ||
2946 | # | |
2947 | # ls markref | |
2948 | # | |
2949 | test_expect_success 'S: ls with garbage after mark must fail' ' | |
2950 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && | |
2951 | ls :302x hello.c | |
2952 | EOF | |
2953 | cat err && | |
2954 | test_i18ngrep "space after mark" err | |
2955 | ' | |
2956 | ||
2957 | test_expect_success 'S: ls with garbage after sha1 must fail' ' | |
2958 | sha1=$(grep :302 marks | cut -d\ -f2) && | |
2959 | test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && | |
2960 | ls ${sha1}x hello.c | |
2961 | EOF | |
2962 | cat err && | |
2963 | test_i18ngrep "space after tree-ish" err | |
2964 | ' | |
2965 | ||
aca70610 JK |
2966 | ### |
2967 | ### series T (ls) | |
2968 | ### | |
2969 | # Setup is carried over from series S. | |
2970 | ||
e0eb6b97 | 2971 | test_expect_success 'T: ls root tree' ' |
aca70610 JK |
2972 | sed -e "s/Z\$//" >expect <<-EOF && |
2973 | 040000 tree $(git rev-parse S^{tree}) Z | |
2974 | EOF | |
2975 | sha1=$(git rev-parse --verify S) && | |
2976 | git fast-import --import-marks=marks <<-EOF >actual && | |
2977 | ls $sha1 "" | |
2978 | EOF | |
2979 | test_cmp expect actual | |
2980 | ' | |
2981 | ||
4ee1b225 FC |
2982 | test_expect_success 'T: delete branch' ' |
2983 | git branch to-delete && | |
2984 | git fast-import <<-EOF && | |
2985 | reset refs/heads/to-delete | |
2986 | from 0000000000000000000000000000000000000000 | |
2987 | EOF | |
2988 | test_must_fail git rev-parse --verify refs/heads/to-delete | |
2989 | ' | |
2990 | ||
2991 | test_expect_success 'T: empty reset doesnt delete branch' ' | |
2992 | git branch not-to-delete && | |
2993 | git fast-import <<-EOF && | |
2994 | reset refs/heads/not-to-delete | |
2995 | EOF | |
2996 | git show-ref && | |
2997 | git rev-parse --verify refs/heads/not-to-delete | |
2998 | ' | |
2999 | ||
8d30d8a8 MB |
3000 | ### |
3001 | ### series U (filedelete) | |
3002 | ### | |
3003 | ||
3004 | cat >input <<INPUT_END | |
3005 | commit refs/heads/U | |
3006 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
3007 | data <<COMMIT | |
3008 | test setup | |
3009 | COMMIT | |
3010 | M 100644 inline hello.c | |
3011 | data <<BLOB | |
3012 | blob 1 | |
3013 | BLOB | |
3014 | M 100644 inline good/night.txt | |
3015 | data <<BLOB | |
3016 | sleep well | |
3017 | BLOB | |
3018 | M 100644 inline good/bye.txt | |
3019 | data <<BLOB | |
3020 | au revoir | |
3021 | BLOB | |
3022 | ||
3023 | INPUT_END | |
3024 | ||
3025 | test_expect_success 'U: initialize for U tests' ' | |
3026 | git fast-import <input | |
3027 | ' | |
3028 | ||
3029 | cat >input <<INPUT_END | |
3030 | commit refs/heads/U | |
3031 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
3032 | data <<COMMIT | |
3033 | delete good/night.txt | |
3034 | COMMIT | |
3035 | from refs/heads/U^0 | |
3036 | D good/night.txt | |
3037 | ||
3038 | INPUT_END | |
3039 | ||
3040 | test_expect_success 'U: filedelete file succeeds' ' | |
3041 | git fast-import <input | |
3042 | ' | |
3043 | ||
3044 | cat >expect <<EOF | |
3045 | :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt | |
3046 | EOF | |
3047 | ||
3048 | git diff-tree -M -r U^1 U >actual | |
3049 | ||
3050 | test_expect_success 'U: validate file delete result' ' | |
3051 | compare_diff_raw expect actual | |
3052 | ' | |
3053 | ||
3054 | cat >input <<INPUT_END | |
3055 | commit refs/heads/U | |
3056 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
3057 | data <<COMMIT | |
3058 | delete good dir | |
3059 | COMMIT | |
3060 | from refs/heads/U^0 | |
3061 | D good | |
3062 | ||
3063 | INPUT_END | |
3064 | ||
3065 | test_expect_success 'U: filedelete directory succeeds' ' | |
3066 | git fast-import <input | |
3067 | ' | |
3068 | ||
3069 | cat >expect <<EOF | |
3070 | :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt | |
3071 | EOF | |
3072 | ||
3073 | git diff-tree -M -r U^1 U >actual | |
3074 | ||
3075 | test_expect_success 'U: validate directory delete result' ' | |
3076 | compare_diff_raw expect actual | |
3077 | ' | |
3078 | ||
3079 | cat >input <<INPUT_END | |
3080 | commit refs/heads/U | |
3081 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
3082 | data <<COMMIT | |
3083 | must succeed | |
3084 | COMMIT | |
3085 | from refs/heads/U^0 | |
3086 | D "" | |
3087 | ||
3088 | INPUT_END | |
3089 | ||
2668d692 | 3090 | test_expect_success 'U: filedelete root succeeds' ' |
8d30d8a8 MB |
3091 | git fast-import <input |
3092 | ' | |
3093 | ||
3094 | cat >expect <<EOF | |
3095 | :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c | |
3096 | EOF | |
3097 | ||
3098 | git diff-tree -M -r U^1 U >actual | |
3099 | ||
2668d692 | 3100 | test_expect_success 'U: validate root delete result' ' |
8d30d8a8 MB |
3101 | compare_diff_raw expect actual |
3102 | ' | |
3103 | ||
50aee995 | 3104 | test_done |