WIP
[git/mjg.git] / t / t5505-remote.sh
blobba8cf74dbb8c6f16515c8d189449714187a65542
1 #!/bin/sh
3 test_description='git remote porcelain-ish'
5 . ./test-lib.sh
7 setup_repository () {
8 mkdir "$1" && (
9 cd "$1" &&
10 git init &&
11 >file &&
12 git add file &&
13 test_tick &&
14 git commit -m "Initial" &&
15 git checkout -b side &&
16 >elif &&
17 git add elif &&
18 test_tick &&
19 git commit -m "Second" &&
20 git checkout master
24 tokens_match () {
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 -ne 's|^ \(.*\) tracked$|\1|p')
32 shift &&
33 tokens_match "$*" "$actual"
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"
44 test_expect_success setup '
46 setup_repository one &&
47 setup_repository two &&
49 cd two && git branch another
50 ) &&
51 git clone one test
55 test_expect_success C_LOCALE_OUTPUT 'remote information for the origin' '
57 cd test &&
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' '
66 cd test &&
67 git remote add -f second ../two &&
68 tokens_match "origin second" "$(git remote)" &&
69 check_tracking_branch second master side another &&
70 git for-each-ref "--format=%(refname)" refs/remotes |
71 sed -e "/^refs\/remotes\/origin\//d" \
72 -e "/^refs\/remotes\/second\//d" >actual &&
73 >expect &&
74 test_cmp expect actual
78 test_expect_success C_LOCALE_OUTPUT 'check remote tracking' '
80 cd test &&
81 check_remote_track origin master side &&
82 check_remote_track second master side another
86 test_expect_success 'remote forces tracking branches' '
88 cd test &&
89 case `git config remote.second.fetch` in
90 +*) true ;;
91 *) false ;;
92 esac
96 test_expect_success 'remove remote' '
98 cd test &&
99 git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
100 git remote rm second
104 test_expect_success C_LOCALE_OUTPUT 'remove remote' '
106 cd test &&
107 tokens_match origin "$(git remote)" &&
108 check_remote_track origin master side &&
109 git for-each-ref "--format=%(refname)" refs/remotes |
110 sed -e "/^refs\/remotes\/origin\//d" >actual &&
111 >expect &&
112 test_cmp expect actual
116 test_expect_success 'remove remote protects local branches' '
118 cd test &&
119 { cat >expect1 <<EOF
120 Note: A branch outside the refs/remotes/ hierarchy was not removed;
121 to delete it, use:
122 git branch -d master
124 } &&
125 { cat >expect2 <<EOF
126 Note: Some branches outside the refs/remotes/ hierarchy were not removed;
127 to delete them, use:
128 git branch -d foobranch
129 git branch -d master
131 } &&
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
145 cat > test/expect << EOF
146 * remote origin
147 URLs:
148 Fetch: $(pwd)/one
149 Push: $(pwd)/one
150 HEAD branch: master
151 Remote branches:
152 master new (next fetch will store in remotes/origin)
153 side tracked
154 Local branches configured for 'git pull':
155 ahead merges with remote master
156 master merges with remote master
157 octopus merges with remote topic-a
158 and with remote topic-b
159 and with remote topic-c
160 rebase rebases onto remote master
161 Local refs configured for 'git push':
162 master pushes to master (local out of date)
163 master pushes to upstream (create)
164 * remote two
165 URLs:
166 Fetch: ../two
167 Push: ../three
168 HEAD branch (remote HEAD is ambiguous, may be one of the following):
169 another
170 master
171 Local refs configured for 'git push':
172 ahead forces to master (fast-forwardable)
173 master pushes to another (up to date)
176 test_expect_success 'show' '
177 (cd test &&
178 git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream &&
179 git fetch &&
180 git checkout -b ahead origin/master &&
181 echo 1 >> file &&
182 test_tick &&
183 git commit -m update file &&
184 git checkout master &&
185 git branch --track octopus origin/master &&
186 git branch --track rebase origin/master &&
187 git branch -d -r origin/master &&
188 git config --add remote.two.url ../two &&
189 git config --add remote.two.pushurl ../three &&
190 git config branch.rebase.rebase true &&
191 git config branch.octopus.merge "topic-a topic-b topic-c" &&
192 (cd ../one &&
193 echo 1 > file &&
194 test_tick &&
195 git commit -m update file) &&
196 git config --add remote.origin.push : &&
197 git config --add remote.origin.push refs/heads/master:refs/heads/upstream &&
198 git config --add remote.origin.push +refs/tags/lastbackup &&
199 git config --add remote.two.push +refs/heads/ahead:refs/heads/master &&
200 git config --add remote.two.push refs/heads/master:refs/heads/another &&
201 git remote show origin two > output &&
202 git branch -d rebase octopus &&
203 test_i18ncmp expect output)
206 cat > test/expect << EOF
207 * remote origin
208 URLs:
209 Fetch: $(pwd)/one
210 Push: $(pwd)/one
211 HEAD branch: (not queried)
212 Remote branches: (status not queried)
213 master
214 side
215 Local branches configured for 'git pull':
216 ahead merges with remote master
217 master merges with remote master
218 Local refs configured for 'git push' (status not queried):
219 (matching) pushes to (matching)
220 refs/heads/master pushes to refs/heads/upstream
221 refs/tags/lastbackup forces to refs/tags/lastbackup
224 test_expect_success 'show -n' '
225 (mv one one.unreachable &&
226 cd test &&
227 git remote show -n origin > output &&
228 mv ../one.unreachable ../one &&
229 test_i18ncmp expect output)
232 test_expect_success 'prune' '
233 (cd one &&
234 git branch -m side side2) &&
235 (cd test &&
236 git fetch origin &&
237 git remote prune origin &&
238 git rev-parse refs/remotes/origin/side2 &&
239 test_must_fail git rev-parse refs/remotes/origin/side)
242 test_expect_success 'set-head --delete' '
243 (cd test &&
244 git symbolic-ref refs/remotes/origin/HEAD &&
245 git remote set-head --delete origin &&
246 test_must_fail git symbolic-ref refs/remotes/origin/HEAD)
249 test_expect_success 'set-head --auto' '
250 (cd test &&
251 git remote set-head --auto origin &&
252 echo refs/remotes/origin/master >expect &&
253 git symbolic-ref refs/remotes/origin/HEAD >output &&
254 test_cmp expect output
258 cat >test/expect <<EOF
259 error: Multiple remote HEAD branches. Please choose one explicitly with:
260 git remote set-head two another
261 git remote set-head two master
264 test_expect_success 'set-head --auto fails w/multiple HEADs' '
265 (cd test &&
266 test_must_fail git remote set-head --auto two >output 2>&1 &&
267 test_i18ncmp expect output)
270 cat >test/expect <<EOF
271 refs/remotes/origin/side2
274 test_expect_success 'set-head explicit' '
275 (cd test &&
276 git remote set-head origin side2 &&
277 git symbolic-ref refs/remotes/origin/HEAD >output &&
278 git remote set-head origin master &&
279 test_cmp expect output)
282 cat > test/expect << EOF
283 Pruning origin
284 URL: $(pwd)/one
285 * [would prune] origin/side2
288 test_expect_success 'prune --dry-run' '
289 (cd one &&
290 git branch -m side2 side) &&
291 (cd test &&
292 git remote prune --dry-run origin > output &&
293 git rev-parse refs/remotes/origin/side2 &&
294 test_must_fail git rev-parse refs/remotes/origin/side &&
295 (cd ../one &&
296 git branch -m side side2) &&
297 test_i18ncmp expect output)
300 test_expect_success 'add --mirror && prune' '
301 (mkdir mirror &&
302 cd mirror &&
303 git init --bare &&
304 git remote add --mirror -f origin ../one) &&
305 (cd one &&
306 git branch -m side2 side) &&
307 (cd mirror &&
308 git rev-parse --verify refs/heads/side2 &&
309 test_must_fail git rev-parse --verify refs/heads/side &&
310 git fetch origin &&
311 git remote prune origin &&
312 test_must_fail git rev-parse --verify refs/heads/side2 &&
313 git rev-parse --verify refs/heads/side)
316 test_expect_success 'add --mirror=fetch' '
317 mkdir mirror-fetch &&
318 git init mirror-fetch/parent &&
319 (cd mirror-fetch/parent &&
320 test_commit one) &&
321 git init --bare mirror-fetch/child &&
322 (cd mirror-fetch/child &&
323 git remote add --mirror=fetch -f parent ../parent)
326 test_expect_success 'fetch mirrors act as mirrors during fetch' '
327 (cd mirror-fetch/parent &&
328 git branch new &&
329 git branch -m master renamed
330 ) &&
331 (cd mirror-fetch/child &&
332 git fetch parent &&
333 git rev-parse --verify refs/heads/new &&
334 git rev-parse --verify refs/heads/renamed
338 test_expect_success 'fetch mirrors can prune' '
339 (cd mirror-fetch/child &&
340 git remote prune parent &&
341 test_must_fail git rev-parse --verify refs/heads/master
345 test_expect_success 'fetch mirrors do not act as mirrors during push' '
346 (cd mirror-fetch/parent &&
347 git checkout HEAD^0
348 ) &&
349 (cd mirror-fetch/child &&
350 git branch -m renamed renamed2 &&
351 git push parent :
352 ) &&
353 (cd mirror-fetch/parent &&
354 git rev-parse --verify renamed &&
355 test_must_fail git rev-parse --verify refs/heads/renamed2
359 test_expect_success 'add fetch mirror with specific branches' '
360 git init --bare mirror-fetch/track &&
361 (cd mirror-fetch/track &&
362 git remote add --mirror=fetch -t heads/new parent ../parent
366 test_expect_success 'fetch mirror respects specific branches' '
367 (cd mirror-fetch/track &&
368 git fetch parent &&
369 git rev-parse --verify refs/heads/new &&
370 test_must_fail git rev-parse --verify refs/heads/renamed
374 test_expect_success 'add --mirror=push' '
375 mkdir mirror-push &&
376 git init --bare mirror-push/public &&
377 git init mirror-push/private &&
378 (cd mirror-push/private &&
379 test_commit one &&
380 git remote add --mirror=push public ../public
384 test_expect_success 'push mirrors act as mirrors during push' '
385 (cd mirror-push/private &&
386 git branch new &&
387 git branch -m master renamed &&
388 git push public
389 ) &&
390 (cd mirror-push/private &&
391 git rev-parse --verify refs/heads/new &&
392 git rev-parse --verify refs/heads/renamed &&
393 test_must_fail git rev-parse --verify refs/heads/master
397 test_expect_success 'push mirrors do not act as mirrors during fetch' '
398 (cd mirror-push/public &&
399 git branch -m renamed renamed2 &&
400 git symbolic-ref HEAD refs/heads/renamed2
401 ) &&
402 (cd mirror-push/private &&
403 git fetch public &&
404 git rev-parse --verify refs/heads/renamed &&
405 test_must_fail git rev-parse --verify refs/heads/renamed2
409 test_expect_success 'push mirrors do not allow you to specify refs' '
410 git init mirror-push/track &&
411 (cd mirror-push/track &&
412 test_must_fail git remote add --mirror=push -t new public ../public
416 test_expect_success 'add alt && prune' '
417 (mkdir alttst &&
418 cd alttst &&
419 git init &&
420 git remote add -f origin ../one &&
421 git config remote.alt.url ../one &&
422 git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*") &&
423 (cd one &&
424 git branch -m side side2) &&
425 (cd alttst &&
426 git rev-parse --verify refs/remotes/origin/side &&
427 test_must_fail git rev-parse --verify refs/remotes/origin/side2 &&
428 git fetch alt &&
429 git remote prune alt &&
430 test_must_fail git rev-parse --verify refs/remotes/origin/side &&
431 git rev-parse --verify refs/remotes/origin/side2)
434 cat >test/expect <<\EOF
435 some-tag
438 test_expect_success 'add with reachable tags (default)' '
439 (cd one &&
440 >foobar &&
441 git add foobar &&
442 git commit -m "Foobar" &&
443 git tag -a -m "Foobar tag" foobar-tag &&
444 git reset --hard HEAD~1 &&
445 git tag -a -m "Some tag" some-tag) &&
446 (mkdir add-tags &&
447 cd add-tags &&
448 git init &&
449 git remote add -f origin ../one &&
450 git tag -l some-tag >../test/output &&
451 git tag -l foobar-tag >>../test/output &&
452 test_must_fail git config remote.origin.tagopt) &&
453 test_cmp test/expect test/output
456 cat >test/expect <<\EOF
457 some-tag
458 foobar-tag
459 --tags
462 test_expect_success 'add --tags' '
463 (rm -rf add-tags &&
464 mkdir add-tags &&
465 cd add-tags &&
466 git init &&
467 git remote add -f --tags origin ../one &&
468 git tag -l some-tag >../test/output &&
469 git tag -l foobar-tag >>../test/output &&
470 git config remote.origin.tagopt >>../test/output) &&
471 test_cmp test/expect test/output
474 cat >test/expect <<\EOF
475 --no-tags
478 test_expect_success 'add --no-tags' '
479 (rm -rf add-tags &&
480 mkdir add-no-tags &&
481 cd add-no-tags &&
482 git init &&
483 git remote add -f --no-tags origin ../one &&
484 git tag -l some-tag >../test/output &&
485 git tag -l foobar-tag >../test/output &&
486 git config remote.origin.tagopt >>../test/output) &&
487 (cd one &&
488 git tag -d some-tag foobar-tag) &&
489 test_cmp test/expect test/output
492 test_expect_success 'reject --no-no-tags' '
493 (cd add-no-tags &&
494 test_must_fail git remote add -f --no-no-tags neworigin ../one)
497 cat > one/expect << EOF
498 apis/master
499 apis/side
500 drosophila/another
501 drosophila/master
502 drosophila/side
505 test_expect_success 'update' '
507 (cd one &&
508 git remote add drosophila ../two &&
509 git remote add apis ../mirror &&
510 git remote update &&
511 git branch -r > output &&
512 test_cmp expect output)
516 cat > one/expect << EOF
517 drosophila/another
518 drosophila/master
519 drosophila/side
520 manduca/master
521 manduca/side
522 megaloprepus/master
523 megaloprepus/side
526 test_expect_success 'update with arguments' '
528 (cd one &&
529 for b in $(git branch -r)
531 git branch -r -d $b || break
532 done &&
533 git remote add manduca ../mirror &&
534 git remote add megaloprepus ../mirror &&
535 git config remotes.phobaeticus "drosophila megaloprepus" &&
536 git config remotes.titanus manduca &&
537 git remote update phobaeticus titanus &&
538 git branch -r > output &&
539 test_cmp expect output)
543 test_expect_success 'update --prune' '
545 (cd one &&
546 git branch -m side2 side3) &&
547 (cd test &&
548 git remote update --prune &&
549 (cd ../one && git branch -m side3 side2) &&
550 git rev-parse refs/remotes/origin/side3 &&
551 test_must_fail git rev-parse refs/remotes/origin/side2)
554 cat > one/expect << EOF
555 apis/master
556 apis/side
557 manduca/master
558 manduca/side
559 megaloprepus/master
560 megaloprepus/side
563 test_expect_success 'update default' '
565 (cd one &&
566 for b in $(git branch -r)
568 git branch -r -d $b || break
569 done &&
570 git config remote.drosophila.skipDefaultUpdate true &&
571 git remote update default &&
572 git branch -r > output &&
573 test_cmp expect output)
577 cat > one/expect << EOF
578 drosophila/another
579 drosophila/master
580 drosophila/side
583 test_expect_success 'update default (overridden, with funny whitespace)' '
585 (cd one &&
586 for b in $(git branch -r)
588 git branch -r -d $b || break
589 done &&
590 git config remotes.default "$(printf "\t drosophila \n")" &&
591 git remote update default &&
592 git branch -r > output &&
593 test_cmp expect output)
597 test_expect_success 'update (with remotes.default defined)' '
599 (cd one &&
600 for b in $(git branch -r)
602 git branch -r -d $b || break
603 done &&
604 git config remotes.default "drosophila" &&
605 git remote update &&
606 git branch -r > output &&
607 test_cmp expect output)
611 test_expect_success '"remote show" does not show symbolic refs' '
613 git clone one three &&
614 (cd three &&
615 git remote show origin > output &&
616 ! grep "^ *HEAD$" < output &&
617 ! grep -i stale < output)
621 test_expect_success 'reject adding remote with an invalid name' '
623 test_must_fail git remote add some:url desired-name
627 # The first three test if the tracking branches are properly renamed,
628 # the last two ones check if the config is updated.
630 test_expect_success 'rename a remote' '
632 git clone one four &&
633 (cd four &&
634 git remote rename origin upstream &&
635 rmdir .git/refs/remotes/origin &&
636 test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" &&
637 test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" &&
638 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" &&
639 test "$(git config branch.master.remote)" = "upstream")
643 test_expect_success 'rename does not update a non-default fetch refspec' '
645 git clone one four.one &&
646 (cd four.one &&
647 git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* &&
648 git remote rename origin upstream &&
649 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*" &&
650 git rev-parse -q origin/master)
654 test_expect_success 'rename a remote with name part of fetch spec' '
656 git clone one four.two &&
657 (cd four.two &&
658 git remote rename origin remote &&
659 git remote rename remote upstream &&
660 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*")
664 test_expect_success 'rename a remote with name prefix of other remote' '
666 git clone one four.three &&
667 (cd four.three &&
668 git remote add o git://example.com/repo.git &&
669 git remote rename o upstream &&
670 test "$(git rev-parse origin/master)" = "$(git rev-parse master)")
674 cat > remotes_origin << EOF
675 URL: $(pwd)/one
676 Push: refs/heads/master:refs/heads/upstream
677 Pull: refs/heads/master:refs/heads/origin
680 test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
681 git clone one five &&
682 origin_url=$(pwd)/one &&
683 (cd five &&
684 git remote remove origin &&
685 mkdir -p .git/remotes &&
686 cat ../remotes_origin > .git/remotes/origin &&
687 git remote rename origin origin &&
688 ! test -f .git/remotes/origin &&
689 test "$(git config remote.origin.url)" = "$origin_url" &&
690 test "$(git config remote.origin.push)" = "refs/heads/master:refs/heads/upstream" &&
691 test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin")
694 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
695 git clone one six &&
696 origin_url=$(pwd)/one &&
697 (cd six &&
698 git remote rm origin &&
699 echo "$origin_url" > .git/branches/origin &&
700 git remote rename origin origin &&
701 ! test -f .git/branches/origin &&
702 test "$(git config remote.origin.url)" = "$origin_url" &&
703 test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin")
706 test_expect_success 'remote prune to cause a dangling symref' '
707 git clone one seven &&
709 cd one &&
710 git checkout side2 &&
711 git branch -D master
712 ) &&
714 cd seven &&
715 git remote prune origin
716 ) >err 2>&1 &&
717 test_i18ngrep "has become dangling" err &&
719 : And the dangling symref will not cause other annoying errors &&
721 cd seven &&
722 git branch -a
723 ) 2>err &&
724 ! grep "points nowhere" err &&
726 cd seven &&
727 test_must_fail git branch nomore origin
728 ) 2>err &&
729 grep "dangling symref" err
732 test_expect_success 'show empty remote' '
734 test_create_repo empty &&
735 git clone empty empty-clone &&
737 cd empty-clone &&
738 git remote show origin
742 test_expect_success 'remote set-branches requires a remote' '
743 test_must_fail git remote set-branches &&
744 test_must_fail git remote set-branches --add
747 test_expect_success 'remote set-branches' '
748 echo "+refs/heads/*:refs/remotes/scratch/*" >expect.initial &&
749 sort <<-\EOF >expect.add &&
750 +refs/heads/*:refs/remotes/scratch/*
751 +refs/heads/other:refs/remotes/scratch/other
753 sort <<-\EOF >expect.replace &&
754 +refs/heads/maint:refs/remotes/scratch/maint
755 +refs/heads/master:refs/remotes/scratch/master
756 +refs/heads/next:refs/remotes/scratch/next
758 sort <<-\EOF >expect.add-two &&
759 +refs/heads/maint:refs/remotes/scratch/maint
760 +refs/heads/master:refs/remotes/scratch/master
761 +refs/heads/next:refs/remotes/scratch/next
762 +refs/heads/pu:refs/remotes/scratch/pu
763 +refs/heads/t/topic:refs/remotes/scratch/t/topic
765 sort <<-\EOF >expect.setup-ffonly &&
766 refs/heads/master:refs/remotes/scratch/master
767 +refs/heads/next:refs/remotes/scratch/next
769 sort <<-\EOF >expect.respect-ffonly &&
770 refs/heads/master:refs/remotes/scratch/master
771 +refs/heads/next:refs/remotes/scratch/next
772 +refs/heads/pu:refs/remotes/scratch/pu
775 git clone .git/ setbranches &&
777 cd setbranches &&
778 git remote rename origin scratch &&
779 git config --get-all remote.scratch.fetch >config-result &&
780 sort <config-result >../actual.initial &&
782 git remote set-branches scratch --add other &&
783 git config --get-all remote.scratch.fetch >config-result &&
784 sort <config-result >../actual.add &&
786 git remote set-branches scratch maint master next &&
787 git config --get-all remote.scratch.fetch >config-result &&
788 sort <config-result >../actual.replace &&
790 git remote set-branches --add scratch pu t/topic &&
791 git config --get-all remote.scratch.fetch >config-result &&
792 sort <config-result >../actual.add-two &&
794 git config --unset-all remote.scratch.fetch &&
795 git config remote.scratch.fetch \
796 refs/heads/master:refs/remotes/scratch/master &&
797 git config --add remote.scratch.fetch \
798 +refs/heads/next:refs/remotes/scratch/next &&
799 git config --get-all remote.scratch.fetch >config-result &&
800 sort <config-result >../actual.setup-ffonly &&
802 git remote set-branches --add scratch pu &&
803 git config --get-all remote.scratch.fetch >config-result &&
804 sort <config-result >../actual.respect-ffonly
805 ) &&
806 test_cmp expect.initial actual.initial &&
807 test_cmp expect.add actual.add &&
808 test_cmp expect.replace actual.replace &&
809 test_cmp expect.add-two actual.add-two &&
810 test_cmp expect.setup-ffonly actual.setup-ffonly &&
811 test_cmp expect.respect-ffonly actual.respect-ffonly
814 test_expect_success 'remote set-branches with --mirror' '
815 echo "+refs/*:refs/*" >expect.initial &&
816 echo "+refs/heads/master:refs/heads/master" >expect.replace &&
817 git clone --mirror .git/ setbranches-mirror &&
819 cd setbranches-mirror &&
820 git remote rename origin scratch &&
821 git config --get-all remote.scratch.fetch >../actual.initial &&
823 git remote set-branches scratch heads/master &&
824 git config --get-all remote.scratch.fetch >../actual.replace
825 ) &&
826 test_cmp expect.initial actual.initial &&
827 test_cmp expect.replace actual.replace
830 test_expect_success 'new remote' '
831 git remote add someremote foo &&
832 echo foo >expect &&
833 git config --get-all remote.someremote.url >actual &&
834 cmp expect actual
837 test_expect_success 'remote set-url bar' '
838 git remote set-url someremote bar &&
839 echo bar >expect &&
840 git config --get-all remote.someremote.url >actual &&
841 cmp expect actual
844 test_expect_success 'remote set-url baz bar' '
845 git remote set-url someremote baz bar &&
846 echo baz >expect &&
847 git config --get-all remote.someremote.url >actual &&
848 cmp expect actual
851 test_expect_success 'remote set-url zot bar' '
852 test_must_fail git remote set-url someremote zot bar &&
853 echo baz >expect &&
854 git config --get-all remote.someremote.url >actual &&
855 cmp expect actual
858 test_expect_success 'remote set-url --push zot baz' '
859 test_must_fail git remote set-url --push someremote zot baz &&
860 echo "YYY" >expect &&
861 echo baz >>expect &&
862 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
863 echo "YYY" >>actual &&
864 git config --get-all remote.someremote.url >>actual &&
865 cmp expect actual
868 test_expect_success 'remote set-url --push zot' '
869 git remote set-url --push someremote zot &&
870 echo zot >expect &&
871 echo "YYY" >>expect &&
872 echo baz >>expect &&
873 git config --get-all remote.someremote.pushurl >actual &&
874 echo "YYY" >>actual &&
875 git config --get-all remote.someremote.url >>actual &&
876 cmp expect actual
879 test_expect_success 'remote set-url --push qux zot' '
880 git remote set-url --push someremote qux zot &&
881 echo qux >expect &&
882 echo "YYY" >>expect &&
883 echo baz >>expect &&
884 git config --get-all remote.someremote.pushurl >actual &&
885 echo "YYY" >>actual &&
886 git config --get-all remote.someremote.url >>actual &&
887 cmp expect actual
890 test_expect_success 'remote set-url --push foo qu+x' '
891 git remote set-url --push someremote foo qu+x &&
892 echo foo >expect &&
893 echo "YYY" >>expect &&
894 echo baz >>expect &&
895 git config --get-all remote.someremote.pushurl >actual &&
896 echo "YYY" >>actual &&
897 git config --get-all remote.someremote.url >>actual &&
898 cmp expect actual
901 test_expect_success 'remote set-url --push --add aaa' '
902 git remote set-url --push --add someremote aaa &&
903 echo foo >expect &&
904 echo aaa >>expect &&
905 echo "YYY" >>expect &&
906 echo baz >>expect &&
907 git config --get-all remote.someremote.pushurl >actual &&
908 echo "YYY" >>actual &&
909 git config --get-all remote.someremote.url >>actual &&
910 cmp expect actual
913 test_expect_success 'remote set-url --push bar aaa' '
914 git remote set-url --push someremote bar aaa &&
915 echo foo >expect &&
916 echo bar >>expect &&
917 echo "YYY" >>expect &&
918 echo baz >>expect &&
919 git config --get-all remote.someremote.pushurl >actual &&
920 echo "YYY" >>actual &&
921 git config --get-all remote.someremote.url >>actual &&
922 cmp expect actual
925 test_expect_success 'remote set-url --push --delete bar' '
926 git remote set-url --push --delete someremote bar &&
927 echo foo >expect &&
928 echo "YYY" >>expect &&
929 echo baz >>expect &&
930 git config --get-all remote.someremote.pushurl >actual &&
931 echo "YYY" >>actual &&
932 git config --get-all remote.someremote.url >>actual &&
933 cmp expect actual
936 test_expect_success 'remote set-url --push --delete foo' '
937 git remote set-url --push --delete someremote foo &&
938 echo "YYY" >expect &&
939 echo baz >>expect &&
940 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
941 echo "YYY" >>actual &&
942 git config --get-all remote.someremote.url >>actual &&
943 cmp expect actual
946 test_expect_success 'remote set-url --add bbb' '
947 git remote set-url --add someremote bbb &&
948 echo "YYY" >expect &&
949 echo baz >>expect &&
950 echo bbb >>expect &&
951 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
952 echo "YYY" >>actual &&
953 git config --get-all remote.someremote.url >>actual &&
954 cmp expect actual
957 test_expect_success 'remote set-url --delete .*' '
958 test_must_fail git remote set-url --delete someremote .\* &&
959 echo "YYY" >expect &&
960 echo baz >>expect &&
961 echo bbb >>expect &&
962 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
963 echo "YYY" >>actual &&
964 git config --get-all remote.someremote.url >>actual &&
965 cmp expect actual
968 test_expect_success 'remote set-url --delete bbb' '
969 git remote set-url --delete someremote bbb &&
970 echo "YYY" >expect &&
971 echo baz >>expect &&
972 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
973 echo "YYY" >>actual &&
974 git config --get-all remote.someremote.url >>actual &&
975 cmp expect actual
978 test_expect_success 'remote set-url --delete baz' '
979 test_must_fail git remote set-url --delete someremote baz &&
980 echo "YYY" >expect &&
981 echo baz >>expect &&
982 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
983 echo "YYY" >>actual &&
984 git config --get-all remote.someremote.url >>actual &&
985 cmp expect actual
988 test_expect_success 'remote set-url --add ccc' '
989 git remote set-url --add someremote ccc &&
990 echo "YYY" >expect &&
991 echo baz >>expect &&
992 echo ccc >>expect &&
993 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
994 echo "YYY" >>actual &&
995 git config --get-all remote.someremote.url >>actual &&
996 cmp expect actual
999 test_expect_success 'remote set-url --delete baz' '
1000 git remote set-url --delete someremote baz &&
1001 echo "YYY" >expect &&
1002 echo ccc >>expect &&
1003 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1004 echo "YYY" >>actual &&
1005 git config --get-all remote.someremote.url >>actual &&
1006 cmp expect actual
1009 test_done