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