]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5505-remote.sh
Change incorrect uses of "remote branch" meaning "remote-tracking"
[thirdparty/git.git] / t / t5505-remote.sh
CommitLineData
683b5679
JH
1#!/bin/sh
2
3test_description='git remote porcelain-ish'
4
5. ./test-lib.sh
6
683b5679
JH
7setup_repository () {
8 mkdir "$1" && (
9 cd "$1" &&
10 git init &&
11 >file &&
12 git add file &&
84521ed6 13 test_tick &&
683b5679
JH
14 git commit -m "Initial" &&
15 git checkout -b side &&
16 >elif &&
17 git add elif &&
84521ed6 18 test_tick &&
683b5679
JH
19 git commit -m "Second" &&
20 git checkout master
21 )
22}
23
24tokens_match () {
25 echo "$1" | tr ' ' '\012' | sort | sed -e '/^$/d' >expect &&
26 echo "$2" | tr ' ' '\012' | sort | sed -e '/^$/d' >actual &&
82ebb0b6 27 test_cmp expect actual
683b5679
JH
28}
29
30check_remote_track () {
7ecbbf87 31 actual=$(git remote show "$1" | sed -ne 's|^ \(.*\) tracked$|\1|p')
683b5679
JH
32 shift &&
33 tokens_match "$*" "$actual"
34}
35
36check_tracking_branch () {
37 f="" &&
38 r=$(git for-each-ref "--format=%(refname)" |
39 sed -ne "s|^refs/remotes/$1/||p") &&
40 shift &&
41 tokens_match "$*" "$r"
42}
43
44test_expect_success setup '
45
46 setup_repository one &&
47 setup_repository two &&
48 (
49 cd two && git branch another
50 ) &&
51 git clone one test
52
53'
54
55test_expect_success 'remote information for the origin' '
56(
57 cd test &&
58 tokens_match origin "$(git remote)" &&
59 check_remote_track origin master side &&
60 check_tracking_branch origin HEAD master side
61)
62'
63
64test_expect_success 'add another remote' '
65(
66 cd test &&
67 git remote add -f second ../two &&
68 tokens_match "origin second" "$(git remote)" &&
69 check_remote_track origin master side &&
70 check_remote_track second master side another &&
71 check_tracking_branch second master side another &&
72 git for-each-ref "--format=%(refname)" refs/remotes |
73 sed -e "/^refs\/remotes\/origin\//d" \
74 -e "/^refs\/remotes\/second\//d" >actual &&
75 >expect &&
82ebb0b6 76 test_cmp expect actual
683b5679
JH
77)
78'
79
1ce89cc4
JK
80test_expect_success 'remote forces tracking branches' '
81(
82 cd test &&
83 case `git config remote.second.fetch` in
84 +*) true ;;
85 *) false ;;
86 esac
87)
88'
89
683b5679
JH
90test_expect_success 'remove remote' '
91(
92 cd test &&
3b9dcff5 93 git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
683b5679
JH
94 git remote rm second
95)
96'
97
98test_expect_success 'remove remote' '
99(
100 cd test &&
101 tokens_match origin "$(git remote)" &&
102 check_remote_track origin master side &&
103 git for-each-ref "--format=%(refname)" refs/remotes |
104 sed -e "/^refs\/remotes\/origin\//d" >actual &&
105 >expect &&
82ebb0b6 106 test_cmp expect actual
683b5679
JH
107)
108'
109
441adf0c
JS
110test_expect_success 'remove remote protects non-remote branches' '
111(
112 cd test &&
65f83dc0 113 { cat >expect1 <<EOF
441adf0c
JS
114Note: A non-remote branch was not removed; to delete it, use:
115 git branch -d master
116EOF
65f83dc0
BC
117 } &&
118 { cat >expect2 <<EOF
441adf0c
JS
119Note: Non-remote branches were not removed; to delete them, use:
120 git branch -d foobranch
121 git branch -d master
122EOF
65f83dc0 123 } &&
f3b1fbf8 124 git tag footag &&
441adf0c
JS
125 git config --add remote.oops.fetch "+refs/*:refs/*" &&
126 git remote rm oops 2>actual1 &&
127 git branch foobranch &&
128 git config --add remote.oops.fetch "+refs/*:refs/*" &&
129 git remote rm oops 2>actual2 &&
130 git branch -d foobranch &&
131 git tag -d footag &&
132 test_cmp expect1 actual1 &&
133 test_cmp expect2 actual2
134)
135'
136
4704640b
JS
137cat > test/expect << EOF
138* remote origin
857f8c30
MG
139 Fetch URL: $(pwd)/one
140 Push URL: $(pwd)/one
e61e0cc6 141 HEAD branch: master
7ecbbf87
JS
142 Remote branches:
143 master new (next fetch will store in remotes/origin)
144 side tracked
145 Local branches configured for 'git pull':
e5dcbfd9 146 ahead merges with remote master
7ecbbf87
JS
147 master merges with remote master
148 octopus merges with remote topic-a
149 and with remote topic-b
150 and with remote topic-c
151 rebase rebases onto remote master
e5dcbfd9
JS
152 Local refs configured for 'git push':
153 master pushes to master (local out of date)
154 master pushes to upstream (create)
e61e0cc6 155* remote two
857f8c30
MG
156 Fetch URL: ../two
157 Push URL: ../three
e61e0cc6
JS
158 HEAD branch (remote HEAD is ambiguous, may be one of the following):
159 another
160 master
e5dcbfd9 161 Local refs configured for 'git push':
a75d7b54 162 ahead forces to master (fast-forwardable)
e5dcbfd9 163 master pushes to another (up to date)
4704640b
JS
164EOF
165
166test_expect_success 'show' '
167 (cd test &&
7ecbbf87 168 git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream &&
4704640b 169 git fetch &&
e5dcbfd9
JS
170 git checkout -b ahead origin/master &&
171 echo 1 >> file &&
172 test_tick &&
173 git commit -m update file &&
174 git checkout master &&
7ecbbf87
JS
175 git branch --track octopus origin/master &&
176 git branch --track rebase origin/master &&
4704640b 177 git branch -d -r origin/master &&
e61e0cc6 178 git config --add remote.two.url ../two &&
857f8c30 179 git config --add remote.two.pushurl ../three &&
7ecbbf87
JS
180 git config branch.rebase.rebase true &&
181 git config branch.octopus.merge "topic-a topic-b topic-c" &&
4704640b
JS
182 (cd ../one &&
183 echo 1 > file &&
84521ed6 184 test_tick &&
4704640b 185 git commit -m update file) &&
e5dcbfd9
JS
186 git config --add remote.origin.push : &&
187 git config --add remote.origin.push refs/heads/master:refs/heads/upstream &&
7ecbbf87 188 git config --add remote.origin.push +refs/tags/lastbackup &&
e5dcbfd9
JS
189 git config --add remote.two.push +refs/heads/ahead:refs/heads/master &&
190 git config --add remote.two.push refs/heads/master:refs/heads/another &&
e61e0cc6 191 git remote show origin two > output &&
7ecbbf87 192 git branch -d rebase octopus &&
3af82863 193 test_cmp expect output)
4704640b
JS
194'
195
0ecfcb3b
OM
196cat > test/expect << EOF
197* remote origin
857f8c30
MG
198 Fetch URL: $(pwd)/one
199 Push URL: $(pwd)/one
e61e0cc6 200 HEAD branch: (not queried)
7ecbbf87 201 Remote branches: (status not queried)
20244ea2
JS
202 master
203 side
e5dcbfd9
JS
204 Local branches configured for 'git pull':
205 ahead merges with remote master
7ecbbf87 206 master merges with remote master
e5dcbfd9
JS
207 Local refs configured for 'git push' (status not queried):
208 (matching) pushes to (matching)
209 refs/heads/master pushes to refs/heads/upstream
210 refs/tags/lastbackup forces to refs/tags/lastbackup
0ecfcb3b
OM
211EOF
212
213test_expect_success 'show -n' '
214 (mv one one.unreachable &&
215 cd test &&
216 git remote show -n origin > output &&
217 mv ../one.unreachable ../one &&
218 test_cmp expect output)
219'
220
4704640b
JS
221test_expect_success 'prune' '
222 (cd one &&
223 git branch -m side side2) &&
224 (cd test &&
225 git fetch origin &&
226 git remote prune origin &&
227 git rev-parse refs/remotes/origin/side2 &&
d492b31c 228 test_must_fail git rev-parse refs/remotes/origin/side)
4704640b
JS
229'
230
bc14fac8
JS
231test_expect_success 'set-head --delete' '
232 (cd test &&
233 git symbolic-ref refs/remotes/origin/HEAD &&
234 git remote set-head --delete origin &&
235 test_must_fail git symbolic-ref refs/remotes/origin/HEAD)
236'
237
238test_expect_success 'set-head --auto' '
239 (cd test &&
240 git remote set-head --auto origin &&
241 echo refs/remotes/origin/master >expect &&
242 git symbolic-ref refs/remotes/origin/HEAD >output &&
243 test_cmp expect output
244 )
245'
246
247cat >test/expect <<EOF
248error: Multiple remote HEAD branches. Please choose one explicitly with:
249 git remote set-head two another
250 git remote set-head two master
251EOF
252
253test_expect_success 'set-head --auto fails w/multiple HEADs' '
254 (cd test &&
255 test_must_fail git remote set-head --auto two >output 2>&1 &&
256 test_cmp expect output)
257'
258
259cat >test/expect <<EOF
260refs/remotes/origin/side2
261EOF
262
263test_expect_success 'set-head explicit' '
264 (cd test &&
265 git remote set-head origin side2 &&
266 git symbolic-ref refs/remotes/origin/HEAD >output &&
267 git remote set-head origin master &&
268 test_cmp expect output)
269'
270
8d767927
OM
271cat > test/expect << EOF
272Pruning origin
86521aca 273URL: $(pwd)/one
8d767927
OM
274 * [would prune] origin/side2
275EOF
276
277test_expect_success 'prune --dry-run' '
278 (cd one &&
279 git branch -m side2 side) &&
280 (cd test &&
281 git remote prune --dry-run origin > output &&
282 git rev-parse refs/remotes/origin/side2 &&
d492b31c 283 test_must_fail git rev-parse refs/remotes/origin/side &&
8d767927
OM
284 (cd ../one &&
285 git branch -m side side2) &&
286 test_cmp expect output)
287'
288
4ebc914c
JS
289test_expect_success 'add --mirror && prune' '
290 (mkdir mirror &&
291 cd mirror &&
8ee5d731 292 git init --bare &&
4ebc914c
JS
293 git remote add --mirror -f origin ../one) &&
294 (cd one &&
295 git branch -m side2 side) &&
296 (cd mirror &&
297 git rev-parse --verify refs/heads/side2 &&
d492b31c 298 test_must_fail git rev-parse --verify refs/heads/side &&
4ebc914c
JS
299 git fetch origin &&
300 git remote prune origin &&
d492b31c 301 test_must_fail git rev-parse --verify refs/heads/side2 &&
4ebc914c
JS
302 git rev-parse --verify refs/heads/side)
303'
304
c175a7ad
SP
305test_expect_success 'add alt && prune' '
306 (mkdir alttst &&
307 cd alttst &&
308 git init &&
309 git remote add -f origin ../one &&
310 git config remote.alt.url ../one &&
311 git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*") &&
312 (cd one &&
313 git branch -m side side2) &&
314 (cd alttst &&
315 git rev-parse --verify refs/remotes/origin/side &&
d492b31c 316 test_must_fail git rev-parse --verify refs/remotes/origin/side2 &&
c175a7ad
SP
317 git fetch alt &&
318 git remote prune alt &&
d492b31c 319 test_must_fail git rev-parse --verify refs/remotes/origin/side &&
c175a7ad
SP
320 git rev-parse --verify refs/remotes/origin/side2)
321'
322
111fb858
ST
323cat >test/expect <<\EOF
324some-tag
325EOF
326
327test_expect_success 'add with reachable tags (default)' '
328 (cd one &&
329 >foobar &&
330 git add foobar &&
331 git commit -m "Foobar" &&
332 git tag -a -m "Foobar tag" foobar-tag &&
333 git reset --hard HEAD~1 &&
334 git tag -a -m "Some tag" some-tag) &&
335 (mkdir add-tags &&
336 cd add-tags &&
337 git init &&
338 git remote add -f origin ../one &&
339 git tag -l some-tag >../test/output &&
340 git tag -l foobar-tag >>../test/output &&
341 test_must_fail git config remote.origin.tagopt) &&
342 test_cmp test/expect test/output
343'
344
345cat >test/expect <<\EOF
346some-tag
347foobar-tag
348--tags
349EOF
350
351test_expect_success 'add --tags' '
352 (rm -rf add-tags &&
353 mkdir add-tags &&
354 cd add-tags &&
355 git init &&
356 git remote add -f --tags origin ../one &&
357 git tag -l some-tag >../test/output &&
358 git tag -l foobar-tag >>../test/output &&
359 git config remote.origin.tagopt >>../test/output) &&
360 test_cmp test/expect test/output
361'
362
363cat >test/expect <<\EOF
364--no-tags
365EOF
366
367test_expect_success 'add --no-tags' '
368 (rm -rf add-tags &&
369 mkdir add-no-tags &&
370 cd add-no-tags &&
371 git init &&
372 git remote add -f --no-tags origin ../one &&
373 git tag -l some-tag >../test/output &&
374 git tag -l foobar-tag >../test/output &&
375 git config remote.origin.tagopt >>../test/output) &&
376 (cd one &&
377 git tag -d some-tag foobar-tag) &&
378 test_cmp test/expect test/output
379'
380
381test_expect_success 'reject --no-no-tags' '
382 (cd add-no-tags &&
383 test_must_fail git remote add -f --no-no-tags neworigin ../one)
384'
385
84521ed6
JS
386cat > one/expect << EOF
387 apis/master
388 apis/side
389 drosophila/another
390 drosophila/master
391 drosophila/side
392EOF
393
394test_expect_success 'update' '
395
396 (cd one &&
397 git remote add drosophila ../two &&
398 git remote add apis ../mirror &&
399 git remote update &&
400 git branch -r > output &&
3af82863 401 test_cmp expect output)
84521ed6
JS
402
403'
404
405cat > one/expect << EOF
406 drosophila/another
407 drosophila/master
408 drosophila/side
409 manduca/master
410 manduca/side
411 megaloprepus/master
412 megaloprepus/side
413EOF
414
415test_expect_success 'update with arguments' '
416
417 (cd one &&
418 for b in $(git branch -r)
419 do
420 git branch -r -d $b || break
421 done &&
422 git remote add manduca ../mirror &&
423 git remote add megaloprepus ../mirror &&
424 git config remotes.phobaeticus "drosophila megaloprepus" &&
425 git config remotes.titanus manduca &&
426 git remote update phobaeticus titanus &&
427 git branch -r > output &&
3af82863 428 test_cmp expect output)
84521ed6
JS
429
430'
431
e2d41c64
BG
432test_expect_success 'update --prune' '
433
434 (cd one &&
435 git branch -m side2 side3) &&
436 (cd test &&
437 git remote update --prune &&
65b26eb4 438 (cd ../one && git branch -m side3 side2) &&
e2d41c64
BG
439 git rev-parse refs/remotes/origin/side3 &&
440 test_must_fail git rev-parse refs/remotes/origin/side2)
441'
442
84521ed6
JS
443cat > one/expect << EOF
444 apis/master
445 apis/side
446 manduca/master
447 manduca/side
448 megaloprepus/master
449 megaloprepus/side
450EOF
451
452test_expect_success 'update default' '
453
454 (cd one &&
455 for b in $(git branch -r)
456 do
457 git branch -r -d $b || break
458 done &&
459 git config remote.drosophila.skipDefaultUpdate true &&
460 git remote update default &&
461 git branch -r > output &&
3af82863 462 test_cmp expect output)
84521ed6
JS
463
464'
465
466cat > one/expect << EOF
467 drosophila/another
468 drosophila/master
469 drosophila/side
470EOF
471
472test_expect_success 'update default (overridden, with funny whitespace)' '
473
474 (cd one &&
475 for b in $(git branch -r)
476 do
477 git branch -r -d $b || break
478 done &&
479 git config remotes.default "$(printf "\t drosophila \n")" &&
480 git remote update default &&
481 git branch -r > output &&
3af82863 482 test_cmp expect output)
84521ed6
JS
483
484'
485
4f2e842d
BG
486test_expect_success 'update (with remotes.default defined)' '
487
488 (cd one &&
489 for b in $(git branch -r)
490 do
491 git branch -r -d $b || break
492 done &&
493 git config remotes.default "drosophila" &&
494 git remote update &&
495 git branch -r > output &&
496 test_cmp expect output)
497
498'
499
740fdd27
JS
500test_expect_success '"remote show" does not show symbolic refs' '
501
502 git clone one three &&
503 (cd three &&
504 git remote show origin > output &&
e61e0cc6 505 ! grep "^ *HEAD$" < output &&
740fdd27
JS
506 ! grep -i stale < output)
507
508'
509
24b6177e
JF
510test_expect_success 'reject adding remote with an invalid name' '
511
d492b31c 512 test_must_fail git remote add some:url desired-name
24b6177e
JF
513
514'
515
bf98421a
MV
516# The first three test if the tracking branches are properly renamed,
517# the last two ones check if the config is updated.
518
519test_expect_success 'rename a remote' '
520
521 git clone one four &&
522 (cd four &&
523 git remote rename origin upstream &&
524 rmdir .git/refs/remotes/origin &&
525 test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" &&
526 test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" &&
527 test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" &&
528 test "$(git config branch.master.remote)" = "upstream")
529
530'
1dd1239a
MV
531
532cat > remotes_origin << EOF
533URL: $(pwd)/one
534Push: refs/heads/master:refs/heads/upstream
535Pull: refs/heads/master:refs/heads/origin
536EOF
537
538test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
539 git clone one five &&
540 origin_url=$(pwd)/one &&
541 (cd five &&
542 git remote rm origin &&
543 mkdir -p .git/remotes &&
544 cat ../remotes_origin > .git/remotes/origin &&
545 git remote rename origin origin &&
546 ! test -f .git/remotes/origin &&
547 test "$(git config remote.origin.url)" = "$origin_url" &&
548 test "$(git config remote.origin.push)" = "refs/heads/master:refs/heads/upstream" &&
549 test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin")
550'
551
552test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
553 git clone one six &&
554 origin_url=$(pwd)/one &&
555 (cd six &&
556 git remote rm origin &&
557 echo "$origin_url" > .git/branches/origin &&
558 git remote rename origin origin &&
559 ! test -f .git/branches/origin &&
560 test "$(git config remote.origin.url)" = "$origin_url" &&
561 test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin")
562'
563
f8948e2f
JH
564test_expect_success 'remote prune to cause a dangling symref' '
565 git clone one seven &&
566 (
567 cd one &&
568 git checkout side2 &&
569 git branch -D master
570 ) &&
571 (
572 cd seven &&
573 git remote prune origin
e01de1c9 574 ) >err 2>&1 &&
f8948e2f
JH
575 grep "has become dangling" err &&
576
e01de1c9 577 : And the dangling symref will not cause other annoying errors &&
f8948e2f
JH
578 (
579 cd seven &&
580 git branch -a
581 ) 2>err &&
e01de1c9 582 ! grep "points nowhere" err &&
057e7138
JH
583 (
584 cd seven &&
585 test_must_fail git branch nomore origin
586 ) 2>err &&
587 grep "dangling symref" err
f8948e2f
JH
588'
589
6a01554e
CB
590test_expect_success 'show empty remote' '
591
592 test_create_repo empty &&
593 git clone empty empty-clone &&
594 (
595 cd empty-clone &&
596 git remote show origin
597 )
598'
599
3d8b6949
JN
600test_expect_success 'remote set-branches requires a remote' '
601 test_must_fail git remote set-branches &&
602 test_must_fail git remote set-branches --add
603'
604
605test_expect_success 'remote set-branches' '
606 echo "+refs/heads/*:refs/remotes/scratch/*" >expect.initial &&
607 sort <<-\EOF >expect.add &&
608 +refs/heads/*:refs/remotes/scratch/*
609 +refs/heads/other:refs/remotes/scratch/other
610 EOF
611 sort <<-\EOF >expect.replace &&
612 +refs/heads/maint:refs/remotes/scratch/maint
613 +refs/heads/master:refs/remotes/scratch/master
614 +refs/heads/next:refs/remotes/scratch/next
615 EOF
616 sort <<-\EOF >expect.add-two &&
617 +refs/heads/maint:refs/remotes/scratch/maint
618 +refs/heads/master:refs/remotes/scratch/master
619 +refs/heads/next:refs/remotes/scratch/next
620 +refs/heads/pu:refs/remotes/scratch/pu
621 +refs/heads/t/topic:refs/remotes/scratch/t/topic
622 EOF
623 sort <<-\EOF >expect.setup-ffonly &&
624 refs/heads/master:refs/remotes/scratch/master
625 +refs/heads/next:refs/remotes/scratch/next
626 EOF
627 sort <<-\EOF >expect.respect-ffonly &&
628 refs/heads/master:refs/remotes/scratch/master
629 +refs/heads/next:refs/remotes/scratch/next
630 +refs/heads/pu:refs/remotes/scratch/pu
631 EOF
632
633 git clone .git/ setbranches &&
634 (
635 cd setbranches &&
636 git remote rename origin scratch &&
637 git config --get-all remote.scratch.fetch >config-result &&
638 sort <config-result >../actual.initial &&
639
640 git remote set-branches scratch --add other &&
641 git config --get-all remote.scratch.fetch >config-result &&
642 sort <config-result >../actual.add &&
643
644 git remote set-branches scratch maint master next &&
645 git config --get-all remote.scratch.fetch >config-result &&
646 sort <config-result >../actual.replace &&
647
648 git remote set-branches --add scratch pu t/topic &&
649 git config --get-all remote.scratch.fetch >config-result &&
650 sort <config-result >../actual.add-two &&
651
652 git config --unset-all remote.scratch.fetch &&
653 git config remote.scratch.fetch \
654 refs/heads/master:refs/remotes/scratch/master &&
655 git config --add remote.scratch.fetch \
656 +refs/heads/next:refs/remotes/scratch/next &&
657 git config --get-all remote.scratch.fetch >config-result &&
658 sort <config-result >../actual.setup-ffonly &&
659
660 git remote set-branches --add scratch pu &&
661 git config --get-all remote.scratch.fetch >config-result &&
662 sort <config-result >../actual.respect-ffonly
663 ) &&
664 test_cmp expect.initial actual.initial &&
665 test_cmp expect.add actual.add &&
666 test_cmp expect.replace actual.replace &&
667 test_cmp expect.add-two actual.add-two &&
668 test_cmp expect.setup-ffonly actual.setup-ffonly &&
669 test_cmp expect.respect-ffonly actual.respect-ffonly
670'
671
672test_expect_success 'remote set-branches with --mirror' '
673 echo "+refs/*:refs/*" >expect.initial &&
674 echo "+refs/heads/master:refs/heads/master" >expect.replace &&
675 git clone --mirror .git/ setbranches-mirror &&
676 (
677 cd setbranches-mirror &&
678 git remote rename origin scratch &&
679 git config --get-all remote.scratch.fetch >../actual.initial &&
680
681 git remote set-branches scratch heads/master &&
682 git config --get-all remote.scratch.fetch >../actual.replace
683 ) &&
684 test_cmp expect.initial actual.initial &&
685 test_cmp expect.replace actual.replace
686'
687
433f2be1 688test_expect_success 'new remote' '
433f2be1
IL
689 git remote add someremote foo &&
690 echo foo >expect &&
691 git config --get-all remote.someremote.url >actual &&
692 cmp expect actual
433f2be1
IL
693'
694
695test_expect_success 'remote set-url bar' '
433f2be1
IL
696 git remote set-url someremote bar &&
697 echo bar >expect &&
698 git config --get-all remote.someremote.url >actual &&
699 cmp expect actual
433f2be1 700'
057e7138 701
433f2be1 702test_expect_success 'remote set-url baz bar' '
433f2be1
IL
703 git remote set-url someremote baz bar &&
704 echo baz >expect &&
705 git config --get-all remote.someremote.url >actual &&
706 cmp expect actual
433f2be1
IL
707'
708
709test_expect_success 'remote set-url zot bar' '
433f2be1
IL
710 test_must_fail git remote set-url someremote zot bar &&
711 echo baz >expect &&
712 git config --get-all remote.someremote.url >actual &&
713 cmp expect actual
433f2be1
IL
714'
715
716test_expect_success 'remote set-url --push zot baz' '
433f2be1
IL
717 test_must_fail git remote set-url --push someremote zot baz &&
718 echo "YYY" >expect &&
719 echo baz >>expect &&
720 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
721 echo "YYY" >>actual &&
722 git config --get-all remote.someremote.url >>actual &&
723 cmp expect actual
433f2be1
IL
724'
725
726test_expect_success 'remote set-url --push zot' '
433f2be1
IL
727 git remote set-url --push someremote zot &&
728 echo zot >expect &&
729 echo "YYY" >>expect &&
730 echo baz >>expect &&
731 git config --get-all remote.someremote.pushurl >actual &&
732 echo "YYY" >>actual &&
733 git config --get-all remote.someremote.url >>actual &&
734 cmp expect actual
433f2be1
IL
735'
736
737test_expect_success 'remote set-url --push qux zot' '
433f2be1
IL
738 git remote set-url --push someremote qux zot &&
739 echo qux >expect &&
740 echo "YYY" >>expect &&
741 echo baz >>expect &&
742 git config --get-all remote.someremote.pushurl >actual &&
743 echo "YYY" >>actual &&
744 git config --get-all remote.someremote.url >>actual &&
745 cmp expect actual
433f2be1
IL
746'
747
748test_expect_success 'remote set-url --push foo qu+x' '
433f2be1
IL
749 git remote set-url --push someremote foo qu+x &&
750 echo foo >expect &&
751 echo "YYY" >>expect &&
752 echo baz >>expect &&
753 git config --get-all remote.someremote.pushurl >actual &&
754 echo "YYY" >>actual &&
755 git config --get-all remote.someremote.url >>actual &&
756 cmp expect actual
433f2be1
IL
757'
758
759test_expect_success 'remote set-url --push --add aaa' '
433f2be1
IL
760 git remote set-url --push --add someremote aaa &&
761 echo foo >expect &&
762 echo aaa >>expect &&
763 echo "YYY" >>expect &&
764 echo baz >>expect &&
765 git config --get-all remote.someremote.pushurl >actual &&
766 echo "YYY" >>actual &&
767 git config --get-all remote.someremote.url >>actual &&
768 cmp expect actual
433f2be1
IL
769'
770
771test_expect_success 'remote set-url --push bar aaa' '
433f2be1
IL
772 git remote set-url --push someremote bar aaa &&
773 echo foo >expect &&
774 echo bar >>expect &&
775 echo "YYY" >>expect &&
776 echo baz >>expect &&
777 git config --get-all remote.someremote.pushurl >actual &&
778 echo "YYY" >>actual &&
779 git config --get-all remote.someremote.url >>actual &&
780 cmp expect actual
433f2be1
IL
781'
782
783test_expect_success 'remote set-url --push --delete bar' '
433f2be1
IL
784 git remote set-url --push --delete someremote bar &&
785 echo foo >expect &&
786 echo "YYY" >>expect &&
787 echo baz >>expect &&
788 git config --get-all remote.someremote.pushurl >actual &&
789 echo "YYY" >>actual &&
790 git config --get-all remote.someremote.url >>actual &&
791 cmp expect actual
433f2be1
IL
792'
793
794test_expect_success 'remote set-url --push --delete foo' '
433f2be1
IL
795 git remote set-url --push --delete someremote foo &&
796 echo "YYY" >expect &&
797 echo baz >>expect &&
798 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
799 echo "YYY" >>actual &&
800 git config --get-all remote.someremote.url >>actual &&
801 cmp expect actual
433f2be1
IL
802'
803
804test_expect_success 'remote set-url --add bbb' '
433f2be1
IL
805 git remote set-url --add someremote bbb &&
806 echo "YYY" >expect &&
807 echo baz >>expect &&
808 echo bbb >>expect &&
809 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
810 echo "YYY" >>actual &&
811 git config --get-all remote.someremote.url >>actual &&
812 cmp expect actual
433f2be1
IL
813'
814
815test_expect_success 'remote set-url --delete .*' '
49de47cf 816 test_must_fail git remote set-url --delete someremote .\* &&
433f2be1
IL
817 echo "YYY" >expect &&
818 echo baz >>expect &&
819 echo bbb >>expect &&
820 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
821 echo "YYY" >>actual &&
822 git config --get-all remote.someremote.url >>actual &&
823 cmp expect actual
433f2be1
IL
824'
825
826test_expect_success 'remote set-url --delete bbb' '
433f2be1
IL
827 git remote set-url --delete someremote bbb &&
828 echo "YYY" >expect &&
829 echo baz >>expect &&
830 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
831 echo "YYY" >>actual &&
832 git config --get-all remote.someremote.url >>actual &&
833 cmp expect actual
433f2be1
IL
834'
835
836test_expect_success 'remote set-url --delete baz' '
433f2be1
IL
837 test_must_fail git remote set-url --delete someremote baz &&
838 echo "YYY" >expect &&
839 echo baz >>expect &&
840 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
841 echo "YYY" >>actual &&
842 git config --get-all remote.someremote.url >>actual &&
843 cmp expect actual
433f2be1
IL
844'
845
846test_expect_success 'remote set-url --add ccc' '
433f2be1
IL
847 git remote set-url --add someremote ccc &&
848 echo "YYY" >expect &&
849 echo baz >>expect &&
850 echo ccc >>expect &&
851 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
852 echo "YYY" >>actual &&
853 git config --get-all remote.someremote.url >>actual &&
854 cmp expect actual
433f2be1
IL
855'
856
857test_expect_success 'remote set-url --delete baz' '
433f2be1
IL
858 git remote set-url --delete someremote baz &&
859 echo "YYY" >expect &&
860 echo ccc >>expect &&
861 test_must_fail git config --get-all remote.someremote.pushurl >actual &&
862 echo "YYY" >>actual &&
863 git config --get-all remote.someremote.url >>actual &&
864 cmp expect actual
433f2be1
IL
865'
866
867test_done