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