]>
Commit | Line | Data |
---|---|---|
683b5679 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='git remote porcelain-ish' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
683b5679 JH |
7 | setup_repository () { |
8 | mkdir "$1" && ( | |
9 | cd "$1" && | |
10 | git init && | |
11 | >file && | |
12 | git add file && | |
84521ed6 | 13 | test_tick && |
683b5679 JH |
14 | git commit -m "Initial" && |
15 | git checkout -b side && | |
16 | >elif && | |
17 | git add elif && | |
84521ed6 | 18 | test_tick && |
683b5679 JH |
19 | git commit -m "Second" && |
20 | git checkout master | |
21 | ) | |
22 | } | |
23 | ||
24 | tokens_match () { | |
25 | echo "$1" | tr ' ' '\012' | sort | sed -e '/^$/d' >expect && | |
26 | echo "$2" | tr ' ' '\012' | sort | sed -e '/^$/d' >actual && | |
82ebb0b6 | 27 | test_cmp expect actual |
683b5679 JH |
28 | } |
29 | ||
30 | check_remote_track () { | |
7ecbbf87 | 31 | actual=$(git remote show "$1" | sed -ne 's|^ \(.*\) tracked$|\1|p') |
683b5679 JH |
32 | shift && |
33 | tokens_match "$*" "$actual" | |
34 | } | |
35 | ||
36 | check_tracking_branch () { | |
37 | f="" && | |
38 | r=$(git for-each-ref "--format=%(refname)" | | |
39 | sed -ne "s|^refs/remotes/$1/||p") && | |
40 | shift && | |
41 | tokens_match "$*" "$r" | |
42 | } | |
43 | ||
44 | test_expect_success setup ' | |
683b5679 JH |
45 | setup_repository one && |
46 | setup_repository two && | |
47 | ( | |
9b9439af RR |
48 | cd two && |
49 | git branch another | |
683b5679 JH |
50 | ) && |
51 | git clone one test | |
683b5679 JH |
52 | ' |
53 | ||
d8ff76cf JS |
54 | test_expect_success 'add remote whose URL agrees with url.<...>.insteadOf' ' |
55 | test_config url.git@host.com:team/repo.git.insteadOf myremote && | |
56 | git remote add myremote git@host.com:team/repo.git | |
57 | ' | |
58 | ||
f7dc6a96 | 59 | test_expect_success C_LOCALE_OUTPUT 'remote information for the origin' ' |
9b9439af RR |
60 | ( |
61 | cd test && | |
62 | tokens_match origin "$(git remote)" && | |
63 | check_remote_track origin master side && | |
64 | check_tracking_branch origin HEAD master side | |
65 | ) | |
683b5679 JH |
66 | ' |
67 | ||
68 | test_expect_success 'add another remote' ' | |
9b9439af RR |
69 | ( |
70 | cd test && | |
71 | git remote add -f second ../two && | |
72 | tokens_match "origin second" "$(git remote)" && | |
73 | check_tracking_branch second master side another && | |
74 | git for-each-ref "--format=%(refname)" refs/remotes | | |
75 | sed -e "/^refs\/remotes\/origin\//d" \ | |
76 | -e "/^refs\/remotes\/second\//d" >actual && | |
77 | >expect && | |
78 | test_cmp expect actual | |
79 | ) | |
683b5679 JH |
80 | ' |
81 | ||
d6ac1d21 | 82 | test_expect_success C_LOCALE_OUTPUT 'check remote-tracking' ' |
9b9439af RR |
83 | ( |
84 | cd test && | |
85 | check_remote_track origin master side && | |
86 | check_remote_track second master side another | |
87 | ) | |
f7dc6a96 JX |
88 | ' |
89 | ||
1ce89cc4 | 90 | test_expect_success 'remote forces tracking branches' ' |
9b9439af RR |
91 | ( |
92 | cd test && | |
c0097814 | 93 | case $(git config remote.second.fetch) in |
9b9439af RR |
94 | +*) true ;; |
95 | *) false ;; | |
96 | esac | |
97 | ) | |
1ce89cc4 JK |
98 | ' |
99 | ||
683b5679 | 100 | test_expect_success 'remove remote' ' |
9b9439af RR |
101 | ( |
102 | cd test && | |
103 | git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master && | |
104 | git remote rm second | |
105 | ) | |
683b5679 JH |
106 | ' |
107 | ||
f7dc6a96 | 108 | test_expect_success C_LOCALE_OUTPUT 'remove remote' ' |
9b9439af RR |
109 | ( |
110 | cd test && | |
111 | tokens_match origin "$(git remote)" && | |
112 | check_remote_track origin master side && | |
113 | git for-each-ref "--format=%(refname)" refs/remotes | | |
114 | sed -e "/^refs\/remotes\/origin\//d" >actual && | |
115 | >expect && | |
116 | test_cmp expect actual | |
117 | ) | |
683b5679 JH |
118 | ' |
119 | ||
13931236 | 120 | test_expect_success 'remove remote protects local branches' ' |
9b9439af RR |
121 | ( |
122 | cd test && | |
123 | cat >expect1 <<-\EOF && | |
124 | Note: A branch outside the refs/remotes/ hierarchy was not removed; | |
125 | to delete it, use: | |
126 | git branch -d master | |
127 | EOF | |
128 | cat >expect2 <<-\EOF && | |
129 | Note: Some branches outside the refs/remotes/ hierarchy were not removed; | |
130 | to delete them, use: | |
131 | git branch -d foobranch | |
132 | git branch -d master | |
133 | EOF | |
134 | git tag footag && | |
135 | git config --add remote.oops.fetch "+refs/*:refs/*" && | |
136 | git remote remove oops 2>actual1 && | |
137 | git branch foobranch && | |
138 | git config --add remote.oops.fetch "+refs/*:refs/*" && | |
139 | git remote rm oops 2>actual2 && | |
140 | git branch -d foobranch && | |
141 | git tag -d footag && | |
142 | test_i18ncmp expect1 actual1 && | |
143 | test_i18ncmp expect2 actual2 | |
144 | ) | |
145 | ' | |
146 | ||
cc8e538d TG |
147 | test_expect_success 'remove errors out early when deleting non-existent branch' ' |
148 | ( | |
149 | cd test && | |
150 | echo "fatal: No such remote: foo" >expect && | |
151 | test_must_fail git remote rm foo 2>actual && | |
152 | test_i18ncmp expect actual | |
153 | ) | |
154 | ' | |
155 | ||
20690b21 RL |
156 | test_expect_success 'remove remote with a branch without configured merge' ' |
157 | test_when_finished "( | |
158 | git -C test checkout master; | |
159 | git -C test branch -D two; | |
160 | git -C test config --remove-section remote.two; | |
161 | git -C test config --remove-section branch.second; | |
162 | true | |
163 | )" && | |
164 | ( | |
165 | cd test && | |
166 | git remote add two ../two && | |
167 | git fetch two && | |
168 | git checkout -b second two/master^0 && | |
169 | git config branch.second.remote two && | |
170 | git checkout master && | |
171 | git remote rm two | |
172 | ) | |
173 | ' | |
174 | ||
cc8e538d TG |
175 | test_expect_success 'rename errors out early when deleting non-existent branch' ' |
176 | ( | |
177 | cd test && | |
178 | echo "fatal: No such remote: foo" >expect && | |
179 | test_must_fail git remote rename foo bar 2>actual && | |
180 | test_i18ncmp expect actual | |
181 | ) | |
182 | ' | |
183 | ||
a31eeae2 TG |
184 | test_expect_success 'add existing foreign_vcs remote' ' |
185 | test_config remote.foo.vcs bar && | |
186 | echo "fatal: remote foo already exists." >expect && | |
187 | test_must_fail git remote add foo bar 2>actual && | |
188 | test_i18ncmp expect actual | |
189 | ' | |
190 | ||
191 | test_expect_success 'add existing foreign_vcs remote' ' | |
192 | test_config remote.foo.vcs bar && | |
193 | test_config remote.bar.vcs bar && | |
194 | echo "fatal: remote bar already exists." >expect && | |
195 | test_must_fail git remote rename foo bar 2>actual && | |
196 | test_i18ncmp expect actual | |
197 | ' | |
198 | ||
9b9439af | 199 | cat >test/expect <<EOF |
4704640b | 200 | * remote origin |
857f8c30 MG |
201 | Fetch URL: $(pwd)/one |
202 | Push URL: $(pwd)/one | |
e61e0cc6 | 203 | HEAD branch: master |
7ecbbf87 JS |
204 | Remote branches: |
205 | master new (next fetch will store in remotes/origin) | |
206 | side tracked | |
207 | Local branches configured for 'git pull': | |
e5dcbfd9 | 208 | ahead merges with remote master |
7ecbbf87 JS |
209 | master merges with remote master |
210 | octopus merges with remote topic-a | |
211 | and with remote topic-b | |
212 | and with remote topic-c | |
213 | rebase rebases onto remote master | |
e5dcbfd9 JS |
214 | Local refs configured for 'git push': |
215 | master pushes to master (local out of date) | |
216 | master pushes to upstream (create) | |
e61e0cc6 | 217 | * remote two |
857f8c30 MG |
218 | Fetch URL: ../two |
219 | Push URL: ../three | |
a45b5f05 | 220 | HEAD branch: master |
e5dcbfd9 | 221 | Local refs configured for 'git push': |
a75d7b54 | 222 | ahead forces to master (fast-forwardable) |
e5dcbfd9 | 223 | master pushes to another (up to date) |
4704640b JS |
224 | EOF |
225 | ||
226 | test_expect_success 'show' ' | |
9b9439af RR |
227 | ( |
228 | cd test && | |
229 | git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream && | |
230 | git fetch && | |
231 | git checkout -b ahead origin/master && | |
232 | echo 1 >>file && | |
233 | test_tick && | |
234 | git commit -m update file && | |
235 | git checkout master && | |
236 | git branch --track octopus origin/master && | |
237 | git branch --track rebase origin/master && | |
238 | git branch -d -r origin/master && | |
239 | git config --add remote.two.url ../two && | |
240 | git config --add remote.two.pushurl ../three && | |
241 | git config branch.rebase.rebase true && | |
242 | git config branch.octopus.merge "topic-a topic-b topic-c" && | |
243 | ( | |
244 | cd ../one && | |
245 | echo 1 >file && | |
246 | test_tick && | |
247 | git commit -m update file | |
248 | ) && | |
249 | git config --add remote.origin.push : && | |
250 | git config --add remote.origin.push refs/heads/master:refs/heads/upstream && | |
251 | git config --add remote.origin.push +refs/tags/lastbackup && | |
252 | git config --add remote.two.push +refs/heads/ahead:refs/heads/master && | |
253 | git config --add remote.two.push refs/heads/master:refs/heads/another && | |
254 | git remote show origin two >output && | |
255 | git branch -d rebase octopus && | |
256 | test_i18ncmp expect output | |
257 | ) | |
258 | ' | |
259 | ||
260 | cat >test/expect <<EOF | |
0ecfcb3b | 261 | * remote origin |
857f8c30 MG |
262 | Fetch URL: $(pwd)/one |
263 | Push URL: $(pwd)/one | |
e61e0cc6 | 264 | HEAD branch: (not queried) |
7ecbbf87 | 265 | Remote branches: (status not queried) |
20244ea2 JS |
266 | master |
267 | side | |
e5dcbfd9 JS |
268 | Local branches configured for 'git pull': |
269 | ahead merges with remote master | |
7ecbbf87 | 270 | master merges with remote master |
e5dcbfd9 JS |
271 | Local refs configured for 'git push' (status not queried): |
272 | (matching) pushes to (matching) | |
273 | refs/heads/master pushes to refs/heads/upstream | |
274 | refs/tags/lastbackup forces to refs/tags/lastbackup | |
0ecfcb3b OM |
275 | EOF |
276 | ||
277 | test_expect_success 'show -n' ' | |
9b9439af RR |
278 | mv one one.unreachable && |
279 | ( | |
280 | cd test && | |
281 | git remote show -n origin >output && | |
282 | mv ../one.unreachable ../one && | |
283 | test_i18ncmp expect output | |
284 | ) | |
0ecfcb3b OM |
285 | ' |
286 | ||
4704640b | 287 | test_expect_success 'prune' ' |
9b9439af RR |
288 | ( |
289 | cd one && | |
290 | git branch -m side side2 | |
291 | ) && | |
292 | ( | |
293 | cd test && | |
294 | git fetch origin && | |
295 | git remote prune origin && | |
296 | git rev-parse refs/remotes/origin/side2 && | |
297 | test_must_fail git rev-parse refs/remotes/origin/side | |
298 | ) | |
4704640b JS |
299 | ' |
300 | ||
bc14fac8 | 301 | test_expect_success 'set-head --delete' ' |
9b9439af RR |
302 | ( |
303 | cd test && | |
304 | git symbolic-ref refs/remotes/origin/HEAD && | |
305 | git remote set-head --delete origin && | |
306 | test_must_fail git symbolic-ref refs/remotes/origin/HEAD | |
307 | ) | |
bc14fac8 JS |
308 | ' |
309 | ||
310 | test_expect_success 'set-head --auto' ' | |
9b9439af RR |
311 | ( |
312 | cd test && | |
313 | git remote set-head --auto origin && | |
314 | echo refs/remotes/origin/master >expect && | |
315 | git symbolic-ref refs/remotes/origin/HEAD >output && | |
316 | test_cmp expect output | |
bc14fac8 JS |
317 | ) |
318 | ' | |
319 | ||
a45b5f05 | 320 | test_expect_success 'set-head --auto has no problem w/multiple HEADs' ' |
9b9439af RR |
321 | ( |
322 | cd test && | |
a4dfee06 | 323 | git fetch two "refs/heads/*:refs/remotes/two/*" && |
a45b5f05 JH |
324 | git remote set-head --auto two >output 2>&1 && |
325 | echo "two/HEAD set to master" >expect && | |
9b9439af RR |
326 | test_i18ncmp expect output |
327 | ) | |
bc14fac8 JS |
328 | ' |
329 | ||
9b9439af | 330 | cat >test/expect <<\EOF |
bc14fac8 JS |
331 | refs/remotes/origin/side2 |
332 | EOF | |
333 | ||
334 | test_expect_success 'set-head explicit' ' | |
9b9439af RR |
335 | ( |
336 | cd test && | |
337 | git remote set-head origin side2 && | |
338 | git symbolic-ref refs/remotes/origin/HEAD >output && | |
339 | git remote set-head origin master && | |
340 | test_cmp expect output | |
341 | ) | |
bc14fac8 JS |
342 | ' |
343 | ||
9b9439af | 344 | cat >test/expect <<EOF |
8d767927 | 345 | Pruning origin |
86521aca | 346 | URL: $(pwd)/one |
8d767927 OM |
347 | * [would prune] origin/side2 |
348 | EOF | |
349 | ||
350 | test_expect_success 'prune --dry-run' ' | |
431f4a26 ES |
351 | git -C one branch -m side2 side && |
352 | test_when_finished "git -C one branch -m side side2" && | |
9b9439af RR |
353 | ( |
354 | cd test && | |
355 | git remote prune --dry-run origin >output && | |
356 | git rev-parse refs/remotes/origin/side2 && | |
357 | test_must_fail git rev-parse refs/remotes/origin/side && | |
9b9439af RR |
358 | test_i18ncmp expect output |
359 | ) | |
8d767927 OM |
360 | ' |
361 | ||
4ebc914c | 362 | test_expect_success 'add --mirror && prune' ' |
9b9439af RR |
363 | mkdir mirror && |
364 | ( | |
365 | cd mirror && | |
366 | git init --bare && | |
367 | git remote add --mirror -f origin ../one | |
368 | ) && | |
369 | ( | |
370 | cd one && | |
371 | git branch -m side2 side | |
372 | ) && | |
373 | ( | |
374 | cd mirror && | |
375 | git rev-parse --verify refs/heads/side2 && | |
376 | test_must_fail git rev-parse --verify refs/heads/side && | |
377 | git fetch origin && | |
378 | git remote prune origin && | |
379 | test_must_fail git rev-parse --verify refs/heads/side2 && | |
380 | git rev-parse --verify refs/heads/side | |
381 | ) | |
4ebc914c JS |
382 | ' |
383 | ||
a9f5a355 JK |
384 | test_expect_success 'add --mirror=fetch' ' |
385 | mkdir mirror-fetch && | |
386 | git init mirror-fetch/parent && | |
9b9439af RR |
387 | ( |
388 | cd mirror-fetch/parent && | |
389 | test_commit one | |
390 | ) && | |
a9f5a355 | 391 | git init --bare mirror-fetch/child && |
9b9439af RR |
392 | ( |
393 | cd mirror-fetch/child && | |
394 | git remote add --mirror=fetch -f parent ../parent | |
395 | ) | |
a9f5a355 JK |
396 | ' |
397 | ||
398 | test_expect_success 'fetch mirrors act as mirrors during fetch' ' | |
9b9439af RR |
399 | ( |
400 | cd mirror-fetch/parent && | |
401 | git branch new && | |
402 | git branch -m master renamed | |
a9f5a355 | 403 | ) && |
9b9439af RR |
404 | ( |
405 | cd mirror-fetch/child && | |
406 | git fetch parent && | |
407 | git rev-parse --verify refs/heads/new && | |
408 | git rev-parse --verify refs/heads/renamed | |
a9f5a355 JK |
409 | ) |
410 | ' | |
411 | ||
412 | test_expect_success 'fetch mirrors can prune' ' | |
9b9439af RR |
413 | ( |
414 | cd mirror-fetch/child && | |
415 | git remote prune parent && | |
416 | test_must_fail git rev-parse --verify refs/heads/master | |
a9f5a355 JK |
417 | ) |
418 | ' | |
419 | ||
420 | test_expect_success 'fetch mirrors do not act as mirrors during push' ' | |
9b9439af RR |
421 | ( |
422 | cd mirror-fetch/parent && | |
423 | git checkout HEAD^0 | |
a9f5a355 | 424 | ) && |
9b9439af RR |
425 | ( |
426 | cd mirror-fetch/child && | |
427 | git branch -m renamed renamed2 && | |
428 | git push parent : | |
a9f5a355 | 429 | ) && |
9b9439af RR |
430 | ( |
431 | cd mirror-fetch/parent && | |
432 | git rev-parse --verify renamed && | |
433 | test_must_fail git rev-parse --verify refs/heads/renamed2 | |
a9f5a355 JK |
434 | ) |
435 | ' | |
436 | ||
3eafdc96 JK |
437 | test_expect_success 'add fetch mirror with specific branches' ' |
438 | git init --bare mirror-fetch/track && | |
9b9439af RR |
439 | ( |
440 | cd mirror-fetch/track && | |
441 | git remote add --mirror=fetch -t heads/new parent ../parent | |
3eafdc96 JK |
442 | ) |
443 | ' | |
444 | ||
445 | test_expect_success 'fetch mirror respects specific branches' ' | |
9b9439af RR |
446 | ( |
447 | cd mirror-fetch/track && | |
448 | git fetch parent && | |
449 | git rev-parse --verify refs/heads/new && | |
450 | test_must_fail git rev-parse --verify refs/heads/renamed | |
3eafdc96 JK |
451 | ) |
452 | ' | |
453 | ||
a9f5a355 JK |
454 | test_expect_success 'add --mirror=push' ' |
455 | mkdir mirror-push && | |
456 | git init --bare mirror-push/public && | |
457 | git init mirror-push/private && | |
9b9439af RR |
458 | ( |
459 | cd mirror-push/private && | |
460 | test_commit one && | |
461 | git remote add --mirror=push public ../public | |
a9f5a355 JK |
462 | ) |
463 | ' | |
464 | ||
465 | test_expect_success 'push mirrors act as mirrors during push' ' | |
9b9439af RR |
466 | ( |
467 | cd mirror-push/private && | |
468 | git branch new && | |
469 | git branch -m master renamed && | |
470 | git push public | |
a9f5a355 | 471 | ) && |
9b9439af RR |
472 | ( |
473 | cd mirror-push/private && | |
474 | git rev-parse --verify refs/heads/new && | |
475 | git rev-parse --verify refs/heads/renamed && | |
476 | test_must_fail git rev-parse --verify refs/heads/master | |
a9f5a355 JK |
477 | ) |
478 | ' | |
479 | ||
480 | test_expect_success 'push mirrors do not act as mirrors during fetch' ' | |
9b9439af RR |
481 | ( |
482 | cd mirror-push/public && | |
483 | git branch -m renamed renamed2 && | |
484 | git symbolic-ref HEAD refs/heads/renamed2 | |
a9f5a355 | 485 | ) && |
9b9439af RR |
486 | ( |
487 | cd mirror-push/private && | |
488 | git fetch public && | |
489 | git rev-parse --verify refs/heads/renamed && | |
490 | test_must_fail git rev-parse --verify refs/heads/renamed2 | |
a9f5a355 JK |
491 | ) |
492 | ' | |
493 | ||
3eafdc96 JK |
494 | test_expect_success 'push mirrors do not allow you to specify refs' ' |
495 | git init mirror-push/track && | |
9b9439af RR |
496 | ( |
497 | cd mirror-push/track && | |
498 | test_must_fail git remote add --mirror=push -t new public ../public | |
3eafdc96 JK |
499 | ) |
500 | ' | |
501 | ||
c175a7ad | 502 | test_expect_success 'add alt && prune' ' |
9b9439af RR |
503 | mkdir alttst && |
504 | ( | |
505 | cd alttst && | |
506 | git init && | |
507 | git remote add -f origin ../one && | |
508 | git config remote.alt.url ../one && | |
509 | git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*" | |
510 | ) && | |
511 | ( | |
512 | cd one && | |
513 | git branch -m side side2 | |
514 | ) && | |
515 | ( | |
516 | cd alttst && | |
517 | git rev-parse --verify refs/remotes/origin/side && | |
518 | test_must_fail git rev-parse --verify refs/remotes/origin/side2 && | |
519 | git fetch alt && | |
520 | git remote prune alt && | |
521 | test_must_fail git rev-parse --verify refs/remotes/origin/side && | |
522 | git rev-parse --verify refs/remotes/origin/side2 | |
523 | ) | |
c175a7ad SP |
524 | ' |
525 | ||
111fb858 ST |
526 | cat >test/expect <<\EOF |
527 | some-tag | |
528 | EOF | |
529 | ||
530 | test_expect_success 'add with reachable tags (default)' ' | |
9b9439af RR |
531 | ( |
532 | cd one && | |
533 | >foobar && | |
534 | git add foobar && | |
535 | git commit -m "Foobar" && | |
536 | git tag -a -m "Foobar tag" foobar-tag && | |
537 | git reset --hard HEAD~1 && | |
538 | git tag -a -m "Some tag" some-tag | |
539 | ) && | |
540 | mkdir add-tags && | |
541 | ( | |
542 | cd add-tags && | |
543 | git init && | |
544 | git remote add -f origin ../one && | |
545 | git tag -l some-tag >../test/output && | |
546 | git tag -l foobar-tag >>../test/output && | |
547 | test_must_fail git config remote.origin.tagopt | |
548 | ) && | |
111fb858 ST |
549 | test_cmp test/expect test/output |
550 | ' | |
551 | ||
552 | cat >test/expect <<\EOF | |
553 | some-tag | |
554 | foobar-tag | |
555 | --tags | |
556 | EOF | |
557 | ||
558 | test_expect_success 'add --tags' ' | |
9b9439af RR |
559 | rm -rf add-tags && |
560 | ( | |
561 | mkdir add-tags && | |
562 | cd add-tags && | |
563 | git init && | |
564 | git remote add -f --tags origin ../one && | |
565 | git tag -l some-tag >../test/output && | |
566 | git tag -l foobar-tag >>../test/output && | |
567 | git config remote.origin.tagopt >>../test/output | |
568 | ) && | |
111fb858 ST |
569 | test_cmp test/expect test/output |
570 | ' | |
571 | ||
572 | cat >test/expect <<\EOF | |
573 | --no-tags | |
574 | EOF | |
575 | ||
576 | test_expect_success 'add --no-tags' ' | |
9b9439af RR |
577 | rm -rf add-tags && |
578 | ( | |
579 | mkdir add-no-tags && | |
580 | cd add-no-tags && | |
581 | git init && | |
582 | git remote add -f --no-tags origin ../one && | |
583 | git tag -l some-tag >../test/output && | |
584 | git tag -l foobar-tag >../test/output && | |
585 | git config remote.origin.tagopt >>../test/output | |
586 | ) && | |
587 | ( | |
588 | cd one && | |
589 | git tag -d some-tag foobar-tag | |
590 | ) && | |
111fb858 ST |
591 | test_cmp test/expect test/output |
592 | ' | |
593 | ||
594 | test_expect_success 'reject --no-no-tags' ' | |
9b9439af RR |
595 | ( |
596 | cd add-no-tags && | |
597 | test_must_fail git remote add -f --no-no-tags neworigin ../one | |
598 | ) | |
111fb858 ST |
599 | ' |
600 | ||
9b9439af | 601 | cat >one/expect <<\EOF |
84521ed6 JS |
602 | apis/master |
603 | apis/side | |
604 | drosophila/another | |
605 | drosophila/master | |
606 | drosophila/side | |
607 | EOF | |
608 | ||
609 | test_expect_success 'update' ' | |
9b9439af RR |
610 | ( |
611 | cd one && | |
612 | git remote add drosophila ../two && | |
613 | git remote add apis ../mirror && | |
614 | git remote update && | |
615 | git branch -r >output && | |
616 | test_cmp expect output | |
617 | ) | |
84521ed6 JS |
618 | ' |
619 | ||
9b9439af | 620 | cat >one/expect <<\EOF |
84521ed6 JS |
621 | drosophila/another |
622 | drosophila/master | |
623 | drosophila/side | |
624 | manduca/master | |
625 | manduca/side | |
626 | megaloprepus/master | |
627 | megaloprepus/side | |
628 | EOF | |
629 | ||
630 | test_expect_success 'update with arguments' ' | |
9b9439af RR |
631 | ( |
632 | cd one && | |
633 | for b in $(git branch -r) | |
634 | do | |
e6821d09 | 635 | git branch -r -d $b || exit 1 |
9b9439af RR |
636 | done && |
637 | git remote add manduca ../mirror && | |
638 | git remote add megaloprepus ../mirror && | |
639 | git config remotes.phobaeticus "drosophila megaloprepus" && | |
640 | git config remotes.titanus manduca && | |
641 | git remote update phobaeticus titanus && | |
642 | git branch -r >output && | |
643 | test_cmp expect output | |
644 | ) | |
84521ed6 JS |
645 | ' |
646 | ||
e2d41c64 | 647 | test_expect_success 'update --prune' ' |
9b9439af RR |
648 | ( |
649 | cd one && | |
650 | git branch -m side2 side3 | |
651 | ) && | |
652 | ( | |
653 | cd test && | |
654 | git remote update --prune && | |
655 | ( | |
656 | cd ../one && | |
657 | git branch -m side3 side2 | |
658 | ) && | |
659 | git rev-parse refs/remotes/origin/side3 && | |
660 | test_must_fail git rev-parse refs/remotes/origin/side2 | |
661 | ) | |
e2d41c64 BG |
662 | ' |
663 | ||
9b9439af | 664 | cat >one/expect <<-\EOF |
84521ed6 JS |
665 | apis/master |
666 | apis/side | |
667 | manduca/master | |
668 | manduca/side | |
669 | megaloprepus/master | |
670 | megaloprepus/side | |
671 | EOF | |
672 | ||
673 | test_expect_success 'update default' ' | |
9b9439af RR |
674 | ( |
675 | cd one && | |
676 | for b in $(git branch -r) | |
677 | do | |
e6821d09 | 678 | git branch -r -d $b || exit 1 |
9b9439af RR |
679 | done && |
680 | git config remote.drosophila.skipDefaultUpdate true && | |
681 | git remote update default && | |
682 | git branch -r >output && | |
683 | test_cmp expect output | |
684 | ) | |
84521ed6 JS |
685 | ' |
686 | ||
9b9439af | 687 | cat >one/expect <<\EOF |
84521ed6 JS |
688 | drosophila/another |
689 | drosophila/master | |
690 | drosophila/side | |
691 | EOF | |
692 | ||
693 | test_expect_success 'update default (overridden, with funny whitespace)' ' | |
9b9439af RR |
694 | ( |
695 | cd one && | |
696 | for b in $(git branch -r) | |
697 | do | |
e6821d09 | 698 | git branch -r -d $b || exit 1 |
9b9439af RR |
699 | done && |
700 | git config remotes.default "$(printf "\t drosophila \n")" && | |
701 | git remote update default && | |
702 | git branch -r >output && | |
703 | test_cmp expect output | |
704 | ) | |
84521ed6 JS |
705 | ' |
706 | ||
4f2e842d | 707 | test_expect_success 'update (with remotes.default defined)' ' |
9b9439af RR |
708 | ( |
709 | cd one && | |
710 | for b in $(git branch -r) | |
711 | do | |
e6821d09 | 712 | git branch -r -d $b || exit 1 |
9b9439af RR |
713 | done && |
714 | git config remotes.default "drosophila" && | |
715 | git remote update && | |
716 | git branch -r >output && | |
717 | test_cmp expect output | |
718 | ) | |
4f2e842d BG |
719 | ' |
720 | ||
740fdd27 | 721 | test_expect_success '"remote show" does not show symbolic refs' ' |
740fdd27 | 722 | git clone one three && |
9b9439af RR |
723 | ( |
724 | cd three && | |
725 | git remote show origin >output && | |
726 | ! grep "^ *HEAD$" < output && | |
727 | ! grep -i stale < output | |
728 | ) | |
740fdd27 JS |
729 | ' |
730 | ||
24b6177e | 731 | test_expect_success 'reject adding remote with an invalid name' ' |
d492b31c | 732 | test_must_fail git remote add some:url desired-name |
24b6177e JF |
733 | ' |
734 | ||
bf98421a MV |
735 | # The first three test if the tracking branches are properly renamed, |
736 | # the last two ones check if the config is updated. | |
737 | ||
738 | test_expect_success 'rename a remote' ' | |
bf98421a | 739 | git clone one four && |
9b9439af RR |
740 | ( |
741 | cd four && | |
742 | git remote rename origin upstream && | |
2eb7a0e5 | 743 | test -z "$(git for-each-ref refs/remotes/origin)" && |
9b9439af RR |
744 | test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" && |
745 | test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" && | |
746 | test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" && | |
747 | test "$(git config branch.master.remote)" = "upstream" | |
748 | ) | |
bf98421a | 749 | ' |
1dd1239a | 750 | |
28f555f6 | 751 | test_expect_success 'rename does not update a non-default fetch refspec' ' |
28f555f6 | 752 | git clone one four.one && |
9b9439af RR |
753 | ( |
754 | cd four.one && | |
755 | git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* && | |
756 | git remote rename origin upstream && | |
757 | test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*" && | |
758 | git rev-parse -q origin/master | |
759 | ) | |
28f555f6 MZ |
760 | ' |
761 | ||
762 | test_expect_success 'rename a remote with name part of fetch spec' ' | |
28f555f6 | 763 | git clone one four.two && |
9b9439af RR |
764 | ( |
765 | cd four.two && | |
766 | git remote rename origin remote && | |
767 | git remote rename remote upstream && | |
768 | test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" | |
769 | ) | |
28f555f6 MZ |
770 | ' |
771 | ||
60e5eee0 | 772 | test_expect_success 'rename a remote with name prefix of other remote' ' |
60e5eee0 | 773 | git clone one four.three && |
9b9439af RR |
774 | ( |
775 | cd four.three && | |
776 | git remote add o git://example.com/repo.git && | |
777 | git remote rename o upstream && | |
778 | test "$(git rev-parse origin/master)" = "$(git rev-parse master)" | |
779 | ) | |
60e5eee0 MZ |
780 | ' |
781 | ||
e459b073 | 782 | test_expect_success 'rename succeeds with existing remote.<target>.prune' ' |
af5bacf4 JS |
783 | git clone one four.four && |
784 | test_when_finished git config --global --unset remote.upstream.prune && | |
785 | git config --global remote.upstream.prune true && | |
786 | git -C four.four remote rename origin upstream | |
787 | ' | |
788 | ||
9b9439af | 789 | cat >remotes_origin <<EOF |
1dd1239a MV |
790 | URL: $(pwd)/one |
791 | Push: refs/heads/master:refs/heads/upstream | |
f0f249d1 | 792 | Push: refs/heads/next:refs/heads/upstream2 |
1dd1239a | 793 | Pull: refs/heads/master:refs/heads/origin |
f0f249d1 | 794 | Pull: refs/heads/next:refs/heads/origin2 |
1dd1239a MV |
795 | EOF |
796 | ||
797 | test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' ' | |
798 | git clone one five && | |
799 | origin_url=$(pwd)/one && | |
9b9439af RR |
800 | ( |
801 | cd five && | |
802 | git remote remove origin && | |
803 | mkdir -p .git/remotes && | |
804 | cat ../remotes_origin >.git/remotes/origin && | |
805 | git remote rename origin origin && | |
fe3c1956 | 806 | test_path_is_missing .git/remotes/origin && |
9b9439af | 807 | test "$(git config remote.origin.url)" = "$origin_url" && |
f0f249d1 RR |
808 | cat >push_expected <<-\EOF && |
809 | refs/heads/master:refs/heads/upstream | |
810 | refs/heads/next:refs/heads/upstream2 | |
811 | EOF | |
812 | cat >fetch_expected <<-\EOF && | |
813 | refs/heads/master:refs/heads/origin | |
814 | refs/heads/next:refs/heads/origin2 | |
815 | EOF | |
816 | git config --get-all remote.origin.push >push_actual && | |
817 | git config --get-all remote.origin.fetch >fetch_actual && | |
818 | test_cmp push_expected push_actual && | |
819 | test_cmp fetch_expected fetch_actual | |
9b9439af | 820 | ) |
1dd1239a MV |
821 | ' |
822 | ||
823 | test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' ' | |
824 | git clone one six && | |
825 | origin_url=$(pwd)/one && | |
9b9439af RR |
826 | ( |
827 | cd six && | |
828 | git remote rm origin && | |
829 | echo "$origin_url" >.git/branches/origin && | |
830 | git remote rename origin origin && | |
fe3c1956 | 831 | test_path_is_missing .git/branches/origin && |
9b9439af | 832 | test "$(git config remote.origin.url)" = "$origin_url" && |
294547f5 RR |
833 | test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin" && |
834 | test "$(git config remote.origin.push)" = "HEAD:refs/heads/master" | |
9b9439af | 835 | ) |
1dd1239a MV |
836 | ' |
837 | ||
1f9a5e90 | 838 | test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' ' |
f8948e2f | 839 | git clone one seven && |
1f9a5e90 RR |
840 | ( |
841 | cd seven && | |
842 | git remote rm origin && | |
843 | echo "quux#foom" > .git/branches/origin && | |
844 | git remote rename origin origin && | |
845 | test_path_is_missing .git/branches/origin && | |
846 | test "$(git config remote.origin.url)" = "quux" && | |
51b85471 | 847 | test "$(git config remote.origin.fetch)" = "refs/heads/foom:refs/heads/origin" && |
1f9a5e90 RR |
848 | test "$(git config remote.origin.push)" = "HEAD:refs/heads/foom" |
849 | ) | |
850 | ' | |
851 | ||
852 | test_expect_success 'remote prune to cause a dangling symref' ' | |
853 | git clone one eight && | |
f8948e2f JH |
854 | ( |
855 | cd one && | |
856 | git checkout side2 && | |
857 | git branch -D master | |
858 | ) && | |
859 | ( | |
1f9a5e90 | 860 | cd eight && |
f8948e2f | 861 | git remote prune origin |
e01de1c9 | 862 | ) >err 2>&1 && |
f7dc6a96 | 863 | test_i18ngrep "has become dangling" err && |
f8948e2f | 864 | |
e01de1c9 | 865 | : And the dangling symref will not cause other annoying errors && |
f8948e2f | 866 | ( |
1f9a5e90 | 867 | cd eight && |
f8948e2f JH |
868 | git branch -a |
869 | ) 2>err && | |
e01de1c9 | 870 | ! grep "points nowhere" err && |
057e7138 | 871 | ( |
1f9a5e90 | 872 | cd eight && |
057e7138 JH |
873 | test_must_fail git branch nomore origin |
874 | ) 2>err && | |
875 | grep "dangling symref" err | |
f8948e2f JH |
876 | ' |
877 | ||
6a01554e | 878 | test_expect_success 'show empty remote' ' |
6a01554e CB |
879 | test_create_repo empty && |
880 | git clone empty empty-clone && | |
881 | ( | |
882 | cd empty-clone && | |
883 | git remote show origin | |
884 | ) | |
885 | ' | |
886 | ||
3d8b6949 JN |
887 | test_expect_success 'remote set-branches requires a remote' ' |
888 | test_must_fail git remote set-branches && | |
889 | test_must_fail git remote set-branches --add | |
890 | ' | |
891 | ||
892 | test_expect_success 'remote set-branches' ' | |
893 | echo "+refs/heads/*:refs/remotes/scratch/*" >expect.initial && | |
894 | sort <<-\EOF >expect.add && | |
895 | +refs/heads/*:refs/remotes/scratch/* | |
896 | +refs/heads/other:refs/remotes/scratch/other | |
897 | EOF | |
898 | sort <<-\EOF >expect.replace && | |
899 | +refs/heads/maint:refs/remotes/scratch/maint | |
900 | +refs/heads/master:refs/remotes/scratch/master | |
901 | +refs/heads/next:refs/remotes/scratch/next | |
902 | EOF | |
903 | sort <<-\EOF >expect.add-two && | |
904 | +refs/heads/maint:refs/remotes/scratch/maint | |
905 | +refs/heads/master:refs/remotes/scratch/master | |
906 | +refs/heads/next:refs/remotes/scratch/next | |
907 | +refs/heads/pu:refs/remotes/scratch/pu | |
908 | +refs/heads/t/topic:refs/remotes/scratch/t/topic | |
909 | EOF | |
910 | sort <<-\EOF >expect.setup-ffonly && | |
911 | refs/heads/master:refs/remotes/scratch/master | |
912 | +refs/heads/next:refs/remotes/scratch/next | |
913 | EOF | |
914 | sort <<-\EOF >expect.respect-ffonly && | |
915 | refs/heads/master:refs/remotes/scratch/master | |
916 | +refs/heads/next:refs/remotes/scratch/next | |
917 | +refs/heads/pu:refs/remotes/scratch/pu | |
918 | EOF | |
919 | ||
920 | git clone .git/ setbranches && | |
921 | ( | |
922 | cd setbranches && | |
923 | git remote rename origin scratch && | |
924 | git config --get-all remote.scratch.fetch >config-result && | |
925 | sort <config-result >../actual.initial && | |
926 | ||
927 | git remote set-branches scratch --add other && | |
928 | git config --get-all remote.scratch.fetch >config-result && | |
929 | sort <config-result >../actual.add && | |
930 | ||
931 | git remote set-branches scratch maint master next && | |
932 | git config --get-all remote.scratch.fetch >config-result && | |
933 | sort <config-result >../actual.replace && | |
934 | ||
935 | git remote set-branches --add scratch pu t/topic && | |
936 | git config --get-all remote.scratch.fetch >config-result && | |
937 | sort <config-result >../actual.add-two && | |
938 | ||
939 | git config --unset-all remote.scratch.fetch && | |
940 | git config remote.scratch.fetch \ | |
941 | refs/heads/master:refs/remotes/scratch/master && | |
942 | git config --add remote.scratch.fetch \ | |
943 | +refs/heads/next:refs/remotes/scratch/next && | |
944 | git config --get-all remote.scratch.fetch >config-result && | |
945 | sort <config-result >../actual.setup-ffonly && | |
946 | ||
947 | git remote set-branches --add scratch pu && | |
948 | git config --get-all remote.scratch.fetch >config-result && | |
949 | sort <config-result >../actual.respect-ffonly | |
950 | ) && | |
951 | test_cmp expect.initial actual.initial && | |
952 | test_cmp expect.add actual.add && | |
953 | test_cmp expect.replace actual.replace && | |
954 | test_cmp expect.add-two actual.add-two && | |
955 | test_cmp expect.setup-ffonly actual.setup-ffonly && | |
956 | test_cmp expect.respect-ffonly actual.respect-ffonly | |
957 | ' | |
958 | ||
959 | test_expect_success 'remote set-branches with --mirror' ' | |
960 | echo "+refs/*:refs/*" >expect.initial && | |
961 | echo "+refs/heads/master:refs/heads/master" >expect.replace && | |
962 | git clone --mirror .git/ setbranches-mirror && | |
963 | ( | |
964 | cd setbranches-mirror && | |
965 | git remote rename origin scratch && | |
966 | git config --get-all remote.scratch.fetch >../actual.initial && | |
967 | ||
968 | git remote set-branches scratch heads/master && | |
969 | git config --get-all remote.scratch.fetch >../actual.replace | |
970 | ) && | |
971 | test_cmp expect.initial actual.initial && | |
972 | test_cmp expect.replace actual.replace | |
973 | ' | |
974 | ||
433f2be1 | 975 | test_expect_success 'new remote' ' |
433f2be1 IL |
976 | git remote add someremote foo && |
977 | echo foo >expect && | |
978 | git config --get-all remote.someremote.url >actual && | |
979 | cmp expect actual | |
433f2be1 IL |
980 | ' |
981 | ||
96f78d39 BB |
982 | get_url_test () { |
983 | cat >expect && | |
984 | git remote get-url "$@" >actual && | |
985 | test_cmp expect actual | |
986 | } | |
987 | ||
988 | test_expect_success 'get-url on new remote' ' | |
989 | echo foo | get_url_test someremote && | |
990 | echo foo | get_url_test --all someremote && | |
991 | echo foo | get_url_test --push someremote && | |
992 | echo foo | get_url_test --push --all someremote | |
993 | ' | |
994 | ||
45ebdcc9 PS |
995 | test_expect_success 'remote set-url with locked config' ' |
996 | test_when_finished "rm -f .git/config.lock" && | |
997 | git config --get-all remote.someremote.url >expect && | |
998 | >.git/config.lock && | |
999 | test_must_fail git remote set-url someremote baz && | |
1000 | git config --get-all remote.someremote.url >actual && | |
1001 | cmp expect actual | |
1002 | ' | |
1003 | ||
433f2be1 | 1004 | test_expect_success 'remote set-url bar' ' |
433f2be1 IL |
1005 | git remote set-url someremote bar && |
1006 | echo bar >expect && | |
1007 | git config --get-all remote.someremote.url >actual && | |
1008 | cmp expect actual | |
433f2be1 | 1009 | ' |
057e7138 | 1010 | |
433f2be1 | 1011 | test_expect_success 'remote set-url baz bar' ' |
433f2be1 IL |
1012 | git remote set-url someremote baz bar && |
1013 | echo baz >expect && | |
1014 | git config --get-all remote.someremote.url >actual && | |
1015 | cmp expect actual | |
433f2be1 IL |
1016 | ' |
1017 | ||
1018 | test_expect_success 'remote set-url zot bar' ' | |
433f2be1 IL |
1019 | test_must_fail git remote set-url someremote zot bar && |
1020 | echo baz >expect && | |
1021 | git config --get-all remote.someremote.url >actual && | |
1022 | cmp expect actual | |
433f2be1 IL |
1023 | ' |
1024 | ||
1025 | test_expect_success 'remote set-url --push zot baz' ' | |
433f2be1 IL |
1026 | test_must_fail git remote set-url --push someremote zot baz && |
1027 | echo "YYY" >expect && | |
1028 | echo baz >>expect && | |
1029 | test_must_fail git config --get-all remote.someremote.pushurl >actual && | |
1030 | echo "YYY" >>actual && | |
1031 | git config --get-all remote.someremote.url >>actual && | |
1032 | cmp expect actual | |
433f2be1 IL |
1033 | ' |
1034 | ||
1035 | test_expect_success 'remote set-url --push zot' ' | |
433f2be1 IL |
1036 | git remote set-url --push someremote zot && |
1037 | echo zot >expect && | |
1038 | echo "YYY" >>expect && | |
1039 | echo baz >>expect && | |
1040 | git config --get-all remote.someremote.pushurl >actual && | |
1041 | echo "YYY" >>actual && | |
1042 | git config --get-all remote.someremote.url >>actual && | |
1043 | cmp expect actual | |
433f2be1 IL |
1044 | ' |
1045 | ||
96f78d39 BB |
1046 | test_expect_success 'get-url with different urls' ' |
1047 | echo baz | get_url_test someremote && | |
1048 | echo baz | get_url_test --all someremote && | |
1049 | echo zot | get_url_test --push someremote && | |
1050 | echo zot | get_url_test --push --all someremote | |
1051 | ' | |
1052 | ||
433f2be1 | 1053 | test_expect_success 'remote set-url --push qux zot' ' |
433f2be1 IL |
1054 | git remote set-url --push someremote qux zot && |
1055 | echo qux >expect && | |
1056 | echo "YYY" >>expect && | |
1057 | echo baz >>expect && | |
1058 | git config --get-all remote.someremote.pushurl >actual && | |
1059 | echo "YYY" >>actual && | |
1060 | git config --get-all remote.someremote.url >>actual && | |
1061 | cmp expect actual | |
433f2be1 IL |
1062 | ' |
1063 | ||
1064 | test_expect_success 'remote set-url --push foo qu+x' ' | |
433f2be1 IL |
1065 | git remote set-url --push someremote foo qu+x && |
1066 | echo foo >expect && | |
1067 | echo "YYY" >>expect && | |
1068 | echo baz >>expect && | |
1069 | git config --get-all remote.someremote.pushurl >actual && | |
1070 | echo "YYY" >>actual && | |
1071 | git config --get-all remote.someremote.url >>actual && | |
1072 | cmp expect actual | |
433f2be1 IL |
1073 | ' |
1074 | ||
1075 | test_expect_success 'remote set-url --push --add aaa' ' | |
433f2be1 IL |
1076 | git remote set-url --push --add someremote aaa && |
1077 | echo foo >expect && | |
1078 | echo aaa >>expect && | |
1079 | echo "YYY" >>expect && | |
1080 | echo baz >>expect && | |
1081 | git config --get-all remote.someremote.pushurl >actual && | |
1082 | echo "YYY" >>actual && | |
1083 | git config --get-all remote.someremote.url >>actual && | |
1084 | cmp expect actual | |
433f2be1 IL |
1085 | ' |
1086 | ||
96f78d39 BB |
1087 | test_expect_success 'get-url on multi push remote' ' |
1088 | echo foo | get_url_test --push someremote && | |
1089 | get_url_test --push --all someremote <<-\EOF | |
1090 | foo | |
1091 | aaa | |
1092 | EOF | |
1093 | ' | |
1094 | ||
433f2be1 | 1095 | test_expect_success 'remote set-url --push bar aaa' ' |
433f2be1 IL |
1096 | git remote set-url --push someremote bar aaa && |
1097 | echo foo >expect && | |
1098 | echo bar >>expect && | |
1099 | echo "YYY" >>expect && | |
1100 | echo baz >>expect && | |
1101 | git config --get-all remote.someremote.pushurl >actual && | |
1102 | echo "YYY" >>actual && | |
1103 | git config --get-all remote.someremote.url >>actual && | |
1104 | cmp expect actual | |
433f2be1 IL |
1105 | ' |
1106 | ||
1107 | test_expect_success 'remote set-url --push --delete bar' ' | |
433f2be1 IL |
1108 | git remote set-url --push --delete someremote bar && |
1109 | echo foo >expect && | |
1110 | echo "YYY" >>expect && | |
1111 | echo baz >>expect && | |
1112 | git config --get-all remote.someremote.pushurl >actual && | |
1113 | echo "YYY" >>actual && | |
1114 | git config --get-all remote.someremote.url >>actual && | |
1115 | cmp expect actual | |
433f2be1 IL |
1116 | ' |
1117 | ||
1118 | test_expect_success 'remote set-url --push --delete foo' ' | |
433f2be1 IL |
1119 | git remote set-url --push --delete someremote foo && |
1120 | echo "YYY" >expect && | |
1121 | echo baz >>expect && | |
1122 | test_must_fail git config --get-all remote.someremote.pushurl >actual && | |
1123 | echo "YYY" >>actual && | |
1124 | git config --get-all remote.someremote.url >>actual && | |
1125 | cmp expect actual | |
433f2be1 IL |
1126 | ' |
1127 | ||
1128 | test_expect_success 'remote set-url --add bbb' ' | |
433f2be1 IL |
1129 | git remote set-url --add someremote bbb && |
1130 | echo "YYY" >expect && | |
1131 | echo baz >>expect && | |
1132 | echo bbb >>expect && | |
1133 | test_must_fail git config --get-all remote.someremote.pushurl >actual && | |
1134 | echo "YYY" >>actual && | |
1135 | git config --get-all remote.someremote.url >>actual && | |
1136 | cmp expect actual | |
433f2be1 IL |
1137 | ' |
1138 | ||
96f78d39 BB |
1139 | test_expect_success 'get-url on multi fetch remote' ' |
1140 | echo baz | get_url_test someremote && | |
1141 | get_url_test --all someremote <<-\EOF | |
1142 | baz | |
1143 | bbb | |
1144 | EOF | |
1145 | ' | |
1146 | ||
433f2be1 | 1147 | test_expect_success 'remote set-url --delete .*' ' |
49de47cf | 1148 | test_must_fail git remote set-url --delete someremote .\* && |
433f2be1 IL |
1149 | echo "YYY" >expect && |
1150 | echo baz >>expect && | |
1151 | echo bbb >>expect && | |
1152 | test_must_fail git config --get-all remote.someremote.pushurl >actual && | |
1153 | echo "YYY" >>actual && | |
1154 | git config --get-all remote.someremote.url >>actual && | |
1155 | cmp expect actual | |
433f2be1 IL |
1156 | ' |
1157 | ||
1158 | test_expect_success 'remote set-url --delete bbb' ' | |
433f2be1 IL |
1159 | git remote set-url --delete someremote bbb && |
1160 | echo "YYY" >expect && | |
1161 | echo baz >>expect && | |
1162 | test_must_fail git config --get-all remote.someremote.pushurl >actual && | |
1163 | echo "YYY" >>actual && | |
1164 | git config --get-all remote.someremote.url >>actual && | |
1165 | cmp expect actual | |
433f2be1 IL |
1166 | ' |
1167 | ||
1168 | test_expect_success 'remote set-url --delete baz' ' | |
433f2be1 IL |
1169 | test_must_fail git remote set-url --delete someremote baz && |
1170 | echo "YYY" >expect && | |
1171 | echo baz >>expect && | |
1172 | test_must_fail git config --get-all remote.someremote.pushurl >actual && | |
1173 | echo "YYY" >>actual && | |
1174 | git config --get-all remote.someremote.url >>actual && | |
1175 | cmp expect actual | |
433f2be1 IL |
1176 | ' |
1177 | ||
1178 | test_expect_success 'remote set-url --add ccc' ' | |
433f2be1 IL |
1179 | git remote set-url --add someremote ccc && |
1180 | echo "YYY" >expect && | |
1181 | echo baz >>expect && | |
1182 | echo ccc >>expect && | |
1183 | test_must_fail git config --get-all remote.someremote.pushurl >actual && | |
1184 | echo "YYY" >>actual && | |
1185 | git config --get-all remote.someremote.url >>actual && | |
1186 | cmp expect actual | |
433f2be1 IL |
1187 | ' |
1188 | ||
1189 | test_expect_success 'remote set-url --delete baz' ' | |
433f2be1 IL |
1190 | git remote set-url --delete someremote baz && |
1191 | echo "YYY" >expect && | |
1192 | echo ccc >>expect && | |
1193 | test_must_fail git config --get-all remote.someremote.pushurl >actual && | |
1194 | echo "YYY" >>actual && | |
1195 | git config --get-all remote.someremote.url >>actual && | |
1196 | cmp expect actual | |
433f2be1 IL |
1197 | ' |
1198 | ||
abf5f872 TR |
1199 | test_expect_success 'extra args: setup' ' |
1200 | # add a dummy origin so that this does not trigger failure | |
1201 | git remote add origin . | |
1202 | ' | |
1203 | ||
1204 | test_extra_arg () { | |
b17dd3f9 | 1205 | test_expect_success "extra args: $*" " |
abf5f872 | 1206 | test_must_fail git remote $* bogus_extra_arg 2>actual && |
1edbaac3 | 1207 | test_i18ngrep '^usage:' actual |
abf5f872 TR |
1208 | " |
1209 | } | |
1210 | ||
2d2e3d25 | 1211 | test_extra_arg add nick url |
abf5f872 TR |
1212 | test_extra_arg rename origin newname |
1213 | test_extra_arg remove origin | |
1214 | test_extra_arg set-head origin master | |
1215 | # set-branches takes any number of args | |
96f78d39 | 1216 | test_extra_arg get-url origin newurl |
abf5f872 | 1217 | test_extra_arg set-url origin newurl oldurl |
b17dd3f9 TR |
1218 | # show takes any number of args |
1219 | # prune takes any number of args | |
abf5f872 TR |
1220 | # update takes any number of args |
1221 | ||
b90c95d9 JS |
1222 | test_expect_success 'add remote matching the "insteadOf" URL' ' |
1223 | git config url.xyz@example.com.insteadOf backup && | |
1224 | git remote add backup xyz@example.com | |
1225 | ' | |
1226 | ||
433f2be1 | 1227 | test_done |