3 test_description
='git remote porcelain-ish'
14 git commit
-m "Initial" &&
15 git checkout
-b side
&&
19 git commit
-m "Second" &&
25 echo "$1" |
tr ' ' '\012' |
sort |
sed -e '/^$/d' >expect
&&
26 echo "$2" |
tr ' ' '\012' |
sort |
sed -e '/^$/d' >actual
&&
27 test_cmp expect actual
30 check_remote_track
() {
31 actual
=$
(git remote show
"$1" |
sed -n -e '$p') &&
33 tokens_match
"$*" "$actual"
36 check_tracking_branch
() {
38 r
=$
(git for-each-ref
"--format=%(refname)" |
39 sed -ne "s|^refs/remotes/$1/||p") &&
41 tokens_match
"$*" "$r"
44 test_expect_success setup
'
46 setup_repository one &&
47 setup_repository two &&
49 cd two && git branch another
55 test_expect_success
'remote information for the origin' '
58 tokens_match origin "$(git remote)" &&
59 check_remote_track origin master side &&
60 check_tracking_branch origin HEAD master side
64 test_expect_success
'add another remote' '
67 git remote add -f second ../two &&
68 tokens_match "origin second" "$(git remote)" &&
69 check_remote_track origin master side &&
70 check_remote_track second master side another &&
71 check_tracking_branch second master side another &&
72 git for-each-ref "--format=%(refname)" refs/remotes |
73 sed -e "/^refs\/remotes\/origin\//d" \
74 -e "/^refs\/remotes\/second\//d" >actual &&
76 test_cmp expect actual
80 test_expect_success
'remote forces tracking branches' '
83 case `git config remote.second.fetch` in
90 test_expect_success
'remove remote' '
93 git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
98 test_expect_success
'remove remote' '
101 tokens_match origin "$(git remote)" &&
102 check_remote_track origin master side &&
103 git for-each-ref "--format=%(refname)" refs/remotes |
104 sed -e "/^refs\/remotes\/origin\//d" >actual &&
106 test_cmp expect actual
111 *MINGW
*) pwd() { builtin pwd -W; } ;;
113 cat > test
/expect
<< EOF
116 Remote branch merged with 'git pull' while on branch master
118 New remote branch (next fetch will store in remotes/origin)
120 Tracked remote branches
122 Local branches pushed with 'git push'
123 master:upstream +refs/tags/lastbackup
126 test_expect_success
'show' '
128 git config --add remote.origin.fetch \
129 refs/heads/master:refs/heads/upstream &&
131 git branch -d -r origin/master &&
135 git commit -m update file) &&
136 git config remote.origin.push \
137 refs/heads/master:refs/heads/upstream &&
138 git config --add remote.origin.push \
139 +refs/tags/lastbackup &&
140 git remote show origin > output &&
141 test_cmp expect output)
144 cat > test
/expect
<< EOF
147 Remote branch merged with 'git pull' while on branch master
149 Tracked remote branches
151 Local branches pushed with 'git push'
152 master:upstream +refs/tags/lastbackup
155 test_expect_success
'show -n' '
156 (mv one one.unreachable &&
158 git remote show -n origin > output &&
159 mv ../one.unreachable ../one &&
160 test_cmp expect output)
163 test_expect_success
'prune' '
165 git branch -m side side2) &&
168 git remote prune origin &&
169 git rev-parse refs/remotes/origin/side2 &&
170 ! git rev-parse refs/remotes/origin/side)
173 cat > test
/expect
<< EOF
176 * [would prune] origin/side2
179 test_expect_success
'prune --dry-run' '
181 git branch -m side2 side) &&
183 git remote prune --dry-run origin > output &&
184 git rev-parse refs/remotes/origin/side2 &&
185 ! git rev-parse refs/remotes/origin/side &&
187 git branch -m side side2) &&
188 test_cmp expect output)
191 test_expect_success
'add --mirror && prune' '
195 git remote add --mirror -f origin ../one) &&
197 git branch -m side2 side) &&
199 git rev-parse --verify refs/heads/side2 &&
200 ! git rev-parse --verify refs/heads/side &&
202 git remote prune origin &&
203 ! git rev-parse --verify refs/heads/side2 &&
204 git rev-parse --verify refs/heads/side)
207 test_expect_success
'add alt && prune' '
211 git remote add -f origin ../one &&
212 git config remote.alt.url ../one &&
213 git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*") &&
215 git branch -m side side2) &&
217 git rev-parse --verify refs/remotes/origin/side &&
218 ! git rev-parse --verify refs/remotes/origin/side2 &&
220 git remote prune alt &&
221 ! git rev-parse --verify refs/remotes/origin/side &&
222 git rev-parse --verify refs/remotes/origin/side2)
225 cat > one
/expect
<< EOF
233 test_expect_success
'update' '
236 git remote add drosophila ../two &&
237 git remote add apis ../mirror &&
239 git branch -r > output &&
240 test_cmp expect output)
244 cat > one
/expect
<< EOF
254 test_expect_success
'update with arguments' '
257 for b in $(git branch -r)
259 git branch -r -d $b || break
261 git remote add manduca ../mirror &&
262 git remote add megaloprepus ../mirror &&
263 git config remotes.phobaeticus "drosophila megaloprepus" &&
264 git config remotes.titanus manduca &&
265 git remote update phobaeticus titanus &&
266 git branch -r > output &&
267 test_cmp expect output)
271 cat > one
/expect
<< EOF
280 test_expect_success
'update default' '
283 for b in $(git branch -r)
285 git branch -r -d $b || break
287 git config remote.drosophila.skipDefaultUpdate true &&
288 git remote update default &&
289 git branch -r > output &&
290 test_cmp expect output)
294 cat > one
/expect
<< EOF
300 test_expect_success
'update default (overridden, with funny whitespace)' '
303 for b in $(git branch -r)
305 git branch -r -d $b || break
307 git config remotes.default "$(printf "\t drosophila \n")" &&
308 git remote update default &&
309 git branch -r > output &&
310 test_cmp expect output)
314 test_expect_success
'"remote show" does not show symbolic refs' '
316 git clone one three &&
318 git remote show origin > output &&
319 ! grep HEAD < output &&
320 ! grep -i stale < output)
324 test_expect_success
'reject adding remote with an invalid name' '
326 ! git remote add some:url desired-name