]>
Commit | Line | Data |
---|---|---|
683b5679 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='git remote porcelain-ish' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
683b5679 JH |
7 | setup_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 | ||
24 | tokens_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 | ||
30 | check_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 | ||
36 | check_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 | ||
44 | test_expect_success setup ' | |
683b5679 JH |
45 | setup_repository one && |
46 | setup_repository two && | |
47 | ( | |
9b9439af RR |
48 | cd two && |
49 | git branch another | |
683b5679 JH |
50 | ) && |
51 | git clone one test | |
683b5679 JH |
52 | ' |
53 | ||
d8ff76cf JS |
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 | |
57 | ' | |
58 | ||
f7dc6a96 | 59 | test_expect_success C_LOCALE_OUTPUT 'remote information for the origin' ' |
9b9439af RR |
60 | ( |
61 | cd test && | |
62 | tokens_match origin "$(git remote)" && | |
63 | check_remote_track origin master side && | |
64 | check_tracking_branch origin HEAD master side | |
65 | ) | |
683b5679 JH |
66 | ' |
67 | ||
68 | test_expect_success 'add another remote' ' | |
9b9439af RR |
69 | ( |
70 | cd test && | |
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 | >expect && | |
78 | test_cmp expect actual | |
79 | ) | |
683b5679 JH |
80 | ' |
81 | ||
d6ac1d21 | 82 | test_expect_success C_LOCALE_OUTPUT 'check remote-tracking' ' |
9b9439af RR |
83 | ( |
84 | cd test && | |
85 | check_remote_track origin master side && | |
86 | check_remote_track second master side another | |
87 | ) | |
f7dc6a96 JX |
88 | ' |
89 | ||
1ce89cc4 | 90 | test_expect_success 'remote forces tracking branches' ' |
9b9439af RR |
91 | ( |
92 | cd test && | |
c0097814 | 93 | case $(git config remote.second.fetch) in |
9b9439af RR |
94 | +*) true ;; |
95 | *) false ;; | |
96 | esac | |
97 | ) | |
1ce89cc4 JK |
98 | ' |
99 | ||
683b5679 | 100 | test_expect_success 'remove remote' ' |
9b9439af RR |
101 | ( |
102 | cd test && | |
103 | git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master && | |
104 | git remote rm second | |
105 | ) | |
683b5679 JH |
106 | ' |
107 | ||
f7dc6a96 | 108 | test_expect_success C_LOCALE_OUTPUT 'remove remote' ' |
9b9439af RR |
109 | ( |
110 | cd test && | |
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 && | |
115 | >expect && | |
116 | test_cmp expect actual | |
117 | ) | |
683b5679 JH |
118 | ' |
119 | ||
13931236 | 120 | test_expect_success 'remove remote protects local branches' ' |
9b9439af RR |
121 | ( |
122 | cd test && | |
123 | cat >expect1 <<-\EOF && | |
124 | Note: A branch outside the refs/remotes/ hierarchy was not removed; | |
125 | to delete it, use: | |
126 | git branch -d master | |
127 | EOF | |
128 | cat >expect2 <<-\EOF && | |
129 | Note: Some branches outside the refs/remotes/ hierarchy were not removed; | |
130 | to delete them, use: | |
131 | git branch -d foobranch | |
132 | git branch -d master | |
133 | EOF | |
134 | git tag footag && | |
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 && | |
141 | git tag -d footag && | |
142 | test_i18ncmp expect1 actual1 && | |
143 | test_i18ncmp expect2 actual2 | |
144 | ) | |
145 | ' | |
146 | ||
cc8e538d TG |
147 | test_expect_success 'remove errors out early when deleting non-existent branch' ' |
148 | ( | |
149 | cd test && | |
150 | echo "fatal: No such remote: foo" >expect && | |
151 | test_must_fail git remote rm foo 2>actual && | |
152 | test_i18ncmp expect actual | |
153 | ) | |
154 | ' | |
155 | ||
20690b21 RL |
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; | |
162 | true | |
163 | )" && | |
164 | ( | |
165 | cd test && | |
166 | git remote add two ../two && | |
167 | git fetch two && | |
168 | git checkout -b second two/master^0 && | |
169 | git config branch.second.remote two && | |
170 | git checkout master && | |
171 | git remote rm two | |
172 | ) | |
173 | ' | |
174 | ||
cc8e538d TG |
175 | test_expect_success 'rename errors out early when deleting non-existent branch' ' |
176 | ( | |
177 | cd test && | |
178 | echo "fatal: No such remote: foo" >expect && | |
179 | test_must_fail git remote rename foo bar 2>actual && | |
180 | test_i18ncmp expect actual | |
181 | ) | |
182 | ' | |
183 | ||
a31eeae2 TG |
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 | |
189 | ' | |
190 | ||
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 | |
197 | ' | |
198 | ||
9b9439af | 199 | cat >test/expect <<EOF |
4704640b | 200 | * remote origin |
857f8c30 MG |
201 | Fetch URL: $(pwd)/one |
202 | Push URL: $(pwd)/one | |
e61e0cc6 | 203 | HEAD branch: master |
7ecbbf87 JS |
204 | Remote branches: |
205 | master new (next fetch will store in remotes/origin) | |
206 | side tracked | |
207 | Local branches configured for 'git pull': | |
e5dcbfd9 | 208 | ahead merges with remote master |
7ecbbf87 JS |
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 | |
e5dcbfd9 JS |
214 | Local refs configured for 'git push': |
215 | master pushes to master (local out of date) | |
216 | master pushes to upstream (create) | |
e61e0cc6 | 217 | * remote two |
857f8c30 MG |
218 | Fetch URL: ../two |
219 | Push URL: ../three | |
a45b5f05 | 220 | HEAD branch: master |
e5dcbfd9 | 221 | Local refs configured for 'git push': |
a75d7b54 | 222 | ahead forces to master (fast-forwardable) |
e5dcbfd9 | 223 | master pushes to another (up to date) |
4704640b JS |
224 | EOF |
225 | ||
226 | test_expect_success 'show' ' | |
9b9439af RR |
227 | ( |
228 | cd test && | |
229 | git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream && | |
230 | git fetch && | |
231 | git checkout -b ahead origin/master && | |
232 | echo 1 >>file && | |
233 | test_tick && | |
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" && | |
243 | ( | |
244 | cd ../one && | |
245 | echo 1 >file && | |
246 | test_tick && | |
247 | git commit -m update file | |
248 | ) && | |
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 | |
257 | ) | |
258 | ' | |
259 | ||
260 | cat >test/expect <<EOF | |
0ecfcb3b | 261 | * remote origin |
857f8c30 MG |
262 | Fetch URL: $(pwd)/one |
263 | Push URL: $(pwd)/one | |
e61e0cc6 | 264 | HEAD branch: (not queried) |
7ecbbf87 | 265 | Remote branches: (status not queried) |
20244ea2 JS |
266 | master |
267 | side | |
e5dcbfd9 JS |
268 | Local branches configured for 'git pull': |
269 | ahead merges with remote master | |
7ecbbf87 | 270 | master merges with remote master |
e5dcbfd9 JS |
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 | |
0ecfcb3b OM |
275 | EOF |
276 | ||
277 | test_expect_success 'show -n' ' | |
9b9439af RR |
278 | mv one one.unreachable && |
279 | ( | |
280 | cd test && | |
281 | git remote show -n origin >output && | |
282 | mv ../one.unreachable ../one && | |
283 | test_i18ncmp expect output | |
284 | ) | |
0ecfcb3b OM |
285 | ' |
286 | ||
4704640b | 287 | test_expect_success 'prune' ' |
9b9439af RR |
288 | ( |
289 | cd one && | |
290 | git branch -m side side2 | |
291 | ) && | |
292 | ( | |
293 | cd test && | |
294 | git fetch origin && | |
295 | git remote prune origin && | |
296 | git rev-parse refs/remotes/origin/side2 && | |
297 | test_must_fail git rev-parse refs/remotes/origin/side | |
298 | ) | |
4704640b JS |
299 | ' |
300 | ||
bc14fac8 | 301 | test_expect_success 'set-head --delete' ' |
9b9439af RR |
302 | ( |
303 | cd test && | |
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 | |
307 | ) | |
bc14fac8 JS |
308 | ' |
309 | ||
310 | test_expect_success 'set-head --auto' ' | |
9b9439af RR |
311 | ( |
312 | cd test && | |
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 | |
bc14fac8 JS |
317 | ) |
318 | ' | |
319 | ||
a45b5f05 | 320 | test_expect_success 'set-head --auto has no problem w/multiple HEADs' ' |
9b9439af RR |
321 | ( |
322 | cd test && | |
a4dfee06 | 323 | git fetch two "refs/heads/*:refs/remotes/two/*" && |
a45b5f05 JH |
324 | git remote set-head --auto two >output 2>&1 && |
325 | echo "two/HEAD set to master" >expect && | |
9b9439af RR |
326 | test_i18ncmp expect output |
327 | ) | |
bc14fac8 JS |
328 | ' |
329 | ||
9b9439af | 330 | cat >test/expect <<\EOF |
bc14fac8 JS |
331 | refs/remotes/origin/side2 |
332 | EOF | |
333 | ||
334 | test_expect_success 'set-head explicit' ' | |
9b9439af RR |
335 | ( |
336 | cd test && | |
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 | |
341 | ) | |
bc14fac8 JS |
342 | ' |
343 | ||
9b9439af | 344 | cat >test/expect <<EOF |
8d767927 | 345 | Pruning origin |
86521aca | 346 | URL: $(pwd)/one |
8d767927 OM |
347 | * [would prune] origin/side2 |
348 | EOF | |
349 | ||
350 | test_expect_success 'prune --dry-run' ' | |
9b9439af RR |
351 | ( |
352 | cd one && | |
353 | git branch -m side2 side) && | |
354 | ( | |
355 | cd test && | |
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 && | |
359 | ( | |
360 | cd ../one && | |
361 | git branch -m side side2) && | |
362 | test_i18ncmp expect output | |
363 | ) | |
8d767927 OM |
364 | ' |
365 | ||
4ebc914c | 366 | test_expect_success 'add --mirror && prune' ' |
9b9439af RR |
367 | mkdir mirror && |
368 | ( | |
369 | cd mirror && | |
370 | git init --bare && | |
371 | git remote add --mirror -f origin ../one | |
372 | ) && | |
373 | ( | |
374 | cd one && | |
375 | git branch -m side2 side | |
376 | ) && | |
377 | ( | |
378 | cd mirror && | |
379 | git rev-parse --verify refs/heads/side2 && | |
380 | test_must_fail git rev-parse --verify refs/heads/side && | |
381 | git fetch origin && | |
382 | git remote prune origin && | |
383 | test_must_fail git rev-parse --verify refs/heads/side2 && | |
384 | git rev-parse --verify refs/heads/side | |
385 | ) | |
4ebc914c JS |
386 | ' |
387 | ||
a9f5a355 JK |
388 | test_expect_success 'add --mirror=fetch' ' |
389 | mkdir mirror-fetch && | |
390 | git init mirror-fetch/parent && | |
9b9439af RR |
391 | ( |
392 | cd mirror-fetch/parent && | |
393 | test_commit one | |
394 | ) && | |
a9f5a355 | 395 | git init --bare mirror-fetch/child && |
9b9439af RR |
396 | ( |
397 | cd mirror-fetch/child && | |
398 | git remote add --mirror=fetch -f parent ../parent | |
399 | ) | |
a9f5a355 JK |
400 | ' |
401 | ||
402 | test_expect_success 'fetch mirrors act as mirrors during fetch' ' | |
9b9439af RR |
403 | ( |
404 | cd mirror-fetch/parent && | |
405 | git branch new && | |
406 | git branch -m master renamed | |
a9f5a355 | 407 | ) && |
9b9439af RR |
408 | ( |
409 | cd mirror-fetch/child && | |
410 | git fetch parent && | |
411 | git rev-parse --verify refs/heads/new && | |
412 | git rev-parse --verify refs/heads/renamed | |
a9f5a355 JK |
413 | ) |
414 | ' | |
415 | ||
416 | test_expect_success 'fetch mirrors can prune' ' | |
9b9439af RR |
417 | ( |
418 | cd mirror-fetch/child && | |
419 | git remote prune parent && | |
420 | test_must_fail git rev-parse --verify refs/heads/master | |
a9f5a355 JK |
421 | ) |
422 | ' | |
423 | ||
424 | test_expect_success 'fetch mirrors do not act as mirrors during push' ' | |
9b9439af RR |
425 | ( |
426 | cd mirror-fetch/parent && | |
427 | git checkout HEAD^0 | |
a9f5a355 | 428 | ) && |
9b9439af RR |
429 | ( |
430 | cd mirror-fetch/child && | |
431 | git branch -m renamed renamed2 && | |
432 | git push parent : | |
a9f5a355 | 433 | ) && |
9b9439af RR |
434 | ( |
435 | cd mirror-fetch/parent && | |
436 | git rev-parse --verify renamed && | |
437 | test_must_fail git rev-parse --verify refs/heads/renamed2 | |
a9f5a355 JK |
438 | ) |
439 | ' | |
440 | ||
3eafdc96 JK |
441 | test_expect_success 'add fetch mirror with specific branches' ' |
442 | git init --bare mirror-fetch/track && | |
9b9439af RR |
443 | ( |
444 | cd mirror-fetch/track && | |
445 | git remote add --mirror=fetch -t heads/new parent ../parent | |
3eafdc96 JK |
446 | ) |
447 | ' | |
448 | ||
449 | test_expect_success 'fetch mirror respects specific branches' ' | |
9b9439af RR |
450 | ( |
451 | cd mirror-fetch/track && | |
452 | git fetch parent && | |
453 | git rev-parse --verify refs/heads/new && | |
454 | test_must_fail git rev-parse --verify refs/heads/renamed | |
3eafdc96 JK |
455 | ) |
456 | ' | |
457 | ||
a9f5a355 JK |
458 | test_expect_success 'add --mirror=push' ' |
459 | mkdir mirror-push && | |
460 | git init --bare mirror-push/public && | |
461 | git init mirror-push/private && | |
9b9439af RR |
462 | ( |
463 | cd mirror-push/private && | |
464 | test_commit one && | |
465 | git remote add --mirror=push public ../public | |
a9f5a355 JK |
466 | ) |
467 | ' | |
468 | ||
469 | test_expect_success 'push mirrors act as mirrors during push' ' | |
9b9439af RR |
470 | ( |
471 | cd mirror-push/private && | |
472 | git branch new && | |
473 | git branch -m master renamed && | |
474 | git push public | |
a9f5a355 | 475 | ) && |
9b9439af RR |
476 | ( |
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 | |
a9f5a355 JK |
481 | ) |
482 | ' | |
483 | ||
484 | test_expect_success 'push mirrors do not act as mirrors during fetch' ' | |
9b9439af RR |
485 | ( |
486 | cd mirror-push/public && | |
487 | git branch -m renamed renamed2 && | |
488 | git symbolic-ref HEAD refs/heads/renamed2 | |
a9f5a355 | 489 | ) && |
9b9439af RR |
490 | ( |
491 | cd mirror-push/private && | |
492 | git fetch public && | |
493 | git rev-parse --verify refs/heads/renamed && | |
494 | test_must_fail git rev-parse --verify refs/heads/renamed2 | |
a9f5a355 JK |
495 | ) |
496 | ' | |
497 | ||
3eafdc96 JK |
498 | test_expect_success 'push mirrors do not allow you to specify refs' ' |
499 | git init mirror-push/track && | |
9b9439af RR |
500 | ( |
501 | cd mirror-push/track && | |
502 | test_must_fail git remote add --mirror=push -t new public ../public | |
3eafdc96 JK |
503 | ) |
504 | ' | |
505 | ||
c175a7ad | 506 | test_expect_success 'add alt && prune' ' |
9b9439af RR |
507 | mkdir alttst && |
508 | ( | |
509 | cd alttst && | |
510 | git init && | |
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/*" | |
514 | ) && | |
515 | ( | |
516 | cd one && | |
517 | git branch -m side side2 | |
518 | ) && | |
519 | ( | |
520 | cd alttst && | |
521 | git rev-parse --verify refs/remotes/origin/side && | |
522 | test_must_fail git rev-parse --verify refs/remotes/origin/side2 && | |
523 | git fetch alt && | |
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 | |
527 | ) | |
c175a7ad SP |
528 | ' |
529 | ||
111fb858 ST |
530 | cat >test/expect <<\EOF |
531 | some-tag | |
532 | EOF | |
533 | ||
534 | test_expect_success 'add with reachable tags (default)' ' | |
9b9439af RR |
535 | ( |
536 | cd one && | |
537 | >foobar && | |
538 | git add foobar && | |
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 | |
543 | ) && | |
544 | mkdir add-tags && | |
545 | ( | |
546 | cd add-tags && | |
547 | git init && | |
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 | |
552 | ) && | |
111fb858 ST |
553 | test_cmp test/expect test/output |
554 | ' | |
555 | ||
556 | cat >test/expect <<\EOF | |
557 | some-tag | |
558 | foobar-tag | |
559 | --tags | |
560 | EOF | |
561 | ||
562 | test_expect_success 'add --tags' ' | |
9b9439af RR |
563 | rm -rf add-tags && |
564 | ( | |
565 | mkdir add-tags && | |
566 | cd add-tags && | |
567 | git init && | |
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 | |
572 | ) && | |
111fb858 ST |
573 | test_cmp test/expect test/output |
574 | ' | |
575 | ||
576 | cat >test/expect <<\EOF | |
577 | --no-tags | |
578 | EOF | |
579 | ||
580 | test_expect_success 'add --no-tags' ' | |
9b9439af RR |
581 | rm -rf add-tags && |
582 | ( | |
583 | mkdir add-no-tags && | |
584 | cd add-no-tags && | |
585 | git init && | |
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 | |
590 | ) && | |
591 | ( | |
592 | cd one && | |
593 | git tag -d some-tag foobar-tag | |
594 | ) && | |
111fb858 ST |
595 | test_cmp test/expect test/output |
596 | ' | |
597 | ||
598 | test_expect_success 'reject --no-no-tags' ' | |
9b9439af RR |
599 | ( |
600 | cd add-no-tags && | |
601 | test_must_fail git remote add -f --no-no-tags neworigin ../one | |
602 | ) | |
111fb858 ST |
603 | ' |
604 | ||
9b9439af | 605 | cat >one/expect <<\EOF |
84521ed6 JS |
606 | apis/master |
607 | apis/side | |
608 | drosophila/another | |
609 | drosophila/master | |
610 | drosophila/side | |
611 | EOF | |
612 | ||
613 | test_expect_success 'update' ' | |
9b9439af RR |
614 | ( |
615 | cd one && | |
616 | git remote add drosophila ../two && | |
617 | git remote add apis ../mirror && | |
618 | git remote update && | |
619 | git branch -r >output && | |
620 | test_cmp expect output | |
621 | ) | |
84521ed6 JS |
622 | ' |
623 | ||
9b9439af | 624 | cat >one/expect <<\EOF |
84521ed6 JS |
625 | drosophila/another |
626 | drosophila/master | |
627 | drosophila/side | |
628 | manduca/master | |
629 | manduca/side | |
630 | megaloprepus/master | |
631 | megaloprepus/side | |
632 | EOF | |
633 | ||
634 | test_expect_success 'update with arguments' ' | |
9b9439af RR |
635 | ( |
636 | cd one && | |
637 | for b in $(git branch -r) | |
638 | do | |
e6821d09 | 639 | git branch -r -d $b || exit 1 |
9b9439af RR |
640 | done && |
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 | |
648 | ) | |
84521ed6 JS |
649 | ' |
650 | ||
e2d41c64 | 651 | test_expect_success 'update --prune' ' |
9b9439af RR |
652 | ( |
653 | cd one && | |
654 | git branch -m side2 side3 | |
655 | ) && | |
656 | ( | |
657 | cd test && | |
658 | git remote update --prune && | |
659 | ( | |
660 | cd ../one && | |
661 | git branch -m side3 side2 | |
662 | ) && | |
663 | git rev-parse refs/remotes/origin/side3 && | |
664 | test_must_fail git rev-parse refs/remotes/origin/side2 | |
665 | ) | |
e2d41c64 BG |
666 | ' |
667 | ||
9b9439af | 668 | cat >one/expect <<-\EOF |
84521ed6 JS |
669 | apis/master |
670 | apis/side | |
671 | manduca/master | |
672 | manduca/side | |
673 | megaloprepus/master | |
674 | megaloprepus/side | |
675 | EOF | |
676 | ||
677 | test_expect_success 'update default' ' | |
9b9439af RR |
678 | ( |
679 | cd one && | |
680 | for b in $(git branch -r) | |
681 | do | |
e6821d09 | 682 | git branch -r -d $b || exit 1 |
9b9439af RR |
683 | done && |
684 | git config remote.drosophila.skipDefaultUpdate true && | |
685 | git remote update default && | |
686 | git branch -r >output && | |
687 | test_cmp expect output | |
688 | ) | |
84521ed6 JS |
689 | ' |
690 | ||
9b9439af | 691 | cat >one/expect <<\EOF |
84521ed6 JS |
692 | drosophila/another |
693 | drosophila/master | |
694 | drosophila/side | |
695 | EOF | |
696 | ||
697 | test_expect_success 'update default (overridden, with funny whitespace)' ' | |
9b9439af RR |
698 | ( |
699 | cd one && | |
700 | for b in $(git branch -r) | |
701 | do | |
e6821d09 | 702 | git branch -r -d $b || exit 1 |
9b9439af RR |
703 | done && |
704 | git config remotes.default "$(printf "\t drosophila \n")" && | |
705 | git remote update default && | |
706 | git branch -r >output && | |
707 | test_cmp expect output | |
708 | ) | |
84521ed6 JS |
709 | ' |
710 | ||
4f2e842d | 711 | test_expect_success 'update (with remotes.default defined)' ' |
9b9439af RR |
712 | ( |
713 | cd one && | |
714 | for b in $(git branch -r) | |
715 | do | |
e6821d09 | 716 | git branch -r -d $b || exit 1 |
9b9439af RR |
717 | done && |
718 | git config remotes.default "drosophila" && | |
719 | git remote update && | |
720 | git branch -r >output && | |
721 | test_cmp expect output | |
722 | ) | |
4f2e842d BG |
723 | ' |
724 | ||
740fdd27 | 725 | test_expect_success '"remote show" does not show symbolic refs' ' |
740fdd27 | 726 | git clone one three && |
9b9439af RR |
727 | ( |
728 | cd three && | |
729 | git remote show origin >output && | |
730 | ! grep "^ *HEAD$" < output && | |
731 | ! grep -i stale < output | |
732 | ) | |
740fdd27 JS |
733 | ' |
734 | ||
24b6177e | 735 | test_expect_success 'reject adding remote with an invalid name' ' |
d492b31c | 736 | test_must_fail git remote add some:url desired-name |
24b6177e JF |
737 | ' |
738 | ||
bf98421a MV |
739 | # The first three test if the tracking branches are properly renamed, |
740 | # the last two ones check if the config is updated. | |
741 | ||
742 | test_expect_success 'rename a remote' ' | |
bf98421a | 743 | git clone one four && |
9b9439af RR |
744 | ( |
745 | cd four && | |
746 | git remote rename origin upstream && | |
2eb7a0e5 | 747 | test -z "$(git for-each-ref refs/remotes/origin)" && |
9b9439af RR |
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" | |
752 | ) | |
bf98421a | 753 | ' |
1dd1239a | 754 | |
28f555f6 | 755 | test_expect_success 'rename does not update a non-default fetch refspec' ' |
28f555f6 | 756 | git clone one four.one && |
9b9439af RR |
757 | ( |
758 | cd 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 | |
763 | ) | |
28f555f6 MZ |
764 | ' |
765 | ||
766 | test_expect_success 'rename a remote with name part of fetch spec' ' | |
28f555f6 | 767 | git clone one four.two && |
9b9439af RR |
768 | ( |
769 | cd 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/*" | |
773 | ) | |
28f555f6 MZ |
774 | ' |
775 | ||
60e5eee0 | 776 | test_expect_success 'rename a remote with name prefix of other remote' ' |
60e5eee0 | 777 | git clone one four.three && |
9b9439af RR |
778 | ( |
779 | cd 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)" | |
783 | ) | |
60e5eee0 MZ |
784 | ' |
785 | ||
e459b073 | 786 | test_expect_success 'rename succeeds with existing remote.<target>.prune' ' |
af5bacf4 JS |
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 | |
791 | ' | |
792 | ||
9b9439af | 793 | cat >remotes_origin <<EOF |
1dd1239a MV |
794 | URL: $(pwd)/one |
795 | Push: refs/heads/master:refs/heads/upstream | |
f0f249d1 | 796 | Push: refs/heads/next:refs/heads/upstream2 |
1dd1239a | 797 | Pull: refs/heads/master:refs/heads/origin |
f0f249d1 | 798 | Pull: refs/heads/next:refs/heads/origin2 |
1dd1239a MV |
799 | EOF |
800 | ||
801 | test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' ' | |
802 | git clone one five && | |
803 | origin_url=$(pwd)/one && | |
9b9439af RR |
804 | ( |
805 | cd five && | |
806 | git remote remove origin && | |
807 | mkdir -p .git/remotes && | |
808 | cat ../remotes_origin >.git/remotes/origin && | |
809 | git remote rename origin origin && | |
fe3c1956 | 810 | test_path_is_missing .git/remotes/origin && |
9b9439af | 811 | test "$(git config remote.origin.url)" = "$origin_url" && |
f0f249d1 RR |
812 | cat >push_expected <<-\EOF && |
813 | refs/heads/master:refs/heads/upstream | |
814 | refs/heads/next:refs/heads/upstream2 | |
815 | EOF | |
816 | cat >fetch_expected <<-\EOF && | |
817 | refs/heads/master:refs/heads/origin | |
818 | refs/heads/next:refs/heads/origin2 | |
819 | EOF | |
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 | |
9b9439af | 824 | ) |
1dd1239a MV |
825 | ' |
826 | ||
827 | test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' ' | |
828 | git clone one six && | |
829 | origin_url=$(pwd)/one && | |
9b9439af RR |
830 | ( |
831 | cd six && | |
832 | git remote rm origin && | |
833 | echo "$origin_url" >.git/branches/origin && | |
834 | git remote rename origin origin && | |
fe3c1956 | 835 | test_path_is_missing .git/branches/origin && |
9b9439af | 836 | test "$(git config remote.origin.url)" = "$origin_url" && |
294547f5 RR |
837 | test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin" && |
838 | test "$(git config remote.origin.push)" = "HEAD:refs/heads/master" | |
9b9439af | 839 | ) |
1dd1239a MV |
840 | ' |
841 | ||
1f9a5e90 | 842 | test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' ' |
f8948e2f | 843 | git clone one seven && |
1f9a5e90 RR |
844 | ( |
845 | cd 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" | |
853 | ) | |
854 | ' | |
855 | ||
856 | test_expect_success 'remote prune to cause a dangling symref' ' | |
857 | git clone one eight && | |
f8948e2f JH |
858 | ( |
859 | cd one && | |
860 | git checkout side2 && | |
861 | git branch -D master | |
862 | ) && | |
863 | ( | |
1f9a5e90 | 864 | cd eight && |
f8948e2f | 865 | git remote prune origin |
e01de1c9 | 866 | ) >err 2>&1 && |
f7dc6a96 | 867 | test_i18ngrep "has become dangling" err && |
f8948e2f | 868 | |
e01de1c9 | 869 | : And the dangling symref will not cause other annoying errors && |
f8948e2f | 870 | ( |
1f9a5e90 | 871 | cd eight && |
f8948e2f JH |
872 | git branch -a |
873 | ) 2>err && | |
e01de1c9 | 874 | ! grep "points nowhere" err && |
057e7138 | 875 | ( |
1f9a5e90 | 876 | cd eight && |
057e7138 JH |
877 | test_must_fail git branch nomore origin |
878 | ) 2>err && | |
879 | grep "dangling symref" err | |
f8948e2f JH |
880 | ' |
881 | ||
6a01554e | 882 | test_expect_success 'show empty remote' ' |
6a01554e CB |
883 | test_create_repo empty && |
884 | git clone empty empty-clone && | |
885 | ( | |
886 | cd empty-clone && | |
887 | git remote show origin | |
888 | ) | |
889 | ' | |
890 | ||
3d8b6949 JN |
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 | |
894 | ' | |
895 | ||
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 | |
901 | EOF | |
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 | |
906 | EOF | |
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 | |
913 | EOF | |
914 | sort <<-\EOF >expect.setup-ffonly && | |
915 | refs/heads/master:refs/remotes/scratch/master | |
916 | +refs/heads/next:refs/remotes/scratch/next | |
917 | EOF | |
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 | |
922 | EOF | |
923 | ||
924 | git clone .git/ setbranches && | |
925 | ( | |
926 | cd setbranches && | |
927 | git remote rename origin scratch && | |
928 | git config --get-all remote.scratch.fetch >config-result && | |
929 | sort <config-result >../actual.initial && | |
930 | ||
931 | git remote set-branches scratch --add other && | |
932 | git config --get-all remote.scratch.fetch >config-result && | |
933 | sort <config-result >../actual.add && | |
934 | ||
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 && | |
938 | ||
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 && | |
942 | ||
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 && | |
950 | ||
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 | |
954 | ) && | |
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 | |
961 | ' | |
962 | ||
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 && | |
967 | ( | |
968 | cd setbranches-mirror && | |
969 | git remote rename origin scratch && | |
970 | git config --get-all remote.scratch.fetch >../actual.initial && | |
971 | ||
972 | git remote set-branches scratch heads/master && | |
973 | git config --get-all remote.scratch.fetch >../actual.replace | |
974 | ) && | |
975 | test_cmp expect.initial actual.initial && | |
976 | test_cmp expect.replace actual.replace | |
977 | ' | |
978 | ||
433f2be1 | 979 | test_expect_success 'new remote' ' |
433f2be1 IL |
980 | git remote add someremote foo && |
981 | echo foo >expect && | |
982 | git config --get-all remote.someremote.url >actual && | |
983 | cmp expect actual | |
433f2be1 IL |
984 | ' |
985 | ||
96f78d39 BB |
986 | get_url_test () { |
987 | cat >expect && | |
988 | git remote get-url "$@" >actual && | |
989 | test_cmp expect actual | |
990 | } | |
991 | ||
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 | |
997 | ' | |
998 | ||
45ebdcc9 PS |
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 && | |
1005 | cmp expect actual | |
1006 | ' | |
1007 | ||
433f2be1 | 1008 | test_expect_success 'remote set-url bar' ' |
433f2be1 IL |
1009 | git remote set-url someremote bar && |
1010 | echo bar >expect && | |
1011 | git config --get-all remote.someremote.url >actual && | |
1012 | cmp expect actual | |
433f2be1 | 1013 | ' |
057e7138 | 1014 | |
433f2be1 | 1015 | test_expect_success 'remote set-url baz bar' ' |
433f2be1 IL |
1016 | git remote set-url someremote baz bar && |
1017 | echo baz >expect && | |
1018 | git config --get-all remote.someremote.url >actual && | |
1019 | cmp expect actual | |
433f2be1 IL |
1020 | ' |
1021 | ||
1022 | test_expect_success 'remote set-url zot bar' ' | |
433f2be1 IL |
1023 | test_must_fail git remote set-url someremote zot bar && |
1024 | echo baz >expect && | |
1025 | git config --get-all remote.someremote.url >actual && | |
1026 | cmp expect actual | |
433f2be1 IL |
1027 | ' |
1028 | ||
1029 | test_expect_success 'remote set-url --push zot baz' ' | |
433f2be1 IL |
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 && | |
1036 | cmp expect actual | |
433f2be1 IL |
1037 | ' |
1038 | ||
1039 | test_expect_success 'remote set-url --push zot' ' | |
433f2be1 IL |
1040 | git remote set-url --push someremote zot && |
1041 | echo zot >expect && | |
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 && | |
1047 | cmp expect actual | |
433f2be1 IL |
1048 | ' |
1049 | ||
96f78d39 BB |
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 | |
1055 | ' | |
1056 | ||
433f2be1 | 1057 | test_expect_success 'remote set-url --push qux zot' ' |
433f2be1 IL |
1058 | git remote set-url --push someremote qux zot && |
1059 | echo qux >expect && | |
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 && | |
1065 | cmp expect actual | |
433f2be1 IL |
1066 | ' |
1067 | ||
1068 | test_expect_success 'remote set-url --push foo qu+x' ' | |
433f2be1 IL |
1069 | git remote set-url --push someremote foo qu+x && |
1070 | echo foo >expect && | |
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 && | |
1076 | cmp expect actual | |
433f2be1 IL |
1077 | ' |
1078 | ||
1079 | test_expect_success 'remote set-url --push --add aaa' ' | |
433f2be1 IL |
1080 | git remote set-url --push --add someremote aaa && |
1081 | echo foo >expect && | |
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 && | |
1088 | cmp expect actual | |
433f2be1 IL |
1089 | ' |
1090 | ||
96f78d39 BB |
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 | |
1094 | foo | |
1095 | aaa | |
1096 | EOF | |
1097 | ' | |
1098 | ||
433f2be1 | 1099 | test_expect_success 'remote set-url --push bar aaa' ' |
433f2be1 IL |
1100 | git remote set-url --push someremote bar aaa && |
1101 | echo foo >expect && | |
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 && | |
1108 | cmp expect actual | |
433f2be1 IL |
1109 | ' |
1110 | ||
1111 | test_expect_success 'remote set-url --push --delete bar' ' | |
433f2be1 IL |
1112 | git remote set-url --push --delete someremote bar && |
1113 | echo foo >expect && | |
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 && | |
1119 | cmp expect actual | |
433f2be1 IL |
1120 | ' |
1121 | ||
1122 | test_expect_success 'remote set-url --push --delete foo' ' | |
433f2be1 IL |
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 && | |
1129 | cmp expect actual | |
433f2be1 IL |
1130 | ' |
1131 | ||
1132 | test_expect_success 'remote set-url --add bbb' ' | |
433f2be1 IL |
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 && | |
1140 | cmp expect actual | |
433f2be1 IL |
1141 | ' |
1142 | ||
96f78d39 BB |
1143 | test_expect_success 'get-url on multi fetch remote' ' |
1144 | echo baz | get_url_test someremote && | |
1145 | get_url_test --all someremote <<-\EOF | |
1146 | baz | |
1147 | bbb | |
1148 | EOF | |
1149 | ' | |
1150 | ||
433f2be1 | 1151 | test_expect_success 'remote set-url --delete .*' ' |
49de47cf | 1152 | test_must_fail git remote set-url --delete someremote .\* && |
433f2be1 IL |
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 && | |
1159 | cmp expect actual | |
433f2be1 IL |
1160 | ' |
1161 | ||
1162 | test_expect_success 'remote set-url --delete bbb' ' | |
433f2be1 IL |
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 && | |
1169 | cmp expect actual | |
433f2be1 IL |
1170 | ' |
1171 | ||
1172 | test_expect_success 'remote set-url --delete baz' ' | |
433f2be1 IL |
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 && | |
1179 | cmp expect actual | |
433f2be1 IL |
1180 | ' |
1181 | ||
1182 | test_expect_success 'remote set-url --add ccc' ' | |
433f2be1 IL |
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 && | |
1190 | cmp expect actual | |
433f2be1 IL |
1191 | ' |
1192 | ||
1193 | test_expect_success 'remote set-url --delete baz' ' | |
433f2be1 IL |
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 && | |
1200 | cmp expect actual | |
433f2be1 IL |
1201 | ' |
1202 | ||
abf5f872 TR |
1203 | test_expect_success 'extra args: setup' ' |
1204 | # add a dummy origin so that this does not trigger failure | |
1205 | git remote add origin . | |
1206 | ' | |
1207 | ||
1208 | test_extra_arg () { | |
b17dd3f9 | 1209 | test_expect_success "extra args: $*" " |
abf5f872 | 1210 | test_must_fail git remote $* bogus_extra_arg 2>actual && |
1edbaac3 | 1211 | test_i18ngrep '^usage:' actual |
abf5f872 TR |
1212 | " |
1213 | } | |
1214 | ||
2d2e3d25 | 1215 | test_extra_arg add nick url |
abf5f872 TR |
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 | |
96f78d39 | 1220 | test_extra_arg get-url origin newurl |
abf5f872 | 1221 | test_extra_arg set-url origin newurl oldurl |
b17dd3f9 TR |
1222 | # show takes any number of args |
1223 | # prune takes any number of args | |
abf5f872 TR |
1224 | # update takes any number of args |
1225 | ||
b90c95d9 JS |
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 | |
1229 | ' | |
1230 | ||
433f2be1 | 1231 | test_done |