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 rmdir .git/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 cat >remotes_origin <<EOF
788 Push: refs/heads/master:refs/heads/upstream
789 Push: refs/heads/next:refs/heads/upstream2
790 Pull: refs/heads/master:refs/heads/origin
791 Pull: refs/heads/next:refs/heads/origin2
794 test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
795 git clone one five &&
796 origin_url=$(pwd)/one &&
799 git remote remove origin &&
800 mkdir -p .git/remotes &&
801 cat ../remotes_origin >.git/remotes/origin &&
802 git remote rename origin origin &&
803 test_path_is_missing .git/remotes/origin &&
804 test "$(git config remote.origin.url)" = "$origin_url" &&
805 cat >push_expected <<-\
EOF &&
806 refs/heads/master:refs/heads/upstream
807 refs/heads/next:refs/heads/upstream2
809 cat >fetch_expected <<-\EOF &&
810 refs/heads/master:refs/heads/origin
811 refs/heads/next:refs/heads/origin2
813 git config --get-all remote.origin.push >push_actual &&
814 git config --get-all remote.origin.fetch >fetch_actual &&
815 test_cmp push_expected push_actual &&
816 test_cmp fetch_expected fetch_actual
820 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
822 origin_url=$(pwd)/one &&
825 git remote rm origin &&
826 echo "$origin_url" >.git/branches/origin &&
827 git remote rename origin origin &&
828 test_path_is_missing .git/branches/origin &&
829 test "$(git config remote.origin.url)" = "$origin_url" &&
830 test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin" &&
831 test "$(git config remote.origin.push)" = "HEAD:refs/heads/master"
835 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' '
836 git clone one seven &&
839 git remote rm origin &&
840 echo "quux#foom" > .git/branches/origin &&
841 git remote rename origin origin &&
842 test_path_is_missing .git/branches/origin &&
843 test "$(git config remote.origin.url)" = "quux" &&
844 test "$(git config remote.origin.fetch)" = "refs/heads/foom:refs/heads/origin"
845 test "$(git config remote.origin.push)" = "HEAD:refs/heads/foom"
849 test_expect_success 'remote prune to cause a dangling symref' '
850 git clone one eight &&
853 git checkout side2 &&
858 git remote prune origin
860 test_i18ngrep "has become dangling" err &&
862 : And the dangling symref will not cause other annoying errors &&
867 ! grep "points nowhere" err &&
870 test_must_fail git branch nomore origin
872 grep "dangling symref" err
875 test_expect_success 'show empty remote' '
876 test_create_repo empty &&
877 git clone empty empty-clone &&
880 git remote show origin
884 test_expect_success 'remote set-branches requires a remote' '
885 test_must_fail git remote set-branches &&
886 test_must_fail git remote set-branches --add
889 test_expect_success 'remote set-branches' '
890 echo "+refs/heads/*:refs/remotes/scratch/*" >expect.initial &&
891 sort <<-\EOF >expect.add &&
892 +refs/heads/*:refs/remotes/scratch/*
893 +refs/heads/other:refs/remotes/scratch/other
895 sort <<-\EOF >expect.replace &&
896 +refs/heads/maint:refs/remotes/scratch/maint
897 +refs/heads/master:refs/remotes/scratch/master
898 +refs/heads/next:refs/remotes/scratch/next
900 sort <<-\EOF >expect.add-two &&
901 +refs/heads/maint:refs/remotes/scratch/maint
902 +refs/heads/master:refs/remotes/scratch/master
903 +refs/heads/next:refs/remotes/scratch/next
904 +refs/heads/pu:refs/remotes/scratch/pu
905 +refs/heads/t/topic:refs/remotes/scratch/t/topic
907 sort <<-\EOF >expect.setup-ffonly &&
908 refs/heads/master:refs/remotes/scratch/master
909 +refs/heads/next:refs/remotes/scratch/next
911 sort <<-\EOF >expect.respect-ffonly &&
912 refs/heads/master:refs/remotes/scratch/master
913 +refs/heads/next:refs/remotes/scratch/next
914 +refs/heads/pu:refs/remotes/scratch/pu
917 git clone .git/ setbranches &&
920 git remote rename origin scratch &&
921 git config --get-all remote.scratch.fetch >config-result &&
922 sort <config-result >../actual.initial &&
924 git remote set-branches scratch --add other &&
925 git config --get-all remote.scratch.fetch >config-result &&
926 sort <config-result >../actual.add &&
928 git remote set-branches scratch maint master next &&
929 git config --get-all remote.scratch.fetch >config-result &&
930 sort <config-result >../actual.replace &&
932 git remote set-branches --add scratch pu t/topic &&
933 git config --get-all remote.scratch.fetch >config-result &&
934 sort <config-result >../actual.add-two &&
936 git config --unset-all remote.scratch.fetch &&
937 git config remote.scratch.fetch \
938 refs/heads/master:refs/remotes/scratch/master &&
939 git config --add remote.scratch.fetch \
940 +refs/heads/next:refs/remotes/scratch/next &&
941 git config --get-all remote.scratch.fetch >config-result &&
942 sort <config-result >../actual.setup-ffonly &&
944 git remote set-branches --add scratch pu &&
945 git config --get-all remote.scratch.fetch >config-result &&
946 sort <config-result >../actual.respect-ffonly
948 test_cmp expect.initial actual.initial &&
949 test_cmp expect.add actual.add &&
950 test_cmp expect.replace actual.replace &&
951 test_cmp expect.add-two actual.add-two &&
952 test_cmp expect.setup-ffonly actual.setup-ffonly &&
953 test_cmp expect.respect-ffonly actual.respect-ffonly
956 test_expect_success 'remote set-branches with --mirror' '
957 echo "+refs/*:refs/*" >expect.initial &&
958 echo "+refs/heads/master:refs/heads/master" >expect.replace &&
959 git clone --mirror .git/ setbranches-mirror &&
961 cd setbranches-mirror &&
962 git remote rename origin scratch &&
963 git config --get-all remote.scratch.fetch >../actual.initial &&
965 git remote set-branches scratch heads/master &&
966 git config --get-all remote.scratch.fetch >../actual.replace
968 test_cmp expect.initial actual.initial &&
969 test_cmp expect.replace actual.replace
972 test_expect_success 'new remote' '
973 git remote add someremote foo &&
975 git config --get-all remote.someremote.url >actual &&
981 git remote get-url "$@" >actual &&
982 test_cmp expect actual
985 test_expect_success 'get-url on new remote' '
986 echo foo | get_url_test someremote &&
987 echo foo | get_url_test --all someremote &&
988 echo foo | get_url_test --push someremote &&
989 echo foo | get_url_test --push --all someremote
992 test_expect_success 'remote set-url with locked config' '
993 test_when_finished "rm -f .git/config.lock" &&
994 git config --get-all remote.someremote.url >expect &&
996 test_must_fail git remote set-url someremote baz &&
997 git config --get-all remote.someremote.url >actual &&
1001 test_expect_success 'remote set-url bar' '
1002 git remote set-url someremote bar &&
1004 git config --get-all remote.someremote.url >actual &&
1008 test_expect_success 'remote set-url baz bar' '
1009 git remote set-url someremote baz bar &&
1011 git config --get-all remote.someremote.url >actual &&
1015 test_expect_success 'remote set-url zot bar' '
1016 test_must_fail git remote set-url someremote zot bar &&
1018 git config --get-all remote.someremote.url >actual &&
1022 test_expect_success 'remote set-url --push zot baz' '
1023 test_must_fail git remote set-url --push someremote zot baz &&
1024 echo "YYY" >expect &&
1025 echo baz >>expect &&
1026 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1027 echo "YYY" >>actual &&
1028 git config --get-all remote.someremote.url >>actual &&
1032 test_expect_success 'remote set-url --push zot' '
1033 git remote set-url --push someremote zot &&
1035 echo "YYY" >>expect &&
1036 echo baz >>expect &&
1037 git config --get-all remote.someremote.pushurl >actual &&
1038 echo "YYY" >>actual &&
1039 git config --get-all remote.someremote.url >>actual &&
1043 test_expect_success 'get-url with different urls' '
1044 echo baz | get_url_test someremote &&
1045 echo baz | get_url_test --all someremote &&
1046 echo zot | get_url_test --push someremote &&
1047 echo zot | get_url_test --push --all someremote
1050 test_expect_success 'remote set-url --push qux zot' '
1051 git remote set-url --push someremote qux zot &&
1053 echo "YYY" >>expect &&
1054 echo baz >>expect &&
1055 git config --get-all remote.someremote.pushurl >actual &&
1056 echo "YYY" >>actual &&
1057 git config --get-all remote.someremote.url >>actual &&
1061 test_expect_success 'remote set-url --push foo qu+x' '
1062 git remote set-url --push someremote foo qu+x &&
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 'remote set-url --push --add aaa' '
1073 git remote set-url --push --add someremote aaa &&
1075 echo aaa >>expect &&
1076 echo "YYY" >>expect &&
1077 echo baz >>expect &&
1078 git config --get-all remote.someremote.pushurl >actual &&
1079 echo "YYY" >>actual &&
1080 git config --get-all remote.someremote.url >>actual &&
1084 test_expect_success 'get-url on multi push remote' '
1085 echo foo | get_url_test --push someremote &&
1086 get_url_test --push --all someremote <<-\EOF
1092 test_expect_success 'remote set-url --push bar aaa' '
1093 git remote set-url --push someremote bar aaa &&
1095 echo bar >>expect &&
1096 echo "YYY" >>expect &&
1097 echo baz >>expect &&
1098 git config --get-all remote.someremote.pushurl >actual &&
1099 echo "YYY" >>actual &&
1100 git config --get-all remote.someremote.url >>actual &&
1104 test_expect_success 'remote set-url --push --delete bar' '
1105 git remote set-url --push --delete someremote bar &&
1107 echo "YYY" >>expect &&
1108 echo baz >>expect &&
1109 git config --get-all remote.someremote.pushurl >actual &&
1110 echo "YYY" >>actual &&
1111 git config --get-all remote.someremote.url >>actual &&
1115 test_expect_success 'remote set-url --push --delete foo' '
1116 git remote set-url --push --delete someremote foo &&
1117 echo "YYY" >expect &&
1118 echo baz >>expect &&
1119 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1120 echo "YYY" >>actual &&
1121 git config --get-all remote.someremote.url >>actual &&
1125 test_expect_success 'remote set-url --add bbb' '
1126 git remote set-url --add someremote bbb &&
1127 echo "YYY" >expect &&
1128 echo baz >>expect &&
1129 echo bbb >>expect &&
1130 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1131 echo "YYY" >>actual &&
1132 git config --get-all remote.someremote.url >>actual &&
1136 test_expect_success 'get-url on multi fetch remote' '
1137 echo baz | get_url_test someremote &&
1138 get_url_test --all someremote <<-\EOF
1144 test_expect_success 'remote set-url --delete .*' '
1145 test_must_fail git remote set-url --delete someremote .\* &&
1146 echo "YYY" >expect &&
1147 echo baz >>expect &&
1148 echo bbb >>expect &&
1149 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1150 echo "YYY" >>actual &&
1151 git config --get-all remote.someremote.url >>actual &&
1155 test_expect_success 'remote set-url --delete bbb' '
1156 git remote set-url --delete someremote bbb &&
1157 echo "YYY" >expect &&
1158 echo baz >>expect &&
1159 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1160 echo "YYY" >>actual &&
1161 git config --get-all remote.someremote.url >>actual &&
1165 test_expect_success 'remote set-url --delete baz' '
1166 test_must_fail git remote set-url --delete someremote baz &&
1167 echo "YYY" >expect &&
1168 echo baz >>expect &&
1169 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1170 echo "YYY" >>actual &&
1171 git config --get-all remote.someremote.url >>actual &&
1175 test_expect_success 'remote set-url --add ccc' '
1176 git remote set-url --add someremote ccc &&
1177 echo "YYY" >expect &&
1178 echo baz >>expect &&
1179 echo ccc >>expect &&
1180 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1181 echo "YYY" >>actual &&
1182 git config --get-all remote.someremote.url >>actual &&
1186 test_expect_success 'remote set-url --delete baz' '
1187 git remote set-url --delete someremote baz &&
1188 echo "YYY" >expect &&
1189 echo ccc >>expect &&
1190 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1191 echo "YYY" >>actual &&
1192 git config --get-all remote.someremote.url >>actual &&
1196 test_expect_success 'extra args: setup' '
1197 # add a dummy origin so that this does not trigger failure
1198 git remote add origin .
1202 test_expect_success "extra args: $*" "
1203 test_must_fail git remote $* bogus_extra_arg 2>actual &&
1204 test_i18ngrep '^usage:' actual
1208 test_extra_arg add nick url
1209 test_extra_arg rename origin newname
1210 test_extra_arg remove origin
1211 test_extra_arg set-head origin master
1212 # set-branches takes any number of args
1213 test_extra_arg get-url origin newurl
1214 test_extra_arg set-url origin newurl oldurl
1215 # show takes any number of args
1216 # prune takes any number of args
1217 # update takes any number of args
1219 test_expect_success 'add remote matching the "insteadOf" URL' '
1220 git config url.xyz@example.com.insteadOf backup &&
1221 git remote add backup xyz@example.com