3 test_description
='pull options'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
11 test_expect_success
'setup' '
13 (cd parent && git init &&
14 echo one >file && git add file &&
18 test_expect_success
'git pull -q --no-rebase' '
20 (cd clonedq && git init &&
21 git pull -q --no-rebase "../parent" >out 2>err &&
22 test_must_be_empty err &&
23 test_must_be_empty out)
26 test_expect_success
'git pull -q --rebase' '
28 (cd clonedqrb && git init &&
29 git pull -q --rebase "../parent" >out 2>err &&
30 test_must_be_empty err &&
31 test_must_be_empty out &&
32 git pull -q --rebase "../parent" >out 2>err &&
33 test_must_be_empty err &&
34 test_must_be_empty out)
37 test_expect_success
'git pull --no-rebase' '
39 (cd cloned && git init &&
40 git pull --no-rebase "../parent" >out 2>err &&
42 test_must_be_empty out)
45 test_expect_success
'git pull --rebase' '
47 (cd clonedrb && git init &&
48 git pull --rebase "../parent" >out 2>err &&
50 test_must_be_empty out)
53 test_expect_success
'git pull -v --no-rebase' '
55 (cd clonedv && git init &&
56 git pull -v --no-rebase "../parent" >out 2>err &&
58 test_must_be_empty out)
61 test_expect_success
'git pull -v --rebase' '
63 (cd clonedvrb && git init &&
64 git pull -v --rebase "../parent" >out 2>err &&
66 test_must_be_empty out)
69 test_expect_success
'git pull -v -q --no-rebase' '
71 (cd clonedvq && git init &&
72 git pull -v -q --no-rebase "../parent" >out 2>err &&
73 test_must_be_empty out &&
74 test_must_be_empty err)
77 test_expect_success
'git pull -q -v --no-rebase' '
79 (cd clonedqv && git init &&
80 git pull -q -v --no-rebase "../parent" >out 2>err &&
81 test_must_be_empty out &&
84 test_expect_success
'git pull --cleanup errors early on invalid argument' '
85 mkdir clonedcleanup &&
86 (cd clonedcleanup && git init &&
87 test_must_fail git pull --no-rebase --cleanup invalid "../parent" >out 2>err &&
88 test_must_be_empty out &&
92 test_expect_success
'git pull --no-write-fetch-head fails' '
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 &&
97 test_grep "no-write-fetch-head" err)
100 test_expect_success
'git pull --force' '
101 mkdir clonedoldstyle &&
102 (cd clonedoldstyle && git init &&
103 cat >>.git/config <<-\EOF &&
106 fetch = refs/heads/main:refs/heads/mirror
109 fetch = refs/heads/main:refs/heads/origin
112 merge = refs/heads/main
116 git branch -f origin &&
117 git pull --no-rebase --all --force
121 test_expect_success
'git pull --all' '
123 (cd clonedmulti && git init &&
124 cat >>.git/config <<-\EOF &&
127 fetch = refs/heads/*:refs/remotes/one/*
130 fetch = refs/heads/*:refs/remotes/two/*
133 merge = refs/heads/main
139 test_expect_success
'git pull --dry-run' '
140 test_when_finished "rm -rf clonedry" &&
144 git pull --dry-run ../parent &&
145 test_path_is_missing .git/FETCH_HEAD &&
146 test_ref_missing refs/heads/main &&
147 test_path_is_missing .git/index &&
148 test_path_is_missing file
152 test_expect_success
'git pull --all --dry-run' '
153 test_when_finished "rm -rf cloneddry" &&
157 git remote add origin ../parent &&
158 git pull --all --dry-run &&
159 test_path_is_missing .git/FETCH_HEAD &&
160 test_ref_missing refs/remotes/origin/main &&
161 test_path_is_missing .git/index &&
162 test_path_is_missing file
166 test_expect_success
'git pull --allow-unrelated-histories' '
167 test_when_finished "rm -fr src dst" &&
177 git checkout --orphan side HEAD^ &&
182 test_must_fail git pull ../src side &&
183 git pull --no-rebase --allow-unrelated-histories ../src side
187 test_expect_success
'git pull does not add a sign-off line' '
188 test_when_finished "rm -fr src dst actual" &&
190 test_commit -C src one &&
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
198 test_expect_success
'git pull --no-signoff does not add sign-off line' '
199 test_when_finished "rm -fr src dst actual" &&
201 test_commit -C src one &&
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
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 &&
213 test_commit -C src one &&
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
221 test_expect_success
'git pull --no-signoff flag cancels --signoff flag' '
222 test_when_finished "rm -fr src dst actual" &&
224 test_commit -C src one &&
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
232 test_expect_success
'git pull --no-verify flag passed to merge' '
233 test_when_finished "rm -fr src dst actual" &&
235 test_commit -C src one &&
237 test_hook -C dst commit-msg <<-\EOF &&
240 test_commit -C src two &&
241 git -C dst pull --no-ff --no-verify
244 test_expect_success
'git pull --no-verify --verify passed to merge' '
245 test_when_finished "rm -fr src dst actual" &&
247 test_commit -C src one &&
249 test_hook -C dst commit-msg <<-\EOF &&
252 test_commit -C src two &&
253 test_must_fail git -C dst pull --no-ff --no-verify --verify