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