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