Get tests passing again.
[git-central.git] / tests / t5200-pull.sh
1 #!/bin/bash
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 -l . --bare server.git &&
14         rm -fr server.git/hooks &&
15         git remote add origin ./server.git &&
16         git checkout -b stable &&
17         git push origin stable
18 '
19
20 test_expect_success 'pull does a rebase' '
21         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         git clone server.git person2 &&
28         cd person2 &&
29         git checkout topic1 &&
30         echo "$test_name" >a &&
31         git commit -a -m "move topic1 on the server" &&
32         git push origin &&
33         cd .. &&
34
35         # Only one parent
36         pull &&
37         test 1 = $(git cat-file commit $(git rev-parse HEAD) | grep parent | wc -l)
38 '
39
40 test_expect_success 'pull does a rebase but does not fuck up merges' '
41         checkout topic2 &&
42         echo "$test_name on topic2" >a.topic2 &&
43         git add a.topic2 &&
44         git commit -a -m "create topic2" &&
45         git push origin topic2 &&
46
47         # Move stable
48         git checkout stable &&
49         echo "$test_name on stable" >a &&
50         git commit -a -m "move stable that will not be replayed" &&
51         git push origin stable &&
52
53         # And merge stable into topic2
54         git checkout topic2 &&
55         git merge stable &&
56
57         # Move topic2 on the server
58         cd person2 &&
59         git fetch &&
60         git checkout -b topic2 origin/topic2 &&
61         echo "$test_name" >a.topic2.server &&
62         git add a.topic2.server &&
63         git commit -m "move topic2 on the server" &&
64         git push origin &&
65         cd .. &&
66
67         # Merge stable locally too--should conflict
68         git checkout topic2 &&
69         pull &&
70         test 1 = $(git rev-list --all --pretty=oneline | grep "replayed" | wc -l) &&
71         push
72 '
73
74 test_expect_success 'pull moves when we have no local changes' '
75         git checkout topic2 &&
76
77         # Move topic2 on the server
78         cd person2 &&
79         git pull &&
80         echo "$test_name" > a.topic2.server &&
81         git commit -a -m "move topic2 on the server" &&
82         git push origin &&
83         cd .. &&
84
85         pull &&
86         test $(git rev-parse HEAD) = $(git rev-parse origin/topic2)
87 '
88
89 test_done
90