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
'remove remote with a branch without configured merge' '
157 test_when_finished "(
158 git -C test checkout master;
159 git -C test branch -D two;
160 git -C test config --remove-section remote.two;
161 git -C test config --remove-section branch.second;
166 git remote add two ../two &&
168 git checkout -b second two/master^0 &&
169 git config branch.second.remote two &&
170 git checkout master &&
175 test_expect_success
'rename errors out early when deleting non-existent branch' '
178 echo "fatal: No such remote: foo" >expect &&
179 test_must_fail git remote rename foo bar 2>actual &&
180 test_i18ncmp expect actual
184 test_expect_success
'add existing foreign_vcs remote' '
185 test_config remote.foo.vcs bar &&
186 echo "fatal: remote foo already exists." >expect &&
187 test_must_fail git remote add foo bar 2>actual &&
188 test_i18ncmp expect actual
191 test_expect_success
'add existing foreign_vcs remote' '
192 test_config remote.foo.vcs bar &&
193 test_config remote.bar.vcs bar &&
194 echo "fatal: remote bar already exists." >expect &&
195 test_must_fail git remote rename foo bar 2>actual &&
196 test_i18ncmp expect actual
199 cat >test
/expect
<<EOF
201 Fetch URL: $(pwd)/one
205 master new (next fetch will store in remotes/origin)
207 Local branches configured for 'git pull':
208 ahead merges with remote master
209 master merges with remote master
210 octopus merges with remote topic-a
211 and with remote topic-b
212 and with remote topic-c
213 rebase rebases onto remote master
214 Local refs configured for 'git push':
215 master pushes to master (local out of date)
216 master pushes to upstream (create)
221 Local refs configured for 'git push':
222 ahead forces to master (fast-forwardable)
223 master pushes to another (up to date)
226 test_expect_success
'show' '
229 git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream &&
231 git checkout -b ahead origin/master &&
234 git commit -m update file &&
235 git checkout master &&
236 git branch --track octopus origin/master &&
237 git branch --track rebase origin/master &&
238 git branch -d -r origin/master &&
239 git config --add remote.two.url ../two &&
240 git config --add remote.two.pushurl ../three &&
241 git config branch.rebase.rebase true &&
242 git config branch.octopus.merge "topic-a topic-b topic-c" &&
247 git commit -m update file
249 git config --add remote.origin.push : &&
250 git config --add remote.origin.push refs/heads/master:refs/heads/upstream &&
251 git config --add remote.origin.push +refs/tags/lastbackup &&
252 git config --add remote.two.push +refs/heads/ahead:refs/heads/master &&
253 git config --add remote.two.push refs/heads/master:refs/heads/another &&
254 git remote show origin two >output &&
255 git branch -d rebase octopus &&
256 test_i18ncmp expect output
260 cat >test
/expect
<<EOF
262 Fetch URL: $(pwd)/one
264 HEAD branch: (not queried)
265 Remote branches: (status not queried)
268 Local branches configured for 'git pull':
269 ahead merges with remote master
270 master merges with remote master
271 Local refs configured for 'git push' (status not queried):
272 (matching) pushes to (matching)
273 refs/heads/master pushes to refs/heads/upstream
274 refs/tags/lastbackup forces to refs/tags/lastbackup
277 test_expect_success
'show -n' '
278 mv one one.unreachable &&
281 git remote show -n origin >output &&
282 mv ../one.unreachable ../one &&
283 test_i18ncmp expect output
287 test_expect_success
'prune' '
290 git branch -m side side2
295 git remote prune origin &&
296 git rev-parse refs/remotes/origin/side2 &&
297 test_must_fail git rev-parse refs/remotes/origin/side
301 test_expect_success
'set-head --delete' '
304 git symbolic-ref refs/remotes/origin/HEAD &&
305 git remote set-head --delete origin &&
306 test_must_fail git symbolic-ref refs/remotes/origin/HEAD
310 test_expect_success
'set-head --auto' '
313 git remote set-head --auto origin &&
314 echo refs/remotes/origin/master >expect &&
315 git symbolic-ref refs/remotes/origin/HEAD >output &&
316 test_cmp expect output
320 test_expect_success
'set-head --auto has no problem w/multiple HEADs' '
323 git fetch two "refs/heads/*:refs/remotes/two/*" &&
324 git remote set-head --auto two >output 2>&1 &&
325 echo "two/HEAD set to master" >expect &&
326 test_i18ncmp expect output
330 cat >test
/expect
<<\EOF
331 refs
/remotes
/origin
/side2
334 test_expect_success
'set-head explicit' '
337 git remote set-head origin side2 &&
338 git symbolic-ref refs/remotes/origin/HEAD >output &&
339 git remote set-head origin master &&
340 test_cmp expect output
344 cat >test
/expect
<<EOF
347 * [would prune] origin/side2
350 test_expect_success
'prune --dry-run' '
353 git branch -m side2 side) &&
356 git remote prune --dry-run origin >output &&
357 git rev-parse refs/remotes/origin/side2 &&
358 test_must_fail git rev-parse refs/remotes/origin/side &&
361 git branch -m side side2) &&
362 test_i18ncmp expect output
366 test_expect_success
'add --mirror && prune' '
371 git remote add --mirror -f origin ../one
375 git branch -m side2 side
379 git rev-parse --verify refs/heads/side2 &&
380 test_must_fail git rev-parse --verify refs/heads/side &&
382 git remote prune origin &&
383 test_must_fail git rev-parse --verify refs/heads/side2 &&
384 git rev-parse --verify refs/heads/side
388 test_expect_success
'add --mirror=fetch' '
389 mkdir mirror-fetch &&
390 git init mirror-fetch/parent &&
392 cd mirror-fetch/parent &&
395 git init --bare mirror-fetch/child &&
397 cd mirror-fetch/child &&
398 git remote add --mirror=fetch -f parent ../parent
402 test_expect_success
'fetch mirrors act as mirrors during fetch' '
404 cd mirror-fetch/parent &&
406 git branch -m master renamed
409 cd mirror-fetch/child &&
411 git rev-parse --verify refs/heads/new &&
412 git rev-parse --verify refs/heads/renamed
416 test_expect_success
'fetch mirrors can prune' '
418 cd mirror-fetch/child &&
419 git remote prune parent &&
420 test_must_fail git rev-parse --verify refs/heads/master
424 test_expect_success
'fetch mirrors do not act as mirrors during push' '
426 cd mirror-fetch/parent &&
430 cd mirror-fetch/child &&
431 git branch -m renamed renamed2 &&
435 cd mirror-fetch/parent &&
436 git rev-parse --verify renamed &&
437 test_must_fail git rev-parse --verify refs/heads/renamed2
441 test_expect_success
'add fetch mirror with specific branches' '
442 git init --bare mirror-fetch/track &&
444 cd mirror-fetch/track &&
445 git remote add --mirror=fetch -t heads/new parent ../parent
449 test_expect_success
'fetch mirror respects specific branches' '
451 cd mirror-fetch/track &&
453 git rev-parse --verify refs/heads/new &&
454 test_must_fail git rev-parse --verify refs/heads/renamed
458 test_expect_success
'add --mirror=push' '
460 git init --bare mirror-push/public &&
461 git init mirror-push/private &&
463 cd mirror-push/private &&
465 git remote add --mirror=push public ../public
469 test_expect_success
'push mirrors act as mirrors during push' '
471 cd mirror-push/private &&
473 git branch -m master renamed &&
477 cd mirror-push/private &&
478 git rev-parse --verify refs/heads/new &&
479 git rev-parse --verify refs/heads/renamed &&
480 test_must_fail git rev-parse --verify refs/heads/master
484 test_expect_success
'push mirrors do not act as mirrors during fetch' '
486 cd mirror-push/public &&
487 git branch -m renamed renamed2 &&
488 git symbolic-ref HEAD refs/heads/renamed2
491 cd mirror-push/private &&
493 git rev-parse --verify refs/heads/renamed &&
494 test_must_fail git rev-parse --verify refs/heads/renamed2
498 test_expect_success
'push mirrors do not allow you to specify refs' '
499 git init mirror-push/track &&
501 cd mirror-push/track &&
502 test_must_fail git remote add --mirror=push -t new public ../public
506 test_expect_success
'add alt && prune' '
511 git remote add -f origin ../one &&
512 git config remote.alt.url ../one &&
513 git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*"
517 git branch -m side side2
521 git rev-parse --verify refs/remotes/origin/side &&
522 test_must_fail git rev-parse --verify refs/remotes/origin/side2 &&
524 git remote prune alt &&
525 test_must_fail git rev-parse --verify refs/remotes/origin/side &&
526 git rev-parse --verify refs/remotes/origin/side2
530 cat >test
/expect
<<\EOF
534 test_expect_success
'add with reachable tags (default)' '
539 git commit -m "Foobar" &&
540 git tag -a -m "Foobar tag" foobar-tag &&
541 git reset --hard HEAD~1 &&
542 git tag -a -m "Some tag" some-tag
548 git remote add -f origin ../one &&
549 git tag -l some-tag >../test/output &&
550 git tag -l foobar-tag >>../test/output &&
551 test_must_fail git config remote.origin.tagopt
553 test_cmp test/expect test/output
556 cat >test
/expect
<<\EOF
562 test_expect_success
'add --tags' '
568 git remote add -f --tags origin ../one &&
569 git tag -l some-tag >../test/output &&
570 git tag -l foobar-tag >>../test/output &&
571 git config remote.origin.tagopt >>../test/output
573 test_cmp test/expect test/output
576 cat >test
/expect
<<\EOF
580 test_expect_success
'add --no-tags' '
586 git remote add -f --no-tags origin ../one &&
587 git tag -l some-tag >../test/output &&
588 git tag -l foobar-tag >../test/output &&
589 git config remote.origin.tagopt >>../test/output
593 git tag -d some-tag foobar-tag
595 test_cmp test/expect test/output
598 test_expect_success
'reject --no-no-tags' '
601 test_must_fail git remote add -f --no-no-tags neworigin ../one
605 cat >one
/expect
<<\EOF
613 test_expect_success
'update' '
616 git remote add drosophila ../two &&
617 git remote add apis ../mirror &&
619 git branch -r >output &&
620 test_cmp expect output
624 cat >one
/expect
<<\EOF
634 test_expect_success
'update with arguments' '
637 for b in $(git branch -r)
639 git branch -r -d $b || exit 1
641 git remote add manduca ../mirror &&
642 git remote add megaloprepus ../mirror &&
643 git config remotes.phobaeticus "drosophila megaloprepus" &&
644 git config remotes.titanus manduca &&
645 git remote update phobaeticus titanus &&
646 git branch -r >output &&
647 test_cmp expect output
651 test_expect_success
'update --prune' '
654 git branch -m side2 side3
658 git remote update --prune &&
661 git branch -m side3 side2
663 git rev-parse refs/remotes/origin/side3 &&
664 test_must_fail git rev-parse refs/remotes/origin/side2
668 cat >one
/expect
<<-\EOF
677 test_expect_success 'update default' '
680 for b in $(git branch -r)
682 git branch -r -d $b || exit 1
684 git config remote.drosophila.skipDefaultUpdate true &&
685 git remote update default &&
686 git branch -r >output &&
687 test_cmp expect output
691 cat >one/expect <<\EOF
697 test_expect_success 'update default (overridden, with funny whitespace)' '
700 for b in $(git branch -r)
702 git branch -r -d $b || exit 1
704 git config remotes.default "$(printf "\t drosophila \n")" &&
705 git remote update default &&
706 git branch -r >output &&
707 test_cmp expect output
711 test_expect_success 'update (with remotes.default defined)' '
714 for b in $(git branch -r)
716 git branch -r -d $b || exit 1
718 git config remotes.default "drosophila" &&
720 git branch -r >output &&
721 test_cmp expect output
725 test_expect_success '"remote show" does not show symbolic refs' '
726 git clone one three &&
729 git remote show origin >output &&
730 ! grep "^ *HEAD$" < output &&
731 ! grep -i stale < output
735 test_expect_success 'reject adding remote with an invalid name' '
736 test_must_fail git remote add some:url desired-name
739 # The first three test if the tracking branches are properly renamed,
740 # the last two ones check if the config is updated.
742 test_expect_success 'rename a remote' '
743 git clone one four &&
746 git remote rename origin upstream &&
747 test -z "$(git for-each-ref refs/remotes/origin)" &&
748 test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" &&
749 test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" &&
750 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" &&
751 test "$(git config branch.master.remote)" = "upstream"
755 test_expect_success 'rename does not update a non-default fetch refspec' '
756 git clone one four.one &&
759 git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* &&
760 git remote rename origin upstream &&
761 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*" &&
762 git rev-parse -q origin/master
766 test_expect_success 'rename a remote with name part of fetch spec' '
767 git clone one four.two &&
770 git remote rename origin remote &&
771 git remote rename remote upstream &&
772 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*"
776 test_expect_success 'rename a remote with name prefix of other remote' '
777 git clone one four.three &&
780 git remote add o git://example.com/repo.git &&
781 git remote rename o upstream &&
782 test "$(git rev-parse origin/master)" = "$(git rev-parse master)"
786 test_expect_success 'rename succeeds with existing remote.<target>.prune' '
787 git clone one four.four &&
788 test_when_finished git config --global --unset remote.upstream.prune &&
789 git config --global remote.upstream.prune true &&
790 git -C four.four remote rename origin upstream
793 cat >remotes_origin <<EOF
795 Push: refs/heads/master:refs/heads/upstream
796 Push: refs/heads/next:refs/heads/upstream2
797 Pull: refs/heads/master:refs/heads/origin
798 Pull: refs/heads/next:refs/heads/origin2
801 test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
802 git clone one five &&
803 origin_url=$(pwd)/one &&
806 git remote remove origin &&
807 mkdir -p .git/remotes &&
808 cat ../remotes_origin >.git/remotes/origin &&
809 git remote rename origin origin &&
810 test_path_is_missing .git/remotes/origin &&
811 test "$(git config remote.origin.url)" = "$origin_url" &&
812 cat >push_expected <<-\
EOF &&
813 refs/heads/master:refs/heads/upstream
814 refs/heads/next:refs/heads/upstream2
816 cat >fetch_expected <<-\EOF &&
817 refs/heads/master:refs/heads/origin
818 refs/heads/next:refs/heads/origin2
820 git config --get-all remote.origin.push >push_actual &&
821 git config --get-all remote.origin.fetch >fetch_actual &&
822 test_cmp push_expected push_actual &&
823 test_cmp fetch_expected fetch_actual
827 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
829 origin_url=$(pwd)/one &&
832 git remote rm origin &&
833 echo "$origin_url" >.git/branches/origin &&
834 git remote rename origin origin &&
835 test_path_is_missing .git/branches/origin &&
836 test "$(git config remote.origin.url)" = "$origin_url" &&
837 test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin" &&
838 test "$(git config remote.origin.push)" = "HEAD:refs/heads/master"
842 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' '
843 git clone one seven &&
846 git remote rm origin &&
847 echo "quux#foom" > .git/branches/origin &&
848 git remote rename origin origin &&
849 test_path_is_missing .git/branches/origin &&
850 test "$(git config remote.origin.url)" = "quux" &&
851 test "$(git config remote.origin.fetch)" = "refs/heads/foom:refs/heads/origin"
852 test "$(git config remote.origin.push)" = "HEAD:refs/heads/foom"
856 test_expect_success 'remote prune to cause a dangling symref' '
857 git clone one eight &&
860 git checkout side2 &&
865 git remote prune origin
867 test_i18ngrep "has become dangling" err &&
869 : And the dangling symref will not cause other annoying errors &&
874 ! grep "points nowhere" err &&
877 test_must_fail git branch nomore origin
879 grep "dangling symref" err
882 test_expect_success 'show empty remote' '
883 test_create_repo empty &&
884 git clone empty empty-clone &&
887 git remote show origin
891 test_expect_success 'remote set-branches requires a remote' '
892 test_must_fail git remote set-branches &&
893 test_must_fail git remote set-branches --add
896 test_expect_success 'remote set-branches' '
897 echo "+refs/heads/*:refs/remotes/scratch/*" >expect.initial &&
898 sort <<-\EOF >expect.add &&
899 +refs/heads/*:refs/remotes/scratch/*
900 +refs/heads/other:refs/remotes/scratch/other
902 sort <<-\EOF >expect.replace &&
903 +refs/heads/maint:refs/remotes/scratch/maint
904 +refs/heads/master:refs/remotes/scratch/master
905 +refs/heads/next:refs/remotes/scratch/next
907 sort <<-\EOF >expect.add-two &&
908 +refs/heads/maint:refs/remotes/scratch/maint
909 +refs/heads/master:refs/remotes/scratch/master
910 +refs/heads/next:refs/remotes/scratch/next
911 +refs/heads/pu:refs/remotes/scratch/pu
912 +refs/heads/t/topic:refs/remotes/scratch/t/topic
914 sort <<-\EOF >expect.setup-ffonly &&
915 refs/heads/master:refs/remotes/scratch/master
916 +refs/heads/next:refs/remotes/scratch/next
918 sort <<-\EOF >expect.respect-ffonly &&
919 refs/heads/master:refs/remotes/scratch/master
920 +refs/heads/next:refs/remotes/scratch/next
921 +refs/heads/pu:refs/remotes/scratch/pu
924 git clone .git/ setbranches &&
927 git remote rename origin scratch &&
928 git config --get-all remote.scratch.fetch >config-result &&
929 sort <config-result >../actual.initial &&
931 git remote set-branches scratch --add other &&
932 git config --get-all remote.scratch.fetch >config-result &&
933 sort <config-result >../actual.add &&
935 git remote set-branches scratch maint master next &&
936 git config --get-all remote.scratch.fetch >config-result &&
937 sort <config-result >../actual.replace &&
939 git remote set-branches --add scratch pu t/topic &&
940 git config --get-all remote.scratch.fetch >config-result &&
941 sort <config-result >../actual.add-two &&
943 git config --unset-all remote.scratch.fetch &&
944 git config remote.scratch.fetch \
945 refs/heads/master:refs/remotes/scratch/master &&
946 git config --add remote.scratch.fetch \
947 +refs/heads/next:refs/remotes/scratch/next &&
948 git config --get-all remote.scratch.fetch >config-result &&
949 sort <config-result >../actual.setup-ffonly &&
951 git remote set-branches --add scratch pu &&
952 git config --get-all remote.scratch.fetch >config-result &&
953 sort <config-result >../actual.respect-ffonly
955 test_cmp expect.initial actual.initial &&
956 test_cmp expect.add actual.add &&
957 test_cmp expect.replace actual.replace &&
958 test_cmp expect.add-two actual.add-two &&
959 test_cmp expect.setup-ffonly actual.setup-ffonly &&
960 test_cmp expect.respect-ffonly actual.respect-ffonly
963 test_expect_success 'remote set-branches with --mirror' '
964 echo "+refs/*:refs/*" >expect.initial &&
965 echo "+refs/heads/master:refs/heads/master" >expect.replace &&
966 git clone --mirror .git/ setbranches-mirror &&
968 cd setbranches-mirror &&
969 git remote rename origin scratch &&
970 git config --get-all remote.scratch.fetch >../actual.initial &&
972 git remote set-branches scratch heads/master &&
973 git config --get-all remote.scratch.fetch >../actual.replace
975 test_cmp expect.initial actual.initial &&
976 test_cmp expect.replace actual.replace
979 test_expect_success 'new remote' '
980 git remote add someremote foo &&
982 git config --get-all remote.someremote.url >actual &&
988 git remote get-url "$@" >actual &&
989 test_cmp expect actual
992 test_expect_success 'get-url on new remote' '
993 echo foo | get_url_test someremote &&
994 echo foo | get_url_test --all someremote &&
995 echo foo | get_url_test --push someremote &&
996 echo foo | get_url_test --push --all someremote
999 test_expect_success 'remote set-url with locked config' '
1000 test_when_finished "rm -f .git/config.lock" &&
1001 git config --get-all remote.someremote.url >expect &&
1002 >.git/config.lock &&
1003 test_must_fail git remote set-url someremote baz &&
1004 git config --get-all remote.someremote.url >actual &&
1008 test_expect_success 'remote set-url bar' '
1009 git remote set-url someremote bar &&
1011 git config --get-all remote.someremote.url >actual &&
1015 test_expect_success 'remote set-url baz bar' '
1016 git remote set-url someremote baz bar &&
1018 git config --get-all remote.someremote.url >actual &&
1022 test_expect_success 'remote set-url zot bar' '
1023 test_must_fail git remote set-url someremote zot bar &&
1025 git config --get-all remote.someremote.url >actual &&
1029 test_expect_success 'remote set-url --push zot baz' '
1030 test_must_fail git remote set-url --push someremote zot baz &&
1031 echo "YYY" >expect &&
1032 echo baz >>expect &&
1033 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1034 echo "YYY" >>actual &&
1035 git config --get-all remote.someremote.url >>actual &&
1039 test_expect_success 'remote set-url --push zot' '
1040 git remote set-url --push someremote zot &&
1042 echo "YYY" >>expect &&
1043 echo baz >>expect &&
1044 git config --get-all remote.someremote.pushurl >actual &&
1045 echo "YYY" >>actual &&
1046 git config --get-all remote.someremote.url >>actual &&
1050 test_expect_success 'get-url with different urls' '
1051 echo baz | get_url_test someremote &&
1052 echo baz | get_url_test --all someremote &&
1053 echo zot | get_url_test --push someremote &&
1054 echo zot | get_url_test --push --all someremote
1057 test_expect_success 'remote set-url --push qux zot' '
1058 git remote set-url --push someremote qux zot &&
1060 echo "YYY" >>expect &&
1061 echo baz >>expect &&
1062 git config --get-all remote.someremote.pushurl >actual &&
1063 echo "YYY" >>actual &&
1064 git config --get-all remote.someremote.url >>actual &&
1068 test_expect_success 'remote set-url --push foo qu+x' '
1069 git remote set-url --push someremote foo qu+x &&
1071 echo "YYY" >>expect &&
1072 echo baz >>expect &&
1073 git config --get-all remote.someremote.pushurl >actual &&
1074 echo "YYY" >>actual &&
1075 git config --get-all remote.someremote.url >>actual &&
1079 test_expect_success 'remote set-url --push --add aaa' '
1080 git remote set-url --push --add someremote aaa &&
1082 echo aaa >>expect &&
1083 echo "YYY" >>expect &&
1084 echo baz >>expect &&
1085 git config --get-all remote.someremote.pushurl >actual &&
1086 echo "YYY" >>actual &&
1087 git config --get-all remote.someremote.url >>actual &&
1091 test_expect_success 'get-url on multi push remote' '
1092 echo foo | get_url_test --push someremote &&
1093 get_url_test --push --all someremote <<-\EOF
1099 test_expect_success 'remote set-url --push bar aaa' '
1100 git remote set-url --push someremote bar aaa &&
1102 echo bar >>expect &&
1103 echo "YYY" >>expect &&
1104 echo baz >>expect &&
1105 git config --get-all remote.someremote.pushurl >actual &&
1106 echo "YYY" >>actual &&
1107 git config --get-all remote.someremote.url >>actual &&
1111 test_expect_success 'remote set-url --push --delete bar' '
1112 git remote set-url --push --delete someremote bar &&
1114 echo "YYY" >>expect &&
1115 echo baz >>expect &&
1116 git config --get-all remote.someremote.pushurl >actual &&
1117 echo "YYY" >>actual &&
1118 git config --get-all remote.someremote.url >>actual &&
1122 test_expect_success 'remote set-url --push --delete foo' '
1123 git remote set-url --push --delete someremote foo &&
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 &&
1132 test_expect_success 'remote set-url --add bbb' '
1133 git remote set-url --add someremote bbb &&
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 'get-url on multi fetch remote' '
1144 echo baz | get_url_test someremote &&
1145 get_url_test --all someremote <<-\EOF
1151 test_expect_success 'remote set-url --delete .*' '
1152 test_must_fail git remote set-url --delete someremote .\* &&
1153 echo "YYY" >expect &&
1154 echo baz >>expect &&
1155 echo bbb >>expect &&
1156 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1157 echo "YYY" >>actual &&
1158 git config --get-all remote.someremote.url >>actual &&
1162 test_expect_success 'remote set-url --delete bbb' '
1163 git remote set-url --delete someremote bbb &&
1164 echo "YYY" >expect &&
1165 echo baz >>expect &&
1166 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1167 echo "YYY" >>actual &&
1168 git config --get-all remote.someremote.url >>actual &&
1172 test_expect_success 'remote set-url --delete baz' '
1173 test_must_fail git remote set-url --delete someremote baz &&
1174 echo "YYY" >expect &&
1175 echo baz >>expect &&
1176 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1177 echo "YYY" >>actual &&
1178 git config --get-all remote.someremote.url >>actual &&
1182 test_expect_success 'remote set-url --add ccc' '
1183 git remote set-url --add someremote ccc &&
1184 echo "YYY" >expect &&
1185 echo baz >>expect &&
1186 echo ccc >>expect &&
1187 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1188 echo "YYY" >>actual &&
1189 git config --get-all remote.someremote.url >>actual &&
1193 test_expect_success 'remote set-url --delete baz' '
1194 git remote set-url --delete someremote baz &&
1195 echo "YYY" >expect &&
1196 echo ccc >>expect &&
1197 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1198 echo "YYY" >>actual &&
1199 git config --get-all remote.someremote.url >>actual &&
1203 test_expect_success 'extra args: setup' '
1204 # add a dummy origin so that this does not trigger failure
1205 git remote add origin .
1209 test_expect_success "extra args: $*" "
1210 test_must_fail git remote $* bogus_extra_arg 2>actual &&
1211 test_i18ngrep '^usage:' actual
1215 test_extra_arg add nick url
1216 test_extra_arg rename origin newname
1217 test_extra_arg remove origin
1218 test_extra_arg set-head origin master
1219 # set-branches takes any number of args
1220 test_extra_arg get-url origin newurl
1221 test_extra_arg set-url origin newurl oldurl
1222 # show takes any number of args
1223 # prune takes any number of args
1224 # update takes any number of args
1226 test_expect_success 'add remote matching the "insteadOf" URL' '
1227 git config url.xyz@example.com.insteadOf backup &&
1228 git remote add backup xyz@example.com