ci: fix setup of custom path for GitLab CI
[alt-git.git] / t / t5521-pull-options.sh
blobdb00c4336b1671158f69b9711e247d9300b5cac8
1 #!/bin/sh
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
9 . ./test-lib.sh
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)
18 test_expect_success 'git pull -q --no-rebase' '
19 mkdir clonedq &&
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' '
27 mkdir clonedqrb &&
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' '
38 mkdir cloned &&
39 (cd cloned && git init &&
40 git pull --no-rebase "../parent" >out 2>err &&
41 test -s err &&
42 test_must_be_empty out)
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 &&
50 test_must_be_empty out)
53 test_expect_success 'git pull -v --no-rebase' '
54 mkdir clonedv &&
55 (cd clonedv && git init &&
56 git pull -v --no-rebase "../parent" >out 2>err &&
57 test -s err &&
58 test_must_be_empty out)
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 &&
66 test_must_be_empty out)
69 test_expect_success 'git pull -v -q --no-rebase' '
70 mkdir clonedvq &&
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' '
78 mkdir clonedqv &&
79 (cd clonedqv && git init &&
80 git pull -q -v --no-rebase "../parent" >out 2>err &&
81 test_must_be_empty out &&
82 test -s err)
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 &&
89 test -s err)
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 &&
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 &&
104 [remote "one"]
105 url = ../parent
106 fetch = refs/heads/main:refs/heads/mirror
107 [remote "two"]
108 url = ../parent
109 fetch = refs/heads/main:refs/heads/origin
110 [branch "main"]
111 remote = two
112 merge = refs/heads/main
114 git pull two &&
115 test_commit A &&
116 git branch -f origin &&
117 git pull --no-rebase --all --force
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/*
131 [branch "main"]
132 remote = one
133 merge = refs/heads/main
135 git pull --all
139 test_expect_success 'git pull --dry-run' '
140 test_when_finished "rm -rf clonedry" &&
141 git init clonedry &&
143 cd 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" &&
154 git init clonedry &&
156 cd clonedry &&
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" &&
168 git init src &&
170 cd src &&
171 test_commit one &&
172 test_commit two
173 ) &&
174 git clone src dst &&
176 cd src &&
177 git checkout --orphan side HEAD^ &&
178 test_commit three
179 ) &&
181 cd dst &&
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" &&
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
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
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
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
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 &&
237 test_hook -C dst commit-msg <<-\EOF &&
238 false
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" &&
246 git init src &&
247 test_commit -C src one &&
248 git clone src dst &&
249 test_hook -C dst commit-msg <<-\EOF &&
250 false
252 test_commit -C src two &&
253 test_must_fail git -C dst pull --no-ff --no-verify --verify
256 test_done