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