3 test_description
='tg update non-remote branches'
11 uctmp
="$(test_get_temp update-check)" || die
13 branch_is_up_to_date
() {
14 needs_update_check
"$@" >"$uctmp" &&
16 read -r uc_processed
&&
21 test z
"$uc_behind" = z
":"
24 test_expect_success
'setup' '
25 test_create_repo pristine &&
27 git checkout --orphan release &&
28 git read-tree --empty &&
30 test_commit "release~1" &&
31 tg_test_create_branches <<-EOT &&
32 t/patch1 [PATCH] alpha patch
35 t/patch2 [PATCH] beta patch
38 git checkout -f t/patch1 &&
39 test_commit "alpha~1" &&
40 git checkout -f t/patch2 &&
41 test_commit "beta~1" &&
42 tg_test_create_branch t/int -m "[INTERMEDIATE] extra level" t/patch2 &&
43 tg_test_create_branch stage -m "[STAGE] staging branch" release t/patch1 t/int &&
44 test_must_fail branch_is_up_to_date stage &&
45 git symbolic-ref HEAD "$(tg --top-bases)/stage" &&
47 git rm --force --ignore-unmatch -- .topmsg .topdeps &&
48 git read-tree -m release t/patch1 t/int &&
49 git rm --force --ignore-unmatch -- .topmsg .topdeps &&
50 newtree="$(git write-tree)" && test -n "$newtree" &&
52 newcommit="$(git commit-tree -p HEAD -p t/patch1 -p t/int -m "mighty octopus" "$newtree")" &&
53 test -n "$newcommit" && git update-ref HEAD "$newcommit" HEAD &&
54 git checkout -f stage &&
56 git merge -m "bases up" "$(tg --top-bases)/stage" &&
57 branch_is_up_to_date stage &&
58 git gc --aggressive --prune=now
61 test_expect_success
'non-tgish dep' '
62 cp -pR pristine nontgish &&
64 git checkout -f release &&
65 echo "amend" >> "release~1.t" &&
68 git commit -m "amend file" &&
69 test_must_fail branch_is_up_to_date stage &&
71 branch_is_up_to_date stage &&
72 git diff --exit-code release:release~1.t stage:release~1.t
75 test_expect_success
'level 1 dep' '
76 cp -pR pristine level1 &&
78 git checkout -f t/patch1 &&
79 echo "amend alpha" >> "alpha~1.t" &&
82 git commit -m "amend alpha" &&
83 test_must_fail branch_is_up_to_date stage &&
85 branch_is_up_to_date stage &&
86 git diff --exit-code t/patch1:alpha~1.t stage:alpha~1.t
89 test_expect_success
'level 2 dep' '
90 cp -pR pristine level2 &&
92 git checkout -f t/patch2 &&
93 echo "amend beta" >> "beta~1.t" &&
96 git commit -m "amend beta" &&
97 test_must_fail branch_is_up_to_date stage &&
99 branch_is_up_to_date stage &&
100 git diff --exit-code t/patch2:beta~1.t stage:beta~1.t
103 test_expect_success
'level 1 base' '
104 cp -pR pristine level1base &&
106 git symbolic-ref HEAD "$(tg --top-bases)/t/patch1" &&
108 echo "amend release" >> "release~1.t" &&
111 git commit -m "amend release on t/patch1 base" &&
112 git tag newrelease &&
113 test_must_fail branch_is_up_to_date stage &&
115 branch_is_up_to_date stage &&
116 test_must_fail git diff --exit-code release:release~1.t stage:release~1.t &&
117 git diff --exit-code newrelease:release~1.t stage:release~1.t
120 test_expect_success
'level 2 base' '
121 cp -pR pristine level2base &&
123 git symbolic-ref HEAD "$(tg --top-bases)/t/patch2" &&
125 echo "amend release" >> "release~1.t" &&
128 git commit -m "amend release on t/patch2 base" &&
129 git tag newrelease &&
130 test_must_fail branch_is_up_to_date stage &&
132 branch_is_up_to_date stage &&
133 test_must_fail git diff --exit-code release:release~1.t stage:release~1.t &&
134 git diff --exit-code newrelease:release~1.t stage:release~1.t
137 test_expect_success
'intermediate base' '
138 cp -pR pristine intbase &&
140 git symbolic-ref HEAD "$(tg --top-bases)/t/int" &&
142 echo "amend beta" >> "beta~1.t" &&
145 git commit -m "amend beta on t/int base" &&
147 test_must_fail branch_is_up_to_date stage &&
149 branch_is_up_to_date stage &&
150 test_must_fail git diff --exit-code t/patch2:beta~1.t stage:beta~1.t &&
151 git diff --exit-code newbeta:beta~1.t stage:beta~1.t
154 test_expect_success
'stage base' '
155 cp -pR pristine stagebase &&
157 git symbolic-ref HEAD "$(tg --top-bases)/stage" &&
159 echo "amend alpha" >> "alpha~1.t" &&
162 git commit -m "amend alpha on stage base" &&
164 test_must_fail branch_is_up_to_date stage &&
166 branch_is_up_to_date stage &&
167 test_must_fail git diff --exit-code t/patch1:alpha~1.t stage:alpha~1.t &&
168 git diff --exit-code newalpha:alpha~1.t stage:alpha~1.t