README_DOCS.rst: update tg prev and tg next usage summary
[topgit/pro.git] / t / t7000-push.sh
blob2e8e1060fd200103110c6c76019b746223854de4
1 #!/bin/sh
3 test_description='check tg push'
5 TEST_NO_CREATE_REPO=1
7 . ./test-lib.sh
9 # We are not testing `git push` here, we are testing
10 # that `tg push` delivers the correct arguments to `git push`
12 mkdir gitshim || die
13 write_script gitshim/git <<\EOT || die
15 [ "$1" = "-c" ] && [ "$3" = "push" ] &&
16 case "$2" in "include.path="*);;*) ! :;esac
17 then
18 shift
19 _fn="${1#include.path=}"; shift
20 shift
21 _n="$#"
22 eval "_v=\"\${$_n}\""
23 case "$_v" in "tg-push-"*)
24 _i=0
25 while _i="$(( $_i + 1 ))" && [ "$_i" -le "$_n" ]; do
26 if [ "$_i" = "$_n" ]; then
27 shift
28 set -- "$@" "tg-push-remote"
29 else
30 _a="$1"
31 shift
32 set -- "$@" "$_a"
34 done
35 esac
36 printf '%s\n' "$@"
37 echo "----------"
38 cat "$_fn" | sed "s/$_v/tg-push-remote/"
39 exit 0
41 exec "$GIT_PATH" "$@"
42 EOT
43 GIT_SHIM_DIR="$PWD/gitshim"
44 tgshim() {
45 GIT_PATH="$GIT_PATH" PATH="$GIT_SHIM_DIR:$PATH" tg "$@"
48 topbases="$(tg --top-bases)" && topbases="${topbases#refs/}" && [ -n "$topbases" ] || die
50 test_plan 26
52 test_expect_success 'setup' '
53 test_create_repo empty &&
54 test_create_repo detached &&
55 test_create_repo nontg &&
56 test_create_repo combined &&
57 mkdir testshim &&
58 cd testshim &&
59 cat <<-EOT >expected &&
60 --dry-run
61 --force
62 some-remote
63 some-ref
64 ----------
65 EOT
66 tgshim -c topgit.alias.git=!git git -c include.path=/dev/null push --dry-run --force some-remote some-ref >actual &&
67 test_cmp actual expected &&
68 git version --build-options >expected &&
69 tgshim -c topgit.alias.git=!git git version --build-options >actual &&
70 test_cmp actual expected &&
71 cd ../detached &&
72 test_commit detached &&
73 git update-ref --no-deref HEAD HEAD HEAD &&
74 git update-ref -d refs/heads/master &&
75 cd ../nontg &&
76 test_commit one &&
77 test_commit two &&
78 git read-tree --empty &&
79 git symbolic-ref HEAD refs/heads/other &&
80 test_commit o1 &&
81 test_commit o2 &&
82 cd ../combined &&
83 tg_test_create_branch remote1::t/branch1 : &&
84 git checkout -f t/branch1 &&
85 test_commit tgb1a &&
86 test_commit tgb1b &&
87 tg_test_create_branch t/branch2 : &&
88 git checkout -f t/branch2 &&
89 test_commit tgb2a &&
90 test_commit tgb2b &&
91 git update-ref refs/remotes/remote2/t/branch2 HEAD "" &&
92 git update-ref refs/remotes/remote2/${topbases#heads/}/t/branch2 "$(tg base t/branch2)" "" &&
93 git checkout -f refs/remotes/remote2/t/branch2 &&
94 git symbolic-ref HEAD refs/remotes/remote2/t/branch2 &&
95 test_commit aheadb2 &&
96 tg_test_create_branch t/branch3 : &&
97 git checkout -f t/branch3 &&
98 test_commit tgb3a &&
99 test_commit tgb3b &&
100 git update-ref refs/remotes/remote3/t/branch3 HEAD "" &&
101 git update-ref refs/remotes/remote3/${topbases#heads/}/t/branch3 "$(tg base t/branch3)" "" &&
102 git checkout -f "refs/remotes/remote3/${topbases#heads/}/t/branch3" &&
103 git symbolic-ref HEAD "refs/remotes/remote3/${topbases#heads/}/t/branch3" &&
104 test_commit aheadb3 &&
105 tg_test_create_branch remote4:t/dep : &&
106 tg_test_create_branch remote4:t/branch4 :refs/remotes/remote4/t/dep t/dep &&
107 git checkout -f refs/remotes/remote4/t/dep &&
108 git symbolic-ref HEAD refs/remotes/remote4/t/dep &&
109 test_commit adep &&
110 tg_test_create_branch t/branch4 :refs/remotes/remote4/t/dep &&
111 git read-tree --empty &&
112 git symbolic-ref HEAD refs/heads/t/mt &&
113 test_commit mt &&
114 git update-ref --no-deref HEAD HEAD HEAD &&
115 git update-ref "refs/$topbases/t/mt" HEAD "" &&
116 git update-ref "refs/$topbases/t/mtann" HEAD "" &&
117 test_commit notmt &&
118 anc="$(git commit-tree -m makeann -p HEAD t/mt^{tree})" && test -n "$anc" &&
119 git update-ref refs/heads/t/mtann "$anc" "" &&
120 git read-tree --empty &&
121 git symbolic-ref HEAD "refs/$topbases/t/fullann" &&
122 test_commit fullann &&
123 echo "t/holdboth" >.topdeps &&
124 git add .topdeps &&
125 test_tick &&
126 git commit -m "topdeps in base" &&
127 git update-ref refs/heads/t/fullann HEAD "" &&
128 git symbolic-ref HEAD "refs/heads/t/fullann" &&
129 test_commit fullcommit &&
130 anc="$(git commit-tree -m makefullann -p HEAD "refs/$topbases/t/fullann^{tree}")" && test -n "$anc" &&
131 git update-ref HEAD "$anc" HEAD &&
132 git read-tree --empty &&
133 git symbolic-ref HEAD refs/heads/master2 &&
134 test_commit m1 &&
135 test_commit m2 &&
136 git read-tree --empty &&
137 git symbolic-ref HEAD refs/heads/other2 &&
138 test_commit o1 &&
139 test_commit o2 &&
140 git read-tree --empty &&
141 git symbolic-ref HEAD "refs/$topbases/t/orphanbase" &&
142 test_commit tgorphanbase &&
143 git read-tree --empty &&
144 git symbolic-ref HEAD refs/heads/tgbranch1 &&
145 test_commit tgbefore1 &&
146 tg_test_create_branch t/both1 tgbranch1 &&
147 git checkout -f t/both1 &&
148 test_commit both1 &&
149 git read-tree --empty &&
150 git symbolic-ref HEAD refs/heads/tgbranch2 &&
151 test_commit tgbefore2 &&
152 tg_test_create_branch t/both2 tgbranch2 &&
153 git checkout -f t/both2 &&
154 test_commit both2 &&
155 git read-tree --empty &&
156 git symbolic-ref HEAD refs/heads/master3 &&
157 test_commit first &&
158 tg_test_create_branch t/branch master3 &&
159 test_commit second &&
160 git read-tree --empty &&
161 git symbolic-ref HEAD refs/heads/base1 &&
162 test_commit base1 &&
163 git read-tree --empty &&
164 git symbolic-ref HEAD refs/heads/base2 &&
165 test_commit base2 &&
166 tg_test_create_branch t/abranch1 base1 &&
167 git checkout -f t/abranch1 &&
168 test_commit abranch1 &&
169 anc="$(git commit-tree -m "annihilate" -p HEAD "$(git rev-parse --verify "refs/$topbases/t/abranch1^{tree}" --)")" &&
170 test -n "$anc" &&
171 git update-ref -m "annihilate branch" HEAD "$anc" HEAD &&
172 tg_test_create_branch t/hold1 t/abranch1 &&
173 tg_test_create_branch t/abranch2 base2 &&
174 git checkout -f t/abranch2 &&
175 test_commit abranch2 &&
176 tg_test_create_branch t/hold2 t/abranch2 &&
177 tg_test_create_branch t/holdboth t/branch t/abranch1 t/abranch2 &&
178 git config remote.nofetch.url "url:nofetch" &&
179 git config remote.notes.url "url:notes" &&
180 git config remote.notes.fetch "refs/notes/*:refs/remotes/notes/*" &&
181 git config remote.notesp.url "url:notesp" &&
182 git config remote.notesp.fetch "+refs/notes/*:refs/remotes/notesp/*" &&
183 git config remote.heads.url "url:heads" &&
184 git config remote.heads.fetch "refs/heads/*:refs/remotes/heads/*" &&
185 git config remote.bases.url "url:bases" &&
186 git config remote.bases.fetch "refs/$topbases/*:refs/remotes/bases/${topbases#heads/}/*" &&
187 git config remote.headsbases.url "url:headsbases" &&
188 git config remote.headsbases.fetch "refs/heads/*:refs/remotes/headsbases/*" &&
189 git config --add remote.headsbases.fetch "refs/$topbases/*:refs/remotes/headsbases/${topbases#heads/}/*" &&
190 git config remote.headsp.url "url:headsp" &&
191 git config remote.headsp.fetch "+refs/heads/*:refs/remotes/headsp/*" &&
192 git config remote.basesp.url "url:basesp" &&
193 git config remote.basesp.fetch "+refs/$topbases/*:refs/remotes/basesp/${topbases#heads/}/*" &&
194 git config remote.headspbasesp.url "url:headspbasesp" &&
195 git config remote.headspbasesp.fetch "+refs/heads/*:refs/remotes/headspbasesp/*" &&
196 git config --add remote.headspbasesp.fetch "+refs/$topbases/*:refs/remotes/headspbasesp/${topbases#heads/}/*" &&
197 git config remote.headspbases.url "url:headspbases" &&
198 git config remote.headspbases.fetch "+refs/heads/*:refs/remotes/headspbases/*" &&
199 git config --add remote.headspbases.fetch "refs/$topbases/*:refs/remotes/headspbases/${topbases#heads/}/*" &&
200 git config remote.headsbasesp.url "url:headsbasesp" &&
201 git config remote.headsbasesp.fetch "refs/heads/*:refs/remotes/headsbasesp/*" &&
202 git config --add remote.headsbasesp.fetch "+refs/$topbases/*:refs/remotes/headsbasesp/${topbases#heads/}/*" &&
203 test_when_finished test_set_prereq SETUP
206 test_expect_success SETUP 'empty fails' '
207 cd empty &&
208 test_must_fail tg push -r . &&
209 test_must_fail tg push -r . --all
212 test_expect_success SETUP 'detached fails' '
213 cd detached &&
214 test_must_fail tg push -r . &&
215 test_must_fail tg push -r . --all
218 test_expect_success SETUP 'branch plus --all fails' '
219 cd nontg &&
220 test_must_fail tg push -r . -a HEAD &&
221 test_must_fail tg push -r . --all HEAD &&
222 test_must_fail tg push -r . HEAD --all &&
223 test_must_fail tg push -r . @ -a &&
224 test_must_fail tg push -r . other -a &&
225 test_must_fail tg push -r . -a master
228 test_expect_success SETUP 'nontg okay' '
229 cd nontg &&
230 test_must_fail tg push -r . --all &&
231 cat <<EOT >expected &&
232 tg-push-remote
233 ----------
234 [remote "tg-push-remote"]
235 url = "origin"
236 push = "refs/heads/other:refs/heads/other"
238 tgshim push -r origin >actual &&
239 test_cmp actual expected &&
240 tgshim push -r origin HEAD >actual &&
241 test_cmp actual expected &&
242 tgshim push -r origin @ >actual &&
243 test_cmp actual expected &&
244 tgshim push -r origin other >actual &&
245 test_cmp actual expected &&
246 tgshim push -r origin @ HEAD other >actual &&
247 test_cmp actual expected &&
248 cat <<EOT >expected &&
249 tg-push-remote
250 ----------
251 [remote "tg-push-remote"]
252 url = "origin"
253 push = "refs/heads/master:refs/heads/master"
255 tgshim push -r origin master >actual &&
256 test_cmp actual expected &&
257 tgshim push -r origin master master >actual &&
258 test_cmp actual expected &&
259 cat <<EOT >expected &&
260 tg-push-remote
261 ----------
262 [remote "tg-push-remote"]
263 url = "origin"
264 push = "refs/heads/master:refs/heads/master"
265 push = "refs/heads/other:refs/heads/other"
267 tgshim push -r origin master other >actual &&
268 test_cmp actual expected &&
269 tgshim push -r origin master HEAD >actual &&
270 test_cmp actual expected &&
271 tgshim push -r origin master @ >actual &&
272 test_cmp actual expected &&
273 tgshim push -r origin other master >actual &&
274 test_cmp actual expected &&
275 tgshim push -r origin HEAD master >actual &&
276 test_cmp actual expected &&
277 tgshim push -r origin @ master >actual &&
278 test_cmp actual expected &&
279 tgshim push -r origin other master HEAD >actual &&
280 test_cmp actual expected &&
281 tgshim push -r origin master other master HEAD >actual &&
282 test_cmp actual expected
285 test_expect_success SETUP 'nontg --tgish-only fails' '
286 cd nontg &&
287 test_must_fail tg push -r . --tgish-only &&
288 test_must_fail tg push -r . --tgish-only HEAD &&
289 test_must_fail tg push -r . --tgish-only @ &&
290 test_must_fail tg push -r . --tgish-only master &&
291 test_must_fail tg push -r . --tgish-only other &&
292 test_must_fail tg push -r . --tgish-only --all
295 test_expect_success SETUP 'correct remote' '
296 cd nontg &&
297 test_must_fail tg push &&
298 test_must_fail tg -c topgit.remote=remote1 -u push &&
299 test_must_fail tg -c topgit.remote=remote1 -r remote1 -u push &&
300 test_must_fail tg -r remote1 -u push &&
301 cat <<EOT >expected &&
302 tg-push-remote
303 ----------
304 [remote "tg-push-remote"]
305 url = "remote1"
306 push = "refs/heads/other:refs/heads/other"
308 tgshim -c topgit.remote=remote1 push >actual &&
309 test_cmp actual expected &&
310 tgshim -r remote1 push >actual &&
311 test_cmp actual expected &&
312 tgshim -r remote1 -c topgit.remote=remote2 push >actual &&
313 test_cmp actual expected &&
314 tgshim -c topgit.remote=remote2 -r remote1 push >actual &&
315 test_cmp actual expected &&
316 cat <<EOT >expected &&
317 tg-push-remote
318 ----------
319 [remote "tg-push-remote"]
320 url = "remote2"
321 push = "refs/heads/other:refs/heads/other"
323 tgshim -c topgit.pushremote=remote2 push >actual &&
324 test_cmp actual expected &&
325 tgshim -c topgit.pushremote=remote2 -c topgit.remote=remote1 push >actual &&
326 test_cmp actual expected &&
327 tgshim -c topgit.pushremote=remote2 -c topgit.remote=remote1 -u push >actual &&
328 test_cmp actual expected &&
329 tgshim -c topgit.pushremote=remote2 -r remote1 push >actual &&
330 test_cmp actual expected &&
331 cat <<EOT >expected &&
332 tg-push-remote
333 ----------
334 [remote "tg-push-remote"]
335 url = "remote3"
336 push = "refs/heads/other:refs/heads/other"
338 tgshim -c topgit.pushremote=remote2 -c topgit.remote=remote1 push -r remote3 >actual &&
339 test_cmp actual expected &&
340 tgshim -c topgit.pushremote=remote2 -c topgit.remote=remote1 -u push -r remote3 >actual &&
341 test_cmp actual expected &&
342 tgshim -c topgit.remote=remote1 push -r remote3 >actual &&
343 test_cmp actual expected &&
344 tgshim -c topgit.remote=remote1 -u push -r remote3 >actual &&
345 test_cmp actual expected &&
346 tgshim -c topgit.pushremote=remote2 push -r remote3 >actual &&
347 test_cmp actual expected &&
348 tgshim -c topgit.pushremote=remote2 -u push -r remote3 >actual &&
349 test_cmp actual expected &&
350 tgshim push -r remote3 >actual &&
351 test_cmp actual expected &&
352 tgshim -r remote1 push -r remote3 >actual &&
353 test_cmp actual expected &&
354 tgshim -r remote1 -c topgit.remote=remote2 push -r remote3 >actual &&
355 test_cmp actual expected
358 test_expect_success SETUP 'pass options' '
359 cd nontg &&
360 cat <<EOT >exprmt &&
361 tg-push-remote
362 ----------
363 [remote "tg-push-remote"]
364 url = "origin"
365 push = "refs/heads/other:refs/heads/other"
367 for opt in "-4" "--ipv4" "--ipv6" "-6" "--dry-run" "--force" "--atomic" "--follow-tags" "--no-follow-tags" "--signed" "--signed=" "--signed=..."; do
368 printf "%s\n" "$opt" >expected &&
369 cat exprmt >>expected &&
370 tgshim push -r origin $opt >actual &&
371 test_cmp actual expected || return
372 done &&
373 printf "%s\n" "-4" "-6" "--dry-run" "--force" "--atomic" "--follow-tags" "--signed=yes" >expected &&
374 cat exprmt >>expected &&
375 tgshim push --force -r origin --ipv6 --atomic --follow-tags --signed -4 -6 --force --dry-run --signed=yes >actual &&
376 test_cmp actual expected &&
377 tgshim push --force -r origin --ipv6 --atomic --no-follow-tags --follow-tags --signed -4 -6 --force --dry-run --signed=yes >actual &&
378 test_cmp actual expected &&
379 printf "%s\n" "-4" "-6" "--dry-run" "--force" "--atomic" "--no-follow-tags" "--signed=yes" >expected &&
380 cat exprmt >>expected &&
381 tgshim push --force -r origin --ipv6 --atomic --no-follow-tags --signed -4 -6 --force --dry-run --signed=yes >actual &&
382 test_cmp actual expected &&
383 tgshim push --force -r origin --ipv6 --atomic --follow-tags --no-follow-tags --signed -4 -6 --force --dry-run --signed=yes >actual &&
384 test_cmp actual expected
387 test_expect_success SETUP 'nontg push' '
388 cd combined &&
389 for b in base1 base2 master2 master3 other2 tgbranch1 tgbranch2; do
390 cat <<EOT >expected &&
391 tg-push-remote
392 ----------
393 [remote "tg-push-remote"]
394 url = "origin"
395 push = "refs/heads/$b:refs/heads/$b"
397 tgshim push -r origin $b >actual &&
398 test_cmp actual expected || return
399 done
402 test_expect_success SETUP 'tg base up-to-date push' '
403 cd combined &&
404 for b in t/abranch1 t/branch1 t/branch2 t/branch3 t/branch4 t/fullann t/mt t/mtann; do
405 cat <<EOT >expected &&
406 tg-push-remote
407 ----------
408 [remote "tg-push-remote"]
409 url = "origin"
410 push = "refs/heads/$b:refs/heads/$b"
411 push = "refs/$topbases/$b:refs/$topbases/$b"
413 tgshim push -r origin $b >actual &&
414 test_cmp actual expected || return
415 done
418 test_expect_success SETUP 'tg --no-deps up-to-date push' '
419 cd combined &&
420 for b in \
421 t/abranch1 t/abranch2 t/both1 t/both2 t/branch1 t/branch2 t/branch3 t/branch4 \
422 t/fullann t/hold1 t/hold2 t/mt t/mtann
424 cat <<EOT >expected &&
425 tg-push-remote
426 ----------
427 [remote "tg-push-remote"]
428 url = "origin"
429 push = "refs/heads/$b:refs/heads/$b"
430 push = "refs/$topbases/$b:refs/$topbases/$b"
432 tgshim push -r origin --no-deps $b >actual &&
433 test_cmp actual expected || return
434 done
437 test_expect_success SETUP 'tg t/branch needs --allow-outdated' '
438 cd combined &&
439 test_must_fail tg push -r . t/branch &&
440 test_must_fail tg push -r . --tgish-only t/branch &&
441 test_must_fail tg push -r . --no-deps t/branch &&
442 test_must_fail tg push -r . --no-deps --tgish-only t/branch &&
443 cat <<EOT >expected &&
444 tg-push-remote
445 ----------
446 [remote "tg-push-remote"]
447 url = "origin"
448 push = "refs/heads/master3:refs/heads/master3"
449 push = "refs/heads/t/branch:refs/heads/t/branch"
450 push = "refs/$topbases/t/branch:refs/$topbases/t/branch"
452 tgshim push -r origin --allow-outdated t/branch >actual &&
453 test_cmp actual expected &&
454 cat <<EOT >expected &&
455 tg-push-remote
456 ----------
457 [remote "tg-push-remote"]
458 url = "origin"
459 push = "refs/heads/t/branch:refs/heads/t/branch"
460 push = "refs/$topbases/t/branch:refs/$topbases/t/branch"
462 tgshim push -r origin --allow-outdated --tgish-only t/branch >actual &&
463 test_cmp actual expected &&
464 tgshim push -r origin --allow-outdated --no-deps t/branch >actual &&
465 test_cmp actual expected &&
466 tgshim push -r origin --allow-outdated --no-deps --tgish-only t/branch >actual &&
467 test_cmp actual expected
470 test_expect_success SETUP 'tg t/holdboth needs --allow-outdated' '
471 cd combined &&
472 test_must_fail tg push -r . t/holdboth &&
473 test_must_fail tg push -r . --no-deps t/holdboth &&
474 test_must_fail tg push -r . --tgish-only t/holdboth &&
475 test_must_fail tg push -r . --no-deps --tgish-only t/holdboth &&
476 cat <<EOT >expected &&
477 tg-push-remote
478 ----------
479 [remote "tg-push-remote"]
480 url = "origin"
481 push = "refs/heads/base2:refs/heads/base2"
482 push = "refs/heads/master3:refs/heads/master3"
483 push = "refs/heads/t/abranch1:refs/heads/t/abranch1"
484 push = "refs/heads/t/abranch2:refs/heads/t/abranch2"
485 push = "refs/heads/t/branch:refs/heads/t/branch"
486 push = "refs/heads/t/holdboth:refs/heads/t/holdboth"
487 push = "refs/$topbases/t/abranch1:refs/$topbases/t/abranch1"
488 push = "refs/$topbases/t/abranch2:refs/$topbases/t/abranch2"
489 push = "refs/$topbases/t/branch:refs/$topbases/t/branch"
490 push = "refs/$topbases/t/holdboth:refs/$topbases/t/holdboth"
492 tgshim push -r origin --allow-outdated t/holdboth >actual &&
493 test_cmp actual expected &&
494 cat <<EOT >expected &&
495 tg-push-remote
496 ----------
497 [remote "tg-push-remote"]
498 url = "origin"
499 push = "refs/heads/t/abranch1:refs/heads/t/abranch1"
500 push = "refs/heads/t/abranch2:refs/heads/t/abranch2"
501 push = "refs/heads/t/branch:refs/heads/t/branch"
502 push = "refs/heads/t/holdboth:refs/heads/t/holdboth"
503 push = "refs/$topbases/t/abranch1:refs/$topbases/t/abranch1"
504 push = "refs/$topbases/t/abranch2:refs/$topbases/t/abranch2"
505 push = "refs/$topbases/t/branch:refs/$topbases/t/branch"
506 push = "refs/$topbases/t/holdboth:refs/$topbases/t/holdboth"
508 tgshim push -r origin --allow-outdated --tgish-only t/holdboth >actual &&
509 test_cmp actual expected &&
510 cat <<EOT >expected &&
511 tg-push-remote
512 ----------
513 [remote "tg-push-remote"]
514 url = "origin"
515 push = "refs/heads/t/holdboth:refs/heads/t/holdboth"
516 push = "refs/$topbases/t/holdboth:refs/$topbases/t/holdboth"
518 tgshim push -r origin --allow-outdated --no-deps t/holdboth >actual &&
519 test_cmp actual expected &&
520 tgshim push -r origin --allow-outdated --no-deps --tgish-only t/holdboth >actual &&
521 test_cmp actual expected
524 test_expect_success SETUP 'tg empty push' '
525 cd combined &&
526 cat <<EOT >expected &&
527 tg-push-remote
528 ----------
529 [remote "tg-push-remote"]
530 url = "origin"
531 push = "refs/heads/t/mt:refs/heads/t/mt"
532 push = "refs/$topbases/t/mt:refs/$topbases/t/mt"
534 tgshim push -r origin t/mt >actual &&
535 test_cmp actual expected
538 test_expect_success SETUP 'tg annihilated empty push' '
539 cd combined &&
540 cat <<EOT >expected &&
541 tg-push-remote
542 ----------
543 [remote "tg-push-remote"]
544 url = "origin"
545 push = "refs/heads/t/mtann:refs/heads/t/mtann"
546 push = "refs/$topbases/t/mtann:refs/$topbases/t/mtann"
548 tgshim push -r origin t/mtann >actual &&
549 test_cmp actual expected
552 test_expect_success SETUP 'tg annihilated full push' '
553 cd combined &&
554 cat <<EOT >expected &&
555 tg-push-remote
556 ----------
557 [remote "tg-push-remote"]
558 url = "origin"
559 push = "refs/heads/t/fullann:refs/heads/t/fullann"
560 push = "refs/$topbases/t/fullann:refs/$topbases/t/fullann"
562 tgshim push -r origin t/fullann >actual &&
563 test_cmp actual expected
566 test_expect_success SETUP 'outdated --all push fails' '
567 cd combined &&
568 test_must_fail tg push -r . --all &&
569 test_must_fail tg push -r . --no-deps --all &&
570 test_must_fail tg push -r . --tgish-only --all &&
571 test_must_fail tg push -r . --no-deps --tgish-only --all
574 test_expect_success SETUP '--allow-outdated --all --no-deps' '
575 cd combined &&
576 cat <<EOT >expected &&
577 tg-push-remote
578 ----------
579 [remote "tg-push-remote"]
580 url = "origin"
581 push = "refs/heads/t/abranch2:refs/heads/t/abranch2"
582 push = "refs/heads/t/both1:refs/heads/t/both1"
583 push = "refs/heads/t/both2:refs/heads/t/both2"
584 push = "refs/heads/t/branch:refs/heads/t/branch"
585 push = "refs/heads/t/branch1:refs/heads/t/branch1"
586 push = "refs/heads/t/branch2:refs/heads/t/branch2"
587 push = "refs/heads/t/branch3:refs/heads/t/branch3"
588 push = "refs/heads/t/branch4:refs/heads/t/branch4"
589 push = "refs/heads/t/hold1:refs/heads/t/hold1"
590 push = "refs/heads/t/hold2:refs/heads/t/hold2"
591 push = "refs/heads/t/holdboth:refs/heads/t/holdboth"
592 push = "refs/$topbases/t/abranch2:refs/$topbases/t/abranch2"
593 push = "refs/$topbases/t/both1:refs/$topbases/t/both1"
594 push = "refs/$topbases/t/both2:refs/$topbases/t/both2"
595 push = "refs/$topbases/t/branch:refs/$topbases/t/branch"
596 push = "refs/$topbases/t/branch1:refs/$topbases/t/branch1"
597 push = "refs/$topbases/t/branch2:refs/$topbases/t/branch2"
598 push = "refs/$topbases/t/branch3:refs/$topbases/t/branch3"
599 push = "refs/$topbases/t/branch4:refs/$topbases/t/branch4"
600 push = "refs/$topbases/t/hold1:refs/$topbases/t/hold1"
601 push = "refs/$topbases/t/hold2:refs/$topbases/t/hold2"
602 push = "refs/$topbases/t/holdboth:refs/$topbases/t/holdboth"
604 tgshim push -r origin --allow-outdated --all --no-deps >actual &&
605 test_cmp actual expected &&
606 tgshim push -r origin --tgish-only --allow-outdated --all --no-deps >actual &&
607 test_cmp actual expected
610 test_expect_success SETUP '--allow-outdated --all --tgish-only' '
611 cd combined &&
612 cat <<EOT >expected &&
613 tg-push-remote
614 ----------
615 [remote "tg-push-remote"]
616 url = "origin"
617 push = "refs/heads/t/abranch1:refs/heads/t/abranch1"
618 push = "refs/heads/t/abranch2:refs/heads/t/abranch2"
619 push = "refs/heads/t/both1:refs/heads/t/both1"
620 push = "refs/heads/t/both2:refs/heads/t/both2"
621 push = "refs/heads/t/branch:refs/heads/t/branch"
622 push = "refs/heads/t/branch1:refs/heads/t/branch1"
623 push = "refs/heads/t/branch2:refs/heads/t/branch2"
624 push = "refs/heads/t/branch3:refs/heads/t/branch3"
625 push = "refs/heads/t/branch4:refs/heads/t/branch4"
626 push = "refs/heads/t/hold1:refs/heads/t/hold1"
627 push = "refs/heads/t/hold2:refs/heads/t/hold2"
628 push = "refs/heads/t/holdboth:refs/heads/t/holdboth"
629 push = "refs/$topbases/t/abranch1:refs/$topbases/t/abranch1"
630 push = "refs/$topbases/t/abranch2:refs/$topbases/t/abranch2"
631 push = "refs/$topbases/t/both1:refs/$topbases/t/both1"
632 push = "refs/$topbases/t/both2:refs/$topbases/t/both2"
633 push = "refs/$topbases/t/branch:refs/$topbases/t/branch"
634 push = "refs/$topbases/t/branch1:refs/$topbases/t/branch1"
635 push = "refs/$topbases/t/branch2:refs/$topbases/t/branch2"
636 push = "refs/$topbases/t/branch3:refs/$topbases/t/branch3"
637 push = "refs/$topbases/t/branch4:refs/$topbases/t/branch4"
638 push = "refs/$topbases/t/hold1:refs/$topbases/t/hold1"
639 push = "refs/$topbases/t/hold2:refs/$topbases/t/hold2"
640 push = "refs/$topbases/t/holdboth:refs/$topbases/t/holdboth"
642 tgshim push -r origin --allow-outdated --all --tgish-only >actual &&
643 test_cmp actual expected
646 test_expect_success SETUP '--allow-outdated --all' '
647 cd combined &&
648 cat <<EOT >expected &&
649 tg-push-remote
650 ----------
651 [remote "tg-push-remote"]
652 url = "origin"
653 push = "refs/heads/base2:refs/heads/base2"
654 push = "refs/heads/master3:refs/heads/master3"
655 push = "refs/heads/t/abranch1:refs/heads/t/abranch1"
656 push = "refs/heads/t/abranch2:refs/heads/t/abranch2"
657 push = "refs/heads/t/both1:refs/heads/t/both1"
658 push = "refs/heads/t/both2:refs/heads/t/both2"
659 push = "refs/heads/t/branch:refs/heads/t/branch"
660 push = "refs/heads/t/branch1:refs/heads/t/branch1"
661 push = "refs/heads/t/branch2:refs/heads/t/branch2"
662 push = "refs/heads/t/branch3:refs/heads/t/branch3"
663 push = "refs/heads/t/branch4:refs/heads/t/branch4"
664 push = "refs/heads/t/hold1:refs/heads/t/hold1"
665 push = "refs/heads/t/hold2:refs/heads/t/hold2"
666 push = "refs/heads/t/holdboth:refs/heads/t/holdboth"
667 push = "refs/heads/tgbranch1:refs/heads/tgbranch1"
668 push = "refs/heads/tgbranch2:refs/heads/tgbranch2"
669 push = "refs/$topbases/t/abranch1:refs/$topbases/t/abranch1"
670 push = "refs/$topbases/t/abranch2:refs/$topbases/t/abranch2"
671 push = "refs/$topbases/t/both1:refs/$topbases/t/both1"
672 push = "refs/$topbases/t/both2:refs/$topbases/t/both2"
673 push = "refs/$topbases/t/branch:refs/$topbases/t/branch"
674 push = "refs/$topbases/t/branch1:refs/$topbases/t/branch1"
675 push = "refs/$topbases/t/branch2:refs/$topbases/t/branch2"
676 push = "refs/$topbases/t/branch3:refs/$topbases/t/branch3"
677 push = "refs/$topbases/t/branch4:refs/$topbases/t/branch4"
678 push = "refs/$topbases/t/hold1:refs/$topbases/t/hold1"
679 push = "refs/$topbases/t/hold2:refs/$topbases/t/hold2"
680 push = "refs/$topbases/t/holdboth:refs/$topbases/t/holdboth"
682 tgshim push -r origin --allow-outdated --all >actual &&
683 test_cmp actual expected
686 test_expect_success SETUP 't/branch1 with remote checks' '
687 cd combined &&
688 cat <<EOT >expected &&
689 tg-push-remote
690 ----------
691 [remote "tg-push-remote"]
692 url = "origin"
693 push = "refs/heads/t/branch1:refs/heads/t/branch1"
694 push = "refs/$topbases/t/branch1:refs/$topbases/t/branch1"
696 tgshim push -r origin t/branch1 >actual &&
697 test_cmp actual expected &&
698 tgshim -r remote1 push -r origin t/branch1 >actual &&
699 test_cmp actual expected &&
700 tgshim -c topgit.remote=remote2 push -r origin t/branch1 >actual &&
701 test_cmp actual expected &&
702 tgshim -c topgit.remote=remote3 push -r origin t/branch1 >actual &&
703 test_cmp actual expected &&
704 tgshim -r remote4 push -r origin t/branch1 >actual &&
705 test_cmp actual expected
708 test_expect_success SETUP 't/branch2 with remote checks' '
709 cd combined &&
710 cat <<EOT >expected &&
711 tg-push-remote
712 ----------
713 [remote "tg-push-remote"]
714 url = "origin"
715 push = "refs/heads/t/branch2:refs/heads/t/branch2"
716 push = "refs/$topbases/t/branch2:refs/$topbases/t/branch2"
718 tgshim push -r origin t/branch2 >actual &&
719 test_cmp actual expected &&
720 tgshim -r remote1 push -r origin t/branch2 >actual &&
721 test_cmp actual expected &&
722 test_must_fail tg -c topgit.remote=remote2 push -r origin t/branch2 &&
723 test_must_fail tg -r remote2 push -r origin t/branch2 &&
724 tgshim -c topgit.remote=remote2 push -r origin --allow-outdated t/branch2 >actual &&
725 test_cmp actual expected &&
726 tgshim -r remote2 push -r origin --allow-outdated t/branch2 >actual &&
727 test_cmp actual expected &&
728 tgshim -c topgit.remote=remote2 -u push -r origin t/branch2 >actual &&
729 test_cmp actual expected &&
730 tgshim -r remote2 -u push -r origin t/branch2 >actual &&
731 test_cmp actual expected &&
732 tgshim -c topgit.remote=remote3 push -r origin t/branch2 >actual &&
733 test_cmp actual expected &&
734 tgshim -r remote4 push -r origin t/branch2 >actual &&
735 test_cmp actual expected
738 test_expect_success SETUP 't/branch3 with remote checks' '
739 cd combined &&
740 cat <<EOT >expected &&
741 tg-push-remote
742 ----------
743 [remote "tg-push-remote"]
744 url = "origin"
745 push = "refs/heads/t/branch3:refs/heads/t/branch3"
746 push = "refs/$topbases/t/branch3:refs/$topbases/t/branch3"
748 tgshim push -r origin t/branch3 >actual &&
749 test_cmp actual expected &&
750 tgshim -r remote1 push -r origin t/branch3 >actual &&
751 test_cmp actual expected &&
752 tgshim -c topgit.remote=remote2 push -r origin t/branch3 >actual &&
753 test_cmp actual expected &&
754 test_must_fail tg -c topgit.remote=remote3 push -r origin t/branch3 &&
755 test_must_fail tg -r remote3 push -r origin t/branch3 &&
756 tgshim -c topgit.remote=remote3 push -r origin --allow-outdated t/branch3 >actual &&
757 test_cmp actual expected &&
758 tgshim -r remote3 push -r origin --allow-outdated t/branch3 >actual &&
759 test_cmp actual expected &&
760 tgshim -c topgit.remote=remote3 -u push -r origin t/branch3 >actual &&
761 test_cmp actual expected &&
762 tgshim -r remote3 -u push -r origin t/branch3 >actual &&
763 test_cmp actual expected &&
764 tgshim -r remote4 push -r origin t/branch3 >actual &&
765 test_cmp actual expected
768 test_expect_success SETUP 't/branch4 with remote checks' '
769 cd combined &&
770 cat <<EOT >expected &&
771 tg-push-remote
772 ----------
773 [remote "tg-push-remote"]
774 url = "origin"
775 push = "refs/heads/t/branch4:refs/heads/t/branch4"
776 push = "refs/$topbases/t/branch4:refs/$topbases/t/branch4"
778 tgshim push -r origin t/branch4 >actual &&
779 test_cmp actual expected &&
780 tgshim -r remote1 push -r origin t/branch4 >actual &&
781 test_cmp actual expected &&
782 tgshim -c topgit.remote=remote2 push -r origin t/branch4 >actual &&
783 test_cmp actual expected &&
784 tgshim -r remote3 -u push -r origin t/branch4 >actual &&
785 test_cmp actual expected &&
786 test_must_fail tg -c topgit.remote=remote4 push -r origin t/branch4 &&
787 test_must_fail tg -r remote4 push -r origin t/branch4 &&
788 tgshim -c topgit.remote=remote4 push -r origin --allow-outdated t/branch4 >actual &&
789 test_cmp actual expected &&
790 tgshim -r remote4 push -r origin --allow-outdated t/branch4 >actual &&
791 test_cmp actual expected &&
792 tgshim -c topgit.remote=remote4 -u push -r origin t/branch4 >actual &&
793 test_cmp actual expected &&
794 tgshim -r remote4 -u push -r origin t/branch4 >actual &&
795 test_cmp actual expected
798 test_expect_success SETUP 'configured remote no match no fetch spec' '
799 cd combined &&
800 for r in nofetch notes notesp; do
801 cat <<EOT >expected &&
802 tg-push-remote
803 ----------
804 [remote "tg-push-remote"]
805 url = "url:$r"
806 push = "refs/heads/t/branch1:refs/heads/t/branch1"
807 push = "refs/$topbases/t/branch1:refs/$topbases/t/branch1"
809 tgshim push -r "$r" t/branch1 >actual &&
810 test_cmp actual expected || return
811 done
814 test_expect_success SETUP 'configured remote match fetch specs' '
815 cd combined &&
816 for r in heads bases headsbases headsp basesp \
817 headspbasesp headspbases headsbasesp; do
818 cat <<EOT >expected &&
819 tg-push-remote
820 ----------
821 [remote "tg-push-remote"]
822 url = "url:$r"
823 fetch = "+refs/heads/*:refs/remotes/$r/*"
824 fetch = "+refs/$topbases/*:refs/remotes/$r/${topbases#heads/}/*"
825 push = "refs/heads/t/branch1:refs/heads/t/branch1"
826 push = "refs/$topbases/t/branch1:refs/$topbases/t/branch1"
828 tgshim push -r "$r" t/branch1 >actual &&
829 test_cmp actual expected || return
830 done
833 test_done