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' '
349 git -C one branch -m side2 side &&
350 test_when_finished "git -C one branch -m side side2" &&
353 git remote prune --dry-run origin >output &&
354 git rev-parse refs/remotes/origin/side2 &&
355 test_must_fail git rev-parse refs/remotes/origin/side &&
356 test_i18ncmp expect output
360 test_expect_success 'add --mirror && prune' '
365 git remote add --mirror -f origin ../one
369 git branch -m side2 side
373 git rev-parse --verify refs/heads/side2 &&
374 test_must_fail git rev-parse --verify refs/heads/side &&
376 git remote prune origin &&
377 test_must_fail git rev-parse --verify refs/heads/side2 &&
378 git rev-parse --verify refs/heads/side
382 test_expect_success 'add --mirror=fetch' '
383 mkdir mirror-fetch &&
384 git init mirror-fetch/parent &&
386 cd mirror-fetch/parent &&
389 git init --bare mirror-fetch/child &&
391 cd mirror-fetch/child &&
392 git remote add --mirror=fetch -f parent ../parent
396 test_expect_success 'fetch mirrors act as mirrors during fetch' '
398 cd mirror-fetch/parent &&
400 git branch -m master renamed
403 cd mirror-fetch/child &&
405 git rev-parse --verify refs/heads/new &&
406 git rev-parse --verify refs/heads/renamed
410 test_expect_success 'fetch mirrors can prune' '
412 cd mirror-fetch/child &&
413 git remote prune parent &&
414 test_must_fail git rev-parse --verify refs/heads/master
418 test_expect_success 'fetch mirrors do not act as mirrors during push' '
420 cd mirror-fetch/parent &&
424 cd mirror-fetch/child &&
425 git branch -m renamed renamed2 &&
429 cd mirror-fetch/parent &&
430 git rev-parse --verify renamed &&
431 test_must_fail git rev-parse --verify refs/heads/renamed2
435 test_expect_success 'add fetch mirror with specific branches' '
436 git init --bare mirror-fetch/track &&
438 cd mirror-fetch/track &&
439 git remote add --mirror=fetch -t heads/new parent ../parent
443 test_expect_success 'fetch mirror respects specific branches' '
445 cd mirror-fetch/track &&
447 git rev-parse --verify refs/heads/new &&
448 test_must_fail git rev-parse --verify refs/heads/renamed
452 test_expect_success 'add --mirror=push' '
454 git init --bare mirror-push/public &&
455 git init mirror-push/private &&
457 cd mirror-push/private &&
459 git remote add --mirror=push public ../public
463 test_expect_success 'push mirrors act as mirrors during push' '
465 cd mirror-push/private &&
467 git branch -m master renamed &&
471 cd mirror-push/private &&
472 git rev-parse --verify refs/heads/new &&
473 git rev-parse --verify refs/heads/renamed &&
474 test_must_fail git rev-parse --verify refs/heads/master
478 test_expect_success 'push mirrors do not act as mirrors during fetch' '
480 cd mirror-push/public &&
481 git branch -m renamed renamed2 &&
482 git symbolic-ref HEAD refs/heads/renamed2
485 cd mirror-push/private &&
487 git rev-parse --verify refs/heads/renamed &&
488 test_must_fail git rev-parse --verify refs/heads/renamed2
492 test_expect_success 'push mirrors do not allow you to specify refs' '
493 git init mirror-push/track &&
495 cd mirror-push/track &&
496 test_must_fail git remote add --mirror=push -t new public ../public
500 test_expect_success 'add alt && prune' '
505 git remote add -f origin ../one &&
506 git config remote.alt.url ../one &&
507 git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*"
511 git branch -m side side2
515 git rev-parse --verify refs/remotes/origin/side &&
516 test_must_fail git rev-parse --verify refs/remotes/origin/side2 &&
518 git remote prune alt &&
519 test_must_fail git rev-parse --verify refs/remotes/origin/side &&
520 git rev-parse --verify refs/remotes/origin/side2
524 cat >test/expect <<\EOF
528 test_expect_success 'add with reachable tags (default)' '
533 git commit -m "Foobar" &&
534 git tag -a -m "Foobar tag" foobar-tag &&
535 git reset --hard HEAD~1 &&
536 git tag -a -m "Some tag" some-tag
542 git remote add -f origin ../one &&
543 git tag -l some-tag >../test/output &&
544 git tag -l foobar-tag >>../test/output &&
545 test_must_fail git config remote.origin.tagopt
547 test_cmp test/expect test/output
550 cat >test/expect <<\EOF
556 test_expect_success 'add --tags' '
562 git remote add -f --tags origin ../one &&
563 git tag -l some-tag >../test/output &&
564 git tag -l foobar-tag >>../test/output &&
565 git config remote.origin.tagopt >>../test/output
567 test_cmp test/expect test/output
570 cat >test/expect <<\EOF
574 test_expect_success 'add --no-tags' '
580 git remote add -f --no-tags origin ../one &&
581 git tag -l some-tag >../test/output &&
582 git tag -l foobar-tag >../test/output &&
583 git config remote.origin.tagopt >>../test/output
587 git tag -d some-tag foobar-tag
589 test_cmp test/expect test/output
592 test_expect_success 'reject --no-no-tags' '
595 test_must_fail git remote add -f --no-no-tags neworigin ../one
599 cat >one/expect <<\EOF
607 test_expect_success 'update' '
610 git remote add drosophila ../two &&
611 git remote add apis ../mirror &&
613 git branch -r >output &&
614 test_cmp expect output
618 cat >one/expect <<\EOF
628 test_expect_success 'update with arguments' '
631 for b in $(git branch -r)
633 git branch -r -d $b || exit 1
635 git remote add manduca ../mirror &&
636 git remote add megaloprepus ../mirror &&
637 git config remotes.phobaeticus "drosophila megaloprepus" &&
638 git config remotes.titanus manduca &&
639 git remote update phobaeticus titanus &&
640 git branch -r >output &&
641 test_cmp expect output
645 test_expect_success 'update --prune' '
648 git branch -m side2 side3
652 git remote update --prune &&
655 git branch -m side3 side2
657 git rev-parse refs/remotes/origin/side3 &&
658 test_must_fail git rev-parse refs/remotes/origin/side2
662 cat >one/expect <<-\EOF
671 test_expect_success 'update default' '
674 for b in $(git branch -r)
676 git branch -r -d $b || exit 1
678 git config remote.drosophila.skipDefaultUpdate true &&
679 git remote update default &&
680 git branch -r >output &&
681 test_cmp expect output
685 cat >one/expect <<\EOF
691 test_expect_success 'update default (overridden, with funny whitespace)' '
694 for b in $(git branch -r)
696 git branch -r -d $b || exit 1
698 git config remotes.default "$(printf "\t drosophila \n")" &&
699 git remote update default &&
700 git branch -r >output &&
701 test_cmp expect output
705 test_expect_success 'update (with remotes.default defined)' '
708 for b in $(git branch -r)
710 git branch -r -d $b || exit 1
712 git config remotes.default "drosophila" &&
714 git branch -r >output &&
715 test_cmp expect output
719 test_expect_success '"remote show" does not show symbolic refs' '
720 git clone one three &&
723 git remote show origin >output &&
724 ! grep "^ *HEAD$" < output &&
725 ! grep -i stale < output
729 test_expect_success 'reject adding remote with an invalid name' '
730 test_must_fail git remote add some:url desired-name
733 # The first three test if the tracking branches are properly renamed,
734 # the last two ones check if the config is updated.
736 test_expect_success 'rename a remote' '
737 git clone one four &&
740 git config branch.master.pushRemote origin &&
741 git remote rename origin upstream &&
742 test -z "$(git for-each-ref refs/remotes/origin)" &&
743 test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" &&
744 test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" &&
745 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" &&
746 test "$(git config branch.master.remote)" = "upstream" &&
747 test "$(git config branch.master.pushRemote)" = "upstream"
751 test_expect_success 'rename does not update a non-default fetch refspec' '
752 git clone one four.one &&
755 git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* &&
756 git remote rename origin upstream &&
757 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*" &&
758 git rev-parse -q origin/master
762 test_expect_success 'rename a remote with name part of fetch spec' '
763 git clone one four.two &&
766 git remote rename origin remote &&
767 git remote rename remote upstream &&
768 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*"
772 test_expect_success 'rename a remote with name prefix of other remote' '
773 git clone one four.three &&
776 git remote add o git://example.com/repo.git &&
777 git remote rename o upstream &&
778 test "$(git rev-parse origin/master)" = "$(git rev-parse master)"
782 test_expect_success 'rename succeeds with existing remote.<target>.prune' '
783 git clone one four.four &&
784 test_when_finished git config --global --unset remote.upstream.prune &&
785 git config --global remote.upstream.prune true &&
786 git -C four.four remote rename origin upstream
789 test_expect_success 'remove a remote' '
790 git clone one four.five &&
793 git config branch.master.pushRemote origin &&
794 git remote remove origin &&
795 test -z "$(git for-each-ref refs/remotes/origin)" &&
796 test_must_fail git config branch.master.remote &&
797 test_must_fail git config branch.master.pushRemote
801 cat >remotes_origin <<EOF
803 Push: refs/heads/master:refs/heads/upstream
804 Push: refs/heads/next:refs/heads/upstream2
805 Pull: refs/heads/master:refs/heads/origin
806 Pull: refs/heads/next:refs/heads/origin2
809 test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
810 git clone one five &&
811 origin_url=$(pwd)/one &&
814 git remote remove origin &&
815 mkdir -p .git/remotes &&
816 cat ../remotes_origin >.git/remotes/origin &&
817 git remote rename origin origin &&
818 test_path_is_missing .git/remotes/origin &&
819 test "$(git config remote.origin.url)" = "$origin_url" &&
820 cat >push_expected <<-\EOF &&
821 refs/heads/master:refs/heads/upstream
822 refs/heads/next:refs/heads/upstream2
824 cat >fetch_expected <<-\EOF &&
825 refs/heads/master:refs/heads/origin
826 refs/heads/next:refs/heads/origin2
828 git config --get-all remote.origin.push >push_actual &&
829 git config --get-all remote.origin.fetch >fetch_actual &&
830 test_cmp push_expected push_actual &&
831 test_cmp fetch_expected fetch_actual
835 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
837 origin_url=$(pwd)/one &&
840 git remote rm origin &&
841 echo "$origin_url" >.git/branches/origin &&
842 git remote rename origin origin &&
843 test_path_is_missing .git/branches/origin &&
844 test "$(git config remote.origin.url)" = "$origin_url" &&
845 test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin" &&
846 test "$(git config remote.origin.push)" = "HEAD:refs/heads/master"
850 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' '
851 git clone one seven &&
854 git remote rm origin &&
855 echo "quux#foom" > .git/branches/origin &&
856 git remote rename origin origin &&
857 test_path_is_missing .git/branches/origin &&
858 test "$(git config remote.origin.url)" = "quux" &&
859 test "$(git config remote.origin.fetch)" = "refs/heads/foom:refs/heads/origin" &&
860 test "$(git config remote.origin.push)" = "HEAD:refs/heads/foom"
864 test_expect_success 'remote prune to cause a dangling symref' '
865 git clone one eight &&
868 git checkout side2 &&
873 git remote prune origin
875 test_i18ngrep "has become dangling" err &&
877 : And the dangling symref will not cause other annoying errors &&
882 ! grep "points nowhere" err &&
885 test_must_fail git branch nomore origin
887 test_i18ngrep "dangling symref" err
890 test_expect_success 'show empty remote' '
891 test_create_repo empty &&
892 git clone empty empty-clone &&
895 git remote show origin
899 test_expect_success 'remote set-branches requires a remote' '
900 test_must_fail git remote set-branches &&
901 test_must_fail git remote set-branches --add
904 test_expect_success 'remote set-branches' '
905 echo "+refs/heads/*:refs/remotes/scratch/*" >expect.initial &&
906 sort <<-\EOF >expect.add &&
907 +refs/heads/*:refs/remotes/scratch/*
908 +refs/heads/other:refs/remotes/scratch/other
910 sort <<-\EOF >expect.replace &&
911 +refs/heads/maint:refs/remotes/scratch/maint
912 +refs/heads/master:refs/remotes/scratch/master
913 +refs/heads/next:refs/remotes/scratch/next
915 sort <<-\EOF >expect.add-two &&
916 +refs/heads/maint:refs/remotes/scratch/maint
917 +refs/heads/master:refs/remotes/scratch/master
918 +refs/heads/next:refs/remotes/scratch/next
919 +refs/heads/pu:refs/remotes/scratch/pu
920 +refs/heads/t/topic:refs/remotes/scratch/t/topic
922 sort <<-\EOF >expect.setup-ffonly &&
923 refs/heads/master:refs/remotes/scratch/master
924 +refs/heads/next:refs/remotes/scratch/next
926 sort <<-\EOF >expect.respect-ffonly &&
927 refs/heads/master:refs/remotes/scratch/master
928 +refs/heads/next:refs/remotes/scratch/next
929 +refs/heads/pu:refs/remotes/scratch/pu
932 git clone .git/ setbranches &&
935 git remote rename origin scratch &&
936 git config --get-all remote.scratch.fetch >config-result &&
937 sort <config-result >../actual.initial &&
939 git remote set-branches scratch --add other &&
940 git config --get-all remote.scratch.fetch >config-result &&
941 sort <config-result >../actual.add &&
943 git remote set-branches scratch maint master next &&
944 git config --get-all remote.scratch.fetch >config-result &&
945 sort <config-result >../actual.replace &&
947 git remote set-branches --add scratch pu t/topic &&
948 git config --get-all remote.scratch.fetch >config-result &&
949 sort <config-result >../actual.add-two &&
951 git config --unset-all remote.scratch.fetch &&
952 git config remote.scratch.fetch \
953 refs/heads/master:refs/remotes/scratch/master &&
954 git config --add remote.scratch.fetch \
955 +refs/heads/next:refs/remotes/scratch/next &&
956 git config --get-all remote.scratch.fetch >config-result &&
957 sort <config-result >../actual.setup-ffonly &&
959 git remote set-branches --add scratch pu &&
960 git config --get-all remote.scratch.fetch >config-result &&
961 sort <config-result >../actual.respect-ffonly
963 test_cmp expect.initial actual.initial &&
964 test_cmp expect.add actual.add &&
965 test_cmp expect.replace actual.replace &&
966 test_cmp expect.add-two actual.add-two &&
967 test_cmp expect.setup-ffonly actual.setup-ffonly &&
968 test_cmp expect.respect-ffonly actual.respect-ffonly
971 test_expect_success 'remote set-branches with --mirror' '
972 echo "+refs/*:refs/*" >expect.initial &&
973 echo "+refs/heads/master:refs/heads/master" >expect.replace &&
974 git clone --mirror .git/ setbranches-mirror &&
976 cd setbranches-mirror &&
977 git remote rename origin scratch &&
978 git config --get-all remote.scratch.fetch >../actual.initial &&
980 git remote set-branches scratch heads/master &&
981 git config --get-all remote.scratch.fetch >../actual.replace
983 test_cmp expect.initial actual.initial &&
984 test_cmp expect.replace actual.replace
987 test_expect_success 'new remote' '
988 git remote add someremote foo &&
990 git config --get-all remote.someremote.url >actual &&
996 git remote get-url "$@" >actual &&
997 test_cmp expect actual
1000 test_expect_success 'get-url on new remote' '
1001 echo foo | get_url_test someremote &&
1002 echo foo | get_url_test --all someremote &&
1003 echo foo | get_url_test --push someremote &&
1004 echo foo | get_url_test --push --all someremote
1007 test_expect_success 'remote set-url with locked config' '
1008 test_when_finished "rm -f .git/config.lock" &&
1009 git config --get-all remote.someremote.url >expect &&
1010 >.git/config.lock &&
1011 test_must_fail git remote set-url someremote baz &&
1012 git config --get-all remote.someremote.url >actual &&
1016 test_expect_success 'remote set-url bar' '
1017 git remote set-url someremote bar &&
1019 git config --get-all remote.someremote.url >actual &&
1023 test_expect_success 'remote set-url baz bar' '
1024 git remote set-url someremote baz bar &&
1026 git config --get-all remote.someremote.url >actual &&
1030 test_expect_success 'remote set-url zot bar' '
1031 test_must_fail git remote set-url someremote zot bar &&
1033 git config --get-all remote.someremote.url >actual &&
1037 test_expect_success 'remote set-url --push zot baz' '
1038 test_must_fail git remote set-url --push someremote zot baz &&
1039 echo "YYY" >expect &&
1040 echo baz >>expect &&
1041 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1042 echo "YYY" >>actual &&
1043 git config --get-all remote.someremote.url >>actual &&
1047 test_expect_success 'remote set-url --push zot' '
1048 git remote set-url --push someremote zot &&
1050 echo "YYY" >>expect &&
1051 echo baz >>expect &&
1052 git config --get-all remote.someremote.pushurl >actual &&
1053 echo "YYY" >>actual &&
1054 git config --get-all remote.someremote.url >>actual &&
1058 test_expect_success 'get-url with different urls' '
1059 echo baz | get_url_test someremote &&
1060 echo baz | get_url_test --all someremote &&
1061 echo zot | get_url_test --push someremote &&
1062 echo zot | get_url_test --push --all someremote
1065 test_expect_success 'remote set-url --push qux zot' '
1066 git remote set-url --push someremote qux zot &&
1068 echo "YYY" >>expect &&
1069 echo baz >>expect &&
1070 git config --get-all remote.someremote.pushurl >actual &&
1071 echo "YYY" >>actual &&
1072 git config --get-all remote.someremote.url >>actual &&
1076 test_expect_success 'remote set-url --push foo qu+x' '
1077 git remote set-url --push someremote foo qu+x &&
1079 echo "YYY" >>expect &&
1080 echo baz >>expect &&
1081 git config --get-all remote.someremote.pushurl >actual &&
1082 echo "YYY" >>actual &&
1083 git config --get-all remote.someremote.url >>actual &&
1087 test_expect_success 'remote set-url --push --add aaa' '
1088 git remote set-url --push --add someremote aaa &&
1090 echo aaa >>expect &&
1091 echo "YYY" >>expect &&
1092 echo baz >>expect &&
1093 git config --get-all remote.someremote.pushurl >actual &&
1094 echo "YYY" >>actual &&
1095 git config --get-all remote.someremote.url >>actual &&
1099 test_expect_success 'get-url on multi push remote' '
1100 echo foo | get_url_test --push someremote &&
1101 get_url_test --push --all someremote <<-\EOF
1107 test_expect_success 'remote set-url --push bar aaa' '
1108 git remote set-url --push someremote bar aaa &&
1110 echo bar >>expect &&
1111 echo "YYY" >>expect &&
1112 echo baz >>expect &&
1113 git config --get-all remote.someremote.pushurl >actual &&
1114 echo "YYY" >>actual &&
1115 git config --get-all remote.someremote.url >>actual &&
1119 test_expect_success 'remote set-url --push --delete bar' '
1120 git remote set-url --push --delete someremote bar &&
1122 echo "YYY" >>expect &&
1123 echo baz >>expect &&
1124 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 --push --delete foo' '
1131 git remote set-url --push --delete someremote foo &&
1132 echo "YYY" >expect &&
1133 echo baz >>expect &&
1134 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1135 echo "YYY" >>actual &&
1136 git config --get-all remote.someremote.url >>actual &&
1140 test_expect_success 'remote set-url --add bbb' '
1141 git remote set-url --add someremote bbb &&
1142 echo "YYY" >expect &&
1143 echo baz >>expect &&
1144 echo bbb >>expect &&
1145 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1146 echo "YYY" >>actual &&
1147 git config --get-all remote.someremote.url >>actual &&
1151 test_expect_success 'get-url on multi fetch remote' '
1152 echo baz | get_url_test someremote &&
1153 get_url_test --all someremote <<-\EOF
1159 test_expect_success 'remote set-url --delete .*' '
1160 test_must_fail git remote set-url --delete someremote .\* &&
1161 echo "YYY" >expect &&
1162 echo baz >>expect &&
1163 echo bbb >>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 bbb' '
1171 git remote set-url --delete someremote bbb &&
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 --delete baz' '
1181 test_must_fail git remote set-url --delete someremote baz &&
1182 echo "YYY" >expect &&
1183 echo baz >>expect &&
1184 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1185 echo "YYY" >>actual &&
1186 git config --get-all remote.someremote.url >>actual &&
1190 test_expect_success 'remote set-url --add ccc' '
1191 git remote set-url --add someremote ccc &&
1192 echo "YYY" >expect &&
1193 echo baz >>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 'remote set-url --delete baz' '
1202 git remote set-url --delete someremote baz &&
1203 echo "YYY" >expect &&
1204 echo ccc >>expect &&
1205 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
1206 echo "YYY" >>actual &&
1207 git config --get-all remote.someremote.url >>actual &&
1211 test_expect_success 'extra args: setup' '
1212 # add a dummy origin so that this does not trigger failure
1213 git remote add origin .
1217 test_expect_success "extra args: $*" "
1218 test_must_fail git remote $* bogus_extra_arg 2>actual &&
1219 test_i18ngrep '^usage:' actual
1223 test_extra_arg add nick url
1224 test_extra_arg rename origin newname
1225 test_extra_arg remove origin
1226 test_extra_arg set-head origin master
1227 # set-branches takes any number of args
1228 test_extra_arg get-url origin newurl
1229 test_extra_arg set-url origin newurl oldurl
1230 # show takes any number of args
1231 # prune takes any number of args
1232 # update takes any number of args
1234 test_expect_success 'add remote matching the "insteadOf" URL' '
1235 git config url.xyz@example.com.insteadOf backup &&
1236 git remote add backup xyz@example.com
1239 test_expect_success 'unqualified <dst> refspec DWIM and advice' '
1240 test_when_finished "(cd test && git tag -d some-tag)" &&
1243 git tag -a -m "Some tag" some-tag master &&
1245 for type in commit tag tree blob
1247 if test "$type" = "blob"
1249 oid=$(git rev-parse some-tag:file)
1251 oid=$(git rev-parse some-tag^{$type})
1253 test_must_fail git push origin $oid:dst 2>err &&
1254 test_i18ngrep "error: The destination you" err &&
1255 test_i18ngrep "hint: Did you mean" err &&
1256 test_must_fail git -c advice.pushUnqualifiedRefName=false \
1257 push origin $oid:dst 2>err &&
1258 test_i18ngrep "error: The destination you" err &&
1259 test_i18ngrep ! "hint: Did you mean" err ||
1266 test_expect_success 'refs/remotes/* <src> refspec and unqualified <dst> DWIM and advice' '
1269 git tag -a -m "Some tag" my-tag master &&
1270 git update-ref refs/trees/my-head-tree HEAD^{tree} &&
1271 git update-ref refs/blobs/my-file-blob HEAD:file
1275 git config --add remote.two.fetch "+refs/tags/*:refs/remotes/tags-from-two/*" &&
1276 git config --add remote.two.fetch "+refs/trees/*:refs/remotes/trees-from-two/*" &&
1277 git config --add remote.two.fetch "+refs/blobs/*:refs/remotes/blobs-from-two/*" &&
1278 git fetch --no-tags two &&
1280 test_must_fail git push origin refs/remotes/two/another:dst 2>err &&
1281 test_i18ngrep "error: The destination you" err &&
1283 test_must_fail git push origin refs/remotes/tags-from-two/my-tag:dst-tag 2>err &&
1284 test_i18ngrep "error: The destination you" err &&
1286 test_must_fail git push origin refs/remotes/trees-from-two/my-head-tree:dst-tree 2>err &&
1287 test_i18ngrep "error: The destination you" err &&
1289 test_must_fail git push origin refs/remotes/blobs-from-two/my-file-blob:dst-blob 2>err &&
1290 test_i18ngrep "error: The destination you" err