Merge branch 'ah/userdiff-markdown'
[git/debian.git] / t / t5520-pull.sh
blob37535d63a9cc0c8d611747bd3235995d0b98a115
1 #!/bin/sh
3 test_description='pulling into void'
5 . ./test-lib.sh
7 modify () {
8 sed -e "$1" "$2" >"$2.x" &&
9 mv "$2.x" "$2"
12 test_pull_autostash () {
13 expect_parent_num="$1" &&
14 shift &&
15 git reset --hard before-rebase &&
16 echo dirty >new_file &&
17 git add new_file &&
18 git pull "$@" . copy &&
19 test_cmp_rev HEAD^"$expect_parent_num" copy &&
20 echo dirty >expect &&
21 test_cmp expect new_file &&
22 echo "modified again" >expect &&
23 test_cmp expect file
26 test_pull_autostash_fail () {
27 git reset --hard before-rebase &&
28 echo dirty >new_file &&
29 git add new_file &&
30 test_must_fail git pull "$@" . copy 2>err &&
31 test_i18ngrep "\(uncommitted changes.\)\|\(overwritten by merge:\)" err
34 test_expect_success setup '
35 echo file >file &&
36 git add file &&
37 git commit -a -m original
40 test_expect_success 'pulling into void' '
41 git init cloned &&
43 cd cloned &&
44 git pull ..
45 ) &&
46 test_path_is_file file &&
47 test_path_is_file cloned/file &&
48 test_cmp file cloned/file
51 test_expect_success 'pulling into void using master:master' '
52 git init cloned-uho &&
54 cd cloned-uho &&
55 git pull .. master:master
56 ) &&
57 test_path_is_file file &&
58 test_path_is_file cloned-uho/file &&
59 test_cmp file cloned-uho/file
62 test_expect_success 'pulling into void does not overwrite untracked files' '
63 git init cloned-untracked &&
65 cd cloned-untracked &&
66 echo untracked >file &&
67 test_must_fail git pull .. master &&
68 echo untracked >expect &&
69 test_cmp expect file
73 test_expect_success 'pulling into void does not overwrite staged files' '
74 git init cloned-staged-colliding &&
76 cd cloned-staged-colliding &&
77 echo "alternate content" >file &&
78 git add file &&
79 test_must_fail git pull .. master &&
80 echo "alternate content" >expect &&
81 test_cmp expect file &&
82 git cat-file blob :file >file.index &&
83 test_cmp expect file.index
87 test_expect_success 'pulling into void does not remove new staged files' '
88 git init cloned-staged-new &&
90 cd cloned-staged-new &&
91 echo "new tracked file" >newfile &&
92 git add newfile &&
93 git pull .. master &&
94 echo "new tracked file" >expect &&
95 test_cmp expect newfile &&
96 git cat-file blob :newfile >newfile.index &&
97 test_cmp expect newfile.index
101 test_expect_success 'pulling into void must not create an octopus' '
102 git init cloned-octopus &&
104 cd cloned-octopus &&
105 test_must_fail git pull .. master master &&
106 test_path_is_missing file
110 test_expect_success 'test . as a remote' '
111 git branch copy master &&
112 git config branch.copy.remote . &&
113 git config branch.copy.merge refs/heads/master &&
114 echo updated >file &&
115 git commit -a -m updated &&
116 git checkout copy &&
117 echo file >expect &&
118 test_cmp expect file &&
119 git pull &&
120 echo updated >expect &&
121 test_cmp expect file &&
122 git reflog -1 >reflog.actual &&
123 sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
124 echo "OBJID HEAD@{0}: pull: Fast-forward" >reflog.expected &&
125 test_cmp reflog.expected reflog.fuzzy
128 test_expect_success 'the default remote . should not break explicit pull' '
129 git checkout -b second master^ &&
130 echo modified >file &&
131 git commit -a -m modified &&
132 git checkout copy &&
133 git reset --hard HEAD^ &&
134 echo file >expect &&
135 test_cmp expect file &&
136 git pull . second &&
137 echo modified >expect &&
138 test_cmp expect file &&
139 git reflog -1 >reflog.actual &&
140 sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
141 echo "OBJID HEAD@{0}: pull . second: Fast-forward" >reflog.expected &&
142 test_cmp reflog.expected reflog.fuzzy
145 test_expect_success 'fail if wildcard spec does not match any refs' '
146 git checkout -b test copy^ &&
147 test_when_finished "git checkout -f copy && git branch -D test" &&
148 echo file >expect &&
149 test_cmp expect file &&
150 test_must_fail git pull . "refs/nonexisting1/*:refs/nonexisting2/*" 2>err &&
151 test_i18ngrep "no candidates for merging" err &&
152 test_cmp expect file
155 test_expect_success 'fail if no branches specified with non-default remote' '
156 git remote add test_remote . &&
157 test_when_finished "git remote remove test_remote" &&
158 git checkout -b test copy^ &&
159 test_when_finished "git checkout -f copy && git branch -D test" &&
160 echo file >expect &&
161 test_cmp expect file &&
162 test_config branch.test.remote origin &&
163 test_must_fail git pull test_remote 2>err &&
164 test_i18ngrep "specify a branch on the command line" err &&
165 test_cmp expect file
168 test_expect_success 'fail if not on a branch' '
169 git remote add origin . &&
170 test_when_finished "git remote remove origin" &&
171 git checkout HEAD^ &&
172 test_when_finished "git checkout -f copy" &&
173 echo file >expect &&
174 test_cmp expect file &&
175 test_must_fail git pull 2>err &&
176 test_i18ngrep "not currently on a branch" err &&
177 test_cmp expect file
180 test_expect_success 'fail if no configuration for current branch' '
181 git remote add test_remote . &&
182 test_when_finished "git remote remove test_remote" &&
183 git checkout -b test copy^ &&
184 test_when_finished "git checkout -f copy && git branch -D test" &&
185 test_config branch.test.remote test_remote &&
186 echo file >expect &&
187 test_cmp expect file &&
188 test_must_fail git pull 2>err &&
189 test_i18ngrep "no tracking information" err &&
190 test_cmp expect file
193 test_expect_success 'pull --all: fail if no configuration for current branch' '
194 git remote add test_remote . &&
195 test_when_finished "git remote remove test_remote" &&
196 git checkout -b test copy^ &&
197 test_when_finished "git checkout -f copy && git branch -D test" &&
198 test_config branch.test.remote test_remote &&
199 echo file >expect &&
200 test_cmp expect file &&
201 test_must_fail git pull --all 2>err &&
202 test_i18ngrep "There is no tracking information" err &&
203 test_cmp expect file
206 test_expect_success 'fail if upstream branch does not exist' '
207 git checkout -b test copy^ &&
208 test_when_finished "git checkout -f copy && git branch -D test" &&
209 test_config branch.test.remote . &&
210 test_config branch.test.merge refs/heads/nonexisting &&
211 echo file >expect &&
212 test_cmp expect file &&
213 test_must_fail git pull 2>err &&
214 test_i18ngrep "no such ref was fetched" err &&
215 test_cmp expect file
218 test_expect_success 'fail if the index has unresolved entries' '
219 git checkout -b third second^ &&
220 test_when_finished "git checkout -f copy && git branch -D third" &&
221 echo file >expect &&
222 test_cmp expect file &&
223 test_commit modified2 file &&
224 git ls-files -u >unmerged &&
225 test_must_be_empty unmerged &&
226 test_must_fail git pull . second &&
227 git ls-files -u >unmerged &&
228 test_file_not_empty unmerged &&
229 cp file expected &&
230 test_must_fail git pull . second 2>err &&
231 test_i18ngrep "Pulling is not possible because you have unmerged files." err &&
232 test_cmp expected file &&
233 git add file &&
234 git ls-files -u >unmerged &&
235 test_must_be_empty unmerged &&
236 test_must_fail git pull . second 2>err &&
237 test_i18ngrep "You have not concluded your merge" err &&
238 test_cmp expected file
241 test_expect_success 'fast-forwards working tree if branch head is updated' '
242 git checkout -b third second^ &&
243 test_when_finished "git checkout -f copy && git branch -D third" &&
244 echo file >expect &&
245 test_cmp expect file &&
246 git pull . second:third 2>err &&
247 test_i18ngrep "fetch updated the current branch head" err &&
248 echo modified >expect &&
249 test_cmp expect file &&
250 test_cmp_rev third second
253 test_expect_success 'fast-forward fails with conflicting work tree' '
254 git checkout -b third second^ &&
255 test_when_finished "git checkout -f copy && git branch -D third" &&
256 echo file >expect &&
257 test_cmp expect file &&
258 echo conflict >file &&
259 test_must_fail git pull . second:third 2>err &&
260 test_i18ngrep "Cannot fast-forward your working tree" err &&
261 echo conflict >expect &&
262 test_cmp expect file &&
263 test_cmp_rev third second
266 test_expect_success '--rebase' '
267 git branch to-rebase &&
268 echo modified again >file &&
269 git commit -m file file &&
270 git checkout to-rebase &&
271 echo new >file2 &&
272 git add file2 &&
273 git commit -m "new file" &&
274 git tag before-rebase &&
275 git pull --rebase . copy &&
276 test_cmp_rev HEAD^ copy &&
277 echo new >expect &&
278 git show HEAD:file2 >actual &&
279 test_cmp expect actual
282 test_expect_success '--rebase (merge) fast forward' '
283 git reset --hard before-rebase &&
284 git checkout -b ff &&
285 echo another modification >file &&
286 git commit -m third file &&
288 git checkout to-rebase &&
289 git -c rebase.backend=merge pull --rebase . ff &&
290 test_cmp_rev HEAD ff &&
292 # The above only validates the result. Did we actually bypass rebase?
293 git reflog -1 >reflog.actual &&
294 sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
295 echo "OBJID HEAD@{0}: pull --rebase . ff: Fast-forward" >reflog.expected &&
296 test_cmp reflog.expected reflog.fuzzy
299 test_expect_success '--rebase (am) fast forward' '
300 git reset --hard before-rebase &&
302 git -c rebase.backend=apply pull --rebase . ff &&
303 test_cmp_rev HEAD ff &&
305 # The above only validates the result. Did we actually bypass rebase?
306 git reflog -1 >reflog.actual &&
307 sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
308 echo "OBJID HEAD@{0}: pull --rebase . ff: Fast-forward" >reflog.expected &&
309 test_cmp reflog.expected reflog.fuzzy
312 test_expect_success '--rebase --autostash fast forward' '
313 test_when_finished "
314 git reset --hard
315 git checkout to-rebase
316 git branch -D to-rebase-ff
317 git branch -D behind" &&
318 git branch behind &&
319 git checkout -b to-rebase-ff &&
320 echo another modification >>file &&
321 git add file &&
322 git commit -m mod &&
324 git checkout behind &&
325 echo dirty >file &&
326 git pull --rebase --autostash . to-rebase-ff &&
327 test_cmp_rev HEAD to-rebase-ff
330 test_expect_success '--rebase with conflicts shows advice' '
331 test_when_finished "git rebase --abort; git checkout -f to-rebase" &&
332 git checkout -b seq &&
333 test_seq 5 >seq.txt &&
334 git add seq.txt &&
335 test_tick &&
336 git commit -m "Add seq.txt" &&
337 echo 6 >>seq.txt &&
338 test_tick &&
339 git commit -m "Append to seq.txt" seq.txt &&
340 git checkout -b with-conflicts HEAD^ &&
341 echo conflicting >>seq.txt &&
342 test_tick &&
343 git commit -m "Create conflict" seq.txt &&
344 test_must_fail git pull --rebase . seq 2>err >out &&
345 test_i18ngrep "Resolve all conflicts manually" err
348 test_expect_success 'failed --rebase shows advice' '
349 test_when_finished "git rebase --abort; git checkout -f to-rebase" &&
350 git checkout -b diverging &&
351 test_commit attributes .gitattributes "* text=auto" attrs &&
352 sha1="$(printf "1\\r\\n" | git hash-object -w --stdin)" &&
353 git update-index --cacheinfo 0644 $sha1 file &&
354 git commit -m v1-with-cr &&
355 # force checkout because `git reset --hard` will not leave clean `file`
356 git checkout -f -b fails-to-rebase HEAD^ &&
357 test_commit v2-without-cr file "2" file2-lf &&
358 test_must_fail git pull --rebase . diverging 2>err >out &&
359 test_i18ngrep "Resolve all conflicts manually" err
362 test_expect_success '--rebase fails with multiple branches' '
363 git reset --hard before-rebase &&
364 test_must_fail git pull --rebase . copy master 2>err &&
365 test_cmp_rev HEAD before-rebase &&
366 test_i18ngrep "Cannot rebase onto multiple branches" err &&
367 echo modified >expect &&
368 git show HEAD:file >actual &&
369 test_cmp expect actual
372 test_expect_success 'pull --rebase succeeds with dirty working directory and rebase.autostash set' '
373 test_config rebase.autostash true &&
374 test_pull_autostash 1 --rebase
377 test_expect_success 'pull --rebase --autostash & rebase.autostash=true' '
378 test_config rebase.autostash true &&
379 test_pull_autostash 1 --rebase --autostash
382 test_expect_success 'pull --rebase --autostash & rebase.autostash=false' '
383 test_config rebase.autostash false &&
384 test_pull_autostash 1 --rebase --autostash
387 test_expect_success 'pull --rebase --autostash & rebase.autostash unset' '
388 test_unconfig rebase.autostash &&
389 test_pull_autostash 1 --rebase --autostash
392 test_expect_success 'pull --rebase --no-autostash & rebase.autostash=true' '
393 test_config rebase.autostash true &&
394 test_pull_autostash_fail --rebase --no-autostash
397 test_expect_success 'pull --rebase --no-autostash & rebase.autostash=false' '
398 test_config rebase.autostash false &&
399 test_pull_autostash_fail --rebase --no-autostash
402 test_expect_success 'pull --rebase --no-autostash & rebase.autostash unset' '
403 test_unconfig rebase.autostash &&
404 test_pull_autostash_fail --rebase --no-autostash
407 test_expect_success 'pull succeeds with dirty working directory and merge.autostash set' '
408 test_config merge.autostash true &&
409 test_pull_autostash 2
412 test_expect_success 'pull --autostash & merge.autostash=true' '
413 test_config merge.autostash true &&
414 test_pull_autostash 2 --autostash
417 test_expect_success 'pull --autostash & merge.autostash=false' '
418 test_config merge.autostash false &&
419 test_pull_autostash 2 --autostash
422 test_expect_success 'pull --autostash & merge.autostash unset' '
423 test_unconfig merge.autostash &&
424 test_pull_autostash 2 --autostash
427 test_expect_success 'pull --no-autostash & merge.autostash=true' '
428 test_config merge.autostash true &&
429 test_pull_autostash_fail --no-autostash
432 test_expect_success 'pull --no-autostash & merge.autostash=false' '
433 test_config merge.autostash false &&
434 test_pull_autostash_fail --no-autostash
437 test_expect_success 'pull --no-autostash & merge.autostash unset' '
438 test_unconfig merge.autostash &&
439 test_pull_autostash_fail --no-autostash
442 test_expect_success 'pull.rebase' '
443 git reset --hard before-rebase &&
444 test_config pull.rebase true &&
445 git pull . copy &&
446 test_cmp_rev HEAD^ copy &&
447 echo new >expect &&
448 git show HEAD:file2 >actual &&
449 test_cmp expect actual
452 test_expect_success 'pull --autostash & pull.rebase=true' '
453 test_config pull.rebase true &&
454 test_pull_autostash 1 --autostash
457 test_expect_success 'pull --no-autostash & pull.rebase=true' '
458 test_config pull.rebase true &&
459 test_pull_autostash_fail --no-autostash
462 test_expect_success 'branch.to-rebase.rebase' '
463 git reset --hard before-rebase &&
464 test_config branch.to-rebase.rebase true &&
465 git pull . copy &&
466 test_cmp_rev HEAD^ copy &&
467 echo new >expect &&
468 git show HEAD:file2 >actual &&
469 test_cmp expect actual
472 test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
473 git reset --hard before-rebase &&
474 test_config pull.rebase true &&
475 test_config branch.to-rebase.rebase false &&
476 git pull . copy &&
477 test_cmp_rev ! HEAD^ copy &&
478 echo new >expect &&
479 git show HEAD:file2 >actual &&
480 test_cmp expect actual
483 test_expect_success 'pull --rebase warns on --verify-signatures' '
484 git reset --hard before-rebase &&
485 git pull --rebase --verify-signatures . copy 2>err &&
486 test_cmp_rev HEAD^ copy &&
487 echo new >expect &&
488 git show HEAD:file2 >actual &&
489 test_cmp expect actual &&
490 test_i18ngrep "ignoring --verify-signatures for rebase" err
493 test_expect_success 'pull --rebase does not warn on --no-verify-signatures' '
494 git reset --hard before-rebase &&
495 git pull --rebase --no-verify-signatures . copy 2>err &&
496 test_cmp_rev HEAD^ copy &&
497 echo new >expect &&
498 git show HEAD:file2 >actual &&
499 test_cmp expect actual &&
500 test_i18ngrep ! "verify-signatures" err
503 # add a feature branch, keep-merge, that is merged into master, so the
504 # test can try preserving the merge commit (or not) with various
505 # --rebase flags/pull.rebase settings.
506 test_expect_success 'preserve merge setup' '
507 git reset --hard before-rebase &&
508 git checkout -b keep-merge second^ &&
509 test_commit file3 &&
510 git checkout to-rebase &&
511 git merge keep-merge &&
512 git tag before-preserve-rebase
515 test_expect_success 'pull.rebase=false create a new merge commit' '
516 git reset --hard before-preserve-rebase &&
517 test_config pull.rebase false &&
518 git pull . copy &&
519 test_cmp_rev HEAD^1 before-preserve-rebase &&
520 test_cmp_rev HEAD^2 copy &&
521 echo file3 >expect &&
522 git show HEAD:file3.t >actual &&
523 test_cmp expect actual
526 test_expect_success 'pull.rebase=true flattens keep-merge' '
527 git reset --hard before-preserve-rebase &&
528 test_config pull.rebase true &&
529 git pull . copy &&
530 test_cmp_rev HEAD^^ copy &&
531 echo file3 >expect &&
532 git show HEAD:file3.t >actual &&
533 test_cmp expect actual
536 test_expect_success 'pull.rebase=1 is treated as true and flattens keep-merge' '
537 git reset --hard before-preserve-rebase &&
538 test_config pull.rebase 1 &&
539 git pull . copy &&
540 test_cmp_rev HEAD^^ copy &&
541 echo file3 >expect &&
542 git show HEAD:file3.t >actual &&
543 test_cmp expect actual
546 test_expect_success REBASE_P \
547 'pull.rebase=preserve rebases and merges keep-merge' '
548 git reset --hard before-preserve-rebase &&
549 test_config pull.rebase preserve &&
550 git pull . copy &&
551 test_cmp_rev HEAD^^ copy &&
552 test_cmp_rev HEAD^2 keep-merge
555 test_expect_success 'pull.rebase=interactive' '
556 write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF &&
557 echo I was here >fake.out &&
558 false
560 test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
561 test_when_finished "test_might_fail git rebase --abort" &&
562 test_must_fail git pull --rebase=interactive . copy &&
563 echo "I was here" >expect &&
564 test_cmp expect fake.out
567 test_expect_success 'pull --rebase=i' '
568 write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF &&
569 echo I was here, too >fake.out &&
570 false
572 test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
573 test_when_finished "test_might_fail git rebase --abort" &&
574 test_must_fail git pull --rebase=i . copy &&
575 echo "I was here, too" >expect &&
576 test_cmp expect fake.out
579 test_expect_success 'pull.rebase=invalid fails' '
580 git reset --hard before-preserve-rebase &&
581 test_config pull.rebase invalid &&
582 test_must_fail git pull . copy
585 test_expect_success '--rebase=false create a new merge commit' '
586 git reset --hard before-preserve-rebase &&
587 test_config pull.rebase true &&
588 git pull --rebase=false . copy &&
589 test_cmp_rev HEAD^1 before-preserve-rebase &&
590 test_cmp_rev HEAD^2 copy &&
591 echo file3 >expect &&
592 git show HEAD:file3.t >actual &&
593 test_cmp expect actual
596 test_expect_success '--rebase=true rebases and flattens keep-merge' '
597 git reset --hard before-preserve-rebase &&
598 test_config pull.rebase preserve &&
599 git pull --rebase=true . copy &&
600 test_cmp_rev HEAD^^ copy &&
601 echo file3 >expect &&
602 git show HEAD:file3.t >actual &&
603 test_cmp expect actual
606 test_expect_success REBASE_P \
607 '--rebase=preserve rebases and merges keep-merge' '
608 git reset --hard before-preserve-rebase &&
609 test_config pull.rebase true &&
610 git pull --rebase=preserve . copy &&
611 test_cmp_rev HEAD^^ copy &&
612 test_cmp_rev HEAD^2 keep-merge
615 test_expect_success '--rebase=invalid fails' '
616 git reset --hard before-preserve-rebase &&
617 test_must_fail git pull --rebase=invalid . copy
620 test_expect_success '--rebase overrides pull.rebase=preserve and flattens keep-merge' '
621 git reset --hard before-preserve-rebase &&
622 test_config pull.rebase preserve &&
623 git pull --rebase . copy &&
624 test_cmp_rev HEAD^^ copy &&
625 echo file3 >expect &&
626 git show HEAD:file3.t >actual &&
627 test_cmp expect actual
630 test_expect_success '--rebase with rebased upstream' '
631 git remote add -f me . &&
632 git checkout copy &&
633 git tag copy-orig &&
634 git reset --hard HEAD^ &&
635 echo conflicting modification >file &&
636 git commit -m conflict file &&
637 git checkout to-rebase &&
638 echo file >file2 &&
639 git commit -m to-rebase file2 &&
640 git tag to-rebase-orig &&
641 git pull --rebase me copy &&
642 echo "conflicting modification" >expect &&
643 test_cmp expect file &&
644 echo file >expect &&
645 test_cmp expect file2
648 test_expect_success '--rebase -f with rebased upstream' '
649 test_when_finished "test_might_fail git rebase --abort" &&
650 git reset --hard to-rebase-orig &&
651 git pull --rebase -f me copy &&
652 echo "conflicting modification" >expect &&
653 test_cmp expect file &&
654 echo file >expect &&
655 test_cmp expect file2
658 test_expect_success '--rebase with rebased default upstream' '
659 git update-ref refs/remotes/me/copy copy-orig &&
660 git checkout --track -b to-rebase2 me/copy &&
661 git reset --hard to-rebase-orig &&
662 git pull --rebase &&
663 echo "conflicting modification" >expect &&
664 test_cmp expect file &&
665 echo file >expect &&
666 test_cmp expect file2
669 test_expect_success 'rebased upstream + fetch + pull --rebase' '
671 git update-ref refs/remotes/me/copy copy-orig &&
672 git reset --hard to-rebase-orig &&
673 git checkout --track -b to-rebase3 me/copy &&
674 git reset --hard to-rebase-orig &&
675 git fetch &&
676 git pull --rebase &&
677 echo "conflicting modification" >expect &&
678 test_cmp expect file &&
679 echo file >expect &&
680 test_cmp expect file2
684 test_expect_success 'pull --rebase dies early with dirty working directory' '
685 git checkout to-rebase &&
686 git update-ref refs/remotes/me/copy copy^ &&
687 COPY="$(git rev-parse --verify me/copy)" &&
688 git rebase --onto $COPY copy &&
689 test_config branch.to-rebase.remote me &&
690 test_config branch.to-rebase.merge refs/heads/copy &&
691 test_config branch.to-rebase.rebase true &&
692 echo dirty >>file &&
693 git add file &&
694 test_must_fail git pull &&
695 test_cmp_rev "$COPY" me/copy &&
696 git checkout HEAD -- file &&
697 git pull &&
698 test_cmp_rev ! "$COPY" me/copy
701 test_expect_success 'pull --rebase works on branch yet to be born' '
702 git rev-parse master >expect &&
703 mkdir empty_repo &&
705 cd empty_repo &&
706 git init &&
707 git pull --rebase .. master &&
708 git rev-parse HEAD >../actual
709 ) &&
710 test_cmp expect actual
713 test_expect_success 'pull --rebase fails on unborn branch with staged changes' '
714 test_when_finished "rm -rf empty_repo2" &&
715 git init empty_repo2 &&
717 cd empty_repo2 &&
718 echo staged-file >staged-file &&
719 git add staged-file &&
720 echo staged-file >expect &&
721 git ls-files >actual &&
722 test_cmp expect actual &&
723 test_must_fail git pull --rebase .. master 2>err &&
724 git ls-files >actual &&
725 test_cmp expect actual &&
726 git show :staged-file >actual &&
727 test_cmp expect actual &&
728 test_i18ngrep "unborn branch with changes added to the index" err
732 test_expect_success 'pull --rebase fails on corrupt HEAD' '
733 test_when_finished "rm -rf corrupt" &&
734 git init corrupt &&
736 cd corrupt &&
737 test_commit one &&
738 git rev-parse --verify HEAD >head &&
739 obj=$(sed "s#^..#&/#" head) &&
740 rm -f .git/objects/$obj &&
741 test_must_fail git pull --rebase
745 test_expect_success 'setup for detecting upstreamed changes' '
746 mkdir src &&
748 cd src &&
749 git init &&
750 printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff &&
751 git add stuff &&
752 git commit -m "Initial revision"
753 ) &&
754 git clone src dst &&
756 cd src &&
757 modify s/5/43/ stuff &&
758 git commit -a -m "5->43" &&
759 modify s/6/42/ stuff &&
760 git commit -a -m "Make it bigger"
761 ) &&
763 cd dst &&
764 modify s/5/43/ stuff &&
765 git commit -a -m "Independent discovery of 5->43"
769 test_expect_success 'git pull --rebase detects upstreamed changes' '
771 cd dst &&
772 git pull --rebase &&
773 git ls-files -u >untracked &&
774 test_must_be_empty untracked
778 test_expect_success 'setup for avoiding reapplying old patches' '
780 cd dst &&
781 test_might_fail git rebase --abort &&
782 git reset --hard origin/master
783 ) &&
784 git clone --bare src src-replace.git &&
785 rm -rf src &&
786 mv src-replace.git src &&
788 cd dst &&
789 modify s/2/22/ stuff &&
790 git commit -a -m "Change 2" &&
791 modify s/3/33/ stuff &&
792 git commit -a -m "Change 3" &&
793 modify s/4/44/ stuff &&
794 git commit -a -m "Change 4" &&
795 git push &&
797 modify s/44/55/ stuff &&
798 git commit --amend -a -m "Modified Change 4"
802 test_expect_success 'git pull --rebase does not reapply old patches' '
804 cd dst &&
805 test_must_fail git pull --rebase &&
806 cat .git/rebase-merge/done .git/rebase-merge/git-rebase-todo >work &&
807 grep -v -e \# -e ^$ work >patches &&
808 test_line_count = 1 patches &&
809 rm -f work
813 test_expect_success 'git pull --rebase against local branch' '
814 git checkout -b copy2 to-rebase-orig &&
815 git pull --rebase . to-rebase &&
816 echo "conflicting modification" >expect &&
817 test_cmp expect file &&
818 echo file >expect &&
819 test_cmp expect file2
822 test_done