]>
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 | |
8232dc42 SP |
10 | file2_data='file2 |
11 | second line of EOF' | |
12 | ||
13 | file3_data='EOF | |
14 | in 3rd file | |
15 | END' | |
16 | ||
17 | file4_data=abcd | |
18 | file4_len=4 | |
19 | ||
b715cfbb SP |
20 | file5_data='an inline file. |
21 | we should see it later.' | |
22 | ||
23 | file6_data='#!/bin/sh | |
24 | echo "$@"' | |
25 | ||
50aee995 SP |
26 | ### |
27 | ### series A | |
28 | ### | |
29 | ||
30 | test_tick | |
31 | cat >input <<INPUT_END | |
32 | blob | |
33 | mark :2 | |
34 | data <<EOF | |
8232dc42 | 35 | $file2_data |
50aee995 SP |
36 | EOF |
37 | ||
38 | blob | |
39 | mark :3 | |
40 | data <<END | |
8232dc42 | 41 | $file3_data |
50aee995 SP |
42 | END |
43 | ||
44 | blob | |
45 | mark :4 | |
8232dc42 SP |
46 | data $file4_len |
47 | $file4_data | |
50aee995 SP |
48 | commit refs/heads/master |
49 | mark :5 | |
50 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
51 | data <<COMMIT | |
52 | initial | |
53 | COMMIT | |
54 | ||
55 | M 644 :2 file2 | |
56 | M 644 :3 file3 | |
57 | M 755 :4 file4 | |
58 | ||
88fbf67b JH |
59 | tag series-A |
60 | from :5 | |
61 | data <<EOF | |
62 | An annotated tag without a tagger | |
63 | EOF | |
64 | ||
50aee995 SP |
65 | INPUT_END |
66 | test_expect_success \ | |
67 | 'A: create pack from stdin' \ | |
eaa2a6fc | 68 | 'git fast-import --export-marks=marks.out <input && |
5be60078 | 69 | git whatchanged master' |
50aee995 SP |
70 | test_expect_success \ |
71 | 'A: verify pack' \ | |
5be60078 | 72 | 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' |
50aee995 SP |
73 | |
74 | cat >expect <<EOF | |
75 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
76 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
77 | ||
78 | initial | |
79 | EOF | |
80 | test_expect_success \ | |
81 | 'A: verify commit' \ | |
5be60078 | 82 | 'git cat-file commit master | sed 1d >actual && |
3af82863 | 83 | test_cmp expect actual' |
50aee995 SP |
84 | |
85 | cat >expect <<EOF | |
86 | 100644 blob file2 | |
87 | 100644 blob file3 | |
88 | 100755 blob file4 | |
89 | EOF | |
90 | test_expect_success \ | |
91 | 'A: verify tree' \ | |
5be60078 | 92 | 'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual && |
3af82863 | 93 | test_cmp expect actual' |
50aee995 | 94 | |
8232dc42 | 95 | echo "$file2_data" >expect |
50aee995 SP |
96 | test_expect_success \ |
97 | 'A: verify file2' \ | |
3af82863 | 98 | 'git cat-file blob master:file2 >actual && test_cmp expect actual' |
50aee995 | 99 | |
8232dc42 | 100 | echo "$file3_data" >expect |
50aee995 SP |
101 | test_expect_success \ |
102 | 'A: verify file3' \ | |
3af82863 | 103 | 'git cat-file blob master:file3 >actual && test_cmp expect actual' |
50aee995 | 104 | |
8232dc42 | 105 | printf "$file4_data" >expect |
50aee995 SP |
106 | test_expect_success \ |
107 | 'A: verify file4' \ | |
3af82863 | 108 | 'git cat-file blob master:file4 >actual && test_cmp expect actual' |
50aee995 | 109 | |
88fbf67b JH |
110 | cat >expect <<EOF |
111 | object $(git rev-parse refs/heads/master) | |
112 | type commit | |
113 | tag series-A | |
114 | ||
115 | An annotated tag without a tagger | |
116 | EOF | |
117 | test_expect_success 'A: verify tag/series-A' ' | |
118 | git cat-file tag tags/series-A >actual && | |
119 | test_cmp expect actual | |
120 | ' | |
121 | ||
50aee995 | 122 | cat >expect <<EOF |
5be60078 JH |
123 | :2 `git rev-parse --verify master:file2` |
124 | :3 `git rev-parse --verify master:file3` | |
125 | :4 `git rev-parse --verify master:file4` | |
126 | :5 `git rev-parse --verify master^0` | |
50aee995 SP |
127 | EOF |
128 | test_expect_success \ | |
129 | 'A: verify marks output' \ | |
3af82863 | 130 | 'test_cmp expect marks.out' |
50aee995 | 131 | |
e8438420 SP |
132 | test_expect_success \ |
133 | 'A: verify marks import' \ | |
eaa2a6fc | 134 | 'git fast-import \ |
e8438420 SP |
135 | --import-marks=marks.out \ |
136 | --export-marks=marks.new \ | |
137 | </dev/null && | |
3af82863 | 138 | test_cmp expect marks.new' |
e8438420 | 139 | |
aac65ed1 SP |
140 | test_tick |
141 | cat >input <<INPUT_END | |
142 | commit refs/heads/verify--import-marks | |
143 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
144 | data <<COMMIT | |
145 | recreate from :5 | |
146 | COMMIT | |
147 | ||
148 | from :5 | |
149 | M 755 :2 copy-of-file2 | |
150 | ||
151 | INPUT_END | |
152 | test_expect_success \ | |
153 | 'A: verify marks import does not crash' \ | |
eaa2a6fc | 154 | 'git fast-import --import-marks=marks.out <input && |
5be60078 | 155 | git whatchanged verify--import-marks' |
aac65ed1 SP |
156 | test_expect_success \ |
157 | 'A: verify pack' \ | |
5be60078 | 158 | 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' |
aac65ed1 SP |
159 | cat >expect <<EOF |
160 | :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2 | |
161 | EOF | |
5be60078 | 162 | git diff-tree -M -r master verify--import-marks >actual |
aac65ed1 SP |
163 | test_expect_success \ |
164 | 'A: verify diff' \ | |
165 | 'compare_diff_raw expect actual && | |
5be60078 JH |
166 | test `git rev-parse --verify master:file2` \ |
167 | = `git rev-parse --verify verify--import-marks:copy-of-file2`' | |
aac65ed1 | 168 | |
50aee995 SP |
169 | ### |
170 | ### series B | |
171 | ### | |
172 | ||
173 | test_tick | |
174 | cat >input <<INPUT_END | |
175 | commit refs/heads/branch | |
176 | mark :1 | |
177 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
178 | data <<COMMIT | |
179 | corrupt | |
180 | COMMIT | |
181 | ||
182 | from refs/heads/master | |
183 | M 755 0000000000000000000000000000000000000001 zero1 | |
184 | ||
185 | INPUT_END | |
41ac414e | 186 | test_expect_success 'B: fail on invalid blob sha1' ' |
eaa2a6fc | 187 | test_must_fail git fast-import <input |
41ac414e | 188 | ' |
50aee995 SP |
189 | rm -f .git/objects/pack_* .git/objects/index_* |
190 | ||
ea08a6fd SP |
191 | cat >input <<INPUT_END |
192 | commit .badbranchname | |
193 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
194 | data <<COMMIT | |
195 | corrupt | |
196 | COMMIT | |
197 | ||
198 | from refs/heads/master | |
199 | ||
200 | INPUT_END | |
41ac414e | 201 | test_expect_success 'B: fail on invalid branch name ".badbranchname"' ' |
eaa2a6fc | 202 | test_must_fail git fast-import <input |
41ac414e | 203 | ' |
ea08a6fd SP |
204 | rm -f .git/objects/pack_* .git/objects/index_* |
205 | ||
206 | cat >input <<INPUT_END | |
207 | commit bad[branch]name | |
208 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
209 | data <<COMMIT | |
210 | corrupt | |
211 | COMMIT | |
212 | ||
213 | from refs/heads/master | |
214 | ||
215 | INPUT_END | |
41ac414e | 216 | test_expect_success 'B: fail on invalid branch name "bad[branch]name"' ' |
eaa2a6fc | 217 | test_must_fail git fast-import <input |
41ac414e | 218 | ' |
ea08a6fd SP |
219 | rm -f .git/objects/pack_* .git/objects/index_* |
220 | ||
221 | cat >input <<INPUT_END | |
222 | commit TEMP_TAG | |
223 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
224 | data <<COMMIT | |
225 | tag base | |
226 | COMMIT | |
227 | ||
228 | from refs/heads/master | |
229 | ||
230 | INPUT_END | |
231 | test_expect_success \ | |
232 | 'B: accept branch name "TEMP_TAG"' \ | |
eaa2a6fc | 233 | 'git fast-import <input && |
ea08a6fd SP |
234 | test -f .git/TEMP_TAG && |
235 | test `git rev-parse master` = `git rev-parse TEMP_TAG^`' | |
236 | rm -f .git/TEMP_TAG | |
237 | ||
50aee995 SP |
238 | ### |
239 | ### series C | |
240 | ### | |
241 | ||
eaa2a6fc | 242 | newf=`echo hi newf | git hash-object -w --stdin` |
5be60078 | 243 | oldf=`git rev-parse --verify master:file2` |
50aee995 SP |
244 | test_tick |
245 | cat >input <<INPUT_END | |
246 | commit refs/heads/branch | |
247 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
248 | data <<COMMIT | |
249 | second | |
250 | COMMIT | |
251 | ||
252 | from refs/heads/master | |
253 | M 644 $oldf file2/oldf | |
254 | M 755 $newf file2/newf | |
255 | D file3 | |
256 | ||
257 | INPUT_END | |
258 | test_expect_success \ | |
259 | 'C: incremental import create pack from stdin' \ | |
eaa2a6fc | 260 | 'git fast-import <input && |
5be60078 | 261 | git whatchanged branch' |
50aee995 SP |
262 | test_expect_success \ |
263 | 'C: verify pack' \ | |
5be60078 | 264 | 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' |
50aee995 SP |
265 | test_expect_success \ |
266 | 'C: validate reuse existing blob' \ | |
5be60078 JH |
267 | 'test $newf = `git rev-parse --verify branch:file2/newf` |
268 | test $oldf = `git rev-parse --verify branch:file2/oldf`' | |
50aee995 SP |
269 | |
270 | cat >expect <<EOF | |
5be60078 | 271 | parent `git rev-parse --verify master^0` |
50aee995 SP |
272 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
273 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
274 | ||
275 | second | |
276 | EOF | |
277 | test_expect_success \ | |
278 | 'C: verify commit' \ | |
5be60078 | 279 | 'git cat-file commit branch | sed 1d >actual && |
3af82863 | 280 | test_cmp expect actual' |
50aee995 SP |
281 | |
282 | cat >expect <<EOF | |
283 | :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf | |
284 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf | |
285 | :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3 | |
286 | EOF | |
5be60078 | 287 | git diff-tree -M -r master branch >actual |
50aee995 SP |
288 | test_expect_success \ |
289 | 'C: validate rename result' \ | |
290 | 'compare_diff_raw expect actual' | |
291 | ||
b715cfbb SP |
292 | ### |
293 | ### series D | |
294 | ### | |
295 | ||
296 | test_tick | |
297 | cat >input <<INPUT_END | |
298 | commit refs/heads/branch | |
299 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
300 | data <<COMMIT | |
301 | third | |
302 | COMMIT | |
303 | ||
304 | from refs/heads/branch^0 | |
305 | M 644 inline newdir/interesting | |
306 | data <<EOF | |
307 | $file5_data | |
308 | EOF | |
309 | ||
310 | M 755 inline newdir/exec.sh | |
311 | data <<EOF | |
312 | $file6_data | |
313 | EOF | |
314 | ||
315 | INPUT_END | |
316 | test_expect_success \ | |
317 | 'D: inline data in commit' \ | |
eaa2a6fc | 318 | 'git fast-import <input && |
5be60078 | 319 | git whatchanged branch' |
b715cfbb SP |
320 | test_expect_success \ |
321 | 'D: verify pack' \ | |
5be60078 | 322 | 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' |
b715cfbb SP |
323 | |
324 | cat >expect <<EOF | |
325 | :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh | |
326 | :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting | |
327 | EOF | |
5be60078 | 328 | git diff-tree -M -r branch^ branch >actual |
b715cfbb SP |
329 | test_expect_success \ |
330 | 'D: validate new files added' \ | |
331 | 'compare_diff_raw expect actual' | |
332 | ||
333 | echo "$file5_data" >expect | |
334 | test_expect_success \ | |
335 | 'D: verify file5' \ | |
5be60078 | 336 | 'git cat-file blob branch:newdir/interesting >actual && |
3af82863 | 337 | test_cmp expect actual' |
b715cfbb SP |
338 | |
339 | echo "$file6_data" >expect | |
340 | test_expect_success \ | |
341 | 'D: verify file6' \ | |
5be60078 | 342 | 'git cat-file blob branch:newdir/exec.sh >actual && |
3af82863 | 343 | test_cmp expect actual' |
b715cfbb | 344 | |
63e0c8b3 SP |
345 | ### |
346 | ### series E | |
347 | ### | |
348 | ||
349 | cat >input <<INPUT_END | |
350 | commit refs/heads/branch | |
351 | author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500 | |
352 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500 | |
353 | data <<COMMIT | |
354 | RFC 2822 type date | |
355 | COMMIT | |
356 | ||
357 | from refs/heads/branch^0 | |
358 | ||
359 | INPUT_END | |
41ac414e | 360 | test_expect_success 'E: rfc2822 date, --date-format=raw' ' |
eaa2a6fc | 361 | test_must_fail git fast-import --date-format=raw <input |
41ac414e | 362 | ' |
63e0c8b3 SP |
363 | test_expect_success \ |
364 | 'E: rfc2822 date, --date-format=rfc2822' \ | |
eaa2a6fc | 365 | 'git fast-import --date-format=rfc2822 <input' |
63e0c8b3 SP |
366 | test_expect_success \ |
367 | 'E: verify pack' \ | |
5be60078 | 368 | 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' |
63e0c8b3 SP |
369 | |
370 | cat >expect <<EOF | |
371 | author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500 | |
372 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500 | |
373 | ||
374 | RFC 2822 type date | |
375 | EOF | |
376 | test_expect_success \ | |
377 | 'E: verify commit' \ | |
5be60078 | 378 | 'git cat-file commit branch | sed 1,2d >actual && |
3af82863 | 379 | test_cmp expect actual' |
63e0c8b3 | 380 | |
7073e69e SP |
381 | ### |
382 | ### series F | |
383 | ### | |
384 | ||
5be60078 | 385 | old_branch=`git rev-parse --verify branch^0` |
7073e69e SP |
386 | test_tick |
387 | cat >input <<INPUT_END | |
388 | commit refs/heads/branch | |
389 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
390 | data <<COMMIT | |
391 | losing things already? | |
392 | COMMIT | |
393 | ||
394 | from refs/heads/branch~1 | |
395 | ||
396 | reset refs/heads/other | |
397 | from refs/heads/branch | |
398 | ||
399 | INPUT_END | |
400 | test_expect_success \ | |
401 | 'F: non-fast-forward update skips' \ | |
eaa2a6fc | 402 | 'if git fast-import <input |
7073e69e SP |
403 | then |
404 | echo BAD gfi did not fail | |
405 | return 1 | |
406 | else | |
5be60078 | 407 | if test $old_branch = `git rev-parse --verify branch^0` |
7073e69e SP |
408 | then |
409 | : branch unaffected and failure returned | |
410 | return 0 | |
411 | else | |
412 | echo BAD gfi changed branch $old_branch | |
413 | return 1 | |
414 | fi | |
415 | fi | |
416 | ' | |
417 | test_expect_success \ | |
418 | 'F: verify pack' \ | |
5be60078 | 419 | 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' |
7073e69e SP |
420 | |
421 | cat >expect <<EOF | |
5be60078 JH |
422 | tree `git rev-parse branch~1^{tree}` |
423 | parent `git rev-parse branch~1` | |
7073e69e SP |
424 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE |
425 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
426 | ||
427 | losing things already? | |
428 | EOF | |
429 | test_expect_success \ | |
430 | 'F: verify other commit' \ | |
5be60078 | 431 | 'git cat-file commit other >actual && |
3af82863 | 432 | test_cmp expect actual' |
7073e69e SP |
433 | |
434 | ### | |
435 | ### series G | |
436 | ### | |
437 | ||
5be60078 | 438 | old_branch=`git rev-parse --verify branch^0` |
7073e69e SP |
439 | test_tick |
440 | cat >input <<INPUT_END | |
441 | commit refs/heads/branch | |
442 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
443 | data <<COMMIT | |
444 | losing things already? | |
445 | COMMIT | |
446 | ||
447 | from refs/heads/branch~1 | |
448 | ||
449 | INPUT_END | |
450 | test_expect_success \ | |
451 | 'G: non-fast-forward update forced' \ | |
eaa2a6fc | 452 | 'git fast-import --force <input' |
7073e69e SP |
453 | test_expect_success \ |
454 | 'G: verify pack' \ | |
5be60078 | 455 | 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' |
7073e69e SP |
456 | test_expect_success \ |
457 | 'G: branch changed, but logged' \ | |
5be60078 JH |
458 | 'test $old_branch != `git rev-parse --verify branch^0` && |
459 | test $old_branch = `git rev-parse --verify branch@{1}`' | |
7073e69e | 460 | |
825769a8 SP |
461 | ### |
462 | ### series H | |
463 | ### | |
464 | ||
465 | test_tick | |
466 | cat >input <<INPUT_END | |
467 | commit refs/heads/H | |
468 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
469 | data <<COMMIT | |
470 | third | |
471 | COMMIT | |
472 | ||
473 | from refs/heads/branch^0 | |
474 | M 644 inline i-will-die | |
475 | data <<EOF | |
476 | this file will never exist. | |
477 | EOF | |
478 | ||
479 | deleteall | |
480 | M 644 inline h/e/l/lo | |
481 | data <<EOF | |
482 | $file5_data | |
483 | EOF | |
484 | ||
485 | INPUT_END | |
486 | test_expect_success \ | |
487 | 'H: deletall, add 1' \ | |
eaa2a6fc | 488 | 'git fast-import <input && |
5be60078 | 489 | git whatchanged H' |
825769a8 SP |
490 | test_expect_success \ |
491 | 'H: verify pack' \ | |
5be60078 | 492 | 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' |
825769a8 SP |
493 | |
494 | cat >expect <<EOF | |
495 | :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf | |
496 | :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf | |
497 | :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4 | |
498 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo | |
499 | :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh | |
500 | EOF | |
5be60078 | 501 | git diff-tree -M -r H^ H >actual |
825769a8 SP |
502 | test_expect_success \ |
503 | 'H: validate old files removed, new files added' \ | |
504 | 'compare_diff_raw expect actual' | |
505 | ||
506 | echo "$file5_data" >expect | |
507 | test_expect_success \ | |
508 | 'H: verify file' \ | |
5be60078 | 509 | 'git cat-file blob H:h/e/l/lo >actual && |
3af82863 | 510 | test_cmp expect actual' |
825769a8 | 511 | |
bdf1c06d SP |
512 | ### |
513 | ### series I | |
514 | ### | |
515 | ||
516 | cat >input <<INPUT_END | |
517 | commit refs/heads/export-boundary | |
518 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
519 | data <<COMMIT | |
520 | we have a border. its only 40 characters wide. | |
521 | COMMIT | |
522 | ||
523 | from refs/heads/branch | |
524 | ||
525 | INPUT_END | |
526 | test_expect_success \ | |
527 | 'I: export-pack-edges' \ | |
eaa2a6fc | 528 | 'git fast-import --export-pack-edges=edges.list <input' |
bdf1c06d SP |
529 | |
530 | cat >expect <<EOF | |
5be60078 | 531 | .git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary` |
bdf1c06d SP |
532 | EOF |
533 | test_expect_success \ | |
534 | 'I: verify edge list' \ | |
535 | 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual && | |
3af82863 | 536 | test_cmp expect actual' |
bdf1c06d | 537 | |
ea5e370a SP |
538 | ### |
539 | ### series J | |
540 | ### | |
541 | ||
542 | cat >input <<INPUT_END | |
543 | commit refs/heads/J | |
544 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
545 | data <<COMMIT | |
546 | create J | |
547 | COMMIT | |
548 | ||
549 | from refs/heads/branch | |
550 | ||
551 | reset refs/heads/J | |
552 | ||
553 | commit refs/heads/J | |
554 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
555 | data <<COMMIT | |
556 | initialize J | |
557 | COMMIT | |
558 | ||
559 | INPUT_END | |
560 | test_expect_success \ | |
561 | 'J: reset existing branch creates empty commit' \ | |
eaa2a6fc | 562 | 'git fast-import <input' |
ea5e370a SP |
563 | test_expect_success \ |
564 | 'J: branch has 1 commit, empty tree' \ | |
5be60078 | 565 | 'test 1 = `git rev-list J | wc -l` && |
ea5e370a SP |
566 | test 0 = `git ls-tree J | wc -l`' |
567 | ||
568 | ### | |
569 | ### series K | |
570 | ### | |
571 | ||
572 | cat >input <<INPUT_END | |
573 | commit refs/heads/K | |
574 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
575 | data <<COMMIT | |
576 | create K | |
577 | COMMIT | |
578 | ||
579 | from refs/heads/branch | |
580 | ||
581 | commit refs/heads/K | |
582 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
583 | data <<COMMIT | |
584 | redo K | |
585 | COMMIT | |
586 | ||
587 | from refs/heads/branch^1 | |
588 | ||
589 | INPUT_END | |
590 | test_expect_success \ | |
591 | 'K: reinit branch with from' \ | |
eaa2a6fc | 592 | 'git fast-import <input' |
ea5e370a SP |
593 | test_expect_success \ |
594 | 'K: verify K^1 = branch^1' \ | |
5be60078 JH |
595 | 'test `git rev-parse --verify branch^1` \ |
596 | = `git rev-parse --verify K^1`' | |
ea5e370a | 597 | |
e7411303 JK |
598 | ### |
599 | ### series L | |
600 | ### | |
601 | ||
602 | cat >input <<INPUT_END | |
603 | blob | |
604 | mark :1 | |
605 | data <<EOF | |
606 | some data | |
607 | EOF | |
608 | ||
609 | blob | |
610 | mark :2 | |
611 | data <<EOF | |
612 | other data | |
613 | EOF | |
614 | ||
615 | commit refs/heads/L | |
616 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
617 | data <<COMMIT | |
618 | create L | |
619 | COMMIT | |
620 | ||
621 | M 644 :1 b. | |
622 | M 644 :1 b/other | |
623 | M 644 :1 ba | |
624 | ||
625 | commit refs/heads/L | |
626 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
627 | data <<COMMIT | |
628 | update L | |
629 | COMMIT | |
630 | ||
631 | M 644 :2 b. | |
632 | M 644 :2 b/other | |
633 | M 644 :2 ba | |
634 | INPUT_END | |
635 | ||
636 | cat >expect <<EXPECT_END | |
637 | :100644 100644 4268632... 55d3a52... M b. | |
638 | :040000 040000 0ae5cac... 443c768... M b | |
639 | :100644 100644 4268632... 55d3a52... M ba | |
640 | EXPECT_END | |
641 | ||
642 | test_expect_success \ | |
643 | 'L: verify internal tree sorting' \ | |
eaa2a6fc | 644 | 'git fast-import <input && |
82cb8afa | 645 | git diff-tree --abbrev --raw L^ L >output && |
3af82863 | 646 | test_cmp expect output' |
e7411303 | 647 | |
f39a946a SP |
648 | ### |
649 | ### series M | |
650 | ### | |
651 | ||
652 | test_tick | |
653 | cat >input <<INPUT_END | |
654 | commit refs/heads/M1 | |
655 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
656 | data <<COMMIT | |
657 | file rename | |
658 | COMMIT | |
659 | ||
660 | from refs/heads/branch^0 | |
661 | R file2/newf file2/n.e.w.f | |
662 | ||
663 | INPUT_END | |
664 | ||
665 | cat >expect <<EOF | |
666 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f | |
667 | EOF | |
668 | test_expect_success \ | |
669 | 'M: rename file in same subdirectory' \ | |
eaa2a6fc | 670 | 'git fast-import <input && |
f39a946a SP |
671 | git diff-tree -M -r M1^ M1 >actual && |
672 | compare_diff_raw expect actual' | |
673 | ||
674 | cat >input <<INPUT_END | |
675 | commit refs/heads/M2 | |
676 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
677 | data <<COMMIT | |
678 | file rename | |
679 | COMMIT | |
680 | ||
681 | from refs/heads/branch^0 | |
682 | R file2/newf i/am/new/to/you | |
683 | ||
684 | INPUT_END | |
685 | ||
686 | cat >expect <<EOF | |
687 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you | |
688 | EOF | |
689 | test_expect_success \ | |
690 | 'M: rename file to new subdirectory' \ | |
eaa2a6fc | 691 | 'git fast-import <input && |
f39a946a SP |
692 | git diff-tree -M -r M2^ M2 >actual && |
693 | compare_diff_raw expect actual' | |
694 | ||
695 | cat >input <<INPUT_END | |
696 | commit refs/heads/M3 | |
697 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
698 | data <<COMMIT | |
699 | file rename | |
700 | COMMIT | |
701 | ||
702 | from refs/heads/M2^0 | |
703 | R i other/sub | |
704 | ||
705 | INPUT_END | |
706 | ||
707 | cat >expect <<EOF | |
708 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you | |
709 | EOF | |
710 | test_expect_success \ | |
711 | 'M: rename subdirectory to new subdirectory' \ | |
eaa2a6fc | 712 | 'git fast-import <input && |
f39a946a SP |
713 | git diff-tree -M -r M3^ M3 >actual && |
714 | compare_diff_raw expect actual' | |
715 | ||
b6f3481b SP |
716 | ### |
717 | ### series N | |
718 | ### | |
719 | ||
720 | test_tick | |
721 | cat >input <<INPUT_END | |
722 | commit refs/heads/N1 | |
723 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
724 | data <<COMMIT | |
725 | file copy | |
726 | COMMIT | |
727 | ||
728 | from refs/heads/branch^0 | |
729 | C file2/newf file2/n.e.w.f | |
730 | ||
731 | INPUT_END | |
732 | ||
733 | cat >expect <<EOF | |
734 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f | |
735 | EOF | |
736 | test_expect_success \ | |
737 | 'N: copy file in same subdirectory' \ | |
eaa2a6fc | 738 | 'git fast-import <input && |
b6f3481b SP |
739 | git diff-tree -C --find-copies-harder -r N1^ N1 >actual && |
740 | compare_diff_raw expect actual' | |
741 | ||
742 | cat >input <<INPUT_END | |
743 | commit refs/heads/N2 | |
744 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
745 | data <<COMMIT | |
746 | clean directory copy | |
747 | COMMIT | |
748 | ||
749 | from refs/heads/branch^0 | |
750 | C file2 file3 | |
751 | ||
752 | commit refs/heads/N2 | |
753 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
754 | data <<COMMIT | |
755 | modify directory copy | |
756 | COMMIT | |
757 | ||
758 | M 644 inline file3/file5 | |
759 | data <<EOF | |
760 | $file5_data | |
761 | EOF | |
762 | ||
763 | INPUT_END | |
764 | ||
765 | cat >expect <<EOF | |
766 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5 | |
767 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf | |
768 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf | |
769 | EOF | |
770 | test_expect_success \ | |
771 | 'N: copy then modify subdirectory' \ | |
eaa2a6fc | 772 | 'git fast-import <input && |
b6f3481b SP |
773 | git diff-tree -C --find-copies-harder -r N2^^ N2 >actual && |
774 | compare_diff_raw expect actual' | |
775 | ||
776 | cat >input <<INPUT_END | |
777 | commit refs/heads/N3 | |
778 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
779 | data <<COMMIT | |
780 | dirty directory copy | |
781 | COMMIT | |
782 | ||
783 | from refs/heads/branch^0 | |
784 | M 644 inline file2/file5 | |
785 | data <<EOF | |
786 | $file5_data | |
787 | EOF | |
788 | ||
789 | C file2 file3 | |
790 | D file2/file5 | |
791 | ||
792 | INPUT_END | |
793 | ||
794 | test_expect_success \ | |
795 | 'N: copy dirty subdirectory' \ | |
eaa2a6fc NS |
796 | 'git fast-import <input && |
797 | test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`' | |
b6f3481b | 798 | |
334fba65 JN |
799 | test_expect_success \ |
800 | 'N: copy directory by id' \ | |
801 | 'cat >expect <<-\EOF && | |
802 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf | |
803 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf | |
804 | EOF | |
805 | subdir=$(git rev-parse refs/heads/branch^0:file2) && | |
806 | cat >input <<-INPUT_END && | |
807 | commit refs/heads/N4 | |
808 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
809 | data <<COMMIT | |
810 | copy by tree hash | |
811 | COMMIT | |
812 | ||
813 | from refs/heads/branch^0 | |
814 | M 040000 $subdir file3 | |
815 | INPUT_END | |
816 | git fast-import <input && | |
817 | git diff-tree -C --find-copies-harder -r N4^ N4 >actual && | |
818 | compare_diff_raw expect actual' | |
819 | ||
820 | test_expect_success \ | |
821 | 'N: modify copied tree' \ | |
822 | 'cat >expect <<-\EOF && | |
823 | :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5 | |
824 | :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf | |
825 | :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf | |
826 | EOF | |
827 | subdir=$(git rev-parse refs/heads/branch^0:file2) && | |
828 | cat >input <<-INPUT_END && | |
829 | commit refs/heads/N5 | |
830 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
831 | data <<COMMIT | |
832 | copy by tree hash | |
833 | COMMIT | |
834 | ||
835 | from refs/heads/branch^0 | |
836 | M 040000 $subdir file3 | |
837 | ||
838 | commit refs/heads/N5 | |
839 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
840 | data <<COMMIT | |
841 | modify directory copy | |
842 | COMMIT | |
843 | ||
844 | M 644 inline file3/file5 | |
845 | data <<EOF | |
846 | $file5_data | |
847 | EOF | |
848 | INPUT_END | |
849 | git fast-import <input && | |
850 | git diff-tree -C --find-copies-harder -r N5^^ N5 >actual && | |
851 | compare_diff_raw expect actual' | |
852 | ||
401d53fa SP |
853 | ### |
854 | ### series O | |
855 | ### | |
856 | ||
857 | cat >input <<INPUT_END | |
858 | #we will | |
859 | commit refs/heads/O1 | |
860 | # -- ignore all of this text | |
861 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
862 | # $GIT_COMMITTER_NAME has inserted here for his benefit. | |
863 | data <<COMMIT | |
864 | dirty directory copy | |
865 | COMMIT | |
866 | ||
867 | # don't forget the import blank line! | |
868 | # | |
869 | # yes, we started from our usual base of branch^0. | |
870 | # i like branch^0. | |
871 | from refs/heads/branch^0 | |
872 | # and we need to reuse file2/file5 from N3 above. | |
873 | M 644 inline file2/file5 | |
874 | # otherwise the tree will be different | |
875 | data <<EOF | |
876 | $file5_data | |
877 | EOF | |
878 | ||
879 | # don't forget to copy file2 to file3 | |
880 | C file2 file3 | |
881 | # | |
882 | # or to delete file5 from file2. | |
883 | D file2/file5 | |
884 | # are we done yet? | |
885 | ||
886 | INPUT_END | |
887 | ||
888 | test_expect_success \ | |
889 | 'O: comments are all skipped' \ | |
eaa2a6fc NS |
890 | 'git fast-import <input && |
891 | test `git rev-parse N3` = `git rev-parse O1`' | |
401d53fa | 892 | |
2c570cde SP |
893 | cat >input <<INPUT_END |
894 | commit refs/heads/O2 | |
895 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
896 | data <<COMMIT | |
897 | dirty directory copy | |
898 | COMMIT | |
899 | from refs/heads/branch^0 | |
900 | M 644 inline file2/file5 | |
901 | data <<EOF | |
902 | $file5_data | |
903 | EOF | |
904 | C file2 file3 | |
905 | D file2/file5 | |
906 | ||
907 | INPUT_END | |
908 | ||
909 | test_expect_success \ | |
910 | 'O: blank lines not necessary after data commands' \ | |
eaa2a6fc NS |
911 | 'git fast-import <input && |
912 | test `git rev-parse N3` = `git rev-parse O2`' | |
2c570cde | 913 | |
1fdb649c SP |
914 | test_expect_success \ |
915 | 'O: repack before next test' \ | |
916 | 'git repack -a -d' | |
917 | ||
918 | cat >input <<INPUT_END | |
919 | commit refs/heads/O3 | |
920 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
921 | data <<COMMIT | |
922 | zstring | |
923 | COMMIT | |
924 | commit refs/heads/O3 | |
925 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
926 | data <<COMMIT | |
927 | zof | |
928 | COMMIT | |
929 | checkpoint | |
930 | commit refs/heads/O3 | |
931 | mark :5 | |
932 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
933 | data <<COMMIT | |
934 | zempty | |
935 | COMMIT | |
936 | checkpoint | |
937 | commit refs/heads/O3 | |
938 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
939 | data <<COMMIT | |
940 | zcommits | |
941 | COMMIT | |
942 | reset refs/tags/O3-2nd | |
943 | from :5 | |
655e8515 AS |
944 | reset refs/tags/O3-3rd |
945 | from :5 | |
1fdb649c SP |
946 | INPUT_END |
947 | ||
948 | cat >expect <<INPUT_END | |
949 | string | |
950 | of | |
951 | empty | |
952 | commits | |
953 | INPUT_END | |
954 | test_expect_success \ | |
955 | 'O: blank lines not necessary after other commands' \ | |
eaa2a6fc | 956 | 'git fast-import <input && |
1fdb649c SP |
957 | test 8 = `find .git/objects/pack -type f | wc -l` && |
958 | test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` && | |
959 | git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual && | |
3af82863 | 960 | test_cmp expect actual' |
1fdb649c | 961 | |
ac053c02 SP |
962 | cat >input <<INPUT_END |
963 | commit refs/heads/O4 | |
964 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
965 | data <<COMMIT | |
966 | zstring | |
967 | COMMIT | |
968 | commit refs/heads/O4 | |
969 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
970 | data <<COMMIT | |
971 | zof | |
972 | COMMIT | |
973 | progress Two commits down, 2 to go! | |
974 | commit refs/heads/O4 | |
975 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
976 | data <<COMMIT | |
977 | zempty | |
978 | COMMIT | |
979 | progress Three commits down, 1 to go! | |
980 | commit refs/heads/O4 | |
981 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
982 | data <<COMMIT | |
983 | zcommits | |
984 | COMMIT | |
985 | progress I'm done! | |
986 | INPUT_END | |
987 | test_expect_success \ | |
988 | 'O: progress outputs as requested by input' \ | |
eaa2a6fc | 989 | 'git fast-import <input >actual && |
ac053c02 | 990 | grep "progress " <input >expect && |
3af82863 | 991 | test_cmp expect actual' |
ac053c02 | 992 | |
03db4525 AG |
993 | ### |
994 | ### series P (gitlinks) | |
995 | ### | |
996 | ||
997 | cat >input <<INPUT_END | |
998 | blob | |
999 | mark :1 | |
1000 | data 10 | |
1001 | test file | |
1002 | ||
1003 | reset refs/heads/sub | |
1004 | commit refs/heads/sub | |
1005 | mark :2 | |
1006 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1007 | data 12 | |
1008 | sub_initial | |
1009 | M 100644 :1 file | |
1010 | ||
1011 | blob | |
1012 | mark :3 | |
1013 | data <<DATAEND | |
1014 | [submodule "sub"] | |
1015 | path = sub | |
1016 | url = "`pwd`/sub" | |
1017 | DATAEND | |
1018 | ||
1019 | commit refs/heads/subuse1 | |
1020 | mark :4 | |
1021 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1022 | data 8 | |
1023 | initial | |
1024 | from refs/heads/master | |
1025 | M 100644 :3 .gitmodules | |
1026 | M 160000 :2 sub | |
1027 | ||
1028 | blob | |
1029 | mark :5 | |
1030 | data 20 | |
1031 | test file | |
1032 | more data | |
1033 | ||
1034 | commit refs/heads/sub | |
1035 | mark :6 | |
1036 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1037 | data 11 | |
1038 | sub_second | |
1039 | from :2 | |
1040 | M 100644 :5 file | |
1041 | ||
1042 | commit refs/heads/subuse1 | |
1043 | mark :7 | |
1044 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1045 | data 7 | |
1046 | second | |
1047 | from :4 | |
1048 | M 160000 :6 sub | |
1049 | ||
1050 | INPUT_END | |
1051 | ||
1052 | test_expect_success \ | |
1053 | 'P: supermodule & submodule mix' \ | |
eaa2a6fc | 1054 | 'git fast-import <input && |
03db4525 AG |
1055 | git checkout subuse1 && |
1056 | rm -rf sub && mkdir sub && cd sub && | |
1057 | git init && | |
8ee5d731 | 1058 | git fetch --update-head-ok .. refs/heads/sub:refs/heads/master && |
03db4525 AG |
1059 | git checkout master && |
1060 | cd .. && | |
1061 | git submodule init && | |
1062 | git submodule update' | |
1063 | ||
eaa2a6fc NS |
1064 | SUBLAST=$(git rev-parse --verify sub) |
1065 | SUBPREV=$(git rev-parse --verify sub^) | |
03db4525 AG |
1066 | |
1067 | cat >input <<INPUT_END | |
1068 | blob | |
1069 | mark :1 | |
1070 | data <<DATAEND | |
1071 | [submodule "sub"] | |
1072 | path = sub | |
1073 | url = "`pwd`/sub" | |
1074 | DATAEND | |
1075 | ||
1076 | commit refs/heads/subuse2 | |
1077 | mark :2 | |
1078 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1079 | data 8 | |
1080 | initial | |
1081 | from refs/heads/master | |
1082 | M 100644 :1 .gitmodules | |
1083 | M 160000 $SUBPREV sub | |
1084 | ||
1085 | commit refs/heads/subuse2 | |
1086 | mark :3 | |
1087 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1088 | data 7 | |
1089 | second | |
1090 | from :2 | |
1091 | M 160000 $SUBLAST sub | |
1092 | ||
1093 | INPUT_END | |
1094 | ||
1095 | test_expect_success \ | |
1096 | 'P: verbatim SHA gitlinks' \ | |
1097 | 'git branch -D sub && | |
1098 | git gc && git prune && | |
eaa2a6fc NS |
1099 | git fast-import <input && |
1100 | test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)' | |
03db4525 AG |
1101 | |
1102 | test_tick | |
1103 | cat >input <<INPUT_END | |
1104 | commit refs/heads/subuse3 | |
1105 | mark :1 | |
1106 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1107 | data <<COMMIT | |
1108 | corrupt | |
1109 | COMMIT | |
1110 | ||
1111 | from refs/heads/subuse2 | |
1112 | M 160000 inline sub | |
1113 | data <<DATA | |
1114 | $SUBPREV | |
1115 | DATA | |
1116 | ||
1117 | INPUT_END | |
1118 | ||
1119 | test_expect_success 'P: fail on inline gitlink' ' | |
eaa2a6fc | 1120 | test_must_fail git fast-import <input' |
03db4525 AG |
1121 | |
1122 | test_tick | |
1123 | cat >input <<INPUT_END | |
1124 | blob | |
1125 | mark :1 | |
1126 | data <<DATA | |
1127 | $SUBPREV | |
1128 | DATA | |
1129 | ||
1130 | commit refs/heads/subuse3 | |
1131 | mark :2 | |
1132 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1133 | data <<COMMIT | |
1134 | corrupt | |
1135 | COMMIT | |
1136 | ||
1137 | from refs/heads/subuse2 | |
1138 | M 160000 :1 sub | |
1139 | ||
1140 | INPUT_END | |
1141 | ||
1142 | test_expect_success 'P: fail on blob mark in gitlink' ' | |
eaa2a6fc | 1143 | test_must_fail git fast-import <input' |
03db4525 | 1144 | |
a8dd2e7d JH |
1145 | ### |
1146 | ### series Q (notes) | |
1147 | ### | |
1148 | ||
2a113aee JH |
1149 | note1_data="The first note for the first commit" |
1150 | note2_data="The first note for the second commit" | |
1151 | note3_data="The first note for the third commit" | |
1152 | note1b_data="The second note for the first commit" | |
1153 | note1c_data="The third note for the first commit" | |
1154 | note2b_data="The second note for the second commit" | |
a8dd2e7d JH |
1155 | |
1156 | test_tick | |
1157 | cat >input <<INPUT_END | |
1158 | blob | |
1159 | mark :2 | |
1160 | data <<EOF | |
1161 | $file2_data | |
1162 | EOF | |
1163 | ||
1164 | commit refs/heads/notes-test | |
1165 | mark :3 | |
1166 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1167 | data <<COMMIT | |
1168 | first (:3) | |
1169 | COMMIT | |
1170 | ||
1171 | M 644 :2 file2 | |
1172 | ||
1173 | blob | |
1174 | mark :4 | |
1175 | data $file4_len | |
1176 | $file4_data | |
1177 | commit refs/heads/notes-test | |
1178 | mark :5 | |
1179 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1180 | data <<COMMIT | |
1181 | second (:5) | |
1182 | COMMIT | |
1183 | ||
1184 | M 644 :4 file4 | |
1185 | ||
1186 | commit refs/heads/notes-test | |
1187 | mark :6 | |
1188 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1189 | data <<COMMIT | |
1190 | third (:6) | |
1191 | COMMIT | |
1192 | ||
1193 | M 644 inline file5 | |
1194 | data <<EOF | |
1195 | $file5_data | |
1196 | EOF | |
1197 | ||
1198 | M 755 inline file6 | |
1199 | data <<EOF | |
1200 | $file6_data | |
1201 | EOF | |
1202 | ||
1203 | blob | |
1204 | mark :7 | |
1205 | data <<EOF | |
1206 | $note1_data | |
1207 | EOF | |
1208 | ||
1209 | blob | |
1210 | mark :8 | |
1211 | data <<EOF | |
1212 | $note2_data | |
1213 | EOF | |
1214 | ||
1215 | commit refs/notes/foobar | |
1216 | mark :9 | |
1217 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1218 | data <<COMMIT | |
1219 | notes (:9) | |
1220 | COMMIT | |
1221 | ||
1222 | N :7 :3 | |
1223 | N :8 :5 | |
1224 | N inline :6 | |
1225 | data <<EOF | |
1226 | $note3_data | |
1227 | EOF | |
1228 | ||
2a113aee JH |
1229 | commit refs/notes/foobar |
1230 | mark :10 | |
1231 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1232 | data <<COMMIT | |
1233 | notes (:10) | |
1234 | COMMIT | |
1235 | ||
1236 | N inline :3 | |
1237 | data <<EOF | |
1238 | $note1b_data | |
1239 | EOF | |
1240 | ||
1241 | commit refs/notes/foobar2 | |
1242 | mark :11 | |
1243 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1244 | data <<COMMIT | |
1245 | notes (:11) | |
1246 | COMMIT | |
1247 | ||
1248 | N inline :3 | |
1249 | data <<EOF | |
1250 | $note1c_data | |
1251 | EOF | |
1252 | ||
1253 | commit refs/notes/foobar | |
1254 | mark :12 | |
1255 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1256 | data <<COMMIT | |
1257 | notes (:12) | |
1258 | COMMIT | |
1259 | ||
1260 | deleteall | |
1261 | N inline :5 | |
1262 | data <<EOF | |
1263 | $note2b_data | |
1264 | EOF | |
1265 | ||
a8dd2e7d | 1266 | INPUT_END |
2a113aee | 1267 | |
a8dd2e7d JH |
1268 | test_expect_success \ |
1269 | 'Q: commit notes' \ | |
1270 | 'git fast-import <input && | |
1271 | git whatchanged notes-test' | |
1272 | test_expect_success \ | |
1273 | 'Q: verify pack' \ | |
1274 | 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done' | |
1275 | ||
1276 | commit1=$(git rev-parse notes-test~2) | |
1277 | commit2=$(git rev-parse notes-test^) | |
1278 | commit3=$(git rev-parse notes-test) | |
1279 | ||
1280 | cat >expect <<EOF | |
1281 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1282 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1283 | ||
1284 | first (:3) | |
1285 | EOF | |
1286 | test_expect_success \ | |
1287 | 'Q: verify first commit' \ | |
1288 | 'git cat-file commit notes-test~2 | sed 1d >actual && | |
1289 | test_cmp expect actual' | |
1290 | ||
1291 | cat >expect <<EOF | |
1292 | parent $commit1 | |
1293 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1294 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1295 | ||
1296 | second (:5) | |
1297 | EOF | |
1298 | test_expect_success \ | |
1299 | 'Q: verify second commit' \ | |
1300 | 'git cat-file commit notes-test^ | sed 1d >actual && | |
1301 | test_cmp expect actual' | |
1302 | ||
1303 | cat >expect <<EOF | |
1304 | parent $commit2 | |
1305 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1306 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1307 | ||
1308 | third (:6) | |
1309 | EOF | |
1310 | test_expect_success \ | |
1311 | 'Q: verify third commit' \ | |
1312 | 'git cat-file commit notes-test | sed 1d >actual && | |
1313 | test_cmp expect actual' | |
1314 | ||
1315 | cat >expect <<EOF | |
1316 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1317 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1318 | ||
1319 | notes (:9) | |
1320 | EOF | |
1321 | test_expect_success \ | |
2a113aee JH |
1322 | 'Q: verify first notes commit' \ |
1323 | 'git cat-file commit refs/notes/foobar~2 | sed 1d >actual && | |
a8dd2e7d JH |
1324 | test_cmp expect actual' |
1325 | ||
1326 | cat >expect.unsorted <<EOF | |
1327 | 100644 blob $commit1 | |
1328 | 100644 blob $commit2 | |
1329 | 100644 blob $commit3 | |
1330 | EOF | |
1331 | cat expect.unsorted | sort >expect | |
1332 | test_expect_success \ | |
2a113aee JH |
1333 | 'Q: verify first notes tree' \ |
1334 | 'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual && | |
a8dd2e7d JH |
1335 | test_cmp expect actual' |
1336 | ||
1337 | echo "$note1_data" >expect | |
1338 | test_expect_success \ | |
2a113aee JH |
1339 | 'Q: verify first note for first commit' \ |
1340 | 'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual' | |
a8dd2e7d JH |
1341 | |
1342 | echo "$note2_data" >expect | |
1343 | test_expect_success \ | |
2a113aee JH |
1344 | 'Q: verify first note for second commit' \ |
1345 | 'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual' | |
1346 | ||
1347 | echo "$note3_data" >expect | |
1348 | test_expect_success \ | |
1349 | 'Q: verify first note for third commit' \ | |
1350 | 'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual' | |
1351 | ||
1352 | cat >expect <<EOF | |
1353 | parent `git rev-parse --verify refs/notes/foobar~2` | |
1354 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1355 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1356 | ||
1357 | notes (:10) | |
1358 | EOF | |
1359 | test_expect_success \ | |
1360 | 'Q: verify second notes commit' \ | |
1361 | 'git cat-file commit refs/notes/foobar^ | sed 1d >actual && | |
1362 | test_cmp expect actual' | |
1363 | ||
1364 | cat >expect.unsorted <<EOF | |
1365 | 100644 blob $commit1 | |
1366 | 100644 blob $commit2 | |
1367 | 100644 blob $commit3 | |
1368 | EOF | |
1369 | cat expect.unsorted | sort >expect | |
1370 | test_expect_success \ | |
1371 | 'Q: verify second notes tree' \ | |
1372 | 'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual && | |
1373 | test_cmp expect actual' | |
1374 | ||
1375 | echo "$note1b_data" >expect | |
1376 | test_expect_success \ | |
1377 | 'Q: verify second note for first commit' \ | |
1378 | 'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual' | |
1379 | ||
1380 | echo "$note2_data" >expect | |
1381 | test_expect_success \ | |
1382 | 'Q: verify first note for second commit' \ | |
1383 | 'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual' | |
a8dd2e7d JH |
1384 | |
1385 | echo "$note3_data" >expect | |
1386 | test_expect_success \ | |
2a113aee JH |
1387 | 'Q: verify first note for third commit' \ |
1388 | 'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual' | |
1389 | ||
1390 | cat >expect <<EOF | |
1391 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1392 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1393 | ||
1394 | notes (:11) | |
1395 | EOF | |
1396 | test_expect_success \ | |
1397 | 'Q: verify third notes commit' \ | |
1398 | 'git cat-file commit refs/notes/foobar2 | sed 1d >actual && | |
1399 | test_cmp expect actual' | |
1400 | ||
1401 | cat >expect.unsorted <<EOF | |
1402 | 100644 blob $commit1 | |
1403 | EOF | |
1404 | cat expect.unsorted | sort >expect | |
1405 | test_expect_success \ | |
1406 | 'Q: verify third notes tree' \ | |
1407 | 'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual && | |
1408 | test_cmp expect actual' | |
1409 | ||
1410 | echo "$note1c_data" >expect | |
1411 | test_expect_success \ | |
1412 | 'Q: verify third note for first commit' \ | |
1413 | 'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual' | |
1414 | ||
1415 | cat >expect <<EOF | |
1416 | parent `git rev-parse --verify refs/notes/foobar^` | |
1417 | author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1418 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1419 | ||
1420 | notes (:12) | |
1421 | EOF | |
1422 | test_expect_success \ | |
1423 | 'Q: verify fourth notes commit' \ | |
1424 | 'git cat-file commit refs/notes/foobar | sed 1d >actual && | |
1425 | test_cmp expect actual' | |
1426 | ||
1427 | cat >expect.unsorted <<EOF | |
1428 | 100644 blob $commit2 | |
1429 | EOF | |
1430 | cat expect.unsorted | sort >expect | |
1431 | test_expect_success \ | |
1432 | 'Q: verify fourth notes tree' \ | |
1433 | 'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual && | |
1434 | test_cmp expect actual' | |
1435 | ||
1436 | echo "$note2b_data" >expect | |
1437 | test_expect_success \ | |
1438 | 'Q: verify second note for second commit' \ | |
1439 | 'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual' | |
a8dd2e7d | 1440 | |
f963bd5d | 1441 | ### |
2792f26c | 1442 | ### series R (feature and option) |
f963bd5d SR |
1443 | ### |
1444 | ||
1445 | cat >input <<EOF | |
1446 | feature no-such-feature-exists | |
1447 | EOF | |
1448 | ||
1449 | test_expect_success 'R: abort on unsupported feature' ' | |
1450 | test_must_fail git fast-import <input | |
1451 | ' | |
1452 | ||
1453 | cat >input <<EOF | |
1454 | feature date-format=now | |
1455 | EOF | |
1456 | ||
1457 | test_expect_success 'R: supported feature is accepted' ' | |
1458 | git fast-import <input | |
1459 | ' | |
1460 | ||
1461 | cat >input << EOF | |
1462 | blob | |
1463 | data 3 | |
1464 | hi | |
1465 | feature date-format=now | |
1466 | EOF | |
1467 | ||
1468 | test_expect_success 'R: abort on receiving feature after data command' ' | |
1469 | test_must_fail git fast-import <input | |
1470 | ' | |
1471 | ||
081751c8 SR |
1472 | cat >input << EOF |
1473 | feature import-marks=git.marks | |
1474 | feature import-marks=git2.marks | |
1475 | EOF | |
1476 | ||
1477 | test_expect_success 'R: only one import-marks feature allowed per stream' ' | |
1478 | test_must_fail git fast-import <input | |
1479 | ' | |
1480 | ||
f963bd5d SR |
1481 | cat >input << EOF |
1482 | feature export-marks=git.marks | |
1483 | blob | |
1484 | mark :1 | |
1485 | data 3 | |
1486 | hi | |
1487 | ||
1488 | EOF | |
1489 | ||
1490 | test_expect_success \ | |
1491 | 'R: export-marks feature results in a marks file being created' \ | |
1492 | 'cat input | git fast-import && | |
1493 | grep :1 git.marks' | |
1494 | ||
1495 | test_expect_success \ | |
1496 | 'R: export-marks options can be overriden by commandline options' \ | |
1497 | 'cat input | git fast-import --export-marks=other.marks && | |
1498 | grep :1 other.marks' | |
1499 | ||
1500 | cat >input << EOF | |
1501 | feature import-marks=marks.out | |
1502 | feature export-marks=marks.new | |
1503 | EOF | |
1504 | ||
1505 | test_expect_success \ | |
1506 | 'R: import to output marks works without any content' \ | |
1507 | 'cat input | git fast-import && | |
1508 | test_cmp marks.out marks.new' | |
1509 | ||
1510 | cat >input <<EOF | |
1511 | feature import-marks=nonexistant.marks | |
1512 | feature export-marks=marks.new | |
1513 | EOF | |
1514 | ||
1515 | test_expect_success \ | |
1516 | 'R: import marks prefers commandline marks file over the stream' \ | |
1517 | 'cat input | git fast-import --import-marks=marks.out && | |
1518 | test_cmp marks.out marks.new' | |
1519 | ||
081751c8 SR |
1520 | |
1521 | cat >input <<EOF | |
1522 | feature import-marks=nonexistant.marks | |
1523 | feature export-marks=combined.marks | |
1524 | EOF | |
1525 | ||
1526 | test_expect_success 'R: multiple --import-marks= should be honoured' ' | |
1527 | head -n2 marks.out > one.marks && | |
1528 | tail -n +3 marks.out > two.marks && | |
1529 | git fast-import --import-marks=one.marks --import-marks=two.marks <input && | |
1530 | test_cmp marks.out combined.marks | |
1531 | ' | |
1532 | ||
bc3c79ae SR |
1533 | cat >input <<EOF |
1534 | feature relative-marks | |
1535 | feature import-marks=relative.in | |
1536 | feature export-marks=relative.out | |
1537 | EOF | |
1538 | ||
1539 | test_expect_success 'R: feature relative-marks should be honoured' ' | |
1540 | mkdir -p .git/info/fast-import/ && | |
1541 | cp marks.new .git/info/fast-import/relative.in && | |
1542 | git fast-import <input && | |
1543 | test_cmp marks.new .git/info/fast-import/relative.out | |
1544 | ' | |
1545 | ||
1546 | cat >input <<EOF | |
1547 | feature relative-marks | |
1548 | feature import-marks=relative.in | |
1549 | feature no-relative-marks | |
1550 | feature export-marks=non-relative.out | |
1551 | EOF | |
1552 | ||
1553 | test_expect_success 'R: feature no-relative-marks should be honoured' ' | |
1554 | git fast-import <input && | |
1555 | test_cmp marks.new non-relative.out | |
1556 | ' | |
1557 | ||
2792f26c SR |
1558 | cat >input << EOF |
1559 | option git quiet | |
1560 | blob | |
1561 | data 3 | |
1562 | hi | |
1563 | ||
1564 | EOF | |
1565 | ||
1566 | touch empty | |
1567 | ||
1568 | test_expect_success 'R: quiet option results in no stats being output' ' | |
1569 | cat input | git fast-import 2> output && | |
1570 | test_cmp empty output | |
1571 | ' | |
1572 | ||
1573 | cat >input <<EOF | |
1574 | option git non-existing-option | |
1575 | EOF | |
1576 | ||
1577 | test_expect_success 'R: die on unknown option' ' | |
1578 | test_must_fail git fast-import <input | |
1579 | ' | |
1580 | ||
1581 | test_expect_success 'R: unknown commandline options are rejected' '\ | |
1582 | test_must_fail git fast-import --non-existing-option < /dev/null | |
1583 | ' | |
1584 | ||
1585 | cat >input <<EOF | |
1586 | option non-existing-vcs non-existing-option | |
1587 | EOF | |
1588 | ||
1589 | test_expect_success 'R: ignore non-git options' ' | |
1590 | git fast-import <input | |
1591 | ' | |
1592 | ||
5eef828b SP |
1593 | ## |
1594 | ## R: very large blobs | |
1595 | ## | |
1596 | blobsize=$((2*1024*1024 + 53)) | |
1597 | test-genrandom bar $blobsize >expect | |
1598 | cat >input <<INPUT_END | |
1599 | commit refs/heads/big-file | |
1600 | committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
1601 | data <<COMMIT | |
1602 | R - big file | |
1603 | COMMIT | |
1604 | ||
1605 | M 644 inline big1 | |
1606 | data $blobsize | |
1607 | INPUT_END | |
1608 | cat expect >>input | |
1609 | cat >>input <<INPUT_END | |
1610 | M 644 inline big2 | |
1611 | data $blobsize | |
1612 | INPUT_END | |
1613 | cat expect >>input | |
1614 | echo >>input | |
1615 | ||
1616 | test_expect_success \ | |
1617 | 'R: blob bigger than threshold' \ | |
1618 | 'test_create_repo R && | |
1619 | git --git-dir=R/.git fast-import --big-file-threshold=1 <input' | |
1620 | test_expect_success \ | |
1621 | 'R: verify created pack' \ | |
1622 | ': >verify && | |
1623 | for p in R/.git/objects/pack/*.pack; | |
1624 | do | |
1625 | git verify-pack -v $p >>verify || exit; | |
1626 | done' | |
1627 | test_expect_success \ | |
1628 | 'R: verify written objects' \ | |
1629 | 'git --git-dir=R/.git cat-file blob big-file:big1 >actual && | |
1630 | test_cmp expect actual && | |
1631 | a=$(git --git-dir=R/.git rev-parse big-file:big1) && | |
1632 | b=$(git --git-dir=R/.git rev-parse big-file:big2) && | |
1633 | test $a = $b' | |
1634 | test_expect_success \ | |
1635 | 'R: blob appears only once' \ | |
1636 | 'n=$(grep $a verify | wc -l) && | |
1637 | test 1 = $n' | |
1638 | ||
50aee995 | 1639 | test_done |