git-remote-mediawiki: update tests to run with the new bin-wrapper
[git.git] / t / t5520-pull.sh
blob6af6c63350383e049082e61d3c8133af79d5a749
1 #!/bin/sh
3 test_description='pulling into void'
5 . ./test-lib.sh
7 modify () {
8 sed -e "$1" <"$2" >"$2.x" &&
9 mv "$2.x" "$2"
12 D=`pwd`
14 test_expect_success setup '
16 echo file >file &&
17 git add file &&
18 git commit -a -m original
22 test_expect_success 'pulling into void' '
23 mkdir cloned &&
24 cd cloned &&
25 git init &&
26 git pull ..
29 cd "$D"
31 test_expect_success 'checking the results' '
32 test -f file &&
33 test -f cloned/file &&
34 test_cmp file cloned/file
37 test_expect_success 'pulling into void using master:master' '
38 mkdir cloned-uho &&
40 cd cloned-uho &&
41 git init &&
42 git pull .. master:master
43 ) &&
44 test -f file &&
45 test -f cloned-uho/file &&
46 test_cmp file cloned-uho/file
49 test_expect_success 'pulling into void does not overwrite untracked files' '
50 git init cloned-untracked &&
52 cd cloned-untracked &&
53 echo untracked >file &&
54 test_must_fail git pull .. master &&
55 echo untracked >expect &&
56 test_cmp expect file
60 test_expect_success 'test . as a remote' '
62 git branch copy master &&
63 git config branch.copy.remote . &&
64 git config branch.copy.merge refs/heads/master &&
65 echo updated >file &&
66 git commit -a -m updated &&
67 git checkout copy &&
68 test `cat file` = file &&
69 git pull &&
70 test `cat file` = updated
73 test_expect_success 'the default remote . should not break explicit pull' '
74 git checkout -b second master^ &&
75 echo modified >file &&
76 git commit -a -m modified &&
77 git checkout copy &&
78 git reset --hard HEAD^ &&
79 test `cat file` = file &&
80 git pull . second &&
81 test `cat file` = modified
84 test_expect_success '--rebase' '
85 git branch to-rebase &&
86 echo modified again > file &&
87 git commit -m file file &&
88 git checkout to-rebase &&
89 echo new > file2 &&
90 git add file2 &&
91 git commit -m "new file" &&
92 git tag before-rebase &&
93 git pull --rebase . copy &&
94 test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
95 test new = $(git show HEAD:file2)
97 test_expect_success 'pull.rebase' '
98 git reset --hard before-rebase &&
99 test_config pull.rebase true &&
100 git pull . copy &&
101 test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
102 test new = $(git show HEAD:file2)
105 test_expect_success 'branch.to-rebase.rebase' '
106 git reset --hard before-rebase &&
107 test_config branch.to-rebase.rebase true &&
108 git pull . copy &&
109 test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
110 test new = $(git show HEAD:file2)
113 test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
114 git reset --hard before-rebase &&
115 test_config pull.rebase true &&
116 test_config branch.to-rebase.rebase false &&
117 git pull . copy &&
118 test $(git rev-parse HEAD^) != $(git rev-parse copy) &&
119 test new = $(git show HEAD:file2)
122 test_expect_success '--rebase with rebased upstream' '
124 git remote add -f me . &&
125 git checkout copy &&
126 git tag copy-orig &&
127 git reset --hard HEAD^ &&
128 echo conflicting modification > file &&
129 git commit -m conflict file &&
130 git checkout to-rebase &&
131 echo file > file2 &&
132 git commit -m to-rebase file2 &&
133 git tag to-rebase-orig &&
134 git pull --rebase me copy &&
135 test "conflicting modification" = "$(cat file)" &&
136 test file = $(cat file2)
140 test_expect_success '--rebase with rebased default upstream' '
142 git update-ref refs/remotes/me/copy copy-orig &&
143 git checkout --track -b to-rebase2 me/copy &&
144 git reset --hard to-rebase-orig &&
145 git pull --rebase &&
146 test "conflicting modification" = "$(cat file)" &&
147 test file = $(cat file2)
151 test_expect_success 'rebased upstream + fetch + pull --rebase' '
153 git update-ref refs/remotes/me/copy copy-orig &&
154 git reset --hard to-rebase-orig &&
155 git checkout --track -b to-rebase3 me/copy &&
156 git reset --hard to-rebase-orig &&
157 git fetch &&
158 git pull --rebase &&
159 test "conflicting modification" = "$(cat file)" &&
160 test file = "$(cat file2)"
164 test_expect_success 'pull --rebase dies early with dirty working directory' '
166 git checkout to-rebase &&
167 git update-ref refs/remotes/me/copy copy^ &&
168 COPY=$(git rev-parse --verify me/copy) &&
169 git rebase --onto $COPY copy &&
170 test_config branch.to-rebase.remote me &&
171 test_config branch.to-rebase.merge refs/heads/copy &&
172 test_config branch.to-rebase.rebase true &&
173 echo dirty >> file &&
174 git add file &&
175 test_must_fail git pull &&
176 test $COPY = $(git rev-parse --verify me/copy) &&
177 git checkout HEAD -- file &&
178 git pull &&
179 test $COPY != $(git rev-parse --verify me/copy)
183 test_expect_success 'pull --rebase works on branch yet to be born' '
184 git rev-parse master >expect &&
185 mkdir empty_repo &&
186 (cd empty_repo &&
187 git init &&
188 git pull --rebase .. master &&
189 git rev-parse HEAD >../actual
190 ) &&
191 test_cmp expect actual
194 test_expect_success 'setup for detecting upstreamed changes' '
195 mkdir src &&
196 (cd src &&
197 git init &&
198 printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff &&
199 git add stuff &&
200 git commit -m "Initial revision"
201 ) &&
202 git clone src dst &&
203 (cd src &&
204 modify s/5/43/ stuff &&
205 git commit -a -m "5->43" &&
206 modify s/6/42/ stuff &&
207 git commit -a -m "Make it bigger"
208 ) &&
209 (cd dst &&
210 modify s/5/43/ stuff &&
211 git commit -a -m "Independent discovery of 5->43"
215 test_expect_success 'git pull --rebase detects upstreamed changes' '
216 (cd dst &&
217 git pull --rebase &&
218 test -z "$(git ls-files -u)"
222 test_expect_success 'setup for avoiding reapplying old patches' '
223 (cd dst &&
224 test_might_fail git rebase --abort &&
225 git reset --hard origin/master
226 ) &&
227 git clone --bare src src-replace.git &&
228 rm -rf src &&
229 mv src-replace.git src &&
230 (cd dst &&
231 modify s/2/22/ stuff &&
232 git commit -a -m "Change 2" &&
233 modify s/3/33/ stuff &&
234 git commit -a -m "Change 3" &&
235 modify s/4/44/ stuff &&
236 git commit -a -m "Change 4" &&
237 git push &&
239 modify s/44/55/ stuff &&
240 git commit --amend -a -m "Modified Change 4"
244 test_expect_success 'git pull --rebase does not reapply old patches' '
245 (cd dst &&
246 test_must_fail git pull --rebase &&
247 test 1 = $(find .git/rebase-apply -name "000*" | wc -l)
251 test_expect_success 'git pull --rebase against local branch' '
252 git checkout -b copy2 to-rebase-orig &&
253 git pull --rebase . to-rebase &&
254 test "conflicting modification" = "$(cat file)" &&
255 test file = "$(cat file2)"
258 test_done