chiark / gitweb /
test suite: --overwrite test: Be more tolerant of exact message
[dgit.git] / tests / tests / gdr-subcommands
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-dependencies GDR
6
7 t-setup-import gdr-convert-gbp
8
9 cd $p
10
11 t-dgit setup-mergechangelogs
12
13 mix-it () {
14         t-git-next-date
15
16         local m=$(git symbolic-ref HEAD)
17         t-some-changes "subcommands $m 1"
18
19         # we want patches mde by dgit, not gdr, for our test cases
20         t-dgit --git-debrebase=true -wgf quilt-fixup
21         t-git-next-date
22
23         t-some-changes "subcommands $m 2"
24         t-git-next-date
25 }
26
27 git checkout -b stitched-laundered master
28 mix-it
29 t-git-debrebase quick
30 t-gdr-good stitched HEAD
31
32 git checkout -b stitched-mixed master
33 mix-it
34
35 git checkout -b unstitched-laundered master
36 mix-it
37 t-git-debrebase
38 t-gdr-good laundered
39
40 git checkout -b unstitched-mixed master
41 t-git-debrebase
42 mix-it
43
44 t-git-next-date
45
46 git show-ref 
47
48 subcmd () {
49         local subcmd=$1
50         shift
51         for startbranch in {stitched,unstitched}-{laundered,mixed}; do
52                 work="work-$subcmd-$startbranch"
53
54                 : "---------- $subcmd $startbranch ----------"
55
56                 git for-each-ref "**/$startbranch"{,/**} \
57                         --format='create %(refname) %(objectname)' \
58                 | sed "s/$startbranch/$work/" \
59                 | git update-ref --stdin
60
61                 git checkout $work
62                 checkletters=$1; shift
63
64                 before=before-$work
65                 git branch $before
66
67                 local xopts=''
68
69                 case "$checkletters" in
70                 XX*)
71                         fail "$checkletters" # for debugging
72                         ;;
73                 esac
74
75                 case "$checkletters" in
76                 X*)
77                         t-expect-fail E:'snags: [0-9]* blockers' \
78                         t-git-debrebase $xopts $subcmd
79                         xopts+=' --force'
80                         next_checkletter
81                         ;;
82                 esac
83
84                 case "$checkletters" in
85                 N*)
86                         t-expect-fail E:. \
87                         t-git-debrebase $xopts $subcmd
88                         xopts+=' --noop-ok'
89                         next_checkletter
90                         ;;
91                 esac
92
93                 case "$checkletters" in
94                 [EF]:*)
95                         t-expect-fail "$checkletters" \
96                         t-git-debrebase $xopts $subcmd
97                         continue
98                         ;;
99                 *)
100                         t-git-debrebase $xopts $subcmd
101                         ;;
102                 esac
103
104                 peel=peel-$subcmd-$startbranch
105                 git checkout -b $peel
106                 t-clean-on-branch $peel
107
108                 : "---------- $subcmd $startbranch $checkletters ----------"
109
110                 while [ "x$checkletters" != x ]; do
111                         : "---- $subcmd $startbranch ...$checkletters ----"
112                         make_check "$checkletters"
113                         checkletters="${checkletters#?}"
114                 done
115         done
116
117 }
118
119 next_checkletter () {
120         checkletters="${checkletters#?}"
121 }
122
123 make_check () {
124         case "$1" in
125         [Nn]*)
126                 t-refs-same-start
127                 t-refs-same refs/heads/$before refs/heads/$work
128                 ;;
129         U*)
130                 t-refs-same-start
131                 t-refs-same refs/heads/$before refs/ffq-prev/heads/$work
132                 make_check u
133                 ;;
134         u*)
135                 t-git-get-ref refs/ffq-prev/heads/$work
136                 t-refs-notexist refs/debrebase-last/heads/$work
137                 ;;
138         V*)
139                 t-refs-same-start
140                 t-refs-same refs/ffq-prev/heads/$work \
141                         refs/ffq-prev/heads/$startbranch
142                 t-refs-notexist refs/debrebase-last/heads/$work
143                 ;;
144         s*)
145                 t-refs-notexist refs/ffq-prev/heads/$work
146                 t-refs-same-start
147                 t-refs-same refs/debrebase-last/heads/$work \
148                         refs/debrebase-last/heads/$startbranch
149                 t-has-ancestor HEAD refs/debrebase-last/heads/$work
150                 ;;
151         S*)
152                 t-refs-notexist refs/ffq-prev/heads/$work
153                 t-refs-same-start refs/debrebase-last/heads/$work
154                 t-ref-head
155                 git diff --quiet HEAD^1
156                 git diff HEAD^2 | grep $startbranch
157                 git reset --hard HEAD^1
158                 ;;
159         P*)
160                 t-dgit -wgf --quilt=nofix quilt-fixup
161                 git diff HEAD~ debian/patches | egrep .
162                 git diff --quiet HEAD~ -- ':.' ':!debian/patches'
163                 git reset --hard HEAD~
164                 ;;
165         l*)
166                 git diff --quiet HEAD refs/heads/$before -- ':.' ':!debian/patches'
167                 t-gdr-good laundered
168                 ;;
169         t*)
170                 git diff --quiet HEAD refs/heads/$before
171                 ;;
172         f*)
173                 t-has-ancestor HEAD refs/heads/$before
174                 ;;
175         *)
176                 fail "$1"
177                 ;;
178         esac
179 }
180
181 Ec="F:No ongoing git-debrebase session"
182 Ep="F:Patch export produced patch amendments"
183
184 # input state:
185 #  stitched?            st'd    st'd    unst'd  unst'd
186 #  laundered?           laund'd mixed   laund'd mixed
187 #
188 # "mixed" means an out of order branch
189 # containing mixed commits and patch additions,
190 # but which needs even more patches
191 #
192 subcmd  ''              Ult     Ull     Vlt     Vl
193 subcmd  stitch          Ns      Nu      Sltf    Stf
194 subcmd  prepush         Ns      Nu      Sltf    Stf
195 subcmd  quick           ns      Sl      Sltf    Sl
196 subcmd  conclude        "$Ec"   "$Ec"   Sltf    Sl
197 subcmd  make-patches    sPft    "$Ep"   uPft    "$Ep"
198 #subcmd dgit-upload-hook Psft   "$Ep"   SPft    "$Ep"
199 #
200 # result codes, each one is a check:
201 #   E:$pat      } this is an error (must come first)
202 #   F:$pat      } arg is passed to expect-fail
203 #
204 #   X           should fail due to snags, but succeed when forced
205 #   XX          crash out of script for manual debugging
206 #
207 #   N           this is a noop, error unless --noop-ok
208 #   n           this is a silent noop
209 # both of these imply tf; but, specify also one of   u s
210 #
211 # should normally specify one of these:
212 #   U           just unstiched: ffq-prev is exactly previous HEAD; implies u
213 #   u           result is unstitched
214 #   V           ffq-prev remains unchanged; implies also u
215 #   s           result is stitched, debrebase-last exists and is unchanged
216 #   S           result is stitch just made, remaining letters apply to result~
217 #
218 #   P           result is add-patches, remaining letters apply to result~
219 #
220 # should normally specify one or both of these:
221 #   l           result is laundered, tree is same as before minus d/patches
222 #   t           tree is exactly same as before
223 #
224 #   f           result is ff from previous HEAD
225
226 t-ok