chiark / gitweb /
wip
[talk-2018-dc18-gdr.git] / talk.txt
1 ===== title slide
2
3 Hi.
4
5 ===== context slide
6
7 Sean Whitton and I are here to present a new git workflow tool for
8 Debian packaging.
9
10 Before I tell you all about it I need to show where it fits into
11 the ecosystem of Debian package management software.  On this slide we
12 have you, the maintainer, on the left.  On the right we have the
13 Debian repositories.
14
15 You may have heard me plugging dgit once or twice.  You should all use
16 dgit!  dgit push publishes your git history so Debian's users can use
17 it!  But, that's not actually what I am here to talk about today.
18 git-debrebase does not need dgit, and dgit does not need
19 git-debrebase.
20
21 git-debrebase is an alternative to gbp pq and to git-dpm, and to
22 other tools in the same kind of area like gitkpkg.  And, of course,
23 it's an alternative to using raw quilt.
24
25 git-debrebase is a tool to help manage your git branch containing the
26 Debian version of a package you maintain.  git-debrebase helps you
27 maintain a useful git branch with the contents you need (for building
28 and uploading).
29
30 It maintains your Debian delta queue - that is, that is, the changes
31 you make, for Debian, to the upstream parts of the package - as a
32 series of commits.  It's primarily intended for Debian package
33 maintainers, although you could use it outside of or alongside Debian.
34
35 git-debrebase does not deal with building at all.  You use whatever
36 your existing build tools are.
37
38 Nor does git-debrebase deal with source packages or orig tarballs.  It
39 does not do uploads.  Of course when you actually upload to Debian you
40 need to produce a source package; usually, this would be done
41 automatically for you by dgit push-source.
42
43 Of course you can share your git branch on a service like salsa,
44 without building or uploading.
45
46 ===== usp slide 1
47
48 git-debrebase offers a standard git-rebase workflow, where you edit
49 the whole package all together.  The experience is very like using
50 plain git-rebase to edit a topic branch.  Delta queue editing can be
51 done at any time, interleaved with packaging work.
52
53 As far as I know there are no other tools that offer these features.
54 Both gbp pq and git-dpm require you to switch to a separate view in
55 order to edit the delta queue.  Some tools have specific functions for
56 cherry-pick, but with none of them you can just use plain git cherry
57 pick or git-am onto your usual branch.  With git-debrebase, you can
58 just edit the code and commit it, with git, in the completely usual
59 way.
60
61 Specifically, at any point, you may make commits to upstream files,
62 and commits to packaging, in any order.  So you can just
63 git-cherry-pick from upstream.  You can make fixup commits, and use
64 the git-rebase autosquash syntax to have them automatically folded in
65 by the next rebase.  If you wish, you may make "mixed" commits
66 containing both changes to upstream files and changes to packaging
67 files.
68
69 Of course you can always directly edit the source if you use a plain
70 git merge workflow and non-quilt source package - for example, as
71 described in the dgit-maint-merge tutorial manpage.  But of course
72 that does not maintain the Debian delta as a broken-down series.
73 Supporting you maintaining such a delta queue is what git-rebase is
74 for.
75
76 Also, unlike git-dpm and some other tools, git-debrebase has no
77 in-tree metadata, so it can't get out of date or be desynchronised,
78 or need any manual changing or fixup.
79
80 ===== usp slide 2
81
82 As I said, unlike with gbp pq and git-dpm, there is no need to ever
83 switch branches.  git-debrebase only uses one branch to handle all for
84 your Debian work.
85
86 Of course usually you will have an upstream remote tracking branch as
87 well.  And if you are working in multiple Debian releases, backports
88 for example, you will have branches for those.  But it's only one
89 branch for each line of Debian development, and no temporary branches
90 or alternative views.
91
92 With git-debrebase, yowr working tree is always immediately buildable
93 with dpkg-buildpackage (or whatever other build tool you prefer).  And
94 it is never made dirty by git-debrebase or any of the other tooling:
95 Because your working tree always has the delta queue applied, it is
96 never dirtied by patch application.  Because there is no metadata, you
97 can never get a metadata conflict.
98
99 Because git-debrebase treats the quilt patches in debian/patches/ as
100 an output, and handles them entirely automatically, your tree is never
101 dirtied by the generation of patches.  And you never need to read any
102 diffs of diffs.
103
104
105 ===== usp slide 3
106
107 And, the final part of my plug:
108
109 With git-debrebase, git-blame, and git-log on a file, work entirely
110 properly.  For example, if you do git-log on a file from upstream
111 which was changed in the Debian delta queue, git-log will show the
112 Debian delta queue commits, preceded by the upstream history.
113
114 If you run git-blame you will see a correct indication of which
115 upstream and/or delta queue commits introduced each line.  Or, for a
116 file in the debian directory, you will see a correct reporting of
117 which commits in the package's packaging history introduced each line.
118
119 With git-debrebase, you never need to use the quilt program.  You can
120 mostly ignore the 3.0 quilt source format.  Unfortunately it is not
121 possible to paper over the cracks completely: you will still get
122 trouble if you make changes in git which 3.0 quilt cannot represent.
123
124 On the other hand, when you use git-debrebase with 3.0 quilt, the
125 generated 3.0 quilt source package is perfect pretty, with your delta
126 queue commits converted nicely into pathes - just as other people
127 consuming .dscs have come to expect.
128
129 And finally: of course, git-debrebase is compatible with dgit.  You do
130 not need to pass any quilt mode option to dgit.  And, you always can
131 upload right away.  All necessary bureaucracy is done automatically by
132 dgit push-source.
133
134 OK, that concludes the marketing spiel.  Now we're going to have a
135 quick demo.  Sean ?
136
137 ===== demo
138
139 ===== data model slide up to "2" [1]
140
141 Now you've seen it in action, I'm going to quickly run through the
142 data model and history structure.
143
144 There are some important detail I'm going to be glossing over, so if
145 you actually want to know what's really going on, please read the
146 reference documentation in the section 5 manpage, where everything is
147 fully and formally defined.
148
149 So.  This slide shows a likely situation, which you might find in the
150 middle of an editing session.
151
152 The horizontal part near the bottom is called the Breakwater.  This
153 branch contains unpatched upstream source code, plus the Debian
154 packaging in the debian directory.  It does not contain /any/
155 representation of the delta queue.  So it contains neither any
156 of your Debian changes to upstream files, nor any debian/patches.
157
158 In the example, commits A and B are packaging work.
159
160 The Debian delta queue sits on top of that.  In this example there are
161 two Debian delta queue commits, 1 and 2.  These are commits touching
162 upstream files.  In the diagram your current HEAD (ie, your local
163 master branch) is at 2.  So your tree contains the patched source code
164 plus the packaging: ie, it is your actual, patched, source package.
165
166 You could build it with dpkg-buildpackage -uc -b, to produce binaries
167 for testing.  You can git grep for things and be told where they are -
168 even if they are in the upstream source but in your delta queue.  You
169 can git log -G for things, and be told where they came from and shown
170 the relevant commit (whether that's upstream, or one of yours).
171
172 OK then, suppose you make a change like the one Sean made in the demo:
173
174 ===== data model slide up to "D3" [2]
175
176 I'm calling this C3.  The reason for this name will be clear in a
177 moment.
178
179 Sean's commit edited an upstream file and also debian/changelog.  So
180 if you do that, your tree is, of course, still fine: you can build and
181 test it right away.
182
183 But suppose you want to tidy things up, and, in particular, that you
184 wanted the new upstream change to actually come before 2.  Maybe it
185 just makes more sense there, or maybe you are going to change patch 3
186 to make use of it.
187
188 ===== data model slide with git-debrebase -i overlay
189
190 So, you run git-debrebase -i.  The usual git-rebase todo list comes
191 up, and you will see in it what looks like commit C3, and reorder
192 that.  Assuming there are no conflicts, the result looks like this:
193
194 ===== data model slide up to "2'" [3]
195
196 You can see that C3 has been split into two commits: C', which
197 contains the changelog change, and 3' which contains the upstream
198 change.  The upstream change is now in the delta queue in the proper
199 place.
200
201 C', the packaging part of your new commit, has been pushed down to the
202 bottom of the stack and become part of the breakwater.
203
204 This is the general scheme of things: we have a fast-forwarding
205 breakwater containing packaging and unchanged upstream files.  It
206 doesn't have a ref to itself; instead, it is contained within your
207 master branch.  Each time you git-debrebase, the rebase starts on the
208 breakwater.
209
210 What about a new upstream version ?
211
212 ===== data model slide up to "2''" [4]
213
214 To rebase onto a new upstream version, you run git-debrebase
215 new-upstream.  git-debrebase expects the upstream code in the form of
216 a git commit, of course.  (Actually, by default, it hopes to find a
217 tag named after the new upstream version number, but you can tell it
218 explicitly if that's not right.)
219
220 git-debrebase arranges to include the new upstream source into the
221 breakwater, and then rebases your delta queue series onto that.
222
223 There are new commits on the breakwater: firstly, a special
224 merge. which folds the new upstream source code, unchanged, into your
225 breakwater branch.  This is called an anchor merge.  The most recent
226 anchor merge is the backstop for rebase processing by git-debrebase.
227
228 The second commit is simply adding a new changelog entry for you.
229
230 Having provided the new base for your delta queue, it then uses
231 git-rebase --onto to rebase the delta queue commits.  If you didn't
232 ask for an interactive rebase, and there are no merge conflicts,
233 that's it as far as the code in git is concerned.
234
235 Of course if you are going to upload to the Debian archive you'll also
236 have to make an orig tarball of the new upstream.  There are tools
237 like git-deborig to help with that.
238
239 ===== data model slide up to PM [5]
240
241 So, indeed, let's consider an upload to Debian.  (And let's imagine
242 you made or obtained a suitable orig tarball.)
243
244 There's a certain amount of bureaucracy to be done.  In the usual case
245 of an upload with dgit, this is all done for you automatically, so you
246 don't really need to worry about it.
247
248 But it's useful to understand what's going on, so I'm going to explain
249 it.
250
251 Firstly, you're going to publish your history, so your history has to
252 be made fast forward from the previous version of the package.  To
253 achieve this, git-debrebase will make a pseudomerge.
254
255 ===== data model zoom in on pseudomerge
256
257 A pseudomerge is a merge commit which takes its contents from only one
258 of its parents.  You would make one by hand with git-merge -s ours,
259 if you wanted to make your HEAD fast forward, and know that all the
260 wanted changes from the other branch are included.
261
262 git-debrebase records the previous branch state, so that it can make
263 the right pseudomerge.  Your new branch is derived from the previous
264 one, so it is right to declare that it is fast forward, too.
265
266 The branch with the pseudomerge is suitable for pushing to any git
267 server.  It's what you would push to salsa, say.
268
269 ===== data model zoom in on pseudomerge and add patches 4b
270
271 Secondly, when you upload a 3.0 quilt package, the contents of
272 debian/patches need to be right.  Again, that is taken care of
273 automatically: a commit is made adding a patch representation of the
274 delta queue to debian/patches.
275
276 You can safely ignore these autogenerated commits
277
278 ===== data model slide up to PM [5] AGAIN
279
280 And indeed, they will be stripped out:
281
282 Next time you stark work, using git-debrebase, both the pseudomerge
283 and the patch addition will be stripped, so that you once again have a
284 nice delta queue to edit.
285
286 That'll put you back in a situation like I introduced at the start.
287
288 ===== data model slide up to PM [5]
289
290 After uploading you'll want to push your branch to salsa, if you have
291 a team repository there.  That makes sure all the views of your
292 package are up to date, so that other members of your team won't
293 accidentally base their work on an old version.
294
295 You can just push a git-debrebase branch which has had the pseudomerge
296 made, called a `stitched' branch, with git push.  It's a normal fast
297 forwarding git branch.
298
299 If you want to push without uploading that's fine too: git-debrebase
300 stitch will just make the pseudomerge for you, giving you a
301 fast-forwarding branch suitable for pushing to salsa or whereever.
302
303 There is one caveat I should mention: right now, if two git-debrebase
304 branches diverge, it is not trivial to merge them again.  If
305 git-debrebase encounters a normal `git merge' it will stop and fail.
306 Sorting this out is not a trivial problem.  gbp pq sometimes handles
307 this kind of situation by expecting you to merge the actual patches:
308 ie, you can end up resolving merge conflicts in diffs.  The other
309 tools can handle this badly too.
310
311 I have ideas about how to do better at this, so watch this space.
312 But, for now, avoid allowing your git-debrebase branch to diverge.
313 git-debrebase will help you with that by often spotting when it is
314 about to occur.
315
316 ===== data model slide merge conflict failure
317
318 What if you have a merge conflict during the upstream rebase ?
319
320 git-rebase users will have seen this kind of situation before.
321 git-rebase stops at the first commit which can't be applied in
322 the new context, and asks the user for help.
323
324 This looks quite bad.  Of course, it's not good.  But, this is an
325 irreducible aspect of maintaining a delta queue on top of a moving
326 target.  Sometimes, you'll need to fix up conflicts.
327
328 At least with git-rebase, you at least get good tools to help you fix
329 it up.  Some of the other workflows can involve trying to resolve
330 merge conflicts during quilt apply.  Much less fun.
331
332 Also, git-debrebase new-upstream is quite low commitment.  Imagine,
333 like on the diagram here, git-rebase has applied commit 1, and stopped
334 because it can't apply commit 3'.
335
336 Now, if you decide that this is too difficult to deal with today, you
337 can just say git rebase --abort and everything just gets put back.
338
339 ===== data model slide merge conflict failure, new stuff greyed out
340
341 The autogenerated special breakwater merge, and changelog entry, are
342 discarded, leaving you just where you were before.  You've wasted no
343 effort because everything you're throwing away was machine-made.
344
345 ===== status and references slide
346
347 git-debrebase is available in testing and stretch-backports and is in
348 good shape.  Since early versions it has been battle-tested to help
349 with security updates to the Debian Xen packages.  The documentation
350 is comprehensive.
351
352 No doubt the user interface and documentation will improve, and new
353 features will will be added, but you can start using it right away.
354
355 The best starting point is probably the tutorial manpage
356 dgit-maint-debrebase (7) (which is in the dgit package).
357
358 Sean and I are holding a workshop on Tuesday morning, where anyone is
359 invited to come and get help with git-debrebase - and also with dgit.
360 So if your questions dun't get answered before then, do drop in.
361
362 And of course I should refer to the reference documentation.
363 git-debrebase(5) has the data model and definition of terminology.
364 git-debrebase(1) is the command line reference.
365
366 But, really, start with the dgit-maint-rebase tutorial, or come to the
367 workshop.