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