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 changes to upstream files are represented
14 as a series of individual git commits,
15 which can worked on with rebase,
18 git-debrebase is designed to work well with dgit.
19 git-debrebase can also be used in workflows without source packages,
20 for example to work on Debian-format packages outside Debian.
22 git-debrebase is not very suitable for use by Debian derivatives,
23 to work on packages inherited from Debian,
24 because it assumes that you want to throw away any packaging
25 provided by your upstream.
29 ------/--A!----/--B3!--%--/--> interchange view
30 / / / with debian/ directory
31 % % % all upstream changes applied
32 / / / 3.0 (quilt) has debian/patches
37 1 1 1 breakwater branch, merging baseline
38 / / / unmodified upstream code
39 ---@-----@--A----@--B--C plus debian/ (but no debian/patches)
40 / / / no ref refers to this: we
41 --#-----#-------#-----> upstream reconstruct its identity by
42 inspecting interchange branch
45 1,2,3 commits touching upstream files only
46 A,B,C commits touching debian/ only
47 B3 mixed commit (eg made by an NMUer)
50 -@- anchor merge, takes contents of debian/ from the
51 / previous `breakwater' commit and rest from upstream
53 -/- pseudomerge; contents are identical to
54 / parent lower on diagram.
56 % dgit-generated commit of debian/patches.
57 `3.0 (quilt)' only; dropped by rebase tool.
59 * Maintainer's HEAD was here while they were editing,
60 before they said they were done, at which point their
61 tools generated [% and] -/- commit[s] to convert to
62 the fast-forwarding interchange branch.
64 ! NMUer's HEAD was here when they said `dgit push'.
65 Rebase branch launderer turns each ! into an
68 =head1 BRANCHES AND BRANCH STATES
70 git-debrebase has one primary branch,
71 the B<interchange branch>.
72 This branch is found on Debian contributor's workstations
73 (typically, a maintainer would call it B<master>),
74 in the Debian dgit git server as the suite branch (B<dgit/dgit/sid>)
75 and on other git servers which support Debian owrk
76 (eg B<master> on salsa).
78 The interchange branch is fast-forwarding
79 (by virtue of pseudomerges, where necessary).
81 It is possible to have multiple different interchange branches
83 stored as different local and remote git branches.
84 However, divergence should be avoided where possible -
85 see L</STITCHING, PSEUDO-MERGES, FFQ RECORD>.
87 A suitable interchange branch can be used directly with dgit.
88 In this case each dgit archive suite branch is a separate
91 Within the ancenstry of the interchange branch,
92 there is another importnt, implicit branch, the
94 The breakwater contains unmodified upstream source,
95 but with Debian's packaging superimposed
96 (replacing any C<debian/> directory that may be in upstream).
97 The breakwater does not contain any representation
98 of Debian's changes to upstream files.
99 The breakwater starts at an B<anchor>,
100 which is usually a special merge generated by git-debrebase.
102 When working, locally,
103 the user's branch can be in a rebasing state,
104 known as B<unstitched>.
105 When a branch is unstitched,
106 its previous tip is recorded so that it can later be
107 stitched into the fast-forwarding interchange form.
109 An unstitched branch may be in
112 which means it has a more particular special form
113 convenient for manipulating the changes to upstream files.
115 =head1 BRANCH CONTENTS
117 It is most convenient to describe the
120 It contains B<in this order> (ancestors first):
127 which is usually a special two-parent merge:
128 The first parent is a previous breakwater branch,
129 whose upstream files are irrelevant,
130 and whose packaging files are identical to the anchor's.
131 The second parent is an upstream source commit;
132 whose packaging files (if any) are irrelevant,
133 and whose upstream files are identical to the anchor's.
134 Anchor merges always contain
135 C<[git-debrebase anchor: ...]>
136 as a line in the commit message.
138 an anchor may be a single-parent commit which introduces
139 the C<debian/> directory and makes no other changes:
140 ie, the start of Debian packaging.
144 Zero or more single-parent commits
145 containing only packaging changes.
146 (And no changes to B<debian/patches/>.)
148 =item Delta from upstream
150 Zero or more single-parent commits
151 contaioning only changes to upstream files.
158 branch state is the same,
159 except that it may contain,
165 =item Linear commits to the source
167 Further commit(s) containing changes to
171 possibly mixed within a single commit.
172 (But no changes to B<debian/patches/>.)
174 =item Patch addition for `3.0 (quilt)'
176 Commit(s) which add patches to B<debian/patches/>,
177 and add those patches to the end of B<series>.
178 These are only necessary or useful when working with
179 packages in C<.dsc 3.0 (quilt)> format.
185 branch state is the same, but may additionally contain
187 possibly intermixed with the extra commits
188 which may be found on an unstitched unlaundered branch):
192 =item Pseudomerge to make fast forward
194 A pseudomerge making the branch fast forward from
196 The contributing parent is itself in interchange format.
197 Normally the overwritten parent is
198 a previous tip of the interchange branch,
199 but this is not necessary as the overwritten
200 parent is not examined.
202 =item dgit dsc import
204 Debian .dsc source package import(s) made by dgit.
205 Each such import must be a two-parent pseudomerge
206 whose contributing parent is in the special
207 dgit format (not described further here).
208 The overwritten parent must be
209 the previous interchange tip
210 (and will be generated that way by normal use of dgit).
214 =head1 STITCHING, PSEUDO-MERGES, FFQ RECORD
216 Whenever the branch C<refs/B> is unstitched,
217 the previous tip is recorded in the git ref C<refs/ffq-prev/heads/B>.
219 Unstiched branches are not fast forward from the published
220 interchange branches. [1]
221 So before a branch can be pushed,
222 the right pseudomerge must be reestablished.
223 This is the stitch operation,
224 which consumes the ffq-prev ref.
226 When the user has an unstituched branch,
227 they may rewrite it freely,
228 from the breakwater tip onwards.
229 Such a git rebase is the default operation for git-debrebase.
230 Rebases should not go back before the breakwater tip,
231 and certainly not before the most recent anchor.
233 Unstitched branches must not be pushed to interchange branch refs
234 (by the use of C<git push -f> or equivalent).
235 It is OK to share an unstitched branch
236 in similar circumstances and with similar warnings
237 to sharing any other rebasing git branch.
239 [1] Strictly, for a package
240 which has never had Debian changes to upstream files,
241 the interchange and breakwater branches may be identical,
242 in which case the unstitched branch is fast forward
243 from the interchange branch and no pseudomerge is needed.
247 Note that the representation described here does not permit
248 general merges on any of the relevant branches.
249 For this reason the tools will try to help the user
250 avoid divergence of the interchange branch.
252 Automatic resolution of divergent interchange branches
253 (or laundering of merges on the interchange branch)
254 is thought to be possible,
255 but there is no tooling for this yet:
257 Nonlinear (merging) history in the interchange branch is awkward
258 because it (obviously) does not preserve
259 the linearity of the delta queue.
260 Easy merging of divergent delta queues is a research problem.
262 Nonlinear (merging) history in the breakwater branch is
263 in principle tolerable,
264 but each of the parents would have to be, in turn,
266 and difficult qeustions arise if they don't have the same anchor.
268 We use the commit message annotation to
269 distinguish the special anchor merges from other general merges,
270 so we can at least detect unsupported merges.
272 =head1 LEGAL OPERATIONS
274 The following basic operations follows from this model
275 (refer to the diagram above):
279 =item Append linear commits
281 No matter the branch state,
282 it is always fine to simply git commit
283 (or cherry-pick etc.)
284 commits containing upstream file changes, packaging changes,
289 Record the previous tip in ffq-prev,
290 if we were stitched before.
292 Reorganise the current branch so that the debian/
294 turning C<-@-A-1-2-B3> into C<...@-A-B-1-2-3>.
296 Drop pseudomerges and any quilt patches.
298 =item Interactive rebase
300 With a laundered branch,
301 one can do an interactive git rebase of the delta queue.
303 =item New upstream rebase
305 Start rebasing onto a new upstream version,
306 turning C<...#..@-A-B-1-2-3> into C<(...#..@-A-B-|...#'-)@'-1-2>.
308 This has to be a wrapper around git-rebase,
309 which prepares @' and then tries to rebase 1 2 onto @'.
310 If the user asks for an interactive rebase,
311 @' doesn't appear in thec ommit list.
313 Note that the construction of @' cannot fail
314 because @' simply copies debian/ from B and and everything else from #'.
315 (Rebasing A and B is undesirable.
316 We want the debian/ files to be non-rebasing
317 so that git log shows the packaging history.)
322 overwriting (and consuming) ffq-prev.
326 To generate a tree which can be represented as a
327 3.0 (quilt) .dsc source packages,
328 the delta queue must be reified inside the git tree
329 in B<debian/patches/>.
330 (These can be stripped out and/or regenerated as needed.)
340 A merge which does not actually merge the trees;
341 instead, it takes its tree by construction from one parent.
342 These are used to make a rewritten history fast forward
344 so that it can be pushed and pulled normally.
345 Manual construction of pseudomerges can be done with
347 but is not normally needed when using git-debrebase.
349 =item Packaging files
351 Files in the source tree within B<debian/>.
352 (Does not include anything which may exist in B<debian/patches/>.)
356 The version of the package without Debian's packaging.
357 Typically provided by the actual upstream project,
358 and often tracked by Debian contributors in a branch C<upstream>.
362 Files in the source tree outside B<debian/>.
363 These may include unmodified source from upstream,
364 but also files which have been modified or created for Debian.
368 =head1 APPENDIX - DGIT IMPORT HANDLING
370 Consider a non-dgit NMU followed by a dgit NMU:
372 interchange --/--B3!--%--/----D*-->
385 --#--------> upstream
390 =XBC% dgit tarball import of .debian.tar.gz containing
391 Debian packaging including changes B C and patches
393 0 dgit tarball import of upstream tarball
394 00 dgit tarball import of supplementary upstream tarball
395 &_ dgit nearly-breakwater import
396 &' git-debrebase converted import (upstream files only)
397 D' git-debrebase converted debian/ changes import
399 * ** before and after HEAD
401 We want to transform this into:
405 =item I. No new upstream version
408 --/--B3!--%--/------D*-------------/-->
419 --@--A-----B-----------------------C--D
421 --#----------------------------------------->
423 =item II. New upstream
427 --/--B3!--%--/------D*-------------/-->
438 --@--A-----B--------------------@--C--D
440 --#----------------------- - - / - - ----->
451 dgit-maint-rebase(7),