3 test_description='git remote porcelain-ish'
14 git commit -m "Initial" &&
15 git checkout -b side &&
19 git commit -m "Second" &&
25 echo "$1" | tr ' ' '\012' | sort | sed -e '/^$/d' >expect &&
26 echo "$2" | tr ' ' '\012' | sort | sed -e '/^$/d' >actual &&
27 test_cmp expect actual
30 check_remote_track () {
31 actual=$(git remote show "$1" | sed -ne 's|^ \(.*\) tracked$|\1|p')
33 tokens_match "$*" "$actual"
36 check_tracking_branch () {
38 r=$(git for-each-ref "--format=%(refname)" |
39 sed -ne "s|^refs/remotes/$1/||p") &&
41 tokens_match "$*" "$r"
44 test_expect_success setup '
45 setup_repository one &&
46 setup_repository two &&
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
59 test_expect_success C_LOCALE_OUTPUT 'remote information for the origin' '
62 tokens_match origin "$(git remote)" &&
63 check_remote_track origin master side &&
64 check_tracking_branch origin HEAD master side
68 test_expect_success 'add another remote' '
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 &&
78 test_cmp expect actual
82 test_expect_success C_LOCALE_OUTPUT 'check remote-tracking' '
85 check_remote_track origin master side &&
86 check_remote_track second master side another
90 test_expect_success 'remote forces tracking branches' '
93 case $(git config remote.second.fetch) in
100 test_expect_success 'remove remote' '
103 git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
108 test_expect_success C_LOCALE_OUTPUT 'remove remote' '
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 &&
116 test_cmp expect actual
120 test_expect_success 'remove remote protects local branches' '
123 cat >expect1 <<-\EOF &&
124 Note: A branch outside the refs/remotes/ hierarchy was not removed;
128 cat >expect2 <<-\EOF &&
129 Note: Some branches outside the refs/remotes/ hierarchy were not removed;
131 git branch -d foobranch
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 &&
142 test_i18ncmp expect1 actual1 &&
143 test_i18ncmp expect2 actual2
147 test_expect_success 'remove errors out early when deleting non-existent branch' '
150 echo "fatal: No such remote: foo" >expect &&
151 test_must_fail git remote rm foo 2>actual &&
152 test_i18ncmp expect actual
156 test_expect_success 'rename errors out early when deleting non-existent branch' '
159 echo "fatal: No such remote: foo" >expect &&
160 test_must_fail git remote rename foo bar 2>actual &&
161 test_i18ncmp expect actual
165 test_expect_success 'add existing foreign_vcs remote' '
166 test_config remote.foo.vcs bar &&
167 echo "fatal: remote foo already exists." >expect &&
168 test_must_fail git remote add foo bar 2>actual &&
169 test_i18ncmp expect actual
172 test_expect_success 'add existing foreign_vcs remote' '
173 test_config remote.foo.vcs bar &&
174 test_config remote.bar.vcs bar &&
175 echo "fatal: remote bar already exists." >expect &&
176 test_must_fail git remote rename foo bar 2>actual &&
177 test_i18ncmp expect actual
180 cat >test/expect <<EOF
182 Fetch URL: $(pwd)/one
186 master new (next fetch will store in remotes/origin)
188 Local branches configured for 'git pull':
189 ahead merges with remote master
190 master merges with remote master
191 octopus merges with remote topic-a
192 and with remote topic-b
193 and with remote topic-c
194 rebase rebases onto remote master
195 Local refs configured for 'git push':
196 master pushes to master (local out of date)
197 master pushes to upstream (create)
202 Local refs configured for 'git push':
203 ahead forces to master (fast-forwardable)
204 master pushes to another (up to date)
207 test_expect_success 'show' '
210 git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream &&
212 git checkout -b ahead origin/master &&
215 git commit -m update file &&
216 git checkout master &&
217 git branch --track octopus origin/master &&
218 git branch --track rebase origin/master &&
219 git branch -d -r origin/master &&
220 git config --add remote.two.url ../two &&
221 git config --add remote.two.pushurl ../three &&
222 git config branch.rebase.rebase true &&
223 git config branch.octopus.merge "topic-a topic-b topic-c" &&
228 git commit -m update file
230 git config --add remote.origin.push : &&
231 git config --add remote.origin.push refs/heads/master:refs/heads/upstream &&
232 git config --add remote.origin.push +refs/tags/lastbackup &&
233 git config --add remote.two.push +refs/heads/ahead:refs/heads/master &&
234 git config --add remote.two.push refs/heads/master:refs/heads/another &&
235 git remote show origin two >output &&
236 git branch -d rebase octopus &&
237 test_i18ncmp expect output
241 cat >test/expect <<EOF
243 Fetch URL: $(pwd)/one
245 HEAD branch: (not queried)
246 Remote branches: (status not queried)
249 Local branches configured for 'git pull':
250 ahead merges with remote master
251 master merges with remote master
252 Local refs configured for 'git push' (status not queried):
253 (matching) pushes to (matching)
254 refs/heads/master pushes to refs/heads/upstream
255 refs/tags/lastbackup forces to refs/tags/lastbackup
258 test_expect_success 'show -n' '
259 mv one one.unreachable &&
262 git remote show -n origin >output &&
263 mv ../one.unreachable ../one &&
264 test_i18ncmp expect output
268 test_expect_success 'prune' '
271 git branch -m side side2
276 git remote prune origin &&
277 git rev-parse refs/remotes/origin/side2 &&
278 test_must_fail git rev-parse refs/remotes/origin/side
282 test_expect_success 'set-head --delete' '
285 git symbolic-ref refs/remotes/origin/HEAD &&
286 git remote set-head --delete origin &&
287 test_must_fail git symbolic-ref refs/remotes/origin/HEAD
291 test_expect_success 'set-head --auto' '
294 git remote set-head --auto origin &&
295 echo refs/remotes/origin/master >expect &&
296 git symbolic-ref refs/remotes/origin/HEAD >output &&
297 test_cmp expect output
301 test_expect_success 'set-head --auto has no problem w/multiple HEADs' '
304 git fetch two "refs/heads/*:refs/remotes/two/*" &&
305 git remote set-head --auto two >output 2>&1 &&
306 echo "two/HEAD set to master" >expect &&
307 test_i18ncmp expect output
311 cat >test/expect <<\EOF
312 refs/remotes/origin/side2
315 test_expect_success 'set-head explicit' '
318 git remote set-head origin side2 &&
319 git symbolic-ref refs/remotes/origin/HEAD >output &&
320 git remote set-head origin master &&
321 test_cmp expect output
325 cat >test/expect <<EOF
328 * [would prune] origin/side2
331 test_expect_success 'prune --dry-run' '
334 git branch -m side2 side) &&
337 git remote prune --dry-run origin >output &&
338 git rev-parse refs/remotes/origin/side2 &&
339 test_must_fail git rev-parse refs/remotes/origin/side &&
342 git branch -m side side2) &&
343 test_i18ncmp expect output
347 test_expect_success 'add --mirror && prune' '
352 git remote add --mirror -f origin ../one
356 git branch -m side2 side
360 git rev-parse --verify refs/heads/side2 &&
361 test_must_fail git rev-parse --verify refs/heads/side &&
363 git remote prune origin &&
364 test_must_fail git rev-parse --verify refs/heads/side2 &&
365 git rev-parse --verify refs/heads/side
369 test_expect_success 'add --mirror=fetch' '
370 mkdir mirror-fetch &&
371 git init mirror-fetch/parent &&
373 cd mirror-fetch/parent &&
376 git init --bare mirror-fetch/child &&
378 cd mirror-fetch/child &&
379 git remote add --mirror=fetch -f parent ../parent
383 test_expect_success 'fetch mirrors act as mirrors during fetch' '
385 cd mirror-fetch/parent &&
387 git branch -m master renamed
390 cd mirror-fetch/child &&
392 git rev-parse --verify refs/heads/new &&
393 git rev-parse --verify refs/heads/renamed
397 test_expect_success 'fetch mirrors can prune' '
399 cd mirror-fetch/child &&
400 git remote prune parent &&
401 test_must_fail git rev-parse --verify refs/heads/master
405 test_expect_success 'fetch mirrors do not act as mirrors during push' '
407 cd mirror-fetch/parent &&
411 cd mirror-fetch/child &&
412 git branch -m renamed renamed2 &&
416 cd mirror-fetch/parent &&
417 git rev-parse --verify renamed &&
418 test_must_fail git rev-parse --verify refs/heads/renamed2
422 test_expect_success 'add fetch mirror with specific branches' '
423 git init --bare mirror-fetch/track &&
425 cd mirror-fetch/track &&
426 git remote add --mirror=fetch -t heads/new parent ../parent
430 test_expect_success 'fetch mirror respects specific branches' '
432 cd mirror-fetch/track &&
434 git rev-parse --verify refs/heads/new &&
435 test_must_fail git rev-parse --verify refs/heads/renamed
439 test_expect_success 'add --mirror=push' '
441 git init --bare mirror-push/public &&
442 git init mirror-push/private &&
444 cd mirror-push/private &&
446 git remote add --mirror=push public ../public
450 test_expect_success 'push mirrors act as mirrors during push' '
452 cd mirror-push/private &&
454 git branch -m master renamed &&
458 cd mirror-push/private &&
459 git rev-parse --verify refs/heads/new &&
460 git rev-parse --verify refs/heads/renamed &&
461 test_must_fail git rev-parse --verify refs/heads/master
465 test_expect_success 'push mirrors do not act as mirrors during fetch' '
467 cd mirror-push/public &&
468 git branch -m renamed renamed2 &&
469 git symbolic-ref HEAD refs/heads/renamed2
472 cd mirror-push/private &&
474 git rev-parse --verify refs/heads/renamed &&
475 test_must_fail git rev-parse --verify refs/heads/renamed2
479 test_expect_success 'push mirrors do not allow you to specify refs' '
480 git init mirror-push/track &&
482 cd mirror-push/track &&
483 test_must_fail git remote add --mirror=push -t new public ../public
487 test_expect_success 'add alt && prune' '
492 git remote add -f origin ../one &&
493 git config remote.alt.url ../one &&
494 git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*"
498 git branch -m side side2
502 git rev-parse --verify refs/remotes/origin/side &&
503 test_must_fail git rev-parse --verify refs/remotes/origin/side2 &&
505 git remote prune alt &&
506 test_must_fail git rev-parse --verify refs/remotes/origin/side &&
507 git rev-parse --verify refs/remotes/origin/side2
511 cat >test/expect <<\EOF
515 test_expect_success 'add with reachable tags (default)' '
520 git commit -m "Foobar" &&
521 git tag -a -m "Foobar tag" foobar-tag &&
522 git reset --hard HEAD~1 &&
523 git tag -a -m "Some tag" some-tag
529 git remote add -f origin ../one &&
530 git tag -l some-tag >../test/output &&
531 git tag -l foobar-tag >>../test/output &&
532 test_must_fail git config remote.origin.tagopt
534 test_cmp test/expect test/output
537 cat >test/expect <<\EOF
543 test_expect_success 'add --tags' '
549 git remote add -f --tags origin ../one &&
550 git tag -l some-tag >../test/output &&
551 git tag -l foobar-tag >>../test/output &&
552 git config remote.origin.tagopt >>../test/output
554 test_cmp test/expect test/output
557 cat >test/expect <<\EOF
561 test_expect_success 'add --no-tags' '
567 git remote add -f --no-tags origin ../one &&
568 git tag -l some-tag >../test/output &&
569 git tag -l foobar-tag >../test/output &&
570 git config remote.origin.tagopt >>../test/output
574 git tag -d some-tag foobar-tag
576 test_cmp test/expect test/output
579 test_expect_success 'reject --no-no-tags' '
582 test_must_fail git remote add -f --no-no-tags neworigin ../one
586 cat >one/expect <<\EOF
594 test_expect_success 'update' '
597 git remote add drosophila ../two &&
598 git remote add apis ../mirror &&
600 git branch -r >output &&
601 test_cmp expect output
605 cat >one/expect <<\EOF
615 test_expect_success 'update with arguments' '
618 for b in $(git branch -r)
620 git branch -r -d $b || exit 1
622 git remote add manduca ../mirror &&
623 git remote add megaloprepus ../mirror &&
624 git config remotes.phobaeticus "drosophila megaloprepus" &&
625 git config remotes.titanus manduca &&
626 git remote update phobaeticus titanus &&
627 git branch -r >output &&
628 test_cmp expect output
632 test_expect_success 'update --prune' '
635 git branch -m side2 side3
639 git remote update --prune &&
642 git branch -m side3 side2
644 git rev-parse refs/remotes/origin/side3 &&
645 test_must_fail git rev-parse refs/remotes/origin/side2
649 cat >one/expect <<-\EOF
658 test_expect_success 'update default' '
661 for b in $(git branch -r)
663 git branch -r -d $b || exit 1
665 git config remote.drosophila.skipDefaultUpdate true &&
666 git remote update default &&
667 git branch -r >output &&
668 test_cmp expect output
672 cat >one/expect <<\EOF
678 test_expect_success 'update default (overridden, with funny whitespace)' '
681 for b in $(git branch -r)
683 git branch -r -d $b || exit 1
685 git config remotes.default "$(printf "\t drosophila \n")" &&
686 git remote update default &&
687 git branch -r >output &&
688 test_cmp expect output
692 test_expect_success 'update (with remotes.default defined)' '
695 for b in $(git branch -r)
697 git branch -r -d $b || exit 1
699 git config remotes.default "drosophila" &&
701 git branch -r >output &&
702 test_cmp expect output
706 test_expect_success '"remote show" does not show symbolic refs' '
707 git clone one three &&
710 git remote show origin >output &&
711 ! grep "^ *HEAD$" < output &&
712 ! grep -i stale < output
716 test_expect_success 'reject adding remote with an invalid name' '
717 test_must_fail git remote add some:url desired-name
720 # The first three test if the tracking branches are properly renamed,
721 # the last two ones check if the config is updated.
723 test_expect_success 'rename a remote' '
724 git clone one four &&
727 git remote rename origin upstream &&
728 rmdir .git/refs/remotes/origin &&
729 test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" &&
730 test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" &&
731 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" &&
732 test "$(git config branch.master.remote)" = "upstream"
736 test_expect_success 'rename does not update a non-default fetch refspec' '
737 git clone one four.one &&
740 git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* &&
741 git remote rename origin upstream &&
742 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*" &&
743 git rev-parse -q origin/master
747 test_expect_success 'rename a remote with name part of fetch spec' '
748 git clone one four.two &&
751 git remote rename origin remote &&
752 git remote rename remote upstream &&
753 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*"
757 test_expect_success 'rename a remote with name prefix of other remote' '
758 git clone one four.three &&
761 git remote add o git://example.com/repo.git &&
762 git remote rename o upstream &&
763 test "$(git rev-parse origin/master)" = "$(git rev-parse master)"
767 test_expect_success 'rename succeeds with existing remote.<target>.prune' '
768 git clone one four.four &&
769 test_when_finished git config --global --unset remote.upstream.prune &&
770 git config --global remote.upstream.prune true &&
771 git -C four.four remote rename origin upstream
774 cat >remotes_origin <<EOF
776 Push: refs/heads/master:refs/heads/upstream
777 Push: refs/heads/next:refs/heads/upstream2
778 Pull: refs/heads/master:refs/heads/origin
779 Pull: refs/heads/next:refs/heads/origin2
782 test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
783 git clone one five &&
784 origin_url=$(pwd)/one &&
787 git remote remove origin &&
788 mkdir -p .git/remotes &&
789 cat ../remotes_origin >.git/remotes/origin &&
790 git remote rename origin origin &&
791 test_path_is_missing .git/remotes/origin &&
792 test "$(git config remote.origin.url)" = "$origin_url" &&
793 cat >push_expected <<-\EOF &&
794 refs/heads/master:refs/heads/upstream
795 refs/heads/next:refs/heads/upstream2
797 cat >fetch_expected <<-\EOF &&
798 refs/heads/master:refs/heads/origin
799 refs/heads/next:refs/heads/origin2
801 git config --get-all remote.origin.push >push_actual &&
802 git config --get-all remote.origin.fetch >fetch_actual &&
803 test_cmp push_expected push_actual &&
804 test_cmp fetch_expected fetch_actual
808 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
810 origin_url=$(pwd)/one &&
813 git remote rm origin &&
814 echo "$origin_url" >.git/branches/origin &&
815 git remote rename origin origin &&
816 test_path_is_missing .git/branches/origin &&
817 test "$(git config remote.origin.url)" = "$origin_url" &&
818 test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin" &&
819 test "$(git config remote.origin.push)" = "HEAD:refs/heads/master"
823 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' '
824 git clone one seven &&
827 git remote rm origin &&
828 echo "quux#foom" > .git/branches/origin &&
829 git remote rename origin origin &&
830 test_path_is_missing .git/branches/origin &&
831 test "$(git config remote.origin.url)" = "quux" &&
832 test "$(git config remote.origin.fetch)" = "refs/heads/foom:refs/heads/origin"
833 test "$(git config remote.origin.push)" = "HEAD:refs/heads/foom"
837 test_expect_success 'remote prune to cause a dangling symref' '
838 git clone one eight &&
841 git checkout side2 &&
846 git remote prune origin
848 test_i18ngrep "has become dangling" err &&
850 : And the dangling symref will not cause other annoying errors &&
855 ! grep "points nowhere" err &&
858 test_must_fail git branch nomore origin
860 grep "dangling symref" err
863 test_expect_success 'show empty remote' '
864 test_create_repo empty &&
865 git clone empty empty-clone &&
868 git remote show origin
872 test_expect_success 'remote set-branches requires a remote' '
873 test_must_fail git remote set-branches &&
874 test_must_fail git remote set-branches --add
877 test_expect_success 'remote set-branches' '
878 echo "+refs/heads/*:refs/remotes/scratch/*" >expect.initial &&
879 sort <<-\EOF >expect.add &&
880 +refs/heads/*:refs/remotes/scratch/*
881 +refs/heads/other:refs/remotes/scratch/other
883 sort <<-\EOF >expect.replace &&
884 +refs/heads/maint:refs/remotes/scratch/maint
885 +refs/heads/master:refs/remotes/scratch/master
886 +refs/heads/next:refs/remotes/scratch/next
888 sort <<-\EOF >expect.add-two &&
889 +refs/heads/maint:refs/remotes/scratch/maint
890 +refs/heads/master:refs/remotes/scratch/master
891 +refs/heads/next:refs/remotes/scratch/next
892 +refs/heads/pu:refs/remotes/scratch/pu
893 +refs/heads/t/topic:refs/remotes/scratch/t/topic
895 sort <<-\EOF >expect.setup-ffonly &&
896 refs/heads/master:refs/remotes/scratch/master
897 +refs/heads/next:refs/remotes/scratch/next
899 sort <<-\EOF >expect.respect-ffonly &&
900 refs/heads/master:refs/remotes/scratch/master
901 +refs/heads/next:refs/remotes/scratch/next
902 +refs/heads/pu:refs/remotes/scratch/pu
905 git clone .git/ setbranches &&
908 git remote rename origin scratch &&
909 git config --get-all remote.scratch.fetch >config-result &&
910 sort <config-result >../actual.initial &&
912 git remote set-branches scratch --add other &&
913 git config --get-all remote.scratch.fetch >config-result &&
914 sort <config-result >../actual.add &&
916 git remote set-branches scratch maint master next &&
917 git config --get-all remote.scratch.fetch >config-result &&
918 sort <config-result >../actual.replace &&
920 git remote set-branches --add scratch pu t/topic &&
921 git config --get-all remote.scratch.fetch >config-result &&
922 sort <config-result >../actual.add-two &&
924 git config --unset-all remote.scratch.fetch &&
925 git config remote.scratch.fetch \
926 refs/heads/master:refs/remotes/scratch/master &&
927 git config --add remote.scratch.fetch \
928 +refs/heads/next:refs/remotes/scratch/next &&
929 git config --get-all remote.scratch.fetch >config-result &&
930 sort <config-result >../actual.setup-ffonly &&
932 git remote set-branches --add scratch pu &&
933 git config --get-all remote.scratch.fetch >config-result &&
934 sort <config-result >../actual.respect-ffonly
936 test_cmp expect.initial actual.initial &&
937 test_cmp expect.add actual.add &&
938 test_cmp expect.replace actual.replace &&
939 test_cmp expect.add-two actual.add-two &&
940 test_cmp expect.setup-ffonly actual.setup-ffonly &&
941 test_cmp expect.respect-ffonly actual.respect-ffonly
944 test_expect_success 'remote set-branches with --mirror' '
945 echo "+refs/*:refs/*" >expect.initial &&
946 echo "+refs/heads/master:refs/heads/master" >expect.replace &&
947 git clone --mirror .git/ setbranches-mirror &&
949 cd setbranches-mirror &&
950 git remote rename origin scratch &&
951 git config --get-all remote.scratch.fetch >../actual.initial &&
953 git remote set-branches scratch heads/master &&
954 git config --get-all remote.scratch.fetch >../actual.replace
956 test_cmp expect.initial actual.initial &&
957 test_cmp expect.replace actual.replace
960 test_expect_success 'new remote' '
961 git remote add someremote foo &&
963 git config --get-all remote.someremote.url >actual &&
969 git remote get-url "$@" >actual &&
970 test_cmp expect actual
973 test_expect_success 'get-url on new remote' '
974 echo foo | get_url_test someremote &&
975 echo foo | get_url_test --all someremote &&
976 echo foo | get_url_test --push someremote &&
977 echo foo | get_url_test --push --all someremote
980 test_expect_success 'remote set-url with locked config' '
981 test_when_finished "rm -f .git/config.lock" &&
982 git config --get-all remote.someremote.url >expect &&
984 test_must_fail git remote set-url someremote baz &&
985 git config --get-all remote.someremote.url >actual &&
989 test_expect_success 'remote set-url bar' '
990 git remote set-url someremote bar &&
992 git config --get-all remote.someremote.url >actual &&
996 test_expect_success 'remote set-url baz bar' '
997 git remote set-url someremote baz bar &&
999 git config --get-all remote.someremote.url >actual &&
1003 test_expect_success 'remote set-url zot bar' '
1004 test_must_fail git remote set-url someremote zot bar &&
1006 git config --get-all remote.someremote.url >actual &&
1010 test_expect_success 'remote set-url --push zot baz' '
1011 test_must_fail git remote set-url --push someremote zot baz &&
1012 echo "YYY" >expect &&
1013 echo baz >>expect &&
1014 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1015 echo "YYY" >>actual &&
1016 git config --get-all remote.someremote.url >>actual &&
1020 test_expect_success 'remote set-url --push zot' '
1021 git remote set-url --push someremote zot &&
1023 echo "YYY" >>expect &&
1024 echo baz >>expect &&
1025 git config --get-all remote.someremote.pushurl >actual &&
1026 echo "YYY" >>actual &&
1027 git config --get-all remote.someremote.url >>actual &&
1031 test_expect_success 'get-url with different urls' '
1032 echo baz | get_url_test someremote &&
1033 echo baz | get_url_test --all someremote &&
1034 echo zot | get_url_test --push someremote &&
1035 echo zot | get_url_test --push --all someremote
1038 test_expect_success 'remote set-url --push qux zot' '
1039 git remote set-url --push someremote qux zot &&
1041 echo "YYY" >>expect &&
1042 echo baz >>expect &&
1043 git config --get-all remote.someremote.pushurl >actual &&
1044 echo "YYY" >>actual &&
1045 git config --get-all remote.someremote.url >>actual &&
1049 test_expect_success 'remote set-url --push foo qu+x' '
1050 git remote set-url --push someremote foo qu+x &&
1052 echo "YYY" >>expect &&
1053 echo baz >>expect &&
1054 git config --get-all remote.someremote.pushurl >actual &&
1055 echo "YYY" >>actual &&
1056 git config --get-all remote.someremote.url >>actual &&
1060 test_expect_success 'remote set-url --push --add aaa' '
1061 git remote set-url --push --add someremote aaa &&
1063 echo aaa >>expect &&
1064 echo "YYY" >>expect &&
1065 echo baz >>expect &&
1066 git config --get-all remote.someremote.pushurl >actual &&
1067 echo "YYY" >>actual &&
1068 git config --get-all remote.someremote.url >>actual &&
1072 test_expect_success 'get-url on multi push remote' '
1073 echo foo | get_url_test --push someremote &&
1074 get_url_test --push --all someremote <<-\EOF
1080 test_expect_success 'remote set-url --push bar aaa' '
1081 git remote set-url --push someremote bar aaa &&
1083 echo bar >>expect &&
1084 echo "YYY" >>expect &&
1085 echo baz >>expect &&
1086 git config --get-all remote.someremote.pushurl >actual &&
1087 echo "YYY" >>actual &&
1088 git config --get-all remote.someremote.url >>actual &&
1092 test_expect_success 'remote set-url --push --delete bar' '
1093 git remote set-url --push --delete someremote bar &&
1095 echo "YYY" >>expect &&
1096 echo baz >>expect &&
1097 git config --get-all remote.someremote.pushurl >actual &&
1098 echo "YYY" >>actual &&
1099 git config --get-all remote.someremote.url >>actual &&
1103 test_expect_success 'remote set-url --push --delete foo' '
1104 git remote set-url --push --delete someremote foo &&
1105 echo "YYY" >expect &&
1106 echo baz >>expect &&
1107 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1108 echo "YYY" >>actual &&
1109 git config --get-all remote.someremote.url >>actual &&
1113 test_expect_success 'remote set-url --add bbb' '
1114 git remote set-url --add someremote bbb &&
1115 echo "YYY" >expect &&
1116 echo baz >>expect &&
1117 echo bbb >>expect &&
1118 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1119 echo "YYY" >>actual &&
1120 git config --get-all remote.someremote.url >>actual &&
1124 test_expect_success 'get-url on multi fetch remote' '
1125 echo baz | get_url_test someremote &&
1126 get_url_test --all someremote <<-\EOF
1132 test_expect_success 'remote set-url --delete .*' '
1133 test_must_fail git remote set-url --delete someremote .\* &&
1134 echo "YYY" >expect &&
1135 echo baz >>expect &&
1136 echo bbb >>expect &&
1137 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1138 echo "YYY" >>actual &&
1139 git config --get-all remote.someremote.url >>actual &&
1143 test_expect_success 'remote set-url --delete bbb' '
1144 git remote set-url --delete someremote bbb &&
1145 echo "YYY" >expect &&
1146 echo baz >>expect &&
1147 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1148 echo "YYY" >>actual &&
1149 git config --get-all remote.someremote.url >>actual &&
1153 test_expect_success 'remote set-url --delete baz' '
1154 test_must_fail git remote set-url --delete someremote baz &&
1155 echo "YYY" >expect &&
1156 echo baz >>expect &&
1157 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1158 echo "YYY" >>actual &&
1159 git config --get-all remote.someremote.url >>actual &&
1163 test_expect_success 'remote set-url --add ccc' '
1164 git remote set-url --add someremote ccc &&
1165 echo "YYY" >expect &&
1166 echo baz >>expect &&
1167 echo ccc >>expect &&
1168 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1169 echo "YYY" >>actual &&
1170 git config --get-all remote.someremote.url >>actual &&
1174 test_expect_success 'remote set-url --delete baz' '
1175 git remote set-url --delete someremote baz &&
1176 echo "YYY" >expect &&
1177 echo ccc >>expect &&
1178 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1179 echo "YYY" >>actual &&
1180 git config --get-all remote.someremote.url >>actual &&
1184 test_expect_success 'extra args: setup' '
1185 # add a dummy origin so that this does not trigger failure
1186 git remote add origin .
1190 test_expect_success "extra args: $*" "
1191 test_must_fail git remote $* bogus_extra_arg 2>actual &&
1192 test_i18ngrep '^usage:' actual
1196 test_extra_arg add nick url
1197 test_extra_arg rename origin newname
1198 test_extra_arg remove origin
1199 test_extra_arg set-head origin master
1200 # set-branches takes any number of args
1201 test_extra_arg get-url origin newurl
1202 test_extra_arg set-url origin newurl oldurl
1203 # show takes any number of args
1204 # prune takes any number of args
1205 # update takes any number of args
1207 test_expect_success 'add remote matching the "insteadOf" URL' '
1208 git config url.xyz@example.com.insteadOf backup &&
1209 git remote add backup xyz@example.com