Skip to content

Commit 3cee923

Browse files
newrengitster
authored andcommitted
t5520-pull: Add testcases showing spurious conflicts from git pull --rebase
Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e923eae commit 3cee923

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

t/t5520-pull.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ test_description='pulling into void'
44

55
. ./test-lib.sh
66

7+
modify () {
8+
sed -e "$1" <"$2" >"$2.x" &&
9+
mv "$2.x" "$2"
10+
}
11+
712
D=`pwd`
813

914
test_expect_success setup '
@@ -160,4 +165,61 @@ test_expect_success 'pull --rebase works on branch yet to be born' '
160165
test_cmp expect actual
161166
'
162167

168+
test_expect_success 'setup for detecting upstreamed changes' '
169+
mkdir src &&
170+
(cd src &&
171+
git init &&
172+
printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff &&
173+
git add stuff &&
174+
git commit -m "Initial revision"
175+
) &&
176+
git clone src dst &&
177+
(cd src &&
178+
modify s/5/43/ stuff &&
179+
git commit -a -m "5->43" &&
180+
modify s/6/42/ stuff &&
181+
git commit -a -m "Make it bigger"
182+
) &&
183+
(cd dst &&
184+
modify s/5/43/ stuff &&
185+
git commit -a -m "Independent discovery of 5->43"
186+
)
187+
'
188+
189+
test_expect_failure 'git pull --rebase detects upstreamed changes' '
190+
(cd dst &&
191+
git pull --rebase &&
192+
test -z "$(git ls-files -u)"
193+
)
194+
'
195+
196+
test_expect_success 'setup for avoiding reapplying old patches' '
197+
(cd dst &&
198+
test_might_fail git rebase --abort &&
199+
git reset --hard origin/master
200+
) &&
201+
git clone --bare src src-replace.git &&
202+
rm -rf src &&
203+
mv src-replace.git src &&
204+
(cd dst &&
205+
modify s/2/22/ stuff &&
206+
git commit -a -m "Change 2" &&
207+
modify s/3/33/ stuff &&
208+
git commit -a -m "Change 3" &&
209+
modify s/4/44/ stuff &&
210+
git commit -a -m "Change 4" &&
211+
git push &&
212+
213+
modify s/44/55/ stuff &&
214+
git commit --amend -a -m "Modified Change 4"
215+
)
216+
'
217+
218+
test_expect_failure 'git pull --rebase does not reapply old patches' '
219+
(cd dst &&
220+
test_must_fail git pull --rebase &&
221+
test 1 = $(find .git/rebase-apply -name "000*" | wc -l)
222+
)
223+
'
224+
163225
test_done

0 commit comments

Comments
 (0)