David D. Kilzer | 25e9325 | 2010-07-28 01:20:16 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git rebase --continue tests' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | . "$TEST_DIRECTORY"/lib-rebase.sh |
| 8 | |
| 9 | set_fake_editor |
| 10 | |
| 11 | test_expect_success 'setup' ' |
| 12 | test_commit "commit-new-file-F1" F1 1 && |
| 13 | test_commit "commit-new-file-F2" F2 2 && |
| 14 | |
| 15 | git checkout -b topic HEAD^ && |
| 16 | test_commit "commit-new-file-F2-on-topic-branch" F2 22 && |
| 17 | |
| 18 | git checkout master |
| 19 | ' |
| 20 | |
| 21 | test_expect_success 'interactive rebase --continue works with touched file' ' |
| 22 | rm -fr .git/rebase-* && |
| 23 | git reset --hard && |
| 24 | git checkout master && |
| 25 | |
| 26 | FAKE_LINES="edit 1" git rebase -i HEAD^ && |
| 27 | test-chmtime =-60 F1 && |
| 28 | git rebase --continue |
| 29 | ' |
| 30 | |
| 31 | test_expect_success 'non-interactive rebase --continue works with touched file' ' |
| 32 | rm -fr .git/rebase-* && |
| 33 | git reset --hard && |
| 34 | git checkout master && |
| 35 | |
| 36 | test_must_fail git rebase --onto master master topic && |
| 37 | echo "Resolved" >F2 && |
| 38 | git add F2 && |
| 39 | test-chmtime =-60 F1 && |
| 40 | git rebase --continue |
| 41 | ' |
| 42 | |
Martin von Zweigbergk | 95135b0 | 2011-02-06 13:43:36 -0500 | [diff] [blame] | 43 | test_expect_success 'rebase --continue can not be used with other options' ' |
| 44 | test_must_fail git rebase -v --continue && |
| 45 | test_must_fail git rebase --continue -v |
| 46 | ' |
| 47 | |
Martin von Zweigbergk | 80ff479 | 2011-02-06 13:43:55 -0500 | [diff] [blame] | 48 | test_expect_success 'rebase --continue remembers merge strategy and options' ' |
| 49 | rm -fr .git/rebase-* && |
| 50 | git reset --hard commit-new-file-F2-on-topic-branch && |
| 51 | test_commit "commit-new-file-F3-on-topic-branch" F3 32 && |
| 52 | test_when_finished "rm -fr test-bin funny.was.run" && |
| 53 | mkdir test-bin && |
Ramkumar Ramachandra | 0238038 | 2011-12-08 18:40:17 +0530 | [diff] [blame] | 54 | cat >test-bin/git-merge-funny <<-EOF && |
Martin von Zweigbergk | 80ff479 | 2011-02-06 13:43:55 -0500 | [diff] [blame] | 55 | #!$SHELL_PATH |
| 56 | case "\$1" in --opt) ;; *) exit 2 ;; esac |
| 57 | shift && |
| 58 | >funny.was.run && |
| 59 | exec git merge-recursive "\$@" |
| 60 | EOF |
| 61 | chmod +x test-bin/git-merge-funny && |
| 62 | ( |
| 63 | PATH=./test-bin:$PATH |
| 64 | test_must_fail git rebase -s funny -Xopt master topic |
| 65 | ) && |
| 66 | test -f funny.was.run && |
| 67 | rm funny.was.run && |
| 68 | echo "Resolved" >F2 && |
| 69 | git add F2 && |
| 70 | ( |
| 71 | PATH=./test-bin:$PATH |
| 72 | git rebase --continue |
| 73 | ) && |
| 74 | test -f funny.was.run |
| 75 | ' |
| 76 | |
Phillip Wood | 5fb415b | 2017-08-02 11:44:16 +0100 | [diff] [blame] | 77 | test_expect_success 'setup rerere database' ' |
Martin von Zweigbergk | b3e4847 | 2011-02-06 13:43:56 -0500 | [diff] [blame] | 78 | rm -fr .git/rebase-* && |
| 79 | git reset --hard commit-new-file-F3-on-topic-branch && |
Ramkumar Ramachandra | 0238038 | 2011-12-08 18:40:17 +0530 | [diff] [blame] | 80 | git checkout master && |
Martin von Zweigbergk | b3e4847 | 2011-02-06 13:43:56 -0500 | [diff] [blame] | 81 | test_commit "commit-new-file-F3" F3 3 && |
Phillip Wood | 5fb415b | 2017-08-02 11:44:16 +0100 | [diff] [blame] | 82 | test_config rerere.enabled true && |
Martin von Zweigbergk | b3e4847 | 2011-02-06 13:43:56 -0500 | [diff] [blame] | 83 | test_must_fail git rebase -m master topic && |
| 84 | echo "Resolved" >F2 && |
Phillip Wood | 5fb415b | 2017-08-02 11:44:16 +0100 | [diff] [blame] | 85 | cp F2 expected-F2 && |
Martin von Zweigbergk | b3e4847 | 2011-02-06 13:43:56 -0500 | [diff] [blame] | 86 | git add F2 && |
| 87 | test_must_fail git rebase --continue && |
| 88 | echo "Resolved" >F3 && |
Phillip Wood | 5fb415b | 2017-08-02 11:44:16 +0100 | [diff] [blame] | 89 | cp F3 expected-F3 && |
Martin von Zweigbergk | b3e4847 | 2011-02-06 13:43:56 -0500 | [diff] [blame] | 90 | git add F3 && |
| 91 | git rebase --continue && |
Phillip Wood | 5fb415b | 2017-08-02 11:44:16 +0100 | [diff] [blame] | 92 | git reset --hard topic@{1} |
Martin von Zweigbergk | b3e4847 | 2011-02-06 13:43:56 -0500 | [diff] [blame] | 93 | ' |
| 94 | |
Phillip Wood | 5fb415b | 2017-08-02 11:44:16 +0100 | [diff] [blame] | 95 | prepare () { |
| 96 | rm -fr .git/rebase-* && |
| 97 | git reset --hard commit-new-file-F3-on-topic-branch && |
| 98 | git checkout master && |
| 99 | test_config rerere.enabled true |
| 100 | } |
| 101 | |
| 102 | test_rerere_autoupdate () { |
| 103 | action=$1 && |
| 104 | test_expect_success "rebase $action --continue remembers --rerere-autoupdate" ' |
| 105 | prepare && |
| 106 | test_must_fail git rebase $action --rerere-autoupdate master topic && |
| 107 | test_cmp expected-F2 F2 && |
| 108 | git diff-files --quiet && |
| 109 | test_must_fail git rebase --continue && |
| 110 | test_cmp expected-F3 F3 && |
| 111 | git diff-files --quiet && |
| 112 | git rebase --continue |
| 113 | ' |
| 114 | |
| 115 | test_expect_success "rebase $action --continue honors rerere.autoUpdate" ' |
| 116 | prepare && |
| 117 | test_config rerere.autoupdate true && |
| 118 | test_must_fail git rebase $action master topic && |
| 119 | test_cmp expected-F2 F2 && |
| 120 | git diff-files --quiet && |
| 121 | test_must_fail git rebase --continue && |
| 122 | test_cmp expected-F3 F3 && |
| 123 | git diff-files --quiet && |
| 124 | git rebase --continue |
| 125 | ' |
| 126 | |
| 127 | test_expect_success "rebase $action --continue remembers --no-rerere-autoupdate" ' |
| 128 | prepare && |
| 129 | test_config rerere.autoupdate true && |
| 130 | test_must_fail git rebase $action --no-rerere-autoupdate master topic && |
| 131 | test_cmp expected-F2 F2 && |
| 132 | test_must_fail git diff-files --quiet && |
| 133 | git add F2 && |
| 134 | test_must_fail git rebase --continue && |
| 135 | test_cmp expected-F3 F3 && |
| 136 | test_must_fail git diff-files --quiet && |
| 137 | git add F3 && |
| 138 | git rebase --continue |
| 139 | ' |
| 140 | } |
| 141 | |
| 142 | test_rerere_autoupdate |
| 143 | test_rerere_autoupdate -m |
Phillip Wood | 9b6d7a6 | 2017-08-02 11:44:17 +0100 | [diff] [blame] | 144 | GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR |
| 145 | test_rerere_autoupdate -i |
| 146 | test_rerere_autoupdate --preserve-merges |
Phillip Wood | 5fb415b | 2017-08-02 11:44:16 +0100 | [diff] [blame] | 147 | |
David D. Kilzer | 25e9325 | 2010-07-28 01:20:16 -0700 | [diff] [blame] | 148 | test_done |