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