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