]>
Commit | Line | Data |
---|---|---|
fc407f98 FC |
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' ' | |
3808b851 FC |
22 | git init server && |
23 | (cd server && | |
fc407f98 FC |
24 | echo content >file && |
25 | git add file && | |
3808b851 | 26 | git commit -m one) |
fc407f98 FC |
27 | ' |
28 | ||
29 | test_expect_success 'cloning from local repo' ' | |
3808b851 FC |
30 | git clone "testgit::${PWD}/server" local && |
31 | test_cmp server/file local/file | |
fc407f98 FC |
32 | ' |
33 | ||
fc407f98 | 34 | test_expect_success 'create new commit on remote' ' |
3808b851 | 35 | (cd server && |
fc407f98 | 36 | echo content >>file && |
3808b851 | 37 | git commit -a -m two) |
fc407f98 FC |
38 | ' |
39 | ||
40 | test_expect_success 'pulling from local repo' ' | |
3808b851 FC |
41 | (cd local && git pull) && |
42 | test_cmp server/file local/file | |
fc407f98 FC |
43 | ' |
44 | ||
fc407f98 | 45 | test_expect_success 'pushing to local repo' ' |
3808b851 | 46 | (cd local && |
fc407f98 FC |
47 | echo content >>file && |
48 | git commit -a -m three && | |
49 | git push) && | |
3808b851 | 50 | compare_refs local HEAD server HEAD |
fc407f98 FC |
51 | ' |
52 | ||
fc407f98 | 53 | test_expect_success 'fetch new branch' ' |
3808b851 FC |
54 | (cd server && |
55 | git reset --hard && | |
fc407f98 FC |
56 | git checkout -b new && |
57 | echo content >>file && | |
3808b851 | 58 | git commit -a -m five |
fc407f98 | 59 | ) && |
3808b851 | 60 | (cd local && |
fc407f98 FC |
61 | git fetch origin new |
62 | ) && | |
3808b851 | 63 | compare_refs server HEAD local FETCH_HEAD |
fc407f98 FC |
64 | ' |
65 | ||
984f3768 FC |
66 | # |
67 | # This is only needed because of a bug not detected by this script. It will be | |
68 | # fixed shortly, but for now lets not cause regressions. | |
69 | # | |
3808b851 FC |
70 | test_expect_success 'bump commit in server' ' |
71 | (cd server && | |
984f3768 | 72 | git checkout master && |
984f3768 | 73 | echo content >>file && |
3808b851 FC |
74 | git commit -a -m four) && |
75 | compare_refs server HEAD server HEAD | |
984f3768 FC |
76 | ' |
77 | ||
fc407f98 | 78 | test_expect_success 'fetch multiple branches' ' |
3808b851 | 79 | (cd local && |
fc407f98 FC |
80 | git fetch |
81 | ) && | |
3808b851 FC |
82 | compare_refs server master local refs/remotes/origin/master && |
83 | compare_refs server new local refs/remotes/origin/new | |
fc407f98 FC |
84 | ' |
85 | ||
86 | test_expect_success 'push when remote has extra refs' ' | |
3808b851 | 87 | (cd local && |
984f3768 | 88 | git reset --hard origin/master && |
fc407f98 FC |
89 | echo content >>file && |
90 | git commit -a -m six && | |
91 | git push | |
92 | ) && | |
3808b851 | 93 | compare_refs local master server master |
fc407f98 FC |
94 | ' |
95 | ||
96 | test_expect_success 'push new branch by name' ' | |
3808b851 | 97 | (cd local && |
fc407f98 FC |
98 | git checkout -b new-name && |
99 | echo content >>file && | |
100 | git commit -a -m seven && | |
101 | git push origin new-name | |
102 | ) && | |
3808b851 | 103 | compare_refs local HEAD server refs/heads/new-name |
fc407f98 FC |
104 | ' |
105 | ||
106 | test_expect_failure 'push new branch with old:new refspec' ' | |
3808b851 | 107 | (cd local && |
fc407f98 FC |
108 | git push origin new-name:new-refspec |
109 | ) && | |
3808b851 | 110 | compare_refs local HEAD server refs/heads/new-refspec |
fc407f98 FC |
111 | ' |
112 | ||
ee10fbf9 FC |
113 | test_expect_success 'cloning without refspec' ' |
114 | GIT_REMOTE_TESTGIT_REFSPEC="" \ | |
115 | git clone "testgit::${PWD}/server" local2 && | |
116 | compare_refs local2 HEAD server HEAD | |
117 | ' | |
118 | ||
119 | test_expect_success 'pulling without refspecs' ' | |
120 | (cd local2 && | |
121 | git reset --hard && | |
122 | GIT_REMOTE_TESTGIT_REFSPEC="" git pull) && | |
123 | compare_refs local2 HEAD server HEAD | |
124 | ' | |
125 | ||
126 | test_expect_failure 'pushing without refspecs' ' | |
127 | test_when_finished "(cd local2 && git reset --hard origin)" && | |
128 | (cd local2 && | |
129 | echo content >>file && | |
130 | git commit -a -m ten && | |
131 | GIT_REMOTE_TESTGIT_REFSPEC="" git push) && | |
132 | compare_refs local2 HEAD server HEAD | |
133 | ' | |
134 | ||
135 | test_expect_success 'pulling with straight refspec' ' | |
136 | (cd local2 && | |
137 | GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) && | |
138 | compare_refs local2 HEAD server HEAD | |
139 | ' | |
140 | ||
141 | test_expect_failure 'pushing with straight refspec' ' | |
142 | test_when_finished "(cd local2 && git reset --hard origin)" && | |
143 | (cd local2 && | |
144 | echo content >>file && | |
145 | git commit -a -m eleven && | |
146 | GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) && | |
147 | compare_refs local2 HEAD server HEAD | |
148 | ' | |
149 | ||
150 | test_expect_success 'pulling without marks' ' | |
151 | (cd local2 && | |
152 | GIT_REMOTE_TESTGIT_NO_MARKS=1 git pull) && | |
153 | compare_refs local2 HEAD server HEAD | |
154 | ' | |
155 | ||
156 | test_expect_failure 'pushing without marks' ' | |
157 | test_when_finished "(cd local2 && git reset --hard origin)" && | |
158 | (cd local2 && | |
159 | echo content >>file && | |
160 | git commit -a -m twelve && | |
161 | GIT_REMOTE_TESTGIT_NO_MARKS=1 git push) && | |
162 | compare_refs local2 HEAD server HEAD | |
163 | ' | |
164 | ||
fc407f98 | 165 | test_done |