l10n: de.po: translate "revision" consistently as "Revision"
[git.git] / t / t5801-remote-helpers.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2010 Sverre Rabbelier
4 #
5
6 test_description='Test remote-helper import and export commands'
7
8 . ./test-lib.sh
9
10 if ! type "${BASH-bash}" >/dev/null 2>&1; then
11         skip_all='skipping remote-testgit tests, bash not available'
12         test_done
13 fi
14
15 compare_refs() {
16         git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
17         git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
18         test_cmp expect actual
19 }
20
21 test_expect_success 'setup repository' '
22         git init server &&
23         (cd server &&
24          echo content >file &&
25          git add file &&
26          git commit -m one)
27 '
28
29 test_expect_success 'cloning from local repo' '
30         git clone "testgit::${PWD}/server" local &&
31         test_cmp server/file local/file
32 '
33
34 test_expect_success 'create new commit on remote' '
35         (cd server &&
36          echo content >>file &&
37          git commit -a -m two)
38 '
39
40 test_expect_success 'pulling from local repo' '
41         (cd local && git pull) &&
42         test_cmp server/file local/file
43 '
44
45 test_expect_success 'pushing to local repo' '
46         (cd local &&
47         echo content >>file &&
48         git commit -a -m three &&
49         git push) &&
50         compare_refs local HEAD server HEAD
51 '
52
53 test_expect_success 'fetch new branch' '
54         (cd server &&
55          git reset --hard &&
56          git checkout -b new &&
57          echo content >>file &&
58          git commit -a -m five
59         ) &&
60         (cd local &&
61          git fetch origin new
62         ) &&
63         compare_refs server HEAD local FETCH_HEAD
64 '
65
66 test_expect_success 'fetch multiple branches' '
67         (cd local &&
68          git fetch
69         ) &&
70         compare_refs server master local refs/remotes/origin/master &&
71         compare_refs server new local refs/remotes/origin/new
72 '
73
74 test_expect_success 'push when remote has extra refs' '
75         (cd local &&
76          git reset --hard origin/master &&
77          echo content >>file &&
78          git commit -a -m six &&
79          git push
80         ) &&
81         compare_refs local master server master
82 '
83
84 test_expect_success 'push new branch by name' '
85         (cd local &&
86          git checkout -b new-name  &&
87          echo content >>file &&
88          git commit -a -m seven &&
89          git push origin new-name
90         ) &&
91         compare_refs local HEAD server refs/heads/new-name
92 '
93
94 test_expect_failure 'push new branch with old:new refspec' '
95         (cd local &&
96          git push origin new-name:new-refspec
97         ) &&
98         compare_refs local HEAD server refs/heads/new-refspec
99 '
100
101 test_expect_success 'cloning without refspec' '
102         GIT_REMOTE_TESTGIT_REFSPEC="" \
103         git clone "testgit::${PWD}/server" local2 &&
104         compare_refs local2 HEAD server HEAD
105 '
106
107 test_expect_success 'pulling without refspecs' '
108         (cd local2 &&
109         git reset --hard &&
110         GIT_REMOTE_TESTGIT_REFSPEC="" git pull) &&
111         compare_refs local2 HEAD server HEAD
112 '
113
114 test_expect_failure 'pushing without refspecs' '
115         test_when_finished "(cd local2 && git reset --hard origin)" &&
116         (cd local2 &&
117         echo content >>file &&
118         git commit -a -m ten &&
119         GIT_REMOTE_TESTGIT_REFSPEC="" git push) &&
120         compare_refs local2 HEAD server HEAD
121 '
122
123 test_expect_success 'pulling with straight refspec' '
124         (cd local2 &&
125         GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) &&
126         compare_refs local2 HEAD server HEAD
127 '
128
129 test_expect_failure 'pushing with straight refspec' '
130         test_when_finished "(cd local2 && git reset --hard origin)" &&
131         (cd local2 &&
132         echo content >>file &&
133         git commit -a -m eleven &&
134         GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) &&
135         compare_refs local2 HEAD server HEAD
136 '
137
138 test_expect_success 'pulling without marks' '
139         (cd local2 &&
140         GIT_REMOTE_TESTGIT_NO_MARKS=1 git pull) &&
141         compare_refs local2 HEAD server HEAD
142 '
143
144 test_expect_failure 'pushing without marks' '
145         test_when_finished "(cd local2 && git reset --hard origin)" &&
146         (cd local2 &&
147         echo content >>file &&
148         git commit -a -m twelve &&
149         GIT_REMOTE_TESTGIT_NO_MARKS=1 git push) &&
150         compare_refs local2 HEAD server HEAD
151 '
152
153 test_expect_success 'push all with existing object' '
154         (cd local &&
155         git branch dup2 master &&
156         git push origin --all
157         ) &&
158         compare_refs local dup2 server dup2
159 '
160
161 test_expect_success 'push ref with existing object' '
162         (cd local &&
163         git branch dup master &&
164         git push origin dup
165         ) &&
166         compare_refs local dup server dup
167 '
168
169 test_done