README_DOCS.rst: update tg prev and tg next usage summary
[topgit/pro.git] / t / t5060-update-continue.sh
blob1c0d4f0e360269d576038aea49cba405187186f3
1 #!/bin/sh
3 test_description='tg update --continue works after merge resolution'
5 TEST_NO_CREATE_REPO=1
7 . ./test-lib.sh
9 test_plan 5
11 sq="'"
13 test_expect_success 'setup' '
14 test_create_repo conflict &&
15 cd conflict &&
16 git checkout --orphan fractious &&
17 git read-tree --empty &&
18 git reset --hard &&
19 test_commit "fractious~1" &&
20 tg_test_create_branches <<-EOT &&
21 t/patch1a [PATCH] patch 1 a
22 fractious
24 t/patch1b [PATCH] patch 1 b
25 fractious
27 t/mergeab [STAGE] merge patch 1 a & 1 b
28 t/patch1a
29 t/patch1b
30 EOT
31 topbases="$(tg --top-bases)" &&
32 topbases="${topbases#refs/heads/}" &&
33 [ -n "$topbases" ] &&
34 test_when_finished topbases="$topbases" &&
35 mergeab_base="$(tg base t/mergeab)" &&
36 test_when_finished mergeab_base="$mergeab_base" &&
37 git checkout -f t/patch1a &&
38 test_commit "alpha" conflict &&
39 git checkout -f t/patch1b &&
40 test_commit "beta" conflict &&
41 cat <<EOT >expected &&
42 Topic Branch: t/mergeab (1/1 commit)
43 Subject: [STAGE] merge patch 1 a & 1 b
44 Dependents: [none]
45 Base: $mergeab_base
46 Depends: t/patch1a
47 t/patch1b
48 Needs update from:
49 t/patch1a (1/1 commit)
50 t/patch1b (2/2 commits)
51 EOT
52 tg info -v t/mergeab >actual &&
53 test_cmp actual expected &&
54 test_when_finished test_set_prereq SETUP
57 test_expect_success SETUP 'tg update creates conflict' '
58 cd conflict &&
59 test_must_fail tg update t/mergeab &&
60 mergeab_base="$(tg base t/mergeab)" &&
61 test_when_finished mergeab_base="$mergeab_base" &&
62 cat <<EOT >expected &&
63 HEAD -> $topbases/t/mergeab [$mergeab_base]
64 tg update in progress; currently updating branch ${sq}t/mergeab${sq}
65 You are currently updating as a result of:
66 tg update t/mergeab
67 (use "tg update --continue" to continue)
68 (use "tg update --skip" to skip this branch and continue)
69 (use "tg update --stop" to stop and retain changes so far)
70 (use "tg update --abort" to restore pre-update state)
71 git merge in progress
72 fix conflicts and then "git commit" the result
73 EOT
74 tg status >actual &&
75 test_cmp actual expected
78 test_expect_success SETUP,LASTOK 'tg status changes with no conflicts' -<<\EOS
79 cd conflict &&
80 echo alphabeta >conflict &&
81 git add conflict &&
82 cat <<EOT >expected &&
83 HEAD -> $topbases/t/mergeab [$mergeab_base]
84 tg update in progress; currently updating branch 't/mergeab'
85 You are currently updating as a result of:
86 tg update t/mergeab
87 (use "tg update --continue" to continue)
88 (use "tg update --skip" to skip this branch and continue)
89 (use "tg update --stop" to stop and retain changes so far)
90 (use "tg update --abort" to restore pre-update state)
91 git merge in progress
92 all conflicts fixed; run "git commit" to record result
93 EOT
94 tg status >actual &&
95 test_cmp actual expected
96 EOS
98 test_expect_success SETUP,LASTOK 'tg status changes with git merge done' -<<\EOS
99 cd conflict &&
100 git commit -m 'no conflict' &&
101 mergeab_base="$(tg base t/mergeab)" &&
102 test_when_finished mergeab_base="$mergeab_base" &&
103 cat <<EOT >expected &&
104 HEAD -> $topbases/t/mergeab [$mergeab_base]
105 tg update in progress; currently updating branch 't/mergeab'
106 You are currently updating as a result of:
107 tg update t/mergeab
108 (use "tg update --continue" to continue)
109 (use "tg update --skip" to skip this branch and continue)
110 (use "tg update --stop" to stop and retain changes so far)
111 (use "tg update --abort" to restore pre-update state)
112 working directory is clean; non-ignored, untracked files present
114 tg status >actual &&
115 test_cmp actual expected
118 test_expect_success SETUP,LASTOK 'tg update --continue succeeds' -<<\EOS
119 cd conflict &&
120 cat <<EOT >expected &&
121 tg: The base is up-to-date.
122 tg: Updating t/mergeab against new base...
123 Merge made by the 'trivial aggressive' strategy.
124 1 file changed, 1 insertion(+)
126 tg update --continue >actual &&
127 test_cmp actual expected &&
128 patch1b="$(git rev-parse --verify --short t/patch1b)" &&
129 final="$(git rev-parse --verify --short t/mergeab)" &&
130 cat <<EOT >expected &&
131 HEAD -> t/patch1b [$patch1b]
132 working directory is clean; non-ignored, untracked files present
134 tg status >actual &&
135 test_cmp actual expected &&
136 cat <<EOT >expected &&
137 HEAD -> t/mergeab [$final]
138 working directory is clean; non-ignored, untracked files present
140 git checkout -f t/mergeab &&
141 tg status >actual &&
142 test_cmp actual expected
145 test_done