tg.sh: handle help -h
[topgit/pro.git] / t / t5021-update-issue-8.sh
blob6cc1ab946158eb64f87b7ecd73ccf0b0b31dc166
1 #!/bin/sh
3 test_description="test update with fast-forwarding base
5 While technically the situation could arise when dealing
6 strictly with local branches, it's much, much, much more
7 likely to arise when dealing with remote bases.
9 When updating the local base and the remote branch's base
10 is merged in as the first dependency and that results in
11 a fast forward, and there's still at least one other
12 update to merge in that cannot fast forward; when creating
13 the merge commit, the first parent must not be the original
14 commit, it must be the commit that was fast-forwarded to.
16 Failure to do this correctly results in the remote base
17 not being contained by the local base although things seem
18 to work (more or less) because the remote branch contains its
19 remote base and when that remote branch gets merged into the
20 local branch that ends up pulling in the remote base changes
21 into the local branch, but not in proper order.
24 TEST_NO_CREATE_REPO=1
26 . ./test-lib.sh
28 test_plan 9
30 # true if $1 is contained by (or the same as) $2
31 # this is never slower than merge-base --is-ancestor and is often slightly faster
32 contained_by() {
33 [ "$(git rev-list --count --max-count=1 "$1" --not "$2" --)" = "0" ]
36 test_expect_success 'setup upstream' '
37 test_create_repo upstream &&
38 cd upstream &&
39 git checkout --orphan master &&
40 test_commit "master upstream" master.txt &&
41 test_when_finished test_tick=$test_tick
44 test_expect_success LASTOK 'setup collab1' '
45 test_create_repo collab1 &&
46 cd collab1 &&
47 git checkout --orphan orphan &&
48 git remote add origin ../upstream &&
49 git fetch &&
50 git update-ref refs/heads/master refs/remotes/origin/master &&
51 git rev-parse --verify --quiet refs/heads/master -- >/dev/null &&
52 tg_test_create_branch t/feature1 master &&
53 git checkout -f t/feature1 &&
54 test_commit "feature one" feature1.txt &&
55 tg_test_create_branch t/feature2 master &&
56 git checkout -f t/feature2 &&
57 test_commit "feature two" feature2.txt &&
58 tg_test_create_branch stage -m "[STAGE] staging" t/feature1 t/feature2 &&
59 git checkout -f stage &&
60 test_tick &&
61 tg update --no-stash &&
62 test_tick &&
63 git commit --amend --reset-author --no-edit &&
64 test_when_finished test_tick=$test_tick
67 test_expect_success LASTOK 'setup collab2' '
68 test_create_repo collab2 &&
69 cd collab2 &&
70 git checkout --orphan orphan &&
71 git remote add origin ../upstream &&
72 git remote add collab1 ../collab1 &&
73 git remote update &&
74 git update-ref refs/heads/master refs/remotes/origin/master &&
75 git rev-parse --verify --quiet refs/heads/master -- >/dev/null &&
76 tg remote --populate collab1 &&
77 git checkout -f stage &&
78 test_when_finished test_set_prereq SETUP
81 test_expect_success SETUP 'upstream add change' '
82 cd upstream &&
83 echo "master upstream with update" >master.txt &&
84 test_tick &&
85 git commit -am "update master" &&
86 test_when_finished test_tick=$test_tick
89 test_expect_success SETUP 'collab1 fetch updates' '
90 cd collab1 &&
91 git remote update &&
92 git update-ref refs/heads/master refs/remotes/origin/master &&
93 git rev-parse --verify --quiet refs/heads/master -- >/dev/null &&
94 git checkout -f t/feature1 &&
95 test_tick &&
96 tg update --no-stash &&
97 git checkout -f stage &&
98 test_tick &&
99 tg update --no-stash &&
100 test_tick &&
101 git commit --amend --reset-author --no-edit &&
102 test_when_finished test_tick=$test_tick
105 test_expect_success SETUP 'collab2 add to feature1' '
106 cd collab2 &&
107 git checkout -f t/feature1 &&
108 echo "more feature1" >> feature1.txt &&
109 test_tick &&
110 git commit -am "update feature1" &&
111 test_when_finished test_tick=$test_tick
114 test_expect_success SETUP 'collab2 fetch updates' '
115 cd collab2 &&
116 git remote update &&
117 git update-ref refs/heads/master refs/remotes/origin/master &&
118 git rev-parse --verify --quiet refs/heads/master -- >/dev/null
121 test_expect_success LASTOK 'collab2 update stage' '
122 cd collab2 &&
123 git checkout -f t/feature1 &&
124 test_tick &&
125 tg update --no-stash &&
126 git checkout -f stage &&
127 test_tick &&
128 tg update --no-stash &&
129 test_tick &&
130 git commit --amend --reset-author --no-edit &&
131 test_when_finished test_tick=$test_tick
134 test_expect_success LASTOK 'collab2 stage base contains remote stage base and deps' '
135 cd collab2 &&
136 topbases="$(tg --top-bases)" &&
137 test -n "$topbases" &&
138 rtopbases="$(tg --top-bases -r)" &&
139 test -n "$rtopbases" &&
140 contained_by refs/heads/t/feature1 "$topbases/stage" &&
141 contained_by refs/heads/t/feature2 "$topbases/stage" &&
142 contained_by "$rtopbases/stage" "$topbases/stage"
145 test_done