3 git-debrebase - git data model for Debian packaging
7 git-debrebase is a tool for representing in git,
9 Debian packages based on upstream source code.
12 has a fast forwarding history.
13 The delta queue (changes to upstream files) is represented
14 as a series of individual git commits,
15 which can worked on with rebase,
20 git-debrebase is designed to work well with dgit.
21 git-debrebase can also be used in workflows without source packages,
22 for example to work on Debian-format packages outside or alongside Debian.
25 itself is not very suitable for use by Debian derivatives,
26 to work on packages inherited from Debian,
27 because it assumes that you want to throw away any packaging
28 provided by your upstream.
29 However, use of git-debrebase in Debian does not make anything harder for
30 derivatives, and it can make some things easier.
32 When using gitk on branches managed by git-debrebase,
33 B<gitk --date-order> and B<gitk --first-parent>
34 produce more useful output than the default.
42 A merge which does not actually merge the trees;
43 instead, it is constructed by taking the tree
44 from one of the parents
45 (ignoring the contents of the other parents).
46 These are used to make a rewritten history fast forward
48 so that it can be pushed and pulled normally.
49 Manual construction of pseudomerges can be done with
51 but is not normally needed when using git-debrebase.
55 Files in the source tree within B<debian/>,
56 excluding anything in B<debian/patches/>.
60 The version of the package without Debian's packaging.
61 Typically provided by the actual upstream project,
62 and sometimes tracked by Debian contributors in a branch C<upstream>.
64 Upstream contains upstream files,
65 but some upstreams also contain packaging files in B<debian/>.
66 Any such non-upstream files found in upstream
67 are thrown away by git-debrebase
68 each time a new upstream version is incorporated.
72 Files in the source tree outside B<debian/>.
73 These may include unmodified source from upstream,
74 but also files which have been modified or created for Debian.
78 Debian's changes to upstream files:
79 a series of git commits.
83 Files in B<debian/patches/> generated for the benefit of
84 dpkg-source's 3.0 (quilt) .dsc source package format.
85 Not used, often deleted, and regenerated when needed
86 (such as when uploading to Debian),
89 =item Interchange branch; breakwater; stitched; laundered
91 See L</BRANCHES AND BRANCH STATES - OVERVIEW>.
93 =item Anchor; Packaging
95 See L</BRANCH CONTENTS - DETAILED SPECIFICATION>.
97 =item ffq-prev; debrebase-last
99 See L</STITCHING, PSEUDO-MERGES, FFQ RECORD>.
105 ------/--A!----/--B3!--%--/--> interchange view
106 / / / with debian/ directory
107 % % % entire delta queue applied
108 / / / 3.0 (quilt) has debian/patches
109 / / 3* "master" on Debian git servers
113 1 1 1 breakwater branch, merging baseline
114 / / / unmodified upstream code
115 ---@-----@--A----@--B--C plus debian/ (but no debian/patches)
116 / / / no ref refers to this: we
117 --#-----#-------#-----> upstream reconstruct its identity by
118 inspecting interchange branch
121 1,2,3 commits touching upstream files only
122 A,B,C commits touching debian/ only
123 B3 mixed commit (eg made by an NMUer)
126 -@- anchor merge, takes contents of debian/ from the
127 / previous `breakwater' commit and rest from upstream
129 -/- pseudomerge; contents are identical to
130 / parent lower on diagram.
132 % dgit- or git-debrebase- generated commit of debian/patches.
133 `3.0 (quilt)' only; generally dropped by git-debrebase.
135 * Maintainer's HEAD was here while they were editing,
136 before they said they were done, at which point their
137 tools made -/- (and maybe %) to convert to
138 the fast-forwarding interchange branch.
140 ! NMUer's HEAD was here when they said `dgit push'.
141 Rebase branch launderer turns each ! into an
144 =head1 BRANCHES AND BRANCH STATES - OVERVIEW
146 git-debrebase has one primary branch,
147 the B<interchange branch>.
148 This branch is found on Debian contributor's workstations
149 (typically, a maintainer would call it B<master>),
150 in the Debian dgit git server as the suite branch (B<dgit/dgit/sid>)
151 and on other git servers which support Debian work
152 (eg B<master> on salsa).
154 The interchange branch is fast-forwarding
155 (by virtue of pseudomerges, where necessary).
157 It is possible to have multiple different interchange branches
158 for the same package,
159 stored as different local and remote git branches.
160 However, divergence should be avoided where possible -
161 see L</OTHER MERGES>.
163 A suitable interchange branch can be used directly with dgit.
164 In this case each dgit archive suite branch is a separate
167 Within the ancestry of the interchange branch,
168 there is another important, implicit branch, the
170 The breakwater contains unmodified upstream source,
171 but with Debian's packaging superimposed
172 (replacing any C<debian/> directory that may be in
173 the upstream commits).
174 The breakwater does not contain any representation of
175 the delta queue (not even debian/patches).
176 The part of the breakwater processed by git-debrebase
177 is the part since the most reecent B<anchor>,
178 which is usually a special merge generated by git-debrebase.
180 When working, locally,
181 the user's branch can be in a rebasing state,
182 known as B<unstitched>.
183 While a branch is unstitched,
184 it is not in interchange format.
185 The previous interchange branch tip
187 so that the previous history
190 stitched into the fast-forwarding interchange form.
192 An unstitched branch may be in
195 which means it has a more particular special form
196 convenient for manipulating the delta queue.
198 =head1 BRANCH CONTENTS - DETAILED SPECIFICATION
200 It is most convenient to describe the
203 A breakwater is B<fast-forwarding>,
204 but is not usually named by a ref.
205 It contains B<in this order> (ancestors first):
212 which is usually a special two-parent merge:
215 contains the most recent version, at that point,
216 of the Debian packaging (in debian/);
217 it also often contains upstream files,
218 but they are to be ignored.
219 Often the first parent is a previous breakwater tip.
222 is an upstream source commit.
223 It may sometimes contain a debian/ subdirectory,
224 but if so that is to be ignored.
225 The second parent's upstream files
226 are identical to the anchor's.
227 Anchor merges always contain
228 C<[git-debrebase anchor: ...]>
229 as a line in the commit message.
232 an anchor may be a single-parent commit which introduces
233 the C<debian/> directory and makes no other changes:
234 ie, the start of Debian packaging.
238 Zero or more single-parent commits
239 containing only packaging changes.
240 (And no quilt patch changes.)
246 branch state is B<rebasing>.
247 A laundered branch is based on a breakwater
248 but also contains, additionally,
249 B<after> the breakwater,
250 a representation of the delta queue:
254 =item Delta queue commits
256 Zero or more single-parent commits
257 contaioning only changes to upstream files.
263 (ie, unstitched but unlaundered)
264 branch state is also B<rebasing>.
265 It has the same contents as the laundered state,
266 except that it may contain,
268 in B<in any order but after the breakwater>:
272 =item Linear commits to the source
274 Further commit(s) containing changes to
278 possibly mixed within a single commit.
279 (But not quilt patch changes.)
281 =item Quilt patch addition for `3.0 (quilt)'
283 Commit(s) which add patches to B<debian/patches/>,
284 and add those patches to the end of B<series>.
286 These are only necessary when working with
287 packages in C<.dsc 3.0 (quilt)> format.
288 For git-debrebase they are purely an output;
289 they are deleted when branches are laundered.
290 git-debrebase takes care to make a proper patch
291 series out of the delta queue,
292 so that any resulting source packages are nice.
298 branch is B<fast forwarding>.
299 It has the same contents as an
300 unlaundered branch state,
301 but may (and usually will) additionally contain
303 possibly intermixed with the extra commits
304 which may be found on an unstitched unlaundered branch):
308 =item Pseudomerge to make fast forward
310 A pseudomerge making the branch fast forward from
312 The contributing parent is itself in interchange format.
313 Normally the overwritten parent is
314 a previous tip of an interchange branch,
315 but this is not necessary as the overwritten
316 parent is not examined.
318 If the two parents have identical trees,
319 the one with the later commit date
320 (or, if the commit dates are the same,
323 the contributing parent.
325 =item dgit dsc import pseudomerge
327 Debian .dsc source package import(s)
329 (during dgit fetch of a package most recently
330 uploaded to Debian without dgit,
331 or during dgit import-dsc).
333 git-debrebase requires that
334 each such import is in the fast-forwarding
335 format produced by dgit:
336 a two-parent pseudomerge,
337 whose contributing parent is in the
339 dgit dsc import format (not described further here),
340 and whose overwritten parent is
341 the previous interchange tip
342 (eg, the previous tip of the dgit suite branch).
346 =head1 STITCHING, PSEUDO-MERGES, FFQ RECORD
348 Whenever the branch C<refs/B> is unstitched,
349 the previous head is recorded in the git ref C<refs/ffq-prev/B>.
351 Unstiched branches are not fast forward from the published
352 interchange branches [1].
353 So before a branch can be pushed,
354 the right pseudomerge must be reestablished.
355 This is the stitch operation,
356 which consumes the ffq-prev ref.
358 When the user has an unstitched branch,
359 they may rewrite it freely,
360 from the breakwater tip onwards.
361 Such a git rebase is the default operation for git-debrebase.
362 Rebases should not go back before the breakwater tip,
363 and certainly not before the most recent anchor.
365 Unstitched branches must not be pushed to interchange branch refs
366 (by the use of C<git push -f> or equivalent).
367 It is OK to share an unstitched branch
368 in similar circumstances and with similar warnings
369 to sharing any other rebasing git branch.
371 [1] Strictly, for a package
372 which has never had a Debian delta queue,
373 the interchange and breakwater branches may be identical,
374 in which case the unstitched branch is fast forward
375 from the interchange branch and no pseudomerge is needed.
377 When ffq-prev is not present,
378 C<refs/debrebase-last/B> records some ancestor of refs/B,
379 (usually, the result of last stitch).
380 This can be used to quickly determine whether refs/B
381 is being maintained in git-debrebase form.
385 Note that the representation described here does not permit
386 general merges on any of the relevant branches.
387 For this reason the tools will try to help the user
388 avoid divergence of the interchange branch.
390 See dgit-maint-rebase(7)
391 for a discussion of what kinds of behaviours
394 they might generate such merges.
396 Automatic resolution of divergent interchange branches
397 (or laundering of merges on the interchange branch)
398 is thought to be possible,
399 but there is no tooling for this yet:
401 Nonlinear (merging) history in the interchange branch is awkward
402 because it (obviously) does not preserve
403 the linearity of the delta queue.
404 Easy merging of divergent delta queues is a research problem.
406 Nonlinear (merging) history in the breakwater branch is
407 in principle tolerable,
408 but each of the parents would have to be, in turn,
410 and difficult questions arise if they don't have the same anchor.
412 We use the commit message annotation to
413 distinguish the special anchor merges from other general merges,
414 so we can at least detect unsupported merges.
416 =head1 LEGAL OPERATIONS
418 The following basic operations follows from this model
419 (refer to the diagram above):
423 =item Append linear commits
425 No matter the branch state,
426 it is always fine to simply git commit
427 (or cherry-pick etc.)
428 commits containing upstream file changes, packaging changes,
431 (This may make the branch unlaundered.)
435 Record the previous head in ffq-prev,
436 if we were stitched before
437 (and delete debrebase-last).
439 Reorganise the current branch so that the packaging
441 followed by the delta queue,
442 turning C<-@-A-1-2-B3> into C<...@-A-B-1-2-3>.
444 Drop pseudomerges and any quilt patch additions.
446 =item Interactive rebase
448 With a laundered branch,
449 one can do an interactive git rebase of the delta queue.
451 =item New upstream rebase
453 Start rebasing onto a new upstream version,
454 turning C<...#..@-A-B-1-2-3> into C<(...#..@-A-B-, ...#'-)@'-1-2>.
456 This has to be a wrapper around git-rebase,
457 which prepares @' and then tries to rebase 1 2 onto @'.
458 If the user asks for an interactive rebase,
459 @' doesn't appear in the commit list, since
460 @' is the newbase of the rebase (see git-rebase(1)).
462 Note that the construction of @' cannot fail
463 because @' simply copies debian/ from B and and everything else from #'.
464 (Rebasing A and B is undesirable.
465 We want the debian/ files to be non-rebasing
466 so that git log shows the packaging history.)
471 whose contributing parent to is the unstitched branch
473 whose overwritten parent is ffq-prev,
474 consuming ffq-prev in the process
475 (and writing debrebase-last instead).
476 Ideally the contributing parent would be a laundered branch,
477 or perhaps a laundered branch with a quilt patch addition commit.
479 =item Commit quilt patches
481 To generate a tree which can be represented as a
482 3.0 (quilt) .dsc source packages,
483 the delta queue must be reified inside the git tree
484 in B<debian/patches/>.
485 These patch files can be stripped out and/or regenerated as needed.
489 =head1 COMMIT MESSAGE ANNOTATIONS
491 git-debrebase makes annotations
492 in the messages of commits it generates.
496 [git-debrebase[ COMMIT-TYPE [ ARGS...]]: PROSE, MORE PROSE]
498 git-debrebase treats anything after the colon as a comment,
499 paying no attention to PROSE.
501 The full set of annotations is:
502 [git-debrebase: split mixed commit, debian part]
503 [git-debrebase: split mixed commit, upstream-part]
504 [git-debrebase: convert dgit import, debian changes]
505 [git-debrebase anchor: convert dgit import, upstream changes]
507 [git-debrebase upstream-combine . PIECE[ PIECE...]: new upstream]
508 [git-debrebase anchor: new upstream NEW-UPSTREAM-VERSION, merge]
509 [git-debrebase: new upstream NEW-UPSTREAM-VERSION, changelog]
510 [git-debrebase: export and commit patches]
512 [git-debrebase convert-from-gbp: drop patches]
513 [git-debrebase anchor: declare upstream]
514 [git-debrebase pseudomerge: stitch]
516 [git-debrebase convert-to-gbp: commit patches]
518 Only anchor merges have the C<[git-debrebase anchor: ...]> tag.
519 Single-parent anchors are not generated by git-debrebase,
520 and when made manually should not
521 contain any C<[git-debrebase ...]> annotation.
523 The C<split mixed commit> and C<convert dgit import>
524 tags are added to the pre-existing commit message,
525 when git-debrebase rewrites the commit.
527 =head1 APPENDIX - DGIT IMPORT HANDLING
529 The dgit .dsc import format is not documented or specified
530 (so some of the following terms are not defined anywhere).
531 The dgit import format it is defined by the implementation in dgit,
532 of which git-debrebase has special knowledge.
534 Consider a non-dgit NMU followed by a dgit NMU:
536 interchange --/--B3!--%--//----D*-->
549 --#--------> upstream
554 =XBC% dgit tarball import of .debian.tar.gz containing
555 Debian packaging including changes B C and quilt patches
556 0 dgit tarball import of upstream tarball
557 00 dgit tarball import of supplementary upstream piece
558 &_ dgit import nearly-breakwater-anchor
559 // dgit fetch / import-dsc pseudomerge to make fast forward
561 &' git-debrebase converted import (upstream files only)
562 C' git-debrebase converted packaging change import
564 * ** before and after HEAD
566 We want to transform this into:
570 =item I. No new upstream version
573 --/--B3!--%--//-----D*-------------/-->
584 --@--A-----B---------------------C'---D
586 --#----------------------------------------->
588 =item II. New upstream
592 --/--B3!--%--//-----D*-------------/-->
603 --@--A-----B-----------------@---C'---D
605 --#--------------------- - - / - - --------->
616 dgit-maint-rebase(7),