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