3 test_description
='pulling into void'
8 sed -e "$1" <"$2" >"$2.x" &&
14 test_expect_success setup
'
18 git commit -a -m original
22 test_expect_success
'pulling into void' '
31 test_expect_success
'checking the results' '
33 test -f cloned/file &&
34 test_cmp file cloned/file
37 test_expect_success
'pulling into void using master:master' '
42 git pull .. master:master
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 &&
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 &&
66 git commit -a -m updated &&
68 test `cat file` = file &&
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 &&
78 git reset --hard HEAD^ &&
79 test `cat file` = file &&
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 &&
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 git config --bool pull.rebase true &&
100 test_when_finished "git config --unset pull.rebase" &&
102 test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
103 test new = $(git show HEAD:file2)
106 test_expect_success
'branch.to-rebase.rebase' '
107 git reset --hard before-rebase &&
108 git config --bool branch.to-rebase.rebase true &&
109 test_when_finished "git config --unset branch.to-rebase.rebase" &&
111 test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
112 test new = $(git show HEAD:file2)
115 test_expect_success
'branch.to-rebase.rebase should override pull.rebase' '
116 git reset --hard before-rebase &&
117 git config --bool pull.rebase true &&
118 test_when_finished "git config --unset pull.rebase" &&
119 git config --bool branch.to-rebase.rebase false &&
120 test_when_finished "git config --unset branch.to-rebase.rebase" &&
122 test $(git rev-parse HEAD^) != $(git rev-parse copy) &&
123 test new = $(git show HEAD:file2)
126 test_expect_success
'--rebase with rebased upstream' '
128 git remote add -f me . &&
131 git reset --hard HEAD^ &&
132 echo conflicting modification > file &&
133 git commit -m conflict file &&
134 git checkout to-rebase &&
136 git commit -m to-rebase file2 &&
137 git tag to-rebase-orig &&
138 git pull --rebase me copy &&
139 test "conflicting modification" = "$(cat file)" &&
140 test file = $(cat file2)
144 test_expect_success
'--rebase with rebased default upstream' '
146 git update-ref refs/remotes/me/copy copy-orig &&
147 git checkout --track -b to-rebase2 me/copy &&
148 git reset --hard to-rebase-orig &&
150 test "conflicting modification" = "$(cat file)" &&
151 test file = $(cat file2)
155 test_expect_success
'rebased upstream + fetch + pull --rebase' '
157 git update-ref refs/remotes/me/copy copy-orig &&
158 git reset --hard to-rebase-orig &&
159 git checkout --track -b to-rebase3 me/copy &&
160 git reset --hard to-rebase-orig &&
163 test "conflicting modification" = "$(cat file)" &&
164 test file = "$(cat file2)"
168 test_expect_success
'pull --rebase dies early with dirty working directory' '
170 git checkout to-rebase &&
171 git update-ref refs/remotes/me/copy copy^ &&
172 COPY=$(git rev-parse --verify me/copy) &&
173 git rebase --onto $COPY copy &&
174 git config branch.to-rebase.remote me &&
175 git config branch.to-rebase.merge refs/heads/copy &&
176 git config branch.to-rebase.rebase true &&
177 echo dirty >> file &&
179 test_must_fail git pull &&
180 test $COPY = $(git rev-parse --verify me/copy) &&
181 git checkout HEAD -- file &&
183 test $COPY != $(git rev-parse --verify me/copy)
187 test_expect_success
'pull --rebase works on branch yet to be born' '
188 git rev-parse master >expect &&
192 git pull --rebase .. master &&
193 git rev-parse HEAD >../actual
195 test_cmp expect actual
198 test_expect_success
'setup for detecting upstreamed changes' '
202 printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff &&
204 git commit -m "Initial revision"
208 modify s/5/43/ stuff &&
209 git commit -a -m "5->43" &&
210 modify s/6/42/ stuff &&
211 git commit -a -m "Make it bigger"
214 modify s/5/43/ stuff &&
215 git commit -a -m "Independent discovery of 5->43"
219 test_expect_success
'git pull --rebase detects upstreamed changes' '
222 test -z "$(git ls-files -u)"
226 test_expect_success
'setup for avoiding reapplying old patches' '
228 test_might_fail git rebase --abort &&
229 git reset --hard origin/master
231 git clone --bare src src-replace.git &&
233 mv src-replace.git src &&
235 modify s/2/22/ stuff &&
236 git commit -a -m "Change 2" &&
237 modify s/3/33/ stuff &&
238 git commit -a -m "Change 3" &&
239 modify s/4/44/ stuff &&
240 git commit -a -m "Change 4" &&
243 modify s/44/55/ stuff &&
244 git commit --amend -a -m "Modified Change 4"
248 test_expect_success
'git pull --rebase does not reapply old patches' '
250 test_must_fail git pull --rebase &&
251 test 1 = $(find .git/rebase-apply -name "000*" | wc -l)
255 test_expect_success
'git pull --rebase against local branch' '
256 git checkout -b copy2 to-rebase-orig &&
257 git pull --rebase . to-rebase &&
258 test "conflicting modification" = "$(cat file)" &&
259 test file = "$(cat file2)"