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