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 &&
77 test_must_be_empty actual
81 test_expect_success C_LOCALE_OUTPUT 'check remote-tracking' '
84 check_remote_track origin master side &&
85 check_remote_track second master side another
89 test_expect_success 'remote forces tracking branches' '
92 case $(git config remote.second.fetch) in
99 test_expect_success 'remove remote' '
102 git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
107 test_expect_success C_LOCALE_OUTPUT 'remove remote' '
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 &&
114 test_must_be_empty actual
118 test_expect_success 'remove remote protects local branches' '
121 cat >expect1 <<-\EOF &&
122 Note: A branch outside the refs/remotes/ hierarchy was not removed;
126 cat >expect2 <<-\EOF &&
127 Note: Some branches outside the refs/remotes/ hierarchy were not removed;
129 git branch -d foobranch
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 &&
140 test_i18ncmp expect1 actual1 &&
141 test_i18ncmp expect2 actual2
145 test_expect_success 'remove errors out early when deleting non-existent branch' '
148 echo "fatal: No such remote: foo" >expect &&
149 test_must_fail git remote rm foo 2>actual &&
150 test_i18ncmp expect actual
154 test_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;
164 git remote add two ../two &&
166 git checkout -b second two/master^0 &&
167 git config branch.second.remote two &&
168 git checkout master &&
173 test_expect_success 'rename errors out early when deleting non-existent branch' '
176 echo "fatal: No such remote: foo" >expect &&
177 test_must_fail git remote rename foo bar 2>actual &&
178 test_i18ncmp expect actual
182 test_expect_success 'add existing foreign_vcs remote' '
183 test_config remote.foo.vcs bar &&
184 echo "fatal: remote foo already exists." >expect &&
185 test_must_fail git remote add foo bar 2>actual &&
186 test_i18ncmp expect actual
189 test_expect_success 'add existing foreign_vcs remote' '
190 test_config remote.foo.vcs bar &&
191 test_config remote.bar.vcs bar &&
192 echo "fatal: remote bar already exists." >expect &&
193 test_must_fail git remote rename foo bar 2>actual &&
194 test_i18ncmp expect actual
197 cat >test/expect <<EOF
199 Fetch URL: $(pwd)/one
203 master new (next fetch will store in remotes/origin)
205 Local branches configured for 'git pull':
206 ahead merges with remote master
207 master merges with remote master
208 octopus merges with remote topic-a
209 and with remote topic-b
210 and with remote topic-c
211 rebase rebases onto remote master
212 Local refs configured for 'git push':
213 master pushes to master (local out of date)
214 master pushes to upstream (create)
219 Local refs configured for 'git push':
220 ahead forces to master (fast-forwardable)
221 master pushes to another (up to date)
224 test_expect_success 'show' '
227 git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream &&
229 git checkout -b ahead origin/master &&
232 git commit -m update file &&
233 git checkout master &&
234 git branch --track octopus origin/master &&
235 git branch --track rebase origin/master &&
236 git branch -d -r origin/master &&
237 git config --add remote.two.url ../two &&
238 git config --add remote.two.pushurl ../three &&
239 git config branch.rebase.rebase true &&
240 git config branch.octopus.merge "topic-a topic-b topic-c" &&
245 git commit -m update file
247 git config --add remote.origin.push : &&
248 git config --add remote.origin.push refs/heads/master:refs/heads/upstream &&
249 git config --add remote.origin.push +refs/tags/lastbackup &&
250 git config --add remote.two.push +refs/heads/ahead:refs/heads/master &&
251 git config --add remote.two.push refs/heads/master:refs/heads/another &&
252 git remote show origin two >output &&
253 git branch -d rebase octopus &&
254 test_i18ncmp expect output
258 cat >test/expect <<EOF
260 Fetch URL: $(pwd)/one
262 HEAD branch: (not queried)
263 Remote branches: (status not queried)
266 Local branches configured for 'git pull':
267 ahead merges with remote master
268 master merges with remote master
269 Local refs configured for 'git push' (status not queried):
270 (matching) pushes to (matching)
271 refs/heads/master pushes to refs/heads/upstream
272 refs/tags/lastbackup forces to refs/tags/lastbackup
275 test_expect_success 'show -n' '
276 mv one one.unreachable &&
279 git remote show -n origin >output &&
280 mv ../one.unreachable ../one &&
281 test_i18ncmp expect output
285 test_expect_success 'prune' '
288 git branch -m side side2
293 git remote prune origin &&
294 git rev-parse refs/remotes/origin/side2 &&
295 test_must_fail git rev-parse refs/remotes/origin/side
299 test_expect_success 'set-head --delete' '
302 git symbolic-ref refs/remotes/origin/HEAD &&
303 git remote set-head --delete origin &&
304 test_must_fail git symbolic-ref refs/remotes/origin/HEAD
308 test_expect_success 'set-head --auto' '
311 git remote set-head --auto origin &&
312 echo refs/remotes/origin/master >expect &&
313 git symbolic-ref refs/remotes/origin/HEAD >output &&
314 test_cmp expect output
318 test_expect_success 'set-head --auto has no problem w/multiple HEADs' '
321 git fetch two "refs/heads/*:refs/remotes/two/*" &&
322 git remote set-head --auto two >output 2>&1 &&
323 echo "two/HEAD set to master" >expect &&
324 test_i18ncmp expect output
328 cat >test/expect <<\EOF
329 refs/remotes/origin/side2
332 test_expect_success 'set-head explicit' '
335 git remote set-head origin side2 &&
336 git symbolic-ref refs/remotes/origin/HEAD >output &&
337 git remote set-head origin master &&
338 test_cmp expect output
342 cat >test/expect <<EOF
345 * [would prune] origin/side2
348 test_expect_success 'prune --dry-run' '
351 git branch -m side2 side) &&
354 git remote prune --dry-run origin >output &&
355 git rev-parse refs/remotes/origin/side2 &&
356 test_must_fail git rev-parse refs/remotes/origin/side &&
359 git branch -m side side2) &&
360 test_i18ncmp expect output
364 test_expect_success 'add --mirror && prune' '
369 git remote add --mirror -f origin ../one
373 git branch -m side2 side
377 git rev-parse --verify refs/heads/side2 &&
378 test_must_fail git rev-parse --verify refs/heads/side &&
380 git remote prune origin &&
381 test_must_fail git rev-parse --verify refs/heads/side2 &&
382 git rev-parse --verify refs/heads/side
386 test_expect_success 'add --mirror=fetch' '
387 mkdir mirror-fetch &&
388 git init mirror-fetch/parent &&
390 cd mirror-fetch/parent &&
393 git init --bare mirror-fetch/child &&
395 cd mirror-fetch/child &&
396 git remote add --mirror=fetch -f parent ../parent
400 test_expect_success 'fetch mirrors act as mirrors during fetch' '
402 cd mirror-fetch/parent &&
404 git branch -m master renamed
407 cd mirror-fetch/child &&
409 git rev-parse --verify refs/heads/new &&
410 git rev-parse --verify refs/heads/renamed
414 test_expect_success 'fetch mirrors can prune' '
416 cd mirror-fetch/child &&
417 git remote prune parent &&
418 test_must_fail git rev-parse --verify refs/heads/master
422 test_expect_success 'fetch mirrors do not act as mirrors during push' '
424 cd mirror-fetch/parent &&
428 cd mirror-fetch/child &&
429 git branch -m renamed renamed2 &&
433 cd mirror-fetch/parent &&
434 git rev-parse --verify renamed &&
435 test_must_fail git rev-parse --verify refs/heads/renamed2
439 test_expect_success 'add fetch mirror with specific branches' '
440 git init --bare mirror-fetch/track &&
442 cd mirror-fetch/track &&
443 git remote add --mirror=fetch -t heads/new parent ../parent
447 test_expect_success 'fetch mirror respects specific branches' '
449 cd mirror-fetch/track &&
451 git rev-parse --verify refs/heads/new &&
452 test_must_fail git rev-parse --verify refs/heads/renamed
456 test_expect_success 'add --mirror=push' '
458 git init --bare mirror-push/public &&
459 git init mirror-push/private &&
461 cd mirror-push/private &&
463 git remote add --mirror=push public ../public
467 test_expect_success 'push mirrors act as mirrors during push' '
469 cd mirror-push/private &&
471 git branch -m master renamed &&
475 cd mirror-push/private &&
476 git rev-parse --verify refs/heads/new &&
477 git rev-parse --verify refs/heads/renamed &&
478 test_must_fail git rev-parse --verify refs/heads/master
482 test_expect_success 'push mirrors do not act as mirrors during fetch' '
484 cd mirror-push/public &&
485 git branch -m renamed renamed2 &&
486 git symbolic-ref HEAD refs/heads/renamed2
489 cd mirror-push/private &&
491 git rev-parse --verify refs/heads/renamed &&
492 test_must_fail git rev-parse --verify refs/heads/renamed2
496 test_expect_success 'push mirrors do not allow you to specify refs' '
497 git init mirror-push/track &&
499 cd mirror-push/track &&
500 test_must_fail git remote add --mirror=push -t new public ../public
504 test_expect_success 'add alt && prune' '
509 git remote add -f origin ../one &&
510 git config remote.alt.url ../one &&
511 git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*"
515 git branch -m side side2
519 git rev-parse --verify refs/remotes/origin/side &&
520 test_must_fail git rev-parse --verify refs/remotes/origin/side2 &&
522 git remote prune alt &&
523 test_must_fail git rev-parse --verify refs/remotes/origin/side &&
524 git rev-parse --verify refs/remotes/origin/side2
528 cat >test/expect <<\EOF
532 test_expect_success 'add with reachable tags (default)' '
537 git commit -m "Foobar" &&
538 git tag -a -m "Foobar tag" foobar-tag &&
539 git reset --hard HEAD~1 &&
540 git tag -a -m "Some tag" some-tag
546 git remote add -f origin ../one &&
547 git tag -l some-tag >../test/output &&
548 git tag -l foobar-tag >>../test/output &&
549 test_must_fail git config remote.origin.tagopt
551 test_cmp test/expect test/output
554 cat >test/expect <<\EOF
560 test_expect_success 'add --tags' '
566 git remote add -f --tags origin ../one &&
567 git tag -l some-tag >../test/output &&
568 git tag -l foobar-tag >>../test/output &&
569 git config remote.origin.tagopt >>../test/output
571 test_cmp test/expect test/output
574 cat >test/expect <<\EOF
578 test_expect_success 'add --no-tags' '
584 git remote add -f --no-tags origin ../one &&
585 git tag -l some-tag >../test/output &&
586 git tag -l foobar-tag >../test/output &&
587 git config remote.origin.tagopt >>../test/output
591 git tag -d some-tag foobar-tag
593 test_cmp test/expect test/output
596 test_expect_success 'reject --no-no-tags' '
599 test_must_fail git remote add -f --no-no-tags neworigin ../one
603 cat >one/expect <<\EOF
611 test_expect_success 'update' '
614 git remote add drosophila ../two &&
615 git remote add apis ../mirror &&
617 git branch -r >output &&
618 test_cmp expect output
622 cat >one/expect <<\EOF
632 test_expect_success 'update with arguments' '
635 for b in $(git branch -r)
637 git branch -r -d $b || exit 1
639 git remote add manduca ../mirror &&
640 git remote add megaloprepus ../mirror &&
641 git config remotes.phobaeticus "drosophila megaloprepus" &&
642 git config remotes.titanus manduca &&
643 git remote update phobaeticus titanus &&
644 git branch -r >output &&
645 test_cmp expect output
649 test_expect_success 'update --prune' '
652 git branch -m side2 side3
656 git remote update --prune &&
659 git branch -m side3 side2
661 git rev-parse refs/remotes/origin/side3 &&
662 test_must_fail git rev-parse refs/remotes/origin/side2
666 cat >one/expect <<-\EOF
675 test_expect_success 'update default' '
678 for b in $(git branch -r)
680 git branch -r -d $b || exit 1
682 git config remote.drosophila.skipDefaultUpdate true &&
683 git remote update default &&
684 git branch -r >output &&
685 test_cmp expect output
689 cat >one/expect <<\EOF
695 test_expect_success 'update default (overridden, with funny whitespace)' '
698 for b in $(git branch -r)
700 git branch -r -d $b || exit 1
702 git config remotes.default "$(printf "\t drosophila \n")" &&
703 git remote update default &&
704 git branch -r >output &&
705 test_cmp expect output
709 test_expect_success 'update (with remotes.default defined)' '
712 for b in $(git branch -r)
714 git branch -r -d $b || exit 1
716 git config remotes.default "drosophila" &&
718 git branch -r >output &&
719 test_cmp expect output
723 test_expect_success '"remote show" does not show symbolic refs' '
724 git clone one three &&
727 git remote show origin >output &&
728 ! grep "^ *HEAD$" < output &&
729 ! grep -i stale < output
733 test_expect_success 'reject adding remote with an invalid name' '
734 test_must_fail git remote add some:url desired-name
737 # The first three test if the tracking branches are properly renamed,
738 # the last two ones check if the config is updated.
740 test_expect_success 'rename a remote' '
741 git clone one four &&
744 git remote rename origin upstream &&
745 test -z "$(git for-each-ref refs/remotes/origin)" &&
746 test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" &&
747 test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" &&
748 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" &&
749 test "$(git config branch.master.remote)" = "upstream"
753 test_expect_success 'rename does not update a non-default fetch refspec' '
754 git clone one four.one &&
757 git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* &&
758 git remote rename origin upstream &&
759 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*" &&
760 git rev-parse -q origin/master
764 test_expect_success 'rename a remote with name part of fetch spec' '
765 git clone one four.two &&
768 git remote rename origin remote &&
769 git remote rename remote upstream &&
770 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*"
774 test_expect_success 'rename a remote with name prefix of other remote' '
775 git clone one four.three &&
778 git remote add o git://example.com/repo.git &&
779 git remote rename o upstream &&
780 test "$(git rev-parse origin/master)" = "$(git rev-parse master)"
784 test_expect_success 'rename succeeds with existing remote.<target>.prune' '
785 git clone one four.four &&
786 test_when_finished git config --global --unset remote.upstream.prune &&
787 git config --global remote.upstream.prune true &&
788 git -C four.four remote rename origin upstream
791 cat >remotes_origin <<EOF
793 Push: refs/heads/master:refs/heads/upstream
794 Push: refs/heads/next:refs/heads/upstream2
795 Pull: refs/heads/master:refs/heads/origin
796 Pull: refs/heads/next:refs/heads/origin2
799 test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
800 git clone one five &&
801 origin_url=$(pwd)/one &&
804 git remote remove origin &&
805 mkdir -p .git/remotes &&
806 cat ../remotes_origin >.git/remotes/origin &&
807 git remote rename origin origin &&
808 test_path_is_missing .git/remotes/origin &&
809 test "$(git config remote.origin.url)" = "$origin_url" &&
810 cat >push_expected <<-\EOF &&
811 refs/heads/master:refs/heads/upstream
812 refs/heads/next:refs/heads/upstream2
814 cat >fetch_expected <<-\EOF &&
815 refs/heads/master:refs/heads/origin
816 refs/heads/next:refs/heads/origin2
818 git config --get-all remote.origin.push >push_actual &&
819 git config --get-all remote.origin.fetch >fetch_actual &&
820 test_cmp push_expected push_actual &&
821 test_cmp fetch_expected fetch_actual
825 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
827 origin_url=$(pwd)/one &&
830 git remote rm origin &&
831 echo "$origin_url" >.git/branches/origin &&
832 git remote rename origin origin &&
833 test_path_is_missing .git/branches/origin &&
834 test "$(git config remote.origin.url)" = "$origin_url" &&
835 test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin" &&
836 test "$(git config remote.origin.push)" = "HEAD:refs/heads/master"
840 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' '
841 git clone one seven &&
844 git remote rm origin &&
845 echo "quux#foom" > .git/branches/origin &&
846 git remote rename origin origin &&
847 test_path_is_missing .git/branches/origin &&
848 test "$(git config remote.origin.url)" = "quux" &&
849 test "$(git config remote.origin.fetch)" = "refs/heads/foom:refs/heads/origin"
850 test "$(git config remote.origin.push)" = "HEAD:refs/heads/foom"
854 test_expect_success 'remote prune to cause a dangling symref' '
855 git clone one eight &&
858 git checkout side2 &&
863 git remote prune origin
865 test_i18ngrep "has become dangling" err &&
867 : And the dangling symref will not cause other annoying errors &&
872 ! grep "points nowhere" err &&
875 test_must_fail git branch nomore origin
877 grep "dangling symref" err
880 test_expect_success 'show empty remote' '
881 test_create_repo empty &&
882 git clone empty empty-clone &&
885 git remote show origin
889 test_expect_success 'remote set-branches requires a remote' '
890 test_must_fail git remote set-branches &&
891 test_must_fail git remote set-branches --add
894 test_expect_success 'remote set-branches' '
895 echo "+refs/heads/*:refs/remotes/scratch/*" >expect.initial &&
896 sort <<-\EOF >expect.add &&
897 +refs/heads/*:refs/remotes/scratch/*
898 +refs/heads/other:refs/remotes/scratch/other
900 sort <<-\EOF >expect.replace &&
901 +refs/heads/maint:refs/remotes/scratch/maint
902 +refs/heads/master:refs/remotes/scratch/master
903 +refs/heads/next:refs/remotes/scratch/next
905 sort <<-\EOF >expect.add-two &&
906 +refs/heads/maint:refs/remotes/scratch/maint
907 +refs/heads/master:refs/remotes/scratch/master
908 +refs/heads/next:refs/remotes/scratch/next
909 +refs/heads/pu:refs/remotes/scratch/pu
910 +refs/heads/t/topic:refs/remotes/scratch/t/topic
912 sort <<-\EOF >expect.setup-ffonly &&
913 refs/heads/master:refs/remotes/scratch/master
914 +refs/heads/next:refs/remotes/scratch/next
916 sort <<-\EOF >expect.respect-ffonly &&
917 refs/heads/master:refs/remotes/scratch/master
918 +refs/heads/next:refs/remotes/scratch/next
919 +refs/heads/pu:refs/remotes/scratch/pu
922 git clone .git/ setbranches &&
925 git remote rename origin scratch &&
926 git config --get-all remote.scratch.fetch >config-result &&
927 sort <config-result >../actual.initial &&
929 git remote set-branches scratch --add other &&
930 git config --get-all remote.scratch.fetch >config-result &&
931 sort <config-result >../actual.add &&
933 git remote set-branches scratch maint master next &&
934 git config --get-all remote.scratch.fetch >config-result &&
935 sort <config-result >../actual.replace &&
937 git remote set-branches --add scratch pu t/topic &&
938 git config --get-all remote.scratch.fetch >config-result &&
939 sort <config-result >../actual.add-two &&
941 git config --unset-all remote.scratch.fetch &&
942 git config remote.scratch.fetch \
943 refs/heads/master:refs/remotes/scratch/master &&
944 git config --add remote.scratch.fetch \
945 +refs/heads/next:refs/remotes/scratch/next &&
946 git config --get-all remote.scratch.fetch >config-result &&
947 sort <config-result >../actual.setup-ffonly &&
949 git remote set-branches --add scratch pu &&
950 git config --get-all remote.scratch.fetch >config-result &&
951 sort <config-result >../actual.respect-ffonly
953 test_cmp expect.initial actual.initial &&
954 test_cmp expect.add actual.add &&
955 test_cmp expect.replace actual.replace &&
956 test_cmp expect.add-two actual.add-two &&
957 test_cmp expect.setup-ffonly actual.setup-ffonly &&
958 test_cmp expect.respect-ffonly actual.respect-ffonly
961 test_expect_success 'remote set-branches with --mirror' '
962 echo "+refs/*:refs/*" >expect.initial &&
963 echo "+refs/heads/master:refs/heads/master" >expect.replace &&
964 git clone --mirror .git/ setbranches-mirror &&
966 cd setbranches-mirror &&
967 git remote rename origin scratch &&
968 git config --get-all remote.scratch.fetch >../actual.initial &&
970 git remote set-branches scratch heads/master &&
971 git config --get-all remote.scratch.fetch >../actual.replace
973 test_cmp expect.initial actual.initial &&
974 test_cmp expect.replace actual.replace
977 test_expect_success 'new remote' '
978 git remote add someremote foo &&
980 git config --get-all remote.someremote.url >actual &&
986 git remote get-url "$@" >actual &&
987 test_cmp expect actual
990 test_expect_success 'get-url on new remote' '
991 echo foo | get_url_test someremote &&
992 echo foo | get_url_test --all someremote &&
993 echo foo | get_url_test --push someremote &&
994 echo foo | get_url_test --push --all someremote
997 test_expect_success 'remote set-url with locked config' '
998 test_when_finished "rm -f .git/config.lock" &&
999 git config --get-all remote.someremote.url >expect &&
1000 >.git/config.lock &&
1001 test_must_fail git remote set-url someremote baz &&
1002 git config --get-all remote.someremote.url >actual &&
1006 test_expect_success 'remote set-url bar' '
1007 git remote set-url someremote bar &&
1009 git config --get-all remote.someremote.url >actual &&
1013 test_expect_success 'remote set-url baz bar' '
1014 git remote set-url someremote baz bar &&
1016 git config --get-all remote.someremote.url >actual &&
1020 test_expect_success 'remote set-url zot bar' '
1021 test_must_fail git remote set-url someremote zot bar &&
1023 git config --get-all remote.someremote.url >actual &&
1027 test_expect_success 'remote set-url --push zot baz' '
1028 test_must_fail git remote set-url --push someremote zot baz &&
1029 echo "YYY" >expect &&
1030 echo baz >>expect &&
1031 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1032 echo "YYY" >>actual &&
1033 git config --get-all remote.someremote.url >>actual &&
1037 test_expect_success 'remote set-url --push zot' '
1038 git remote set-url --push someremote zot &&
1040 echo "YYY" >>expect &&
1041 echo baz >>expect &&
1042 git config --get-all remote.someremote.pushurl >actual &&
1043 echo "YYY" >>actual &&
1044 git config --get-all remote.someremote.url >>actual &&
1048 test_expect_success 'get-url with different urls' '
1049 echo baz | get_url_test someremote &&
1050 echo baz | get_url_test --all someremote &&
1051 echo zot | get_url_test --push someremote &&
1052 echo zot | get_url_test --push --all someremote
1055 test_expect_success 'remote set-url --push qux zot' '
1056 git remote set-url --push someremote qux zot &&
1058 echo "YYY" >>expect &&
1059 echo baz >>expect &&
1060 git config --get-all remote.someremote.pushurl >actual &&
1061 echo "YYY" >>actual &&
1062 git config --get-all remote.someremote.url >>actual &&
1066 test_expect_success 'remote set-url --push foo qu+x' '
1067 git remote set-url --push someremote foo qu+x &&
1069 echo "YYY" >>expect &&
1070 echo baz >>expect &&
1071 git config --get-all remote.someremote.pushurl >actual &&
1072 echo "YYY" >>actual &&
1073 git config --get-all remote.someremote.url >>actual &&
1077 test_expect_success 'remote set-url --push --add aaa' '
1078 git remote set-url --push --add someremote aaa &&
1080 echo aaa >>expect &&
1081 echo "YYY" >>expect &&
1082 echo baz >>expect &&
1083 git config --get-all remote.someremote.pushurl >actual &&
1084 echo "YYY" >>actual &&
1085 git config --get-all remote.someremote.url >>actual &&
1089 test_expect_success 'get-url on multi push remote' '
1090 echo foo | get_url_test --push someremote &&
1091 get_url_test --push --all someremote <<-\EOF
1097 test_expect_success 'remote set-url --push bar aaa' '
1098 git remote set-url --push someremote bar aaa &&
1100 echo bar >>expect &&
1101 echo "YYY" >>expect &&
1102 echo baz >>expect &&
1103 git config --get-all remote.someremote.pushurl >actual &&
1104 echo "YYY" >>actual &&
1105 git config --get-all remote.someremote.url >>actual &&
1109 test_expect_success 'remote set-url --push --delete bar' '
1110 git remote set-url --push --delete someremote bar &&
1112 echo "YYY" >>expect &&
1113 echo baz >>expect &&
1114 git config --get-all remote.someremote.pushurl >actual &&
1115 echo "YYY" >>actual &&
1116 git config --get-all remote.someremote.url >>actual &&
1120 test_expect_success 'remote set-url --push --delete foo' '
1121 git remote set-url --push --delete someremote foo &&
1122 echo "YYY" >expect &&
1123 echo baz >>expect &&
1124 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1125 echo "YYY" >>actual &&
1126 git config --get-all remote.someremote.url >>actual &&
1130 test_expect_success 'remote set-url --add bbb' '
1131 git remote set-url --add someremote bbb &&
1132 echo "YYY" >expect &&
1133 echo baz >>expect &&
1134 echo bbb >>expect &&
1135 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1136 echo "YYY" >>actual &&
1137 git config --get-all remote.someremote.url >>actual &&
1141 test_expect_success 'get-url on multi fetch remote' '
1142 echo baz | get_url_test someremote &&
1143 get_url_test --all someremote <<-\EOF
1149 test_expect_success 'remote set-url --delete .*' '
1150 test_must_fail git remote set-url --delete someremote .\* &&
1151 echo "YYY" >expect &&
1152 echo baz >>expect &&
1153 echo bbb >>expect &&
1154 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1155 echo "YYY" >>actual &&
1156 git config --get-all remote.someremote.url >>actual &&
1160 test_expect_success 'remote set-url --delete bbb' '
1161 git remote set-url --delete someremote bbb &&
1162 echo "YYY" >expect &&
1163 echo baz >>expect &&
1164 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1165 echo "YYY" >>actual &&
1166 git config --get-all remote.someremote.url >>actual &&
1170 test_expect_success 'remote set-url --delete baz' '
1171 test_must_fail git remote set-url --delete someremote baz &&
1172 echo "YYY" >expect &&
1173 echo baz >>expect &&
1174 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1175 echo "YYY" >>actual &&
1176 git config --get-all remote.someremote.url >>actual &&
1180 test_expect_success 'remote set-url --add ccc' '
1181 git remote set-url --add someremote ccc &&
1182 echo "YYY" >expect &&
1183 echo baz >>expect &&
1184 echo ccc >>expect &&
1185 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1186 echo "YYY" >>actual &&
1187 git config --get-all remote.someremote.url >>actual &&
1191 test_expect_success 'remote set-url --delete baz' '
1192 git remote set-url --delete someremote baz &&
1193 echo "YYY" >expect &&
1194 echo ccc >>expect &&
1195 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1196 echo "YYY" >>actual &&
1197 git config --get-all remote.someremote.url >>actual &&
1201 test_expect_success 'extra args: setup' '
1202 # add a dummy origin so that this does not trigger failure
1203 git remote add origin .
1207 test_expect_success "extra args: $*" "
1208 test_must_fail git remote $* bogus_extra_arg 2>actual &&
1209 test_i18ngrep '^usage:' actual
1213 test_extra_arg add nick url
1214 test_extra_arg rename origin newname
1215 test_extra_arg remove origin
1216 test_extra_arg set-head origin master
1217 # set-branches takes any number of args
1218 test_extra_arg get-url origin newurl
1219 test_extra_arg set-url origin newurl oldurl
1220 # show takes any number of args
1221 # prune takes any number of args
1222 # update takes any number of args
1224 test_expect_success 'add remote matching the "insteadOf" URL' '
1225 git config url.xyz@example.com.insteadOf backup &&
1226 git remote add backup xyz@example.com