]>
Commit | Line | Data |
---|---|---|
25e93250 DK |
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 | ||
95135b06 MZ |
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 | ||
80ff4795 MZ |
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 && | |
02380389 | 54 | cat >test-bin/git-merge-funny <<-EOF && |
80ff4795 MZ |
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 | ' | |
dd6fb005 JS |
76 | |
77 | test_expect_success 'rebase passes merge strategy options correctly' ' | |
78 | rm -fr .git/rebase-* && | |
79 | git reset --hard commit-new-file-F3-on-topic-branch && | |
80 | test_commit theirs-to-merge && | |
81 | git reset --hard HEAD^ && | |
82 | test_commit some-commit && | |
83 | test_tick && | |
84 | git merge --no-ff theirs-to-merge && | |
85 | FAKE_LINES="1 edit 2 3" git rebase -i -f -p -m \ | |
86 | -s recursive --strategy-option=theirs HEAD~2 && | |
87 | test_commit force-change && | |
88 | git rebase --continue | |
89 | ' | |
80ff4795 | 90 | |
5fb415b5 | 91 | test_expect_success 'setup rerere database' ' |
b3e4847e MZ |
92 | rm -fr .git/rebase-* && |
93 | git reset --hard commit-new-file-F3-on-topic-branch && | |
02380389 | 94 | git checkout master && |
b3e4847e | 95 | test_commit "commit-new-file-F3" F3 3 && |
5fb415b5 | 96 | test_config rerere.enabled true && |
b3e4847e MZ |
97 | test_must_fail git rebase -m master topic && |
98 | echo "Resolved" >F2 && | |
5fb415b5 | 99 | cp F2 expected-F2 && |
b3e4847e MZ |
100 | git add F2 && |
101 | test_must_fail git rebase --continue && | |
102 | echo "Resolved" >F3 && | |
5fb415b5 | 103 | cp F3 expected-F3 && |
b3e4847e MZ |
104 | git add F3 && |
105 | git rebase --continue && | |
5fb415b5 | 106 | git reset --hard topic@{1} |
b3e4847e MZ |
107 | ' |
108 | ||
5fb415b5 PW |
109 | prepare () { |
110 | rm -fr .git/rebase-* && | |
111 | git reset --hard commit-new-file-F3-on-topic-branch && | |
112 | git checkout master && | |
113 | test_config rerere.enabled true | |
114 | } | |
115 | ||
116 | test_rerere_autoupdate () { | |
117 | action=$1 && | |
118 | test_expect_success "rebase $action --continue remembers --rerere-autoupdate" ' | |
119 | prepare && | |
120 | test_must_fail git rebase $action --rerere-autoupdate master topic && | |
121 | test_cmp expected-F2 F2 && | |
122 | git diff-files --quiet && | |
123 | test_must_fail git rebase --continue && | |
124 | test_cmp expected-F3 F3 && | |
125 | git diff-files --quiet && | |
126 | git rebase --continue | |
127 | ' | |
128 | ||
129 | test_expect_success "rebase $action --continue honors rerere.autoUpdate" ' | |
130 | prepare && | |
131 | test_config rerere.autoupdate true && | |
132 | test_must_fail git rebase $action master topic && | |
133 | test_cmp expected-F2 F2 && | |
134 | git diff-files --quiet && | |
135 | test_must_fail git rebase --continue && | |
136 | test_cmp expected-F3 F3 && | |
137 | git diff-files --quiet && | |
138 | git rebase --continue | |
139 | ' | |
140 | ||
141 | test_expect_success "rebase $action --continue remembers --no-rerere-autoupdate" ' | |
142 | prepare && | |
143 | test_config rerere.autoupdate true && | |
144 | test_must_fail git rebase $action --no-rerere-autoupdate master topic && | |
145 | test_cmp expected-F2 F2 && | |
146 | test_must_fail git diff-files --quiet && | |
147 | git add F2 && | |
148 | test_must_fail git rebase --continue && | |
149 | test_cmp expected-F3 F3 && | |
150 | test_must_fail git diff-files --quiet && | |
151 | git add F3 && | |
152 | git rebase --continue | |
153 | ' | |
154 | } | |
155 | ||
156 | test_rerere_autoupdate | |
157 | test_rerere_autoupdate -m | |
9b6d7a62 PW |
158 | GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR |
159 | test_rerere_autoupdate -i | |
160 | test_rerere_autoupdate --preserve-merges | |
5fb415b5 | 161 | |
25e93250 | 162 | test_done |