test: remove httpd tests that ask for user
[git] / t / t5580-update.sh
1 #!/bin/sh
2
3 test_description='update'
4
5 . ./test-lib.sh
6
7 check () {
8         git rev-parse -q --verify $1 > expected &&
9         git rev-parse -q --verify $2 > actual &&
10         test_cmp expected actual
11 }
12
13 check_msg () {
14         if test "$1" = "$2"
15         then
16                 echo "Update branch '$1'" > expected
17         else
18                 test "$2" != "master" && into=" into $2"
19                 echo "Merge branch '$1'${into}" > expected
20         fi &&
21         git log -1 --format=%s > actual &&
22         test_cmp expected actual
23 }
24
25 test_expect_success 'setup' '
26         echo one > file &&
27         git add file &&
28         git commit -a -m one &&
29         echo two > file &&
30         git commit -a -m two &&
31         git clone . remote &&
32         git remote add origin remote
33 '
34
35 test_expect_success 'basic update' '
36         test_when_finished "rm -rf test" &&
37         (
38         git clone . test &&
39         cd test &&
40         git reset --hard @^ &&
41         git update &&
42         check master origin/master
43         )
44 '
45
46 test_expect_success 'basic update without upstream' '
47         test_when_finished "rm -rf test" &&
48         (
49         git clone . test &&
50         cd test &&
51         git reset --hard @^ &&
52         git branch --unset-upstream &&
53         git update &&
54         check master origin/master
55         )
56 '
57
58 test_expect_success 'basic update no-ff' '
59         test_when_finished "rm -rf test" &&
60         (
61         git clone . test &&
62         cd test &&
63         git reset --hard @^ &&
64         git update --no-ff &&
65         check @^1 origin/master &&
66         check_msg master master
67         )
68 '
69
70 test_expect_success 'git update non-fast-forward' '
71         test_when_finished "rm -rf test" &&
72         (
73         git clone . test &&
74         cd test &&
75         git checkout -b other master^ &&
76         >new &&
77         git add new &&
78         git commit -m new &&
79         git checkout -b test -t other &&
80         git reset --hard master &&
81         test_must_fail git update &&
82         check @ master
83         )
84 '
85
86 test_expect_success 'git update non-fast-forward with merge' '
87         test_when_finished "rm -rf test" &&
88         (
89         git clone . test &&
90         cd test &&
91         git checkout -b other master^ &&
92         >new &&
93         git add new &&
94         git commit -m new &&
95         git checkout -b test -t other &&
96         git reset --hard master &&
97         git update --merge &&
98         check @^2 master &&
99         check @^1 other &&
100         check_msg test other
101         )
102 '
103
104 test_expect_success 'git update non-fast-forward with rebase' '
105         test_when_finished "rm -rf test" &&
106         (
107         git clone . test &&
108         cd test &&
109         git checkout -b other master^ &&
110         >new &&
111         git add new &&
112         git commit -m new &&
113         git checkout -b test -t other &&
114         git reset --hard master &&
115         git update --rebase &&
116         check @^ other
117         )
118 '
119
120 test_expect_success 'git update with argument' '
121         test_when_finished "rm -rf test" &&
122         (
123         git clone . test &&
124         cd test &&
125         git checkout -b test &&
126         git reset --hard @^ &&
127         git update master &&
128         check test master
129         )
130 '
131
132 test_expect_success 'git update with remote argument' '
133         test_when_finished "rm -rf test" &&
134         (
135         git clone . test &&
136         cd test &&
137         git checkout -b test &&
138         git reset --hard @^ &&
139         git update origin/master &&
140         check test master
141         )
142 '
143
144 test_done