3 test_description
='tg update remote branches'
13 uctmp
="$(test_get_temp update-check)" || die
15 branch_is_up_to_date
() {
16 needs_update_check
"$@" >"$uctmp" &&
18 read -r uc_processed
&&
23 test z
"$uc_behind" = z
":"
26 test_expect_success
'setup' '
27 test_create_repo pristine &&
29 git checkout --orphan release &&
30 git read-tree --empty &&
32 test_commit "release~1" &&
33 tg_test_create_branches <<-EOT &&
34 t/patch1 [PATCH] alpha patch
37 t/patch2 [PATCH] beta patch
40 git checkout -f t/patch1 &&
41 test_commit "alpha~1" &&
42 git checkout -f t/patch2 &&
43 test_commit "beta~1" &&
44 tg_test_create_branch t/int -m "[INTERMEDIATE] extra level" t/patch2 &&
45 tg_test_create_branch stage -m "[STAGE] staging branch" release t/patch1 t/int &&
46 test_must_fail branch_is_up_to_date stage &&
47 git symbolic-ref HEAD "$(tg --top-bases)/stage" &&
49 git rm --force --ignore-unmatch -- .topmsg .topdeps &&
50 git read-tree -m release t/patch1 t/int &&
51 git rm --force --ignore-unmatch -- .topmsg .topdeps &&
52 newtree="$(git write-tree)" && test -n "$newtree" &&
54 newcommit="$(git commit-tree -p HEAD -p t/patch1 -p t/int -m "mighty octopus" "$newtree")" &&
55 test -n "$newcommit" && git update-ref HEAD "$newcommit" HEAD &&
56 git checkout -f stage &&
58 git merge -m "bases up" "$(tg --top-bases)/stage" &&
59 git config remote.uranus.url "." &&
60 git config topgit.remote uranus &&
61 git for-each-ref --format="%(refname)" >refs &&
65 sub(/\/heads\//, \"/remotes/uranus/\")
69 \$0 ~ /\/top-bases\// {
70 sub(/\/top-bases\//, \"/remotes/uranus/top-bases/\")
74 \$0 ~ /\/heads\/\{top-bases\}\// {
75 sub(/\/heads\/\{top-bases\}\//, \"/remotes/uranus/{top-bases}/\")
80 while read -r newref oldref; do
81 echo "oldref = $oldref" &&
82 echo "newref = $newref" &&
83 git update-ref "$newref" "$oldref" ""
86 branch_is_up_to_date stage &&
87 git gc --aggressive --prune=now
90 test_expect_success
'remote level 1 dep' '
91 cp -pR pristine level1 &&
93 git symbolic-ref HEAD refs/remotes/uranus/t/patch1 &&
96 echo "amend alpha" >> "alpha~1.t" &&
99 git commit -m "amend alpha" &&
101 test_must_fail git diff --exit-code oldalpha:alpha~1.t newalpha:alpha~1.t &&
102 test_must_fail branch_is_up_to_date stage &&
104 branch_is_up_to_date stage &&
105 test_must_fail git diff --exit-code oldalpha:alpha~1.t stage:alpha~1.t &&
106 git diff --exit-code newalpha:alpha~1.t stage:alpha~1.t
109 test_expect_success
'remote level 2 dep' '
110 cp -pR pristine level2 &&
112 git symbolic-ref HEAD refs/remotes/uranus/t/patch2 &&
115 echo "amend beta" >> "beta~1.t" &&
118 git commit -m "amend beta" &&
120 test_must_fail git diff --exit-code oldbeta:beta~1.t newbeta:beta~1.t &&
121 test_must_fail branch_is_up_to_date stage &&
123 branch_is_up_to_date stage &&
124 test_must_fail git diff --exit-code oldbeta:beta~1.t stage:beta~1.t &&
125 git diff --exit-code newbeta:beta~1.t stage:beta~1.t
128 test_expect_success
'remote level 1 base' '
129 cp -pR pristine level1base &&
131 git symbolic-ref HEAD "$(tg --top-bases -r)/t/patch1" &&
133 git tag oldrelease &&
134 echo "amend release" >> "release~1.t" &&
137 git commit -m "amend release on t/patch1 base" &&
138 git tag newrelease &&
139 test_must_fail git diff --exit-code oldrelease:release~1.t newrelease:release~1.t &&
140 test_must_fail branch_is_up_to_date stage &&
142 branch_is_up_to_date stage &&
143 test_must_fail git diff --exit-code oldrelease:release~1.t stage:release~1.t &&
144 git diff --exit-code newrelease:release~1.t stage:release~1.t
147 test_expect_success
'remote level 2 base' '
148 cp -pR pristine level2base &&
150 git symbolic-ref HEAD "$(tg --top-bases -r)/t/patch2" &&
152 git tag oldrelease &&
153 echo "amend release" >> "release~1.t" &&
156 git commit -m "amend release on t/patch2 base" &&
157 git tag newrelease &&
158 test_must_fail git diff --exit-code oldrelease:release~1.t newrelease:release~1.t &&
159 test_must_fail branch_is_up_to_date stage &&
161 branch_is_up_to_date stage &&
162 test_must_fail git diff --exit-code oldrelease:release~1.t stage:release~1.t &&
163 git diff --exit-code newrelease:release~1.t stage:release~1.t
166 test_expect_success
'remote intermediate base' '
167 cp -pR pristine intbase &&
169 git symbolic-ref HEAD "$(tg --top-bases -r)/t/int" &&
172 echo "amend beta" >> "beta~1.t" &&
175 git commit -m "amend beta on t/int base" &&
177 test_must_fail git diff --exit-code oldbeta:beta~1.t newbeta:beta~1.t &&
178 test_must_fail branch_is_up_to_date stage &&
180 branch_is_up_to_date stage &&
181 test_must_fail git diff --exit-code oldbeta:beta~1.t stage:beta~1.t &&
182 git diff --exit-code newbeta:beta~1.t stage:beta~1.t
185 test_expect_success
'remote stage base' '
186 cp -pR pristine stagebase &&
188 git symbolic-ref HEAD "$(tg --top-bases -r)/stage" &&
191 echo "amend alpha" >> "alpha~1.t" &&
194 git commit -m "amend alpha on stage base" &&
196 test_must_fail git diff --exit-code oldalpha:alpha~1.t newalpha:alpha~1.t &&
197 test_must_fail branch_is_up_to_date stage &&
199 branch_is_up_to_date stage &&
200 test_must_fail git diff --exit-code oldalpha:alpha~1.t stage:alpha~1.t &&
201 git diff --exit-code newalpha:alpha~1.t stage:alpha~1.t