Reproduce and fix with gc-pull the merge replay problem.
[git-central.git] / tests / t5200-script-pull.sh
1 #!/bin/sh
2
3 test_description='script pull'
4
5 . ./test-lib.sh
6
7 export PATH=$PATH:../../scripts
8
9 test_expect_success 'setup' '
10         echo "setup" >a &&
11         git add a &&
12         git commit -m "setup" &&
13         git clone ./. server &&
14         rm -fr server/.git/hooks &&
15         git remote add origin ./server &&
16         git checkout -b stable &&
17         git push origin stable
18 '
19
20 test_expect_success 'pull does a rebase' '
21         gc-checkout topic1 &&
22         echo "$test_name" >a.topic1 &&
23         git add a.topic1 &&
24         git commit -m "move topic1" &&
25
26         # Move topic1 on the server
27         cd server &&
28         git checkout topic1 &&
29         echo "$test_name" >a &&
30         git commit -a -m "move topic1 on the server" &&
31         cd .. &&
32
33         # Only one parent
34         gc-pull &&
35         test 1 = $(git cat-file commit $(git rev-parse HEAD) | grep parent | wc -l)
36 '
37
38 test_expect_success 'pull does a rebase but does not fuck up merges' '
39         gc-checkout topic2 &&
40         echo "$test_name on topic2" >a.topic2 &&
41         git add a.topic2 &&
42         git commit -a -m "create topic2" &&
43         git push origin topic2 &&
44
45         # Move stable
46         git checkout stable &&
47         echo "$test_name on stable" >a &&
48         git commit -a -m "move stable that will not be replayed" &&
49         git push origin stable &&
50
51         # And merge stable into topic2
52         git checkout topic2 &&
53         git merge stable &&
54
55         # Move topic2 on the server
56         cd server &&
57         git checkout topic2 &&
58         echo "$test_name" >a.topic2.server &&
59         git add a.topic2.server &&
60         git commit -m "move topic2 on the server" &&
61         cd .. &&
62
63         # Merge stable locally too--should conflict
64         git checkout topic2 &&
65         gc-pull &&
66         test 1 = $(git rev-list --all --pretty=oneline | grep "replayed" | wc -l)
67 '
68
69 test_done
70