3 # Copyright (c) 2007 Shawn Pearce
6 test_description='test git-fast-import utility'
8 . ../diff-lib.sh ;# test-lib chdir's into trash
20 file5_data='an inline file.
21 we should see it later.'
31 cat >input <<INPUT_END
48 commit refs/heads/master
50 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
61 'A: create pack from stdin' \
62 'git-fast-import --export-marks=marks.out <input &&
63 git-whatchanged master'
66 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
69 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
70 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
76 'git-cat-file commit master | sed 1d >actual &&
77 git diff expect actual'
86 'git-cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
87 git diff expect actual'
89 echo "$file2_data" >expect
92 'git-cat-file blob master:file2 >actual && git diff expect actual'
94 echo "$file3_data" >expect
97 'git-cat-file blob master:file3 >actual && git diff expect actual'
99 printf "$file4_data" >expect
100 test_expect_success \
102 'git-cat-file blob master:file4 >actual && git diff expect actual'
105 :2 `git-rev-parse --verify master:file2`
106 :3 `git-rev-parse --verify master:file3`
107 :4 `git-rev-parse --verify master:file4`
108 :5 `git-rev-parse --verify master^0`
110 test_expect_success \
111 'A: verify marks output' \
112 'git diff expect marks.out'
114 test_expect_success \
115 'A: verify marks import' \
117 --import-marks=marks.out \
118 --export-marks=marks.new \
120 git diff -u expect marks.new'
127 cat >input <<INPUT_END
128 commit refs/heads/branch
130 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
135 from refs/heads/master
136 M 755 0000000000000000000000000000000000000001 zero1
139 test_expect_failure \
140 'B: fail on invalid blob sha1' \
141 'git-fast-import <input'
142 rm -f .git/objects/pack_* .git/objects/index_*
148 newf=`echo hi newf | git-hash-object -w --stdin`
149 oldf=`git-rev-parse --verify master:file2`
151 cat >input <<INPUT_END
152 commit refs/heads/branch
153 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
158 from refs/heads/master
159 M 644 $oldf file2/oldf
160 M 755 $newf file2/newf
164 test_expect_success \
165 'C: incremental import create pack from stdin' \
166 'git-fast-import <input &&
167 git-whatchanged branch'
168 test_expect_success \
170 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
171 test_expect_success \
172 'C: validate reuse existing blob' \
173 'test $newf = `git-rev-parse --verify branch:file2/newf`
174 test $oldf = `git-rev-parse --verify branch:file2/oldf`'
177 parent `git-rev-parse --verify master^0`
178 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
179 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
183 test_expect_success \
185 'git-cat-file commit branch | sed 1d >actual &&
186 git diff expect actual'
189 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
190 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
191 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
193 git-diff-tree -M -r master branch >actual
194 test_expect_success \
195 'C: validate rename result' \
196 'compare_diff_raw expect actual'
203 cat >input <<INPUT_END
204 commit refs/heads/branch
205 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
210 from refs/heads/branch^0
211 M 644 inline newdir/interesting
216 M 755 inline newdir/exec.sh
222 test_expect_success \
223 'D: inline data in commit' \
224 'git-fast-import <input &&
225 git-whatchanged branch'
226 test_expect_success \
228 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
231 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
232 :000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
234 git-diff-tree -M -r branch^ branch >actual
235 test_expect_success \
236 'D: validate new files added' \
237 'compare_diff_raw expect actual'
239 echo "$file5_data" >expect
240 test_expect_success \
242 'git-cat-file blob branch:newdir/interesting >actual &&
243 git diff expect actual'
245 echo "$file6_data" >expect
246 test_expect_success \
248 'git-cat-file blob branch:newdir/exec.sh >actual &&
249 git diff expect actual'
255 cat >input <<INPUT_END
256 commit refs/heads/branch
257 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
258 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
263 from refs/heads/branch^0
266 test_expect_failure \
267 'E: rfc2822 date, --date-format=raw' \
268 'git-fast-import --date-format=raw <input'
269 test_expect_success \
270 'E: rfc2822 date, --date-format=rfc2822' \
271 'git-fast-import --date-format=rfc2822 <input'
272 test_expect_success \
274 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
277 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
278 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
282 test_expect_success \
284 'git-cat-file commit branch | sed 1,2d >actual &&
285 git diff expect actual'
291 old_branch=`git-rev-parse --verify branch^0`
293 cat >input <<INPUT_END
294 commit refs/heads/branch
295 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
297 losing things already?
300 from refs/heads/branch~1
302 reset refs/heads/other
303 from refs/heads/branch
306 test_expect_success \
307 'F: non-fast-forward update skips' \
308 'if git-fast-import <input
310 echo BAD gfi did not fail
313 if test $old_branch = `git-rev-parse --verify branch^0`
315 : branch unaffected and failure returned
318 echo BAD gfi changed branch $old_branch
323 test_expect_success \
325 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
328 tree `git-rev-parse branch~1^{tree}`
329 parent `git-rev-parse branch~1`
330 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
331 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
333 losing things already?
335 test_expect_success \
336 'F: verify other commit' \
337 'git-cat-file commit other >actual &&
338 git diff expect actual'
344 old_branch=`git-rev-parse --verify branch^0`
346 cat >input <<INPUT_END
347 commit refs/heads/branch
348 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
350 losing things already?
353 from refs/heads/branch~1
356 test_expect_success \
357 'G: non-fast-forward update forced' \
358 'git-fast-import --force <input'
359 test_expect_success \
361 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
362 test_expect_success \
363 'G: branch changed, but logged' \
364 'test $old_branch != `git-rev-parse --verify branch^0` &&
365 test $old_branch = `git-rev-parse --verify branch@{1}`'
372 cat >input <<INPUT_END
374 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
379 from refs/heads/branch^0
380 M 644 inline i-will-die
382 this file will never exist.
386 M 644 inline h/e/l/lo
392 test_expect_success \
393 'H: deletall, add 1' \
394 'git-fast-import <input &&
396 test_expect_success \
398 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
401 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
402 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
403 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
404 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
405 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
407 git-diff-tree -M -r H^ H >actual
408 test_expect_success \
409 'H: validate old files removed, new files added' \
410 'compare_diff_raw expect actual'
412 echo "$file5_data" >expect
413 test_expect_success \
415 'git-cat-file blob H:h/e/l/lo >actual &&
416 git diff expect actual'
422 cat >input <<INPUT_END
423 commit refs/heads/export-boundary
424 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
426 we have a border. its only 40 characters wide.
429 from refs/heads/branch
432 test_expect_success \
433 'I: export-pack-edges' \
434 'git-fast-import --export-pack-edges=edges.list <input'
437 .git/objects/pack/pack-.pack: `git-rev-parse --verify export-boundary`
439 test_expect_success \
440 'I: verify edge list' \
441 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
442 git diff expect actual'
448 cat >input <<INPUT_END
450 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
455 from refs/heads/branch
460 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
466 test_expect_success \
467 'J: reset existing branch creates empty commit' \
468 'git-fast-import <input'
469 test_expect_success \
470 'J: branch has 1 commit, empty tree' \
471 'test 1 = `git-rev-list J | wc -l` &&
472 test 0 = `git ls-tree J | wc -l`'
478 cat >input <<INPUT_END
480 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
485 from refs/heads/branch
488 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
493 from refs/heads/branch^1
496 test_expect_success \
497 'K: reinit branch with from' \
498 'git-fast-import <input'
499 test_expect_success \
500 'K: verify K^1 = branch^1' \
501 'test `git-rev-parse --verify branch^1` \
502 = `git-rev-parse --verify K^1`'
508 cat >input <<INPUT_END
522 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
532 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
542 cat >expect <<EXPECT_END
543 :100644 100644 4268632... 55d3a52... M b.
544 :040000 040000 0ae5cac... 443c768... M b
545 :100644 100644 4268632... 55d3a52... M ba
548 test_expect_success \
549 'L: verify internal tree sorting' \
550 'git-fast-import <input &&
551 git-diff --raw L^ L >output &&
552 git diff expect output'