t/t5505-remote: modernize style

Modernize the style of all tests throughout the file: - Remove spurious blank lines. - Indent the test body. - Make sure that all lines end with &&, to make it easier to spot breaks in the chain. - When executing something in a subshell, put the parenthesis on separate lines and indent the body. Also make sure that the first statement in the subshell is a 'cd'. - When redirecting input or output, do not use SP between redirection operator and the target filename. - Use the <<-\EOF and <<-EOF forms of heredoc, not <<EOF, when the command is indented and the heredoc text itself does not have to have a leading tab. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramkumar Ramachandra committed Jun 22, 2013 at 13:28 UTC 9b9439afd8e08a2370d008af2836198ff9008179
1 file changed +440 -373
t/t5505-remote.sh
+440 -373
@@ -42,107 +42,104 @@ check_tracking_branch () {
42 }
43
44 test_expect_success setup '
45 -
45 setup_repository one &&
46 setup_repository two &&
47 (
49 - cd two && git branch another
48 + cd two &&
49 + git branch another
50 ) &&
51 git clone one test
52 -
52 '
53
54 test_expect_success C_LOCALE_OUTPUT '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 -)
55 + (
56 + cd test &&
57 + tokens_match origin "$(git remote)" &&
58 + check_remote_track origin master side &&
59 + check_tracking_branch origin HEAD master side
60 + )
61 '
62
63 test_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_tracking_branch second master side another &&
70 - git for-each-ref "--format=%(refname)" refs/remotes |
71 - sed -e "/^refs\/remotes\/origin\//d" \
72 - -e "/^refs\/remotes\/second\//d" >actual &&
73 - >expect &&
74 - test_cmp expect actual
75 -)
64 + (
65 + cd test &&
66 + git remote add -f second ../two &&
67 + tokens_match "origin second" "$(git remote)" &&
68 + check_tracking_branch second master side another &&
69 + git for-each-ref "--format=%(refname)" refs/remotes |
70 + sed -e "/^refs\/remotes\/origin\//d" \
71 + -e "/^refs\/remotes\/second\//d" >actual &&
72 + >expect &&
73 + test_cmp expect actual
74 + )
75 '
76
77 test_expect_success C_LOCALE_OUTPUT 'check remote tracking' '
79 -(
80 - cd test &&
81 - check_remote_track origin master side &&
82 - check_remote_track second master side another
83 -)
78 + (
79 + cd test &&
80 + check_remote_track origin master side &&
81 + check_remote_track second master side another
82 + )
83 '
84
85 test_expect_success 'remote forces tracking branches' '
87 -(
88 - cd test &&
89 - case `git config remote.second.fetch` in
90 - +*) true ;;
91 - *) false ;;
92 - esac
93 -)
86 + (
87 + cd test &&
88 + case `git config remote.second.fetch` in
89 + +*) true ;;
90 + *) false ;;
91 + esac
92 + )
93 '
94
95 test_expect_success 'remove remote' '
97 -(
98 - cd test &&
99 - git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
100 - git remote rm second
101 -)
96 + (
97 + cd test &&
98 + git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
99 + git remote rm second
100 + )
101 '
102
103 test_expect_success C_LOCALE_OUTPUT 'remove remote' '
105 -(
106 - cd test &&
107 - tokens_match origin "$(git remote)" &&
108 - check_remote_track origin master side &&
109 - git for-each-ref "--format=%(refname)" refs/remotes |
110 - sed -e "/^refs\/remotes\/origin\//d" >actual &&
111 - >expect &&
112 - test_cmp expect actual
113 -)
104 + (
105 + cd test &&
106 + tokens_match origin "$(git remote)" &&
107 + check_remote_track origin master side &&
108 + git for-each-ref "--format=%(refname)" refs/remotes |
109 + sed -e "/^refs\/remotes\/origin\//d" >actual &&
110 + >expect &&
111 + test_cmp expect actual
112 + )
113 '
114
115 test_expect_success 'remove remote protects local branches' '
117 -(
118 - cd test &&
119 - { cat >expect1 <<EOF
120 -Note: A branch outside the refs/remotes/ hierarchy was not removed;
121 -to delete it, use:
122 - git branch -d master
123 -EOF
124 - } &&
125 - { cat >expect2 <<EOF
126 -Note: Some branches outside the refs/remotes/ hierarchy were not removed;
127 -to delete them, use:
128 - git branch -d foobranch
129 - git branch -d master
130 -EOF
131 - } &&
132 - git tag footag &&
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 &&
139 - git tag -d footag &&
140 - test_i18ncmp expect1 actual1 &&
141 - test_i18ncmp expect2 actual2
142 -)
143 -'
144 -
145 -cat > test/expect << EOF
116 + (
117 + cd test &&
118 + cat >expect1 <<-\EOF &&
119 + Note: A branch outside the refs/remotes/ hierarchy was not removed;
120 + to delete it, use:
121 + git branch -d master
122 + EOF
123 + cat >expect2 <<-\EOF &&
124 + Note: Some branches outside the refs/remotes/ hierarchy were not removed;
125 + to delete them, use:
126 + git branch -d foobranch
127 + git branch -d master
128 + EOF
129 + git tag footag &&
130 + git config --add remote.oops.fetch "+refs/*:refs/*" &&
131 + git remote remove oops 2>actual1 &&
132 + git branch foobranch &&
133 + git config --add remote.oops.fetch "+refs/*:refs/*" &&
134 + git remote rm oops 2>actual2 &&
135 + git branch -d foobranch &&
136 + git tag -d footag &&
137 + test_i18ncmp expect1 actual1 &&
138 + test_i18ncmp expect2 actual2
139 + )
140 +'
141 +
142 +cat >test/expect <<EOF
143 * remote origin
144 Fetch URL: $(pwd)/one
145 Push URL: $(pwd)/one
@@ -172,36 +169,40 @@ cat > test/expect << EOF
169 EOF
170
171 test_expect_success 'show' '
175 - (cd test &&
176 - git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream &&
177 - git fetch &&
178 - git checkout -b ahead origin/master &&
179 - echo 1 >> file &&
180 - test_tick &&
181 - git commit -m update file &&
182 - git checkout master &&
183 - git branch --track octopus origin/master &&
184 - git branch --track rebase origin/master &&
185 - git branch -d -r origin/master &&
186 - git config --add remote.two.url ../two &&
187 - git config --add remote.two.pushurl ../three &&
188 - git config branch.rebase.rebase true &&
189 - git config branch.octopus.merge "topic-a topic-b topic-c" &&
190 - (cd ../one &&
191 - echo 1 > file &&
192 - test_tick &&
193 - git commit -m update file) &&
194 - git config --add remote.origin.push : &&
195 - git config --add remote.origin.push refs/heads/master:refs/heads/upstream &&
196 - git config --add remote.origin.push +refs/tags/lastbackup &&
197 - git config --add remote.two.push +refs/heads/ahead:refs/heads/master &&
198 - git config --add remote.two.push refs/heads/master:refs/heads/another &&
199 - git remote show origin two > output &&
200 - git branch -d rebase octopus &&
201 - test_i18ncmp expect output)
202 -'
203 -
204 -cat > test/expect << EOF
172 + (
173 + cd test &&
174 + git config --add remote.origin.fetch refs/heads/master:refs/heads/upstream &&
175 + git fetch &&
176 + git checkout -b ahead origin/master &&
177 + echo 1 >>file &&
178 + test_tick &&
179 + git commit -m update file &&
180 + git checkout master &&
181 + git branch --track octopus origin/master &&
182 + git branch --track rebase origin/master &&
183 + git branch -d -r origin/master &&
184 + git config --add remote.two.url ../two &&
185 + git config --add remote.two.pushurl ../three &&
186 + git config branch.rebase.rebase true &&
187 + git config branch.octopus.merge "topic-a topic-b topic-c" &&
188 + (
189 + cd ../one &&
190 + echo 1 >file &&
191 + test_tick &&
192 + git commit -m update file
193 + ) &&
194 + git config --add remote.origin.push : &&
195 + git config --add remote.origin.push refs/heads/master:refs/heads/upstream &&
196 + git config --add remote.origin.push +refs/tags/lastbackup &&
197 + git config --add remote.two.push +refs/heads/ahead:refs/heads/master &&
198 + git config --add remote.two.push refs/heads/master:refs/heads/another &&
199 + git remote show origin two >output &&
200 + git branch -d rebase octopus &&
201 + test_i18ncmp expect output
202 + )
203 +'
204 +
205 +cat >test/expect <<EOF
206 * remote origin
207 Fetch URL: $(pwd)/one
208 Push URL: $(pwd)/one
@@ -219,152 +220,187 @@ cat > test/expect << EOF
220 EOF
221
222 test_expect_success 'show -n' '
222 - (mv one one.unreachable &&
223 - cd test &&
224 - git remote show -n origin > output &&
225 - mv ../one.unreachable ../one &&
226 - test_i18ncmp expect output)
223 + mv one one.unreachable &&
224 + (
225 + cd test &&
226 + git remote show -n origin >output &&
227 + mv ../one.unreachable ../one &&
228 + test_i18ncmp expect output
229 + )
230 '
231
232 test_expect_success 'prune' '
230 - (cd one &&
231 - git branch -m side side2) &&
232 - (cd test &&
233 - git fetch origin &&
234 - git remote prune origin &&
235 - git rev-parse refs/remotes/origin/side2 &&
236 - test_must_fail git rev-parse refs/remotes/origin/side)
233 + (
234 + cd one &&
235 + git branch -m side side2
236 + ) &&
237 + (
238 + cd test &&
239 + git fetch origin &&
240 + git remote prune origin &&
241 + git rev-parse refs/remotes/origin/side2 &&
242 + test_must_fail git rev-parse refs/remotes/origin/side
243 + )
244 '
245
246 test_expect_success 'set-head --delete' '
240 - (cd test &&
241 - git symbolic-ref refs/remotes/origin/HEAD &&
242 - git remote set-head --delete origin &&
243 - test_must_fail git symbolic-ref refs/remotes/origin/HEAD)
247 + (
248 + cd test &&
249 + git symbolic-ref refs/remotes/origin/HEAD &&
250 + git remote set-head --delete origin &&
251 + test_must_fail git symbolic-ref refs/remotes/origin/HEAD
252 + )
253 '
254
255 test_expect_success 'set-head --auto' '
247 - (cd test &&
248 - git remote set-head --auto origin &&
249 - echo refs/remotes/origin/master >expect &&
250 - git symbolic-ref refs/remotes/origin/HEAD >output &&
251 - test_cmp expect output
256 + (
257 + cd test &&
258 + git remote set-head --auto origin &&
259 + echo refs/remotes/origin/master >expect &&
260 + git symbolic-ref refs/remotes/origin/HEAD >output &&
261 + test_cmp expect output
262 )
263 '
264
255 -cat >test/expect <<EOF
265 +cat >test/expect <<\EOF
266 error: Multiple remote HEAD branches. Please choose one explicitly with:
267 git remote set-head two another
268 git remote set-head two master
269 EOF
270
271 test_expect_success 'set-head --auto fails w/multiple HEADs' '
262 - (cd test &&
263 - test_must_fail git remote set-head --auto two >output 2>&1 &&
264 - test_i18ncmp expect output)
272 + (
273 + cd test &&
274 + test_must_fail git remote set-head --auto two >output 2>&1 &&
275 + test_i18ncmp expect output
276 + )
277 '
278
267 -cat >test/expect <<EOF
279 +cat >test/expect <<\EOF
280 refs/remotes/origin/side2
281 EOF
282
283 test_expect_success 'set-head explicit' '
272 - (cd test &&
273 - git remote set-head origin side2 &&
274 - git symbolic-ref refs/remotes/origin/HEAD >output &&
275 - git remote set-head origin master &&
276 - test_cmp expect output)
284 + (
285 + cd test &&
286 + git remote set-head origin side2 &&
287 + git symbolic-ref refs/remotes/origin/HEAD >output &&
288 + git remote set-head origin master &&
289 + test_cmp expect output
290 + )
291 '
292
279 -cat > test/expect << EOF
293 +cat >test/expect <<EOF
294 Pruning origin
295 URL: $(pwd)/one
296 * [would prune] origin/side2
297 EOF
298
299 test_expect_success 'prune --dry-run' '
286 - (cd one &&
287 - git branch -m side2 side) &&
288 - (cd test &&
289 - git remote prune --dry-run origin > output &&
290 - git rev-parse refs/remotes/origin/side2 &&
291 - test_must_fail git rev-parse refs/remotes/origin/side &&
292 - (cd ../one &&
293 - git branch -m side side2) &&
294 - test_i18ncmp expect output)
300 + (
301 + cd one &&
302 + git branch -m side2 side) &&
303 + (
304 + cd test &&
305 + git remote prune --dry-run origin >output &&
306 + git rev-parse refs/remotes/origin/side2 &&
307 + test_must_fail git rev-parse refs/remotes/origin/side &&
308 + (
309 + cd ../one &&
310 + git branch -m side side2) &&
311 + test_i18ncmp expect output
312 + )
313 '
314
315 test_expect_success 'add --mirror && prune' '
298 - (mkdir mirror &&
299 - cd mirror &&
300 - git init --bare &&
301 - git remote add --mirror -f origin ../one) &&
302 - (cd one &&
303 - git branch -m side2 side) &&
304 - (cd mirror &&
305 - git rev-parse --verify refs/heads/side2 &&
306 - test_must_fail git rev-parse --verify refs/heads/side &&
307 - git fetch origin &&
308 - git remote prune origin &&
309 - test_must_fail git rev-parse --verify refs/heads/side2 &&
310 - git rev-parse --verify refs/heads/side)
316 + mkdir mirror &&
317 + (
318 + cd mirror &&
319 + git init --bare &&
320 + git remote add --mirror -f origin ../one
321 + ) &&
322 + (
323 + cd one &&
324 + git branch -m side2 side
325 + ) &&
326 + (
327 + cd mirror &&
328 + git rev-parse --verify refs/heads/side2 &&
329 + test_must_fail git rev-parse --verify refs/heads/side &&
330 + git fetch origin &&
331 + git remote prune origin &&
332 + test_must_fail git rev-parse --verify refs/heads/side2 &&
333 + git rev-parse --verify refs/heads/side
334 + )
335 '
336
337 test_expect_success 'add --mirror=fetch' '
338 mkdir mirror-fetch &&
339 git init mirror-fetch/parent &&
316 - (cd mirror-fetch/parent &&
317 - test_commit one) &&
340 + (
341 + cd mirror-fetch/parent &&
342 + test_commit one
343 + ) &&
344 git init --bare mirror-fetch/child &&
319 - (cd mirror-fetch/child &&
320 - git remote add --mirror=fetch -f parent ../parent)
345 + (
346 + cd mirror-fetch/child &&
347 + git remote add --mirror=fetch -f parent ../parent
348 + )
349 '
350
351 test_expect_success 'fetch mirrors act as mirrors during fetch' '
324 - (cd mirror-fetch/parent &&
325 - git branch new &&
326 - git branch -m master renamed
352 + (
353 + cd mirror-fetch/parent &&
354 + git branch new &&
355 + git branch -m master renamed
356 ) &&
328 - (cd mirror-fetch/child &&
329 - git fetch parent &&
330 - git rev-parse --verify refs/heads/new &&
331 - git rev-parse --verify refs/heads/renamed
357 + (
358 + cd mirror-fetch/child &&
359 + git fetch parent &&
360 + git rev-parse --verify refs/heads/new &&
361 + git rev-parse --verify refs/heads/renamed
362 )
363 '
364
365 test_expect_success 'fetch mirrors can prune' '
336 - (cd mirror-fetch/child &&
337 - git remote prune parent &&
338 - test_must_fail git rev-parse --verify refs/heads/master
366 + (
367 + cd mirror-fetch/child &&
368 + git remote prune parent &&
369 + test_must_fail git rev-parse --verify refs/heads/master
370 )
371 '
372
373 test_expect_success 'fetch mirrors do not act as mirrors during push' '
343 - (cd mirror-fetch/parent &&
344 - git checkout HEAD^0
374 + (
375 + cd mirror-fetch/parent &&
376 + git checkout HEAD^0
377 ) &&
346 - (cd mirror-fetch/child &&
347 - git branch -m renamed renamed2 &&
348 - git push parent :
378 + (
379 + cd mirror-fetch/child &&
380 + git branch -m renamed renamed2 &&
381 + git push parent :
382 ) &&
350 - (cd mirror-fetch/parent &&
351 - git rev-parse --verify renamed &&
352 - test_must_fail git rev-parse --verify refs/heads/renamed2
383 + (
384 + cd mirror-fetch/parent &&
385 + git rev-parse --verify renamed &&
386 + test_must_fail git rev-parse --verify refs/heads/renamed2
387 )
388 '
389
390 test_expect_success 'add fetch mirror with specific branches' '
391 git init --bare mirror-fetch/track &&
358 - (cd mirror-fetch/track &&
359 - git remote add --mirror=fetch -t heads/new parent ../parent
392 + (
393 + cd mirror-fetch/track &&
394 + git remote add --mirror=fetch -t heads/new parent ../parent
395 )
396 '
397
398 test_expect_success 'fetch mirror respects specific branches' '
364 - (cd mirror-fetch/track &&
365 - git fetch parent &&
366 - git rev-parse --verify refs/heads/new &&
367 - test_must_fail git rev-parse --verify refs/heads/renamed
399 + (
400 + cd mirror-fetch/track &&
401 + git fetch parent &&
402 + git rev-parse --verify refs/heads/new &&
403 + test_must_fail git rev-parse --verify refs/heads/renamed
404 )
405 '
406
@@ -372,60 +408,72 @@ test_expect_success 'add --mirror=push' '
408 mkdir mirror-push &&
409 git init --bare mirror-push/public &&
410 git init mirror-push/private &&
375 - (cd mirror-push/private &&
376 - test_commit one &&
377 - git remote add --mirror=push public ../public
411 + (
412 + cd mirror-push/private &&
413 + test_commit one &&
414 + git remote add --mirror=push public ../public
415 )
416 '
417
418 test_expect_success 'push mirrors act as mirrors during push' '
382 - (cd mirror-push/private &&
383 - git branch new &&
384 - git branch -m master renamed &&
385 - git push public
419 + (
420 + cd mirror-push/private &&
421 + git branch new &&
422 + git branch -m master renamed &&
423 + git push public
424 ) &&
387 - (cd mirror-push/private &&
388 - git rev-parse --verify refs/heads/new &&
389 - git rev-parse --verify refs/heads/renamed &&
390 - test_must_fail git rev-parse --verify refs/heads/master
425 + (
426 + cd mirror-push/private &&
427 + git rev-parse --verify refs/heads/new &&
428 + git rev-parse --verify refs/heads/renamed &&
429 + test_must_fail git rev-parse --verify refs/heads/master
430 )
431 '
432
433 test_expect_success 'push mirrors do not act as mirrors during fetch' '
395 - (cd mirror-push/public &&
396 - git branch -m renamed renamed2 &&
397 - git symbolic-ref HEAD refs/heads/renamed2
434 + (
435 + cd mirror-push/public &&
436 + git branch -m renamed renamed2 &&
437 + git symbolic-ref HEAD refs/heads/renamed2
438 ) &&
399 - (cd mirror-push/private &&
400 - git fetch public &&
401 - git rev-parse --verify refs/heads/renamed &&
402 - test_must_fail git rev-parse --verify refs/heads/renamed2
439 + (
440 + cd mirror-push/private &&
441 + git fetch public &&
442 + git rev-parse --verify refs/heads/renamed &&
443 + test_must_fail git rev-parse --verify refs/heads/renamed2
444 )
445 '
446
447 test_expect_success 'push mirrors do not allow you to specify refs' '
448 git init mirror-push/track &&
408 - (cd mirror-push/track &&
409 - test_must_fail git remote add --mirror=push -t new public ../public
449 + (
450 + cd mirror-push/track &&
451 + test_must_fail git remote add --mirror=push -t new public ../public
452 )
453 '
454
455 test_expect_success 'add alt && prune' '
414 - (mkdir alttst &&
415 - cd alttst &&
416 - git init &&
417 - git remote add -f origin ../one &&
418 - git config remote.alt.url ../one &&
419 - git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*") &&
420 - (cd one &&
421 - git branch -m side side2) &&
422 - (cd alttst &&
423 - git rev-parse --verify refs/remotes/origin/side &&
424 - test_must_fail git rev-parse --verify refs/remotes/origin/side2 &&
425 - git fetch alt &&
426 - git remote prune alt &&
427 - test_must_fail git rev-parse --verify refs/remotes/origin/side &&
428 - git rev-parse --verify refs/remotes/origin/side2)
456 + mkdir alttst &&
457 + (
458 + cd alttst &&
459 + git init &&
460 + git remote add -f origin ../one &&
461 + git config remote.alt.url ../one &&
462 + git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*"
463 + ) &&
464 + (
465 + cd one &&
466 + git branch -m side side2
467 + ) &&
468 + (
469 + cd alttst &&
470 + git rev-parse --verify refs/remotes/origin/side &&
471 + test_must_fail git rev-parse --verify refs/remotes/origin/side2 &&
472 + git fetch alt &&
473 + git remote prune alt &&
474 + test_must_fail git rev-parse --verify refs/remotes/origin/side &&
475 + git rev-parse --verify refs/remotes/origin/side2
476 + )
477 '
478
479 cat >test/expect <<\EOF
@@ -433,20 +481,24 @@ some-tag
481 EOF
482
483 test_expect_success 'add with reachable tags (default)' '
436 - (cd one &&
437 - >foobar &&
438 - git add foobar &&
439 - git commit -m "Foobar" &&
440 - git tag -a -m "Foobar tag" foobar-tag &&
441 - git reset --hard HEAD~1 &&
442 - git tag -a -m "Some tag" some-tag) &&
443 - (mkdir add-tags &&
444 - cd add-tags &&
445 - git init &&
446 - git remote add -f origin ../one &&
447 - git tag -l some-tag >../test/output &&
448 - git tag -l foobar-tag >>../test/output &&
449 - test_must_fail git config remote.origin.tagopt) &&
484 + (
485 + cd one &&
486 + >foobar &&
487 + git add foobar &&
488 + git commit -m "Foobar" &&
489 + git tag -a -m "Foobar tag" foobar-tag &&
490 + git reset --hard HEAD~1 &&
491 + git tag -a -m "Some tag" some-tag
492 + ) &&
493 + mkdir add-tags &&
494 + (
495 + cd add-tags &&
496 + git init &&
497 + git remote add -f origin ../one &&
498 + git tag -l some-tag >../test/output &&
499 + git tag -l foobar-tag >>../test/output &&
500 + test_must_fail git config remote.origin.tagopt
501 + ) &&
502 test_cmp test/expect test/output
503 '
504
@@ -457,14 +509,16 @@ foobar-tag
509 EOF
510
511 test_expect_success 'add --tags' '
460 - (rm -rf add-tags &&
461 - mkdir add-tags &&
462 - cd add-tags &&
463 - git init &&
464 - git remote add -f --tags origin ../one &&
465 - git tag -l some-tag >../test/output &&
466 - git tag -l foobar-tag >>../test/output &&
467 - git config remote.origin.tagopt >>../test/output) &&
512 + rm -rf add-tags &&
513 + (
514 + mkdir add-tags &&
515 + cd add-tags &&
516 + git init &&
517 + git remote add -f --tags origin ../one &&
518 + git tag -l some-tag >../test/output &&
519 + git tag -l foobar-tag >>../test/output &&
520 + git config remote.origin.tagopt >>../test/output
521 + ) &&
522 test_cmp test/expect test/output
523 '
524
@@ -473,25 +527,31 @@ cat >test/expect <<\EOF
527 EOF
528
529 test_expect_success 'add --no-tags' '
476 - (rm -rf add-tags &&
477 - mkdir add-no-tags &&
478 - cd add-no-tags &&
479 - git init &&
480 - git remote add -f --no-tags origin ../one &&
481 - git tag -l some-tag >../test/output &&
482 - git tag -l foobar-tag >../test/output &&
483 - git config remote.origin.tagopt >>../test/output) &&
484 - (cd one &&
485 - git tag -d some-tag foobar-tag) &&
530 + rm -rf add-tags &&
531 + (
532 + mkdir add-no-tags &&
533 + cd add-no-tags &&
534 + git init &&
535 + git remote add -f --no-tags origin ../one &&
536 + git tag -l some-tag >../test/output &&
537 + git tag -l foobar-tag >../test/output &&
538 + git config remote.origin.tagopt >>../test/output
539 + ) &&
540 + (
541 + cd one &&
542 + git tag -d some-tag foobar-tag
543 + ) &&
544 test_cmp test/expect test/output
545 '
546
547 test_expect_success 'reject --no-no-tags' '
490 - (cd add-no-tags &&
491 - test_must_fail git remote add -f --no-no-tags neworigin ../one)
548 + (
549 + cd add-no-tags &&
550 + test_must_fail git remote add -f --no-no-tags neworigin ../one
551 + )
552 '
553
494 -cat > one/expect << EOF
554 +cat >one/expect <<\EOF
555 apis/master
556 apis/side
557 drosophila/another
@@ -500,17 +560,17 @@ cat > one/expect << EOF
560 EOF
561
562 test_expect_success 'update' '
503 -
504 - (cd one &&
505 - git remote add drosophila ../two &&
506 - git remote add apis ../mirror &&
507 - git remote update &&
508 - git branch -r > output &&
509 - test_cmp expect output)
510 -
563 + (
564 + cd one &&
565 + git remote add drosophila ../two &&
566 + git remote add apis ../mirror &&
567 + git remote update &&
568 + git branch -r >output &&
569 + test_cmp expect output
570 + )
571 '
572
513 -cat > one/expect << EOF
573 +cat >one/expect <<\EOF
574 drosophila/another
575 drosophila/master
576 drosophila/side
@@ -521,34 +581,40 @@ cat > one/expect << EOF
581 EOF
582
583 test_expect_success 'update with arguments' '
524 -
525 - (cd one &&
526 - for b in $(git branch -r)
527 - do
584 + (
585 + cd one &&
586 + for b in $(git branch -r)
587 + do
588 git branch -r -d $b || break
529 - done &&
530 - git remote add manduca ../mirror &&
531 - git remote add megaloprepus ../mirror &&
532 - git config remotes.phobaeticus "drosophila megaloprepus" &&
533 - git config remotes.titanus manduca &&
534 - git remote update phobaeticus titanus &&
535 - git branch -r > output &&
536 - test_cmp expect output)
537 -
589 + done &&
590 + git remote add manduca ../mirror &&
591 + git remote add megaloprepus ../mirror &&
592 + git config remotes.phobaeticus "drosophila megaloprepus" &&
593 + git config remotes.titanus manduca &&
594 + git remote update phobaeticus titanus &&
595 + git branch -r >output &&
596 + test_cmp expect output
597 + )
598 '
599
600 test_expect_success 'update --prune' '
541 -
542 - (cd one &&
543 - git branch -m side2 side3) &&
544 - (cd test &&
545 - git remote update --prune &&
546 - (cd ../one && git branch -m side3 side2) &&
547 - git rev-parse refs/remotes/origin/side3 &&
548 - test_must_fail git rev-parse refs/remotes/origin/side2)
601 + (
602 + cd one &&
603 + git branch -m side2 side3
604 + ) &&
605 + (
606 + cd test &&
607 + git remote update --prune &&
608 + (
609 + cd ../one &&
610 + git branch -m side3 side2
611 + ) &&
612 + git rev-parse refs/remotes/origin/side3 &&
613 + test_must_fail git rev-parse refs/remotes/origin/side2
614 + )
615 '
616
551 -cat > one/expect << EOF
617 +cat >one/expect <<-\EOF
618 apis/master
619 apis/side
620 manduca/master
@@ -558,117 +624,115 @@ cat > one/expect << EOF
624 EOF
625
626 test_expect_success 'update default' '
561 -
562 - (cd one &&
563 - for b in $(git branch -r)
564 - do
627 + (
628 + cd one &&
629 + for b in $(git branch -r)
630 + do
631 git branch -r -d $b || break
566 - done &&
567 - git config remote.drosophila.skipDefaultUpdate true &&
568 - git remote update default &&
569 - git branch -r > output &&
570 - test_cmp expect output)
571 -
632 + done &&
633 + git config remote.drosophila.skipDefaultUpdate true &&
634 + git remote update default &&
635 + git branch -r >output &&
636 + test_cmp expect output
637 + )
638 '
639
574 -cat > one/expect << EOF
640 +cat >one/expect <<\EOF
641 drosophila/another
642 drosophila/master
643 drosophila/side
644 EOF
645
646 test_expect_success 'update default (overridden, with funny whitespace)' '
581 -
582 - (cd one &&
583 - for b in $(git branch -r)
584 - do
647 + (
648 + cd one &&
649 + for b in $(git branch -r)
650 + do
651 git branch -r -d $b || break
586 - done &&
587 - git config remotes.default "$(printf "\t drosophila \n")" &&
588 - git remote update default &&
589 - git branch -r > output &&
590 - test_cmp expect output)
591 -
652 + done &&
653 + git config remotes.default "$(printf "\t drosophila \n")" &&
654 + git remote update default &&
655 + git branch -r >output &&
656 + test_cmp expect output
657 + )
658 '
659
660 test_expect_success 'update (with remotes.default defined)' '
595 -
596 - (cd one &&
597 - for b in $(git branch -r)
598 - do
661 + (
662 + cd one &&
663 + for b in $(git branch -r)
664 + do
665 git branch -r -d $b || break
600 - done &&
601 - git config remotes.default "drosophila" &&
602 - git remote update &&
603 - git branch -r > output &&
604 - test_cmp expect output)
605 -
666 + done &&
667 + git config remotes.default "drosophila" &&
668 + git remote update &&
669 + git branch -r >output &&
670 + test_cmp expect output
671 + )
672 '
673
674 test_expect_success '"remote show" does not show symbolic refs' '
609 -
675 git clone one three &&
611 - (cd three &&
612 - git remote show origin > output &&
613 - ! grep "^ *HEAD$" < output &&
614 - ! grep -i stale < output)
615 -
676 + (
677 + cd three &&
678 + git remote show origin >output &&
679 + ! grep "^ *HEAD$" < output &&
680 + ! grep -i stale < output
681 + )
682 '
683
684 test_expect_success 'reject adding remote with an invalid name' '
619 -
685 test_must_fail git remote add some:url desired-name
621 -
686 '
687
688 # The first three test if the tracking branches are properly renamed,
689 # the last two ones check if the config is updated.
690
691 test_expect_success 'rename a remote' '
628 -
692 git clone one four &&
630 - (cd four &&
631 - git remote rename origin upstream &&
632 - rmdir .git/refs/remotes/origin &&
633 - test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" &&
634 - test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" &&
635 - test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" &&
636 - test "$(git config branch.master.remote)" = "upstream")
637 -
693 + (
694 + cd four &&
695 + git remote rename origin upstream &&
696 + rmdir .git/refs/remotes/origin &&
697 + test "$(git symbolic-ref refs/remotes/upstream/HEAD)" = "refs/remotes/upstream/master" &&
698 + test "$(git rev-parse upstream/master)" = "$(git rev-parse master)" &&
699 + test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*" &&
700 + test "$(git config branch.master.remote)" = "upstream"
701 + )
702 '
703
704 test_expect_success 'rename does not update a non-default fetch refspec' '
641 -
705 git clone one four.one &&
643 - (cd four.one &&
644 - git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* &&
645 - git remote rename origin upstream &&
646 - test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*" &&
647 - git rev-parse -q origin/master)
648 -
706 + (
707 + cd four.one &&
708 + git config remote.origin.fetch +refs/heads/*:refs/heads/origin/* &&
709 + git remote rename origin upstream &&
710 + test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/heads/origin/*" &&
711 + git rev-parse -q origin/master
712 + )
713 '
714
715 test_expect_success 'rename a remote with name part of fetch spec' '
652 -
716 git clone one four.two &&
654 - (cd four.two &&
655 - git remote rename origin remote &&
656 - git remote rename remote upstream &&
657 - test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*")
658 -
717 + (
718 + cd four.two &&
719 + git remote rename origin remote &&
720 + git remote rename remote upstream &&
721 + test "$(git config remote.upstream.fetch)" = "+refs/heads/*:refs/remotes/upstream/*"
722 + )
723 '
724
725 test_expect_success 'rename a remote with name prefix of other remote' '
662 -
726 git clone one four.three &&
664 - (cd four.three &&
665 - git remote add o git://example.com/repo.git &&
666 - git remote rename o upstream &&
667 - test "$(git rev-parse origin/master)" = "$(git rev-parse master)")
668 -
727 + (
728 + cd four.three &&
729 + git remote add o git://example.com/repo.git &&
730 + git remote rename o upstream &&
731 + test "$(git rev-parse origin/master)" = "$(git rev-parse master)"
732 + )
733 '
734
671 -cat > remotes_origin << EOF
735 +cat >remotes_origin <<EOF
736 URL: $(pwd)/one
737 Push: refs/heads/master:refs/heads/upstream
738 Pull: refs/heads/master:refs/heads/origin
@@ -677,27 +741,31 @@ EOF
741 test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
742 git clone one five &&
743 origin_url=$(pwd)/one &&
680 - (cd five &&
681 - git remote remove origin &&
682 - mkdir -p .git/remotes &&
683 - cat ../remotes_origin > .git/remotes/origin &&
684 - git remote rename origin origin &&
685 - ! test -f .git/remotes/origin &&
686 - test "$(git config remote.origin.url)" = "$origin_url" &&
687 - test "$(git config remote.origin.push)" = "refs/heads/master:refs/heads/upstream" &&
688 - test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin")
744 + (
745 + cd five &&
746 + git remote remove origin &&
747 + mkdir -p .git/remotes &&
748 + cat ../remotes_origin >.git/remotes/origin &&
749 + git remote rename origin origin &&
750 + ! test -f .git/remotes/origin &&
751 + test "$(git config remote.origin.url)" = "$origin_url" &&
752 + test "$(git config remote.origin.push)" = "refs/heads/master:refs/heads/upstream" &&
753 + test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin"
754 + )
755 '
756
757 test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
758 git clone one six &&
759 origin_url=$(pwd)/one &&
694 - (cd six &&
695 - git remote rm origin &&
696 - echo "$origin_url" > .git/branches/origin &&
697 - git remote rename origin origin &&
698 - ! test -f .git/branches/origin &&
699 - test "$(git config remote.origin.url)" = "$origin_url" &&
700 - test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin")
760 + (
761 + cd six &&
762 + git remote rm origin &&
763 + echo "$origin_url" >.git/branches/origin &&
764 + git remote rename origin origin &&
765 + ! test -f .git/branches/origin &&
766 + test "$(git config remote.origin.url)" = "$origin_url" &&
767 + test "$(git config remote.origin.fetch)" = "refs/heads/master:refs/heads/origin"
768 + )
769 '
770
771 test_expect_success 'remote prune to cause a dangling symref' '
@@ -727,7 +795,6 @@ test_expect_success 'remote prune to cause a dangling symref' '
795 '
796
797 test_expect_success 'show empty remote' '
730 -
798 test_create_repo empty &&
799 git clone empty empty-clone &&
800 (