chiark / gitweb /
e5b84a0b140b9fc6067d8c3649716707d9f9078e
[dgit.git] / git-debrebase.1.pod
1 =head1 NAME
2
3 git-debrebase - delta queue rebase tool for Debian packaging
4
5 =head1 SYNOPSYS
6
7  git-debrebase [<options...>] [-- <git-rebase options...>]
8  git-debrebase [<options...>] <operation> [<operation options...>
9
10 =head1 INTRODUCTION
11
12 git-debrebase is a tool for representing in git,
13 and manpulating,
14 Debian packages based on upstream source code.
15
16 This is the command line reference.
17 Please read the tutorial
18 L<dgit-maint-debrebase(7)>.
19 For background, theory of operation,
20 and definitions see L<git-debrebase(5)>.
21
22 You should read this manpage in conjunction with
23 L<git-debrebase(5)/TERMINOLOGY>,
24 which defines many important terms used here.
25
26 =head1 PRINCIPAL OPERATIONS
27
28 =over
29
30 =item git-debrebase [-- <git-rebase options...>]
31
32 =item git-debrebase [-i <further git-rebase options...>]
33
34 Unstitches and launders the branch.
35 (See L</UNSTITCHING AND LAUNDERING> below.)
36
37 Then, if any git-rebase options were supplied,
38 edits the Debian delta queue,
39 using git-rebase, by running
40
41     git rebase <git-rebase options> <breakwater-tip>
42
43 Do not pass a base branch argument:
44 git-debrebase will supply that.
45 Do not use --onto, or --fork-point.
46 Useful git-rebase options include -i and --autosquash.
47
48 If git-rebase stops for any reason,
49 you may git-rebase --abort, --continue, or --skip, as usual.
50 If you abort the git-rebase,
51 the branch will still have been laundered,
52 but everything in the rebase will be undone.
53
54 The options for git-rebase must either start with C<-i>,
55 or be prececded by C<-->,
56 to distinguish them from options for git-debrebase.
57
58 It is hazardous to use plain git-rebase on a git-debrebase branch,
59 because git-rebase has a tendency to start the rebase
60 too far back in history,
61 and then drop important commits.
62 See L<git-debrebase(5)/ILLEGAL OPERATIONS>
63
64 =item git-debrebase status
65
66 Analyses the current branch,
67 both in terms of its contents,
68 and the refs which are relevant to git-debrebase,
69 and prints a human-readable summary.
70
71 Please do not attempt to parse the output;
72 it may be reformatted or reorganised in the future.
73 Instead,
74 use one of the L<UNDERLYING AND SUPPLEMENTARY OPERATIONS>
75 described below.
76
77 =item git-debrebase conclude
78
79 Finishes a git-debrebase session,
80 tidying up the branch and making it fast forward again.
81
82 Specifically: if the branch is unstitched,
83 launders and restitches it,
84 making a new pseudomerge.
85 Otherwise, it is an error,
86 unless --noop-ok.
87
88 =item git-debrebase quick
89
90 Unconditionally launders and restitches the branch,
91 consuming any ffq-prev
92 and making a new pseudomerge.
93
94 If the branch is already laundered and stitched, does nothing.
95
96 =item git-debrebase prepush [--prose=<for commit message>]
97
98 If the branch is unstitched,
99 stitches it,
100 consuming ffq-prev.
101
102 This is a good command to run before pushing to a git server.
103 You should consider using B<conclude> instead,
104 because that launders the branch too.
105
106 =item git-debrebase stitch [--prose=<for commit message>]
107
108 Stitches the branch,
109 consuming ffq-prev.
110
111 If there is no ffq-prev, it is an error, unless --noop-ok.
112
113 You should consider using B<prepush> or B<conclude> instead.
114
115 =item git-debrebase scrap
116
117 Throws away all the work since the branch was last stitched.
118 This is done by rewinding you to ffq-prev.
119
120 If you are in the middle of a git-rebase, will abort that too.
121
122 =item git-debrebase new-upstream <new-version> [<upstream-details>...]
123
124 Rebases the delta queue
125 onto a new upstream version.  In detail:
126
127 Firstly, checks that the proposed rebase seems to make sense:
128 It is a snag unless the new upstream(s)
129 are fast forward from the previous upstream(s)
130 as found in the current breakwater anchor.
131 And, in the case of a multi-piece upstream
132 (a multi-component upstream, in dpkg-source terminology),
133 if the pieces are not in the same order, with the same names.
134
135 If all seems well, unstitches and launders the branch.
136
137 Then,
138 generates
139 (in a private working area)
140 a new anchor merge commit,
141 on top of the breakwater tip,
142 and on top of that a commit to
143 update the version number in debian/changelog.
144
145 Finally,
146 starts a git-rebase
147 of the delta queue onto these new commits.
148
149 That git-rebase may complete successfully,
150 or it may require your assistance,
151 just like a normal git-rebase.
152
153 If you git-rebase --abort,
154 the whole new upstream operation is aborted,
155 except for the laundering.
156
157 <new-version>
158 may be a whole new Debian version, including revision,
159 or just the upstream part,
160 in which case -1 will be appended
161 to make the new Debian version.
162
163 The <upstream-details> are, optionally, in order:
164
165 =over
166
167 =item <upstream-commit-ish>
168
169 The new upstream branch (or commit-ish).
170 The default is to look for one of these tags, in this order:
171 U vU upstream/U;
172 where U is the new upstream version.
173 (This is the same algorithm as L<git-deborig(1)>.)
174
175 It is a snag if the upstream contains a debian/ directory;
176 if forced to proceed,
177 git-debrebase will disregard the upstream's debian/ and
178 take (only) the packaging from the current breakwater.
179
180 =item <piece-name> <piece-upstream-commit-ish>
181
182 Specifies that this is a multi-piece upstream.
183 May be repeated.
184
185 When such a pair is specified,
186 git-debrebase will first combine the pieces of the upstream
187 together,
188 and then use the result as the combined new upstream.
189
190 For each <piece-name>,
191 the tree of the <piece-upstream-commit-ish>
192 becomes the subdirectory <piece-name>
193 in the combined new upstream
194 (supplanting any subdirectory that might be there in
195 the main upstream branch).
196
197 <piece-name> has a restricted syntax:
198 it may contain only ASCII alphanumerics and hyphens.
199
200 The combined upstream is itself recorded as a commit,
201 with each of the upstream pieces' commits as parents.
202 The combined commit contains an annotation
203 to allow a future git-debrebase new upstream operation
204 to make the coherency checks described above.
205
206 =item <git-rebase options>
207
208 These will be passed to git rebase.
209
210 If the upstream rebase is troublesome, -i may be helpful.
211 As with plain git-debrebase,
212 do not specify a base, or --onto, or --fork-point.
213
214 =back
215
216 If you are planning to generate a .dsc,
217 you will also need to have, or generate,
218 actual orig tarball(s),
219 which must be identical to the rev-spec(s)
220 passed to git-debrebase.
221 git-debrebase does not concern itself with source packages
222 so neither helps with this, nor checks it.
223 L<git-deborig(1)>,
224 L<git-archive(1)>, L<dgit(1)> and
225 L<gbp-import-orig(1)> may be able to help.
226
227 =item git-debrebase make-patches [--quiet-would-amend]
228
229 Generate patches in debian/patches/
230 representing the changes made to upstream files.
231
232 It is not normally necessary to run this command explicitly.
233 When uploading to Debian,
234 dgit and git-debrebase
235 will cooperate to regenerate patches as necessary.
236 When working with pure git remotes,
237 the patches are not needed.
238
239 Normally git-debrebase make-patches will
240 require a laundered branch.
241 (A laundered branch does not contain any patches.)
242 But if there are already some patches made by
243 git-debrebase make-patches,
244 and all that has happened is that more
245 changes to upstream files have been committed,
246 running it again can add the missing patches.
247
248 If the patches implied by the current branch
249 are not a simple superset of those already in debian/patches,
250 make-patches will fail with exit status 7,
251 and an error message.
252 (The message can be suppressed with --quiet-would-amend.)
253 If the problem is simply that
254 the existing patches were not made by git-debrebase,
255 using dgit quilt-fixup instead should succeed.
256
257 =item git-debrebase convert-from-unapplied [<upstream-commit-ish>]
258
259 =item git-debrebase convert-from-gbp [<upstream-commit-ish>]
260
261 Converts any of the following into a git-debrebase interchange branch:
262
263 =over
264
265 =item
266
267 a gbp patches-unapplied branch (but not a gbp pq patch-queue branch)
268
269 =item
270
271 a patches-unapplied git packaging branch containing debian/patches,
272 as used with quilt
273
274 =item
275
276 a git branch for a package which has no Debian delta -
277 ie where upstream files are have not been modified in Debian,
278 so there are no patches
279
280 =back
281
282 (These two commands operate identically and are simply aliases.)
283
284 The conversion is done by generating a new anchor merge,
285 converting any quilt patches as a delta queue,
286 and dropping the patches from the tree.
287
288 The upstream commit-ish should correspond to
289 the upstream branch or tag, if there is one.
290 It is a snag if it is not an ancestor of HEAD,
291 or if the history between the upstream and HEAD
292 contains commits which make changes to upstream files.
293 If it is not specified,
294 the same algorithm is used as for git-debrebase new-upstream.
295
296 It is also a snag if the specified upstream
297 has a debian/ subdirectory.
298 This check exists to detect certain likely user errors,
299 but if this situation is true and expected,
300 forcing it is fine.
301
302 git-debrebase will try to look for the dgit archive view
303 of the most recent release,
304 and if it finds it will make a pseduomerge so that
305 your new git-debrebase view is appropriately fast forward.
306
307 The result is a well-formed git-debrebase interchange branch.
308 The result is also fast-forward from the original branch.
309
310 It is a snag if the new branch looks like it will have diverged,
311 just as for a laundering/unstitching call to git-debrebase;
312 See L</Establish the current branch's ffq-prev>, below.
313
314 Note that it is dangerous not to know whether you are
315 dealing with a (gbp) patches-unapplied branch containing quilt patches,
316 or a git-debrebase interchange branch.
317 At worst,
318 using the wrong tool for the branch format might result in
319 a dropped patch queue!
320
321 =back
322
323 =head1 UNDERLYING AND SUPPLEMENTARY OPERATIONS
324
325 =over
326
327 =item git-debrebase breakwater
328
329 Prints the breakwater tip commitid.
330 If your HEAD branch is not fully laundered,
331 prints the tip of the so-far-laundered breakwater.
332
333 =item git-debrebase anchor
334
335 Prints the breakwater anchor commitid.
336
337 =item git-debrebase analyse
338
339 Walks the history of the current branch,
340 most recent commit first,
341 back until the most recent anchor,
342 printing the commit object id,
343 and commit type and info
344 (ie the semantics in the git-debrebase model)
345 for each commit.
346
347 =item git-debrebase record-ffq-prev
348
349 Establishes the current branch's ffq-prev,
350 as discussed in L</UNSTITCHING AND LAUNDERING>,
351 but does not launder the branch or move HEAD.
352
353 It is an error if the ffq-prev could not be recorded.
354 It is also an error if an ffq-prev has already been recorded,
355 unless --noop-ok.
356
357 =item git-debrebase launder-v0
358
359 Launders the branch without recording anything in ffq-prev.
360 Then prints some information about the current branch.
361 Do not use this operation;
362 it will be withdrawn soon.
363
364 =item git-debrebase convert-to-gbp
365
366 Converts a laundered branch into a
367 gbp patches-unapplied branch containing quilt patches.
368 The result is not fast forward from the interchange branch,
369 and any ffq-prev is deleted.
370
371 This is provided mostly for the test suite
372 and for unusual situations.
373 It should be used only with care and 
374 with a proper understanding of the underlying theory.
375
376 Be sure to not accidentally treat the result as
377 a git-debrebase branch,
378 or you will drop all the patches!
379
380 =item git-debrebase convert-from-dgit-view [<convert-options>] [upstream]
381
382 Converts any dgit-compatible git branch
383 corresponding to a (possibly hypothetical) 3.0 quilt dsc source package
384 into a git-debrebase-compatible branch.
385
386 This operation should not be used
387 if the branch is already in git-debrebase form.
388 Normally git-debrebase will refuse to continue in this case
389 (or silently do nothing if the global --noop-ok option is used).
390
391 Some representation of the original upstream source code will be needed.
392 If I<upstream> is supplied, that must be a suitable upstream commit.
393 By default,
394 git-debrebase will look first for git tags (as for new-upstream),
395 and then for orig tarballs which it will ask dgit to process.
396
397 The upstream source must be exactly right and
398 all the patches in debian/patches must be up to date.
399 Applying the patches from debian/patches to the upstream source
400 must result in exactly your HEAD.
401
402 The output is laundered and stitched.
403 The resulting history is not particularly pretty,
404 especially if orig tarball(s) were imported
405 to produce a synthetic upstream commit.
406
407 The available convert-options are as follows.
408 (These must come after convert-from-dgit-view.)
409
410 =over
411
412 =item --[no-]diagnose
413
414 Print additional error messages to help diagnose
415 failure to find an appropriate upstream.
416 --no-diagnose is the default.
417
418 =item --build-products-dir
419
420 Directory to look in for orig tarballs.
421 The default is the git config option
422 dgit.default.build-products-dir
423 or failing that, "C<..>".
424 Passed on to dgit, if git-debrebase invokes dgit.
425
426 =item --[no-]origs
427
428 Whether to try to look for or use any orig tarballs.
429 --origs is the default.
430
431 =item --[no-]tags
432
433 Whether to try to look for or use any upstream git tags.
434 --tags is the default.
435
436 =item --always-convert-anyway
437
438 Perform the conversion operation,
439 producing unpleasant extra history,
440 even if the branch seems to be in git-debrebase form already.
441 This should not be done unless necessary,
442 and it should not be necessary.
443
444 =back
445
446 =item git-debrebase forget-was-ever-debrebase
447
448 Deletes the ffq-prev and debrebase-last refs
449 associated with this branch,
450 that git-debrebase and dgit use to determine
451 whether this branch is managed by git-debrebase,
452 and what previous head may need to be stitched back in.
453
454 This can be useful if you were just playing with git-debrebase,
455 and have used git-reset --hard to go back to a commit
456 before your experiments.
457
458 Do not use this if you expect to run git-debrebase on the branch again.
459
460 =back
461
462 =head1 OPTIONS
463
464 This section documents the general options
465 to git-debrebase
466 (ie, the ones which immediately follow
467 git-debrebase
468 or
469 git debrebase
470 on the command line).
471 Individual operations may have their own options which are
472 docuented under each operation.
473
474 =over
475
476 =item -f<snag-id>
477
478 Turns snag(s) with id <snag-id> into warnings.
479
480 Some troublesome things which git-debrebase encounters
481 are B<snag>s.
482 (The specific instances are discussed
483 in the text for the relevant operation.)
484
485 When a snag is detected,
486 a message is printed to stderr containing the snag id
487 (in the form C<-f<snag-idE<gt>>),
488 along with some prose.
489
490 If snags are detected, git-debrebase does not continue,
491 unless the relevant -f<snag-id> is specified,
492 or --force is specified.
493
494 =item --force
495
496 Turns all snags into warnings.
497 See the -f<snag-id> option.
498
499 Do not invoke git-debrebase --force in scripts and aliases;
500 instead, specify the particular -f<snag-id> for expected snags.
501
502 =item --noop-ok
503
504 Suppresses the error in
505 some situations where git-debrebase does nothing,
506 because there is nothing to do.
507
508 The specific instances are discussed
509 in the text for the relvant operation.
510
511 =item --anchor=<commit-ish>
512
513 Treats <commit-ish> as an anchor.
514 This overrides the usual logic which automatically classifies
515 commits as anchors, pseudomerges, delta queue commits, etc.
516
517 It also disables some coherency checks
518 which depend on metadata extracted from its commit message,
519 so
520 it is a snag if <commit-ish> is the anchor
521 for the previous upstream version in
522 git-debrebase new-upstream operations.
523
524 =item --dgit=<program>
525
526 Run <program>, instead of dgit from PATH,
527 when invocation of dgit is necessary.
528 This is provided mostly for the benefit of the test suite.
529
530 =item -D
531
532 Requests (more) debugging.  May be repeated.
533
534 =item --experimntal-merge-resolution
535
536 Enable experimental code for handling general merges
537 (see L<git-debrebase(5)/General merges>).
538
539 This option may generate lossage of various kinds,
540 including misleading error messages,
541 references to nonexistent documentation, and
542 you being handed an incomprehensible pile of
543 multidimensional merge wreckage.
544
545 =back
546
547 =head1 UNSTITCHING AND LAUNDERING
548
549 Several operations unstitch and launder the branch first.
550 In detail this means:
551
552 =head2 Establish the current branch's ffq-prev
553
554 If ffq-prev is not yet recorded,
555 git-debrebase checks that the current branch is ahead of relevant
556 remote tracking branches.
557 The relevant branches depend on
558 the current branch (and its
559 git configuration)
560 and are as follows:
561
562 =over
563
564 =item
565
566 The branch that git would merge from
567 (remote.<branch>.merge, remote.<branch>.remote);
568
569 =item
570
571 The branch git would push to, if different
572 (remote.<branch>.pushRemote etc.);
573
574 =item
575
576 For local dgit suite branches,
577 the corresponding tracking remote;
578
579 =item
580
581 If you are on C<master>,
582 remotes/dgit/dgit/sid.
583
584 =back
585
586 The apparently relevant ref names to check are filtered through
587 branch.<branch>.ffq-ffrefs,
588 which is a semicolon-separated list of glob patterns,
589 each optionally preceded by !; first match wins.
590
591 In each case it is a snag if
592 the local HEAD is behind the checked remote,
593 or if local HEAD has diverged from it.
594 All the checks are done locally using the remote tracking refs:
595 git-debrebase does not fetch anything from anywhere.
596
597 If these checks pass,
598 or are forced,
599 git-debrebse then records the current tip as ffq-prev.
600
601 =head2 Examine the branch
602
603 git-debrebase
604 analyses the current HEAD's history to find the anchor
605 in its breakwater,
606 and the most recent breakwater tip.
607
608 =head2 Rewrite the commits into laundered form
609
610 Mixed debian+upstream commits are split into two commits each.
611 Delta queue (upstream files) commits bubble to the top.
612 Pseudomerges,
613 and quilt patch additions,
614 are dropped.
615
616 This rewrite will always succeed, by construction.
617 The result is the laundered branch.
618
619 =head1 SEE ALSO
620
621 git-debrebase(1),
622 dgit-maint-rebase(7),
623 dgit(1),
624 gitglossary(7)