3 test_description
='pull options'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 test_expect_success
'setup' '
12 (cd parent && git init &&
13 echo one >file && git add file &&
17 test_expect_success
'git pull -q --no-rebase' '
19 (cd clonedq && git init &&
20 git pull -q --no-rebase "../parent" >out 2>err &&
21 test_must_be_empty err &&
22 test_must_be_empty out)
25 test_expect_success
'git pull -q --rebase' '
27 (cd clonedqrb && git init &&
28 git pull -q --rebase "../parent" >out 2>err &&
29 test_must_be_empty err &&
30 test_must_be_empty out &&
31 git pull -q --rebase "../parent" >out 2>err &&
32 test_must_be_empty err &&
33 test_must_be_empty out)
36 test_expect_success
'git pull --no-rebase' '
38 (cd cloned && git init &&
39 git pull --no-rebase "../parent" >out 2>err &&
41 test_must_be_empty out)
44 test_expect_success
'git pull --rebase' '
46 (cd clonedrb && git init &&
47 git pull --rebase "../parent" >out 2>err &&
49 test_must_be_empty out)
52 test_expect_success
'git pull -v --no-rebase' '
54 (cd clonedv && git init &&
55 git pull -v --no-rebase "../parent" >out 2>err &&
57 test_must_be_empty out)
60 test_expect_success
'git pull -v --rebase' '
62 (cd clonedvrb && git init &&
63 git pull -v --rebase "../parent" >out 2>err &&
65 test_must_be_empty out)
68 test_expect_success
'git pull -v -q --no-rebase' '
70 (cd clonedvq && git init &&
71 git pull -v -q --no-rebase "../parent" >out 2>err &&
72 test_must_be_empty out &&
73 test_must_be_empty err)
76 test_expect_success
'git pull -q -v --no-rebase' '
78 (cd clonedqv && git init &&
79 git pull -q -v --no-rebase "../parent" >out 2>err &&
80 test_must_be_empty out &&
83 test_expect_success
'git pull --cleanup errors early on invalid argument' '
84 mkdir clonedcleanup &&
85 (cd clonedcleanup && git init &&
86 test_must_fail git pull --no-rebase --cleanup invalid "../parent" >out 2>err &&
87 test_must_be_empty out &&
91 test_expect_success
'git pull --no-write-fetch-head fails' '
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)
99 test_expect_success
'git pull --force' '
100 mkdir clonedoldstyle &&
101 (cd clonedoldstyle && git init &&
102 cat >>.git/config <<-\EOF &&
105 fetch = refs/heads/main:refs/heads/mirror
108 fetch = refs/heads/main:refs/heads/origin
111 merge = refs/heads/main
115 git branch -f origin &&
116 git pull --all --force
120 test_expect_success
'git pull --all' '
122 (cd clonedmulti && git init &&
123 cat >>.git/config <<-\EOF &&
126 fetch = refs/heads/*:refs/remotes/one/*
129 fetch = refs/heads/*:refs/remotes/two/*
132 merge = refs/heads/main
138 test_expect_success
'git pull --dry-run' '
139 test_when_finished "rm -rf clonedry" &&
143 git pull --dry-run ../parent &&
144 test_path_is_missing .git/FETCH_HEAD &&
145 test_path_is_missing .git/refs/heads/main &&
146 test_path_is_missing .git/index &&
147 test_path_is_missing file
151 test_expect_success
'git pull --all --dry-run' '
152 test_when_finished "rm -rf cloneddry" &&
156 git remote add origin ../parent &&
157 git pull --all --dry-run &&
158 test_path_is_missing .git/FETCH_HEAD &&
159 test_path_is_missing .git/refs/remotes/origin/main &&
160 test_path_is_missing .git/index &&
161 test_path_is_missing file
165 test_expect_success
'git pull --allow-unrelated-histories' '
166 test_when_finished "rm -fr src dst" &&
176 git checkout --orphan side HEAD^ &&
181 test_must_fail git pull ../src side &&
182 git pull --allow-unrelated-histories ../src side
186 test_expect_success
'git pull does not add a sign-off line' '
187 test_when_finished "rm -fr src dst actual" &&
189 test_commit -C src one &&
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
197 test_expect_success
'git pull --no-signoff does not add sign-off line' '
198 test_when_finished "rm -fr src dst actual" &&
200 test_commit -C src one &&
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
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 &&
212 test_commit -C src one &&
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
220 test_expect_success
'git pull --no-signoff flag cancels --signoff flag' '
221 test_when_finished "rm -fr src dst actual" &&
223 test_commit -C src one &&
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