tg.sh: handle help -h
[topgit/pro.git] / t / t5040-update-octopus.sh
blob7cbbfbc8e705452b478b86b3e15d5ee2cab611f8
1 #!/bin/sh
3 test_description='tg update can create an octopus merge'
5 TEST_NO_CREATE_REPO=1
7 . ./test-lib.sh
9 test_plan 4
11 uctmp="$(test_get_temp update-check)" || die
13 branch_is_up_to_date() {
14 needs_update_check "$@" >"$uctmp" &&
16 read -r uc_processed &&
17 read -r uc_behind &&
18 read -r uc_ahead &&
19 read -r uc_partial
20 } <"$uctmp" &&
21 test z"$uc_behind" = z":"
24 test_expect_success 'setup' '
25 test_create_repo pristine &&
26 cd pristine &&
27 git checkout --orphan release &&
28 git read-tree --empty &&
29 git reset --hard &&
30 test_commit "release~1" &&
31 tg_test_create_branches <<-EOT &&
32 t/patch1 [PATCH] alpha patch
33 release
35 t/patch2 [PATCH] beta patch
36 release
38 t/patch3 [PATCH] gamma patch
39 release
40 EOT
41 git checkout -f t/patch1 &&
42 test_commit "alpha~1" &&
43 git checkout -f t/patch2 &&
44 test_commit "beta~1" &&
45 git checkout -f t/patch3 &&
46 test_commit "gamma~1" &&
47 tg_test_create_branch t/int -m "[INTERMEDIATE] extra level" t/patch2 &&
48 tg_test_create_branch stage -m "[STAGE] staging branch" release t/patch1 t/int t/patch3 &&
49 test_must_fail branch_is_up_to_date stage &&
50 git gc --aggressive --prune=now &&
51 cd .. &&
52 cp -pR pristine octopus
55 cd octopus || die
57 test_expect_success 'tg update to make octopus' '
58 tg update stage
61 test_expect_success 'verify 4-way octopus created' '
62 tmp1="$(test_get_temp cmt)" &&
63 tmp2="$(test_get_temp hdr)" &&
64 tmp3="$(test_get_temp pnt)" &&
65 git cat-file commit "$(tg --top-bases)/stage" >"$tmp1" &&
66 sed -n "1,/^\$/p" <"$tmp1" >"$tmp2" &&
67 sed -n "/^parent /p" <"$tmp2" >"$tmp3" &&
68 lines="$(wc -l <"$tmp3")" &&
69 test "$lines" -eq 4
72 test_expect_success 'verify all files present' '
73 git diff --exit-code release:release~1.t stage:release~1.t &&
74 git diff --exit-code t/patch1:alpha~1.t stage:alpha~1.t &&
75 git diff --exit-code t/patch2:beta~1.t stage:beta~1.t &&
76 git diff --exit-code t/patch3:gamma~1.t stage:gamma~1.t
79 test_done