]>
Commit | Line | Data |
---|---|---|
7f87aff2 TA |
1 | #!/bin/sh |
2 | ||
3 | test_description='pull options' | |
4 | ||
3ac8f630 | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
7 | ||
ec97ad12 | 8 | TEST_PASSES_SANITIZE_LEAK=true |
7f87aff2 TA |
9 | . ./test-lib.sh |
10 | ||
7f87aff2 TA |
11 | test_expect_success 'setup' ' |
12 | mkdir parent && | |
13 | (cd parent && git init && | |
14 | echo one >file && git add file && | |
15 | git commit -m one) | |
16 | ' | |
17 | ||
d18c950a | 18 | test_expect_success 'git pull -q --no-rebase' ' |
7f87aff2 | 19 | mkdir clonedq && |
13e65fe6 | 20 | (cd clonedq && git init && |
d18c950a | 21 | git pull -q --no-rebase "../parent" >out 2>err && |
ca8d148d JH |
22 | test_must_be_empty err && |
23 | test_must_be_empty out) | |
7f87aff2 TA |
24 | ' |
25 | ||
ce4c4d4e PE |
26 | test_expect_success 'git pull -q --rebase' ' |
27 | mkdir clonedqrb && | |
28 | (cd clonedqrb && git init && | |
29 | git pull -q --rebase "../parent" >out 2>err && | |
ca8d148d JH |
30 | test_must_be_empty err && |
31 | test_must_be_empty out && | |
ce4c4d4e | 32 | git pull -q --rebase "../parent" >out 2>err && |
ca8d148d JH |
33 | test_must_be_empty err && |
34 | test_must_be_empty out) | |
ce4c4d4e PE |
35 | ' |
36 | ||
d18c950a | 37 | test_expect_success 'git pull --no-rebase' ' |
7f87aff2 | 38 | mkdir cloned && |
13e65fe6 | 39 | (cd cloned && git init && |
d18c950a | 40 | git pull --no-rebase "../parent" >out 2>err && |
13e65fe6 | 41 | test -s err && |
ca8d148d | 42 | test_must_be_empty out) |
7f87aff2 | 43 | ' |
7f87aff2 | 44 | |
ce4c4d4e PE |
45 | test_expect_success 'git pull --rebase' ' |
46 | mkdir clonedrb && | |
47 | (cd clonedrb && git init && | |
48 | git pull --rebase "../parent" >out 2>err && | |
49 | test -s err && | |
ca8d148d | 50 | test_must_be_empty out) |
ce4c4d4e PE |
51 | ' |
52 | ||
d18c950a | 53 | test_expect_success 'git pull -v --no-rebase' ' |
7f87aff2 | 54 | mkdir clonedv && |
13e65fe6 | 55 | (cd clonedv && git init && |
d18c950a | 56 | git pull -v --no-rebase "../parent" >out 2>err && |
13e65fe6 | 57 | test -s err && |
ca8d148d | 58 | test_must_be_empty out) |
7f87aff2 TA |
59 | ' |
60 | ||
ce4c4d4e PE |
61 | test_expect_success 'git pull -v --rebase' ' |
62 | mkdir clonedvrb && | |
63 | (cd clonedvrb && git init && | |
64 | git pull -v --rebase "../parent" >out 2>err && | |
65 | test -s err && | |
ca8d148d | 66 | test_must_be_empty out) |
ce4c4d4e PE |
67 | ' |
68 | ||
d18c950a | 69 | test_expect_success 'git pull -v -q --no-rebase' ' |
7f87aff2 | 70 | mkdir clonedvq && |
13e65fe6 | 71 | (cd clonedvq && git init && |
d18c950a | 72 | git pull -v -q --no-rebase "../parent" >out 2>err && |
ca8d148d JH |
73 | test_must_be_empty out && |
74 | test_must_be_empty err) | |
7f87aff2 TA |
75 | ' |
76 | ||
d18c950a | 77 | test_expect_success 'git pull -q -v --no-rebase' ' |
7f87aff2 | 78 | mkdir clonedqv && |
13e65fe6 | 79 | (cd clonedqv && git init && |
d18c950a | 80 | git pull -q -v --no-rebase "../parent" >out 2>err && |
ca8d148d | 81 | test_must_be_empty out && |
13e65fe6 | 82 | test -s err) |
7f87aff2 | 83 | ' |
d540b70c DL |
84 | test_expect_success 'git pull --cleanup errors early on invalid argument' ' |
85 | mkdir clonedcleanup && | |
86 | (cd clonedcleanup && git init && | |
d18c950a | 87 | test_must_fail git pull --no-rebase --cleanup invalid "../parent" >out 2>err && |
d540b70c DL |
88 | test_must_be_empty out && |
89 | test -s err) | |
90 | ' | |
91 | ||
887952b8 JH |
92 | test_expect_success 'git pull --no-write-fetch-head fails' ' |
93 | mkdir clonedwfh && | |
94 | (cd clonedwfh && git init && | |
95 | test_expect_code 129 git pull --no-write-fetch-head "../parent" >out 2>err && | |
96 | test_must_be_empty out && | |
6789275d | 97 | test_grep "no-write-fetch-head" err) |
887952b8 | 98 | ' |
7f87aff2 | 99 | |
bba5322a JH |
100 | test_expect_success 'git pull --force' ' |
101 | mkdir clonedoldstyle && | |
102 | (cd clonedoldstyle && git init && | |
103 | cat >>.git/config <<-\EOF && | |
104 | [remote "one"] | |
105 | url = ../parent | |
3ac8f630 | 106 | fetch = refs/heads/main:refs/heads/mirror |
bba5322a JH |
107 | [remote "two"] |
108 | url = ../parent | |
3ac8f630 JS |
109 | fetch = refs/heads/main:refs/heads/origin |
110 | [branch "main"] | |
bba5322a | 111 | remote = two |
3ac8f630 | 112 | merge = refs/heads/main |
bba5322a JH |
113 | EOF |
114 | git pull two && | |
115 | test_commit A && | |
116 | git branch -f origin && | |
031e2f7a | 117 | git pull --no-rebase --all --force |
bba5322a JH |
118 | ) |
119 | ' | |
120 | ||
e6cc5104 JH |
121 | test_expect_success 'git pull --all' ' |
122 | mkdir clonedmulti && | |
123 | (cd clonedmulti && git init && | |
124 | cat >>.git/config <<-\EOF && | |
125 | [remote "one"] | |
126 | url = ../parent | |
127 | fetch = refs/heads/*:refs/remotes/one/* | |
128 | [remote "two"] | |
129 | url = ../parent | |
130 | fetch = refs/heads/*:refs/remotes/two/* | |
3ac8f630 | 131 | [branch "main"] |
e6cc5104 | 132 | remote = one |
3ac8f630 | 133 | merge = refs/heads/main |
e6cc5104 JH |
134 | EOF |
135 | git pull --all | |
136 | ) | |
137 | ' | |
138 | ||
5504f13a PT |
139 | test_expect_success 'git pull --dry-run' ' |
140 | test_when_finished "rm -rf clonedry" && | |
141 | git init clonedry && | |
142 | ( | |
143 | cd clonedry && | |
144 | git pull --dry-run ../parent && | |
145 | test_path_is_missing .git/FETCH_HEAD && | |
0497e6c6 | 146 | test_ref_missing refs/heads/main && |
5504f13a PT |
147 | test_path_is_missing .git/index && |
148 | test_path_is_missing file | |
149 | ) | |
150 | ' | |
151 | ||
eb2a8d9e PT |
152 | test_expect_success 'git pull --all --dry-run' ' |
153 | test_when_finished "rm -rf cloneddry" && | |
154 | git init clonedry && | |
155 | ( | |
156 | cd clonedry && | |
157 | git remote add origin ../parent && | |
158 | git pull --all --dry-run && | |
159 | test_path_is_missing .git/FETCH_HEAD && | |
0497e6c6 | 160 | test_ref_missing refs/remotes/origin/main && |
eb2a8d9e PT |
161 | test_path_is_missing .git/index && |
162 | test_path_is_missing file | |
163 | ) | |
164 | ' | |
165 | ||
09c2cb87 JH |
166 | test_expect_success 'git pull --allow-unrelated-histories' ' |
167 | test_when_finished "rm -fr src dst" && | |
168 | git init src && | |
169 | ( | |
170 | cd src && | |
171 | test_commit one && | |
172 | test_commit two | |
173 | ) && | |
174 | git clone src dst && | |
175 | ( | |
176 | cd src && | |
177 | git checkout --orphan side HEAD^ && | |
178 | test_commit three | |
179 | ) && | |
180 | ( | |
181 | cd dst && | |
182 | test_must_fail git pull ../src side && | |
031e2f7a | 183 | git pull --no-rebase --allow-unrelated-histories ../src side |
09c2cb87 JH |
184 | ) |
185 | ' | |
186 | ||
3a4d2c74 TK |
187 | test_expect_success 'git pull does not add a sign-off line' ' |
188 | test_when_finished "rm -fr src dst actual" && | |
189 | git init src && | |
190 | test_commit -C src one && | |
191 | git clone src dst && | |
192 | test_commit -C src two && | |
193 | git -C dst pull --no-ff && | |
194 | git -C dst show -s --pretty="format:%(trailers)" HEAD >actual && | |
195 | test_must_be_empty actual | |
196 | ' | |
197 | ||
198 | test_expect_success 'git pull --no-signoff does not add sign-off line' ' | |
199 | test_when_finished "rm -fr src dst actual" && | |
200 | git init src && | |
201 | test_commit -C src one && | |
202 | git clone src dst && | |
203 | test_commit -C src two && | |
204 | git -C dst pull --no-signoff --no-ff && | |
205 | git -C dst show -s --pretty="format:%(trailers)" HEAD >actual && | |
206 | test_must_be_empty actual | |
207 | ' | |
208 | ||
209 | test_expect_success 'git pull --signoff add a sign-off line' ' | |
210 | test_when_finished "rm -fr src dst expected actual" && | |
211 | echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected && | |
212 | git init src && | |
213 | test_commit -C src one && | |
214 | git clone src dst && | |
215 | test_commit -C src two && | |
216 | git -C dst pull --signoff --no-ff && | |
217 | git -C dst show -s --pretty="format:%(trailers)" HEAD >actual && | |
218 | test_cmp expected actual | |
219 | ' | |
220 | ||
221 | test_expect_success 'git pull --no-signoff flag cancels --signoff flag' ' | |
222 | test_when_finished "rm -fr src dst actual" && | |
223 | git init src && | |
224 | test_commit -C src one && | |
225 | git clone src dst && | |
226 | test_commit -C src two && | |
227 | git -C dst pull --signoff --no-signoff --no-ff && | |
228 | git -C dst show -s --pretty="format:%(trailers)" HEAD >actual && | |
229 | test_must_be_empty actual | |
230 | ' | |
231 | ||
47bfdfb3 AR |
232 | test_expect_success 'git pull --no-verify flag passed to merge' ' |
233 | test_when_finished "rm -fr src dst actual" && | |
234 | git init src && | |
235 | test_commit -C src one && | |
236 | git clone src dst && | |
7da7f63c | 237 | test_hook -C dst commit-msg <<-\EOF && |
47bfdfb3 AR |
238 | false |
239 | EOF | |
240 | test_commit -C src two && | |
241 | git -C dst pull --no-ff --no-verify | |
242 | ' | |
243 | ||
244 | test_expect_success 'git pull --no-verify --verify passed to merge' ' | |
245 | test_when_finished "rm -fr src dst actual" && | |
246 | git init src && | |
247 | test_commit -C src one && | |
248 | git clone src dst && | |
7da7f63c | 249 | test_hook -C dst commit-msg <<-\EOF && |
47bfdfb3 AR |
250 | false |
251 | EOF | |
252 | test_commit -C src two && | |
253 | test_must_fail git -C dst pull --no-ff --no-verify --verify | |
254 | ' | |
255 | ||
7f87aff2 | 256 | test_done |