create-html-usage.pl: fuss with options indentation
[topgit/pro.git] / README_DOCS.rst
blobb1a8ae95fa8e181510f5a35c5ee3721414c619b5
1 =========================================
2 TopGit -- A Different Patch Queue Manager
3 =========================================
6 DESCRIPTION
7 -----------
9 TopGit aims to make handling of large amounts of interdependent topic
10 branches easier. In fact, it is designed especially for the case where
11 you maintain a queue of third-party patches on top of another (perhaps
12 Git-controlled) project and want to easily organize, maintain and submit
13 them -- TopGit achieves that by keeping a separate topic branch for each
14 patch and providing some tools to maintain the branches.
16 See also:
18         :REQUIREMENTS_:      Installation requirements
19         :SYNOPSIS_:          Command line example session
20         :USAGE_:             Command line details
21         :`NO UNDO`_:         Where's the undo!!!
22         :CONVENTIONS_:       Suggestions for organizing your TopGit branches
23         :`EXTRA SETTINGS`_:  Various possible "topgit.*" config settings
24         :ALIASES_:           Git-like TopGit command aliases
25         :NAVIGATION_:        Getting around with "next" and "prev"
26         :`WAYBACK MACHINE`_: Turn back the clock and then come back
27         :GLOSSARY_:          All the TopGit vocabulary in one place
28         :TECHNICAL_:         How it works behind the scenes
29         :`TESTING TOPGIT`_:  How to run the TopGit test suite
32 REQUIREMENTS
33 ------------
35 TopGit is a collection of POSIX shell scripts so a POSIX-compliant shell is
36 required along with some standard POSIX-compliant utilities (e.g. sed, awk,
37 cat, etc.).  Git version 1.9.2 or later is also required.
39 To use TopGit with linked working trees (the ``git worktree add`` command),
40 at least Git version 2.5.0 (obviously, since that's when the ``git worktree``
41 command first appeared) is needed in which case linked working trees are then
42 fully supported for use with TopGit.
44 The scripts need to be preprocessed and installed.  The Makefile that does
45 this requires a POSIX make utility (using "``make``" and "``make install``")
46 and some version of ``perl`` in the ``PATH`` somewhere (the ``perl`` binary
47 is needed for correct help text file generation prior to the actual install).
49 Once installed, TopGit uses only POSIX-compliant utilities (except that it
50 also requires, obviously, Git).
52 Running the tests (see `TESTING TOPGIT`_) has the same requirements as for
53 installation (i.e. POSIX plus Perl).
55 It is possible to use the DESTDIR functionality to install TopGit to a
56 staging area on one machine, archive that and then unarchive it on another
57 machine to perform an install (provided the build prefix and other options are
58 compatible with the final installed location).
61 INSTALLATION
62 ------------
64 See the file ``INSTALL``.
67 GIT REPOSITORY
68 --------------
70 The TopGit git repository can be found at <https://repo.or.cz/topgit/pro>.
73 RATIONALE
74 ---------
76 Why not use something like StGIT or Guilt or ``rebase -i`` for maintaining
77 your patch queue?  The advantage of these tools is their simplicity;
78 they work with patch *series* and defer to the reflog facility for
79 version control of patches (reordering of patches is not
80 version-controlled at all).  But there are several disadvantages -- for
81 one, these tools (especially StGIT) do not actually fit well with plain
82 Git at all: it is basically impossible to take advantage of the index
83 effectively when using StGIT.  But more importantly, these tools
84 horribly fail in the face of a distributed environment.
86 TopGit has been designed around three main tenets:
88         (i) TopGit is as thin a layer on top of Git as possible.  You
89         still maintain your index and commit using Git; TopGit will only
90         automate a few indispensable tasks.
92         (ii) TopGit is anxious about *keeping* your history.  It will
93         never rewrite your history, and all metadata is also tracked
94         by Git, smoothly and non-obnoxiously.  It is good to have a
95         *single* point when the history is cleaned up, and that is at
96         the point of inclusion in the upstream project; locally, you
97         can see how your patch has evolved and easily return to older
98         versions.
100         (iii) TopGit is specifically designed to work in a
101         distributed environment.  You can have several instances of
102         TopGit-aware repositories and smoothly keep them all
103         up-to-date and transfer your changes between them.
105 As mentioned above, the main intended use-case for TopGit is tracking
106 third-party patches, where each patch is effectively a single topic
107 branch.  In order to flexibly accommodate even complex scenarios when
108 you track many patches where many are independent but some depend on
109 others, TopGit ignores the ancient Quilt heritage of patch series and
110 instead allows the patches to freely form graphs (DAGs just like Git
111 history itself, only "one level higher").  For now, you have to manually
112 specify which patches the current one depends on, but TopGit might help
113 you with that in the future in a darcs-like fashion.
115 A glossary_ plug: The union (i.e. merge) of patch dependencies is called
116 a *base* of the patch (topic branch).
118 Of course, TopGit is perhaps not the right tool for you:
120         (i) TopGit is not complicated, but StGIT et al. are somewhat
121         simpler, conceptually.  If you just want to make a linear
122         purely-local patch queue, deferring to StGIT instead might
123         make more sense.
125         (ii) When using TopGit, your history can get a little hairy
126         over time, especially with all the merges rippling through.
127         ;-)
130 SYNOPSIS
131 --------
135         ## Create and evolve a topic branch
136         $ tg create t/gitweb/pathinfo-action
137         tg: automatically marking dependency on master
138         tg: creating t/gitweb/pathinfo-action base from master...
139         $ ..hack..
140         $ git commit
141         $ ..fix a mistake..
142         $ git commit
144         ## Create another topic branch on top of the former one
145         $ tg create t/gitweb/nifty-links
146         tg: automatically marking dependency on t/gitweb/pathinfo-action
147         tg: creating t/gitweb/nifty-links base from t/gitweb/pathinfo-action...
148         $ ..hack..
149         $ git commit
151         ## Create another topic branch on top of master and submit
152         ## the resulting patch upstream
153         $ tg create t/revlist/author-fixed master
154         tg: creating t/revlist/author-fixed base from master...
155         $ ..hack..
156         $ git commit
157         $ tg patch -m
158         tg: Sent t/revlist/author-fixed
159         From: pasky@suse.cz
160         To: git@vger.kernel.org
161         Cc: gitster@pobox.com
162         Subject: [PATCH] Fix broken revlist --author when --fixed-string
164         ## Create another topic branch depending on two others non-trivially
165         $ tg create t/whatever t/revlist/author-fixed t/gitweb/nifty-links
166         tg: creating t/whatever base from t/revlist/author-fixed...
167         tg: Topic branch t/whatever created.
168         tg: Running tg update to merge in dependencies.
169         tg: Updating t/whatever base with t/gitweb/nifty-links changes...
170         Automatic merge failed; fix conflicts and then commit the result.
171         tg: Please commit merge resolution and call `tg update --continue`
172         tg: (use `tg status` to see more options)
173         $ ..resolve..
174         $ git commit
175         $ tg update --continue
176         $ ..hack..
177         $ git commit
179         ## Update a single topic branch and propagate the changes to
180         ## a different one
181         $ git checkout t/gitweb/nifty-links
182         $ ..hack..
183         $ git commit
184         $ git checkout t/whatever
185         $ tg info
186         Topic Branch: t/whatever (2/1 commits)
187         Subject: [PATCH] Whatever patch
188         Base: 3f47ebc1
189         Depends: t/revlist/author-fixed
190                  t/gitweb/nifty-links
191         Needs update from:
192                 t/gitweb/nifty-links (1/1 commit)
193         $ tg update
194         tg: Updating t/whatever base with t/gitweb/nifty-links changes...
195         Automatic merge failed; fix conflicts and then commit the result.
196         tg: Please commit merge resolution and call `tg update --continue`
197         tg: (use `tg status` to see more options)
198         $ ..resolve..
199         $ git commit
200         $ tg update --continue
201         tg: Updating t/whatever against new base...
202         Automatic merge failed; fix conflicts and then commit the result.
203         tg: Please commit merge resolution and call `tg update --continue`
204         tg: (use `tg status` to see more options)
205         $ ..resolve..
206         $ git commit
207         $ tg update --continue
209         ## Update a single topic branch and propagate the changes
210         ## further through the dependency chain
211         $ git checkout t/gitweb/pathinfo-action
212         $ ..hack..
213         $ git commit
214         $ git checkout t/whatever
215         $ tg info
216         Topic Branch: t/whatever (1/2 commits)
217         Subject: [PATCH] Whatever patch
218         Base: 0ab2c9b3
219         Depends: t/revlist/author-fixed
220                  t/gitweb/nifty-links
221         Needs update from:
222                 t/gitweb/pathinfo-action (<= t/gitweb/nifty-links) (1/1 commit)
223         $ tg update
224         tg: Recursing to t/gitweb/nifty-links...
225         ==> [t/gitweb/nifty-links]
226         tg: Updating t/gitweb/nifty-links base with t/gitweb/pathinfo-action changes...
227         Automatic merge failed; fix conflicts and then commit the result.
228         tg: Please commit merge resolution and call `tg update --continue`
229         tg: (use `tg status` to see more options)
230         $ ..resolve..
231         $ git commit
232         $ tg update --continue
233         ==> [t/gitweb/nifty-links]
234         tg: Updating t/gitweb/nifty-links against new base...
235         Automatic merge failed; fix conflicts and then commit the result.
236         tg: Please commit merge resolution and call `tg update --continue`
237         tg: (use `tg status` to see more options)
238         $ ..resolve..
239         $ git commit
240         $ tg update --continue
241         tg: Updating t/whatever base with t/gitweb/nifty-links changes...
242         tg: Updating t/whatever against new base...
244         ## Clone a TopGit-controlled repository
245         $ git clone URL repo
246         $ cd repo
247         $ tg remote --populate origin
248         ...
249         $ git fetch
250         $ tg update
252         ## Add a TopGit remote to a repository and push to it
253         $ git remote add foo URL
254         $ tg remote foo
255         $ tg push -r foo
257         ## Update from a non-default TopGit remote
258         $ git fetch foo
259         $ tg -r foo summary
260         $ tg -r foo update
263 CONVENTIONS
264 -----------
266 When using TopGit there are several common conventions used when working with
267 TopGit branches.  None of them are enforced, they are only suggestions.
269 There are three typical uses for a TopGit branch:
271     1. [PATCH]
272        Normal TopGit branches that represent a single patch.  These are known
273        as "patch" TopGit branches.
274     2. [BASE]
275        Empty TopGit branches with no dependencies (an empty ``.topdeps`` file)
276        that represent a base upon which other "normal" TopGit branches depend.
277        These are known as "base" TopGit branches (not to be confused with
278        the refs/top-bases/... refs).  When such a branch is created on an
279        unborn branch (meaning the base has no parent commit), it will typically
280        be named [ROOT] instead of [BASE].  When the base refers to the release
281        of some external dependency these branches are sometimes named [RELEASE]
282        instead of [BASE].
283     3. [STAGE]
284        Empty TopGit branches that serve as a staging area to bring together
285        several other TopGit branches into one place so they can be used/tested
286        all together.  These are known as "stage" TopGit branches and are
287        sometimes named [RELEASE] instead of [STAGE].
289 An "empty" TopGit branch is one that does not have any changes of its own -- it
290 may still have dependencies though ("stage" branches do, "base" branches do
291 not).  The ``tg summary`` output shows empty branches annotated with a ``0`` in
292 the output.  Branches which have not been annihilated (but which still might be
293 "empty") such as normal "patch" branches, "base" and "stage" branches are shown
294 in the ``tg summary`` output by default.  Annihilated branches are normally
295 omitted from the ``tg summary`` output but can be shown if given explicitly as
296 an argument to the ``tg summary`` command.  However, the message line will be
297 unavailable since an annihilated branch has no ``.topmsg`` file of its own.
299 A "patch" branch name typically starts with ``t/`` whereas "base" and "stage"
300 branch names often do not.
302 A "base" branch is created by using the ``--base`` option of ``tg create``
303 (aka ``--no-deps``) which will automatically suggest a "[BASE]" message prefix
304 rather than "[PATCH]".  A "stage" branch is created like a normal patch branch
305 except that the only changes that will ever be made to it are typically to
306 add/remove dependencies.  Its subject prefix must be manually changed to
307 "[STAGE]" to reflect its purpose.
309 Since both "base" and "stage" branches typically only have a use for the
310 "Subject:" line from their ``.topmsg`` file, they are quite easily created
311 using the ``--topmsg`` option of ``tg create``.
313 Use of "stage" and "base" branches is completely optional.  However, without
314 use of a "stage" branch it will be difficult to test multiple independent
315 patches together all at once.  A "base" branch is merely a convenience that
316 provides more explicit control over when a common base for a set of patches
317 gets updated as well as providing a branch that shows in ``tg summary`` output
318 and participates in ``tg remote --populate`` setup.
320 Occasionally the functionality of a "base" branch is needed but it may not
321 be possible to add any ``.topdeps`` or ``.topmsg`` files to the desired branch
322 (perhaps it's externally controlled).  `BARE BRANCHES`_ can be used in this
323 case, but while TopGit allows them it deliberately does not provide assistance
324 in setting them up.
326 Another advantage to using a "stage" branch is that if a new "patch" branch
327 is created remotely and that new branch is added to a pre-existing "stage"
328 branch on the remote then when the local version of the "stage" branch is
329 updated (after fetching remote updates of course), that new dependency will
330 be merged into the local "stage" branch and the local version of the new remote
331 "patch" branch will be automatically set up at "tg update" time.
333 When using the ``tg tag`` command to create tags that record the current state
334 of one or more TopGit branches, the tags are often created with a name that
335 starts with ``t/``.
337 One last thing, you have enabled ``git rerere`` haven't you?
340 NO UNDO
341 -------
343 Beware, there is no "undo" after running a ``tg update``!
345 Well, that's not entirely correct.  Since ``tg update`` never discards commits
346 an "undo" operation is technically feasible provided the old values of all the
347 refs that were affected by the ``tg update`` operation can be determined and
348 then they are simply changed back to their previous values.
350 In practice though, it can be extremely tedious and error prone looking through
351 log information to try and determine what the correct previous values were.
352 Although, since TopGit tries to make sure reflogs are enabled for top-bases
353 refs, using Git's ``@{date}`` notation on all the refs dumped out by a
354 ``tg tag --refs foo``, where "foo" is the branch that was updated whose update
355 needs to be undone, may work.
357 Alternatively, ``tg tag --stash`` can be used prior to the update and then
358 ``tg revert`` used after the update to restore the previous state.  This
359 assumes, of course, that you remember to run ``tg tag --stash`` first.
361 The ``tg update`` command understands a ``--stash`` option that tells it to
362 automatically run ``tg tag --stash`` before it starts making changes (if
363 everything is up-to-date it won't run the stash command at all).
365 The ``--stash`` option is the default nowadays when running ``tg update``,
366 add the ``--no-stash`` option to turn it off.
368 There is a preference for this.  Setting the config value ``topgit.autostash``
369 to ``false`` will implicitly add the ``--no-stash`` option to any ``tg update``
370 command unless an explicit ``--stash`` option is given.
372 If you are likely to ever want to undo a ``tg update``, setting
373 ``topgit.autostash`` to ``false`` is highly discouraged!
375 Note that if you have foolishly disabled the autostash functionality and
376 suddenly find yourself in an emergency "WHERE'S THE UNDO???" situation you
377 *may* be able to use the special ``TG_STASH`` ref.  But only if you're quick.
378 It's only set if you've foolishly disabled autostash and it always overwrites
379 the previous ``TG_STASH`` value if there was one (there's no reflog for it)
380 and it will most likely *not* survive a ``git gc`` (even an automatic one) no
381 matter what gc expiration values are used.  However, as a last gasp attempt
382 to save your butt, a previously existing ``TG_STASH`` will first be renamed
383 to ``ORIG_TG_STASH`` immediately before a new ``TG_STASH`` gets written
384 (stepping on any previously existing ``ORIG_TG_STASH`` at that point).
386 Note that the tags saved by ``tg tag --stash`` are stored in the
387 ``refs/tgstash`` ref and its reflog.  Unfortunately, while Git is happy to
388 maintain the reflog (once it's been enabled which ``tg tag`` guarantees for
389 ``refs/tgstash``), Git is unable to view an annotated/signed tag's reflog!
390 Instead Git dereferences the tag and shows the wrong thing.
392 Use the ``tg tag -g`` command to view the ``refs/tgstash`` reflog instead.
395 WAYBACK MACHINE
396 ---------------
398 After reading about `NO UNDO`_ and the `tg tag`_ command used to provide a
399 semblance of undo in some cases, you have the foundation to understand the
400 wayback machine.
402 The "wayback machine" provides a way to go back to a previous ref state as
403 stored in a TopGit tag created by `tg tag`_.  It actually normally returns to a
404 hybrid state as it does not prune (unless you prefix the wayback tag with
405 a ``:``).  In other words, any refs that have been newly created since the
406 target tag was made will continue to exist in the "wayback" view of things
407 (unless you used a pruning wayback tag -- one prefixed with a ``:``).
409 Any operations that are read-only and do not require working tree files (e.g.
410 the ``-i`` or ``-w`` options of `tg patch`_) are allowed using the wayback
411 machine.  Simply add a global ``-w <tgtag>`` option to the command.
413 This functionality can be extremely useful for quickly examining/querying a
414 previous state recorded some time ago with a `tg tag`_.
416 As the wayback machine uses a separate caching area, expect initial operations
417 to be less speedy, but repeated wayback operations on the same wayback tag
418 should happen at normal speed.
420 One new command exists expressly for use with the wayback machine.
422 The `tg shell`_ command will spawn an interactive shell or run a specific shell
423 command in a temporary writable and non-bare repository that has its ref
424 namespace set to the (possibly pruned if it's a pruning wayback tag) wayback
425 tag's view of the world.  This pretty much lifts all wayback restrictions, but
426 read the description for `tg shell`_ for more details.  There is an option
427 available to specify the location where this "temporary" directory is created
428 thereby allowing it to persist, but the same warnings then apply as using the
429 ``git clone --shared`` command.
432 EXTRA SETTINGS
433 --------------
435 TopGit supports various config settings:
437         :`tg tag`_:             ``color.tgtag`` on/off color for ``tg tag -g``
438         :`tg tag`_:             ``color.tgtag.commit`` reflog hash color
439         :`tg tag`_:             ``color.tgtag.date`` reflog date line color
440         :`tg tag`_:             ``color.tgtag.meta`` reflog object type color
441         :`tg tag`_:             ``color.tgtag.time`` reflog time info color
442         :`tg create`_:          ``format.signoff`` template Signed-off-by line
443         :ALIASES_:              ``topgit.alias.*`` for Git-like command aliases
444         :`tg update`_:          ``topgit.autostash`` automatic stash control
445         :`tg create`_:          ``topgit.bcc`` default "Bcc:" value for create
446         :`tg create`_:          ``topgit.cc`` default "Cc:" value for create
447         :`tg patch`_:           ``topgit.from`` "From:" fixups by ``tg patch``
448         :`tg export`_:          ``topgit.notesExport`` export ``---`` notes
449         :`tg import`_:          ``topgit.notesImport`` import ``---`` notes
450         :`tg push`_:            ``topgit.pushRemote`` default push remote
451         :`REMOTE HANDLING`_:    ``topgit.remote`` TopGit's default remote
452         :SEQUESTRATION_:        ``topgit.sequester`` for sequestration control
453         :`tg update`_:          ``topgit.setAutoUpdate`` => ``rerere.autoUpdate``
454         :`tg export`_:          ``topgit.subjectMode`` export [...] tag removal
455         :`tg create`_:          ``topgit.subjectPrefix`` "[$prefix PATCH] foo"
456         :`tg create`_:          ``topgit.to`` default "To:" value for create
457         :`tg migrate-bases`_:   ``topgit.top-bases`` for refs bases location
460 ALIASES
461 -------
463 These work exactly like Git's aliases except they are stored under
464 ``topgit.alias.*`` instead.  See the ``git help config`` output under
465 the ``alias.*`` section for details.  Do note that while alias nesting is
466 explicitly permitted, a maximum nesting depth of 10 is enforced to help
467 detect accidental aliasing loops and keep them from wedging the machine.
469 For example, to create an ``lc`` alias for the ``tg log --compact`` command
470 this command may be used:
474         git config --global topgit.alias.lc "log --compact"
476 To make it specific to a particular repository just omit the ``--global``
477 option from the command.
479 There is one implicit universal alias as though this were set:
483         git config topgit.alias.goto "checkout goto"
485 But only if no explicit alias has already been set for ``topgit.alias.goto``.
488 NAVIGATION
489 ----------
490 From Previous to Next
491 ~~~~~~~~~~~~~~~~~~~~~
493 For this section, consider the following patch series, to be applied
494 in numerical order as shown:
498         0001-F_first-patch.diff
499         0002-G_second-builds-on-F.diff
500         0003-H_third-builds-on-G.diff
501         0004-I_fourth-builds-on-H.diff
502         0005-J_fifth-builds-on-I.diff
503         0006-K_sixth-builds-on-J.diff
504         0007-L_last-patch-needs-K.diff
506 If these were applied to some commit in a Git repository, say commit "A"
507 then a history that looks like this would be created:
511         A---F---G---H---I---J---K---L
513 Where the parent of commit "F" is "A" and so on to where the parent of
514 commit "L" is commit "K".
516 If that commit history, from A through L, was then imported into TopGit, one
517 TopGit branch would be created corresponding to each of the commits F
518 through L.  This way, for example, if the fourth patch in the series
519 (``0004-I_...diff``) needs work, the TopGit branch corresponding to its patch
520 can be checked out and changes made and then a new version of its patch
521 created (using ``tg patch``) without disturbing the other patches in the series
522 and when ``tg update`` is run, the patches that "follow" the fourth patch
523 (i.e. 5, 6 and 7) will have their corresponding TopGit branches automatically
524 updated to take into account the changes made to the fourth patch.
526 Okay, enough with the review of TopGit systemology
527 ``````````````````````````````````````````````````
529 Imagine then that you are working on the fourth patch (i.e. you have its
530 branch checked out into the working tree) and you want to move to the following
531 patch in the series because you have a nit to pick with it too.
533 If you can't remember the exact name you might have to fumble around or, you
534 can display the name of the following or "next" patch's branch with the, you
535 guessed it, ``tg next`` command.  Think of "next" as the "next" logical patch
536 in the series or the next following patch.  If the patches are numbered as in
537 the list above, "next" corresponds to the "+1" (plus one) patch.
539 You might have already guessed there's a corresponding ``tg prev`` command
540 which displays the "-1" (minus one) patch.  If these commands (``tg next``
541 and ``tg prev``) are not given a branch name to start at they start at the
542 patch corresponding to the current ``HEAD``.
544 Displaying, however, is not so helpful as actually going there.  That's where
545 the ``tg checkout`` command comes in.  ``tg checkout next`` does a
546 ``git checkout`` of the ``tg next`` branch and, not surprisingly,
547 ``tg checkout prev`` does a ``git checkout`` of the ``tg prev`` branch.  For
548 the lazy a single ``n`` or ``p`` can be used with ``tg checkout`` instead of
549 typing out the entire ``next`` or ``prev``.  Or, for the anal, ``previous``
550 will also be accepted for ``prev``.
552 Referring to the A...L commit graph shown above, I is the parent of J and,
553 conversely, J is the child of I.  (Git only explicitly records the child to
554 parent links, in other words a "child" points to zero or more "parents", but
555 parents are completely clueless about their own children.)
557 For historical reasons, the ``tg checkout`` command accepts ``child`` as a
558 synonym for ``next`` and ``parent`` as a synonym for ``prev``.  However, this
559 terminology can be confusing since Git has "parent" links but ``tg checkout``
560 is referring to the TopGit DAG, not Git's.  Best to just avoid using ``child``
561 or ``parent`` to talk about navigating the TopGit DAG and reserve them
562 strictly for discussing the Git DAG.
564 There may be more than one
565 ``````````````````````````
567 In a simple linear history as shown above there's always only one "next" or
568 "prev" patch.  However, TopGit does not restrict one to only a linear
569 history (although that can make patch exports just a bushel of fun).
571 Suffice it to say that there is always a single linearized ordering for any
572 TopGit patch series since it's always a DAG (Directed Acyclic Graph), but it
573 may not be immediately obvious to the casual observer what that is.
575 The ``tg checkout`` command will display a list to choose from if ``next``
576 or ``prev`` would be ambiguous.
578 Use the ``tg info/checkout --series`` command
579 `````````````````````````````````````````````
581 To see the full, linearized, list of patches with their summary displayed in
582 order from first to last patch in the series, just run the ``tg info --series``
583 command.  It takes the name of any patch in the series automatically using
584 ``HEAD`` if none is given.  It even provides a nice "YOU ARE HERE" mark in
585 the output list helpful to those who have been absent for a time engaging in
586 otherwise distracting activities and need to be reminded where they are.
588 Using ``tg checkout --series`` can take you there (picking from a list) if
589 you've forgotten the way back to wherever you're supposed to be.
591 Don't get pushy, there's just one more thing
592 ````````````````````````````````````````````
594 For historical reasons, ``tg checkout`` with no arguments whatsoever behaves
595 like ``tg checkout next``.  For the same historical reasons, ``tg checkout ..``
596 behaves like ``tg checkout prev`` (think of ``..`` as the "parent" directory
597 and since "parent" means "prev" in this context it will then make sense).
599 Now, for that one more thing.  Consider that you have a pristine "upstream"
600 tarball, repository, source dump or otherwise obtained set of unmodified
601 source files that need to be patched.  View them like so:
605         +-------------------------------+
606         | Unmodified "upstream" source  |
607         | files represented with "A"    |
608         +-------------------------------+
610 Now, add the first patch, 0001, to them and view the result like so:
614         +--------------------------+----+
615         | Patch 0001 represented by "F" |
616         +-------------------------------+
617         | Unmodified "upstream" source  |
618         | files represented with "A"    |
619         +-------------------------------+
621 Not stopping there, "push" patches 2, 3 and 4 onto the stack as well like so:
625         +--------------------------+----+
626         | Patch 0004 represented by "I" |
627         +--------------------------+----+
628         | Patch 0003 represented by "H" |
629         +--------------------------+----+
630         | Patch 0002 represented by "G" |
631         +--------------------------+----+
632         | Patch 0001 represented by "F" |
633         +-------------------------------+
634         | Unmodified "upstream" source  |
635         | files represented with "A"    |
636         +-------------------------------+
638 In other words, to go to the "next" patch in the series it needs to be "push"ed
639 onto the stack.  ``tg checkout`` accepts ``push`` as an alias for ``next``.
641 Similarly to go to the "previous" patch in the series the current one needs
642 to be "pop"ped off the stack.  ``tg checkout`` accepts ``pop`` as an alias
643 for ``prev``.
645 Unfortunately for these aliases, in Git terminology a "push" has quite a
646 different meaning and the ``tg push`` command does something quite different
647 from ``tg checkout push``.  Then there's the matter of using a single letter
648 abbreviation for the lazy -- ``p`` would mean what exactly?
650 ``tg checkout`` continues to accept the ``push`` and ``pop`` aliases for
651 ``next`` and ``prev`` respectively,  but it's best to avoid them since
652 ``push`` has an alternate meaning everywhere else in TopGit and Git and that
653 leaves ``pop`` all alone in the dark.
656 SEQUESTRATION
657 -------------
659 No, this is not a section about budget nonsense.  ;)
661 TopGit keeps its metadata in ``.topdeps`` and ``.topmsg`` files.  In an effort
662 to facilitate cherry-picking and other Git activities on the patch changes
663 themselves while ignoring the TopGit metadata, TopGit attempts to keep all
664 changes to ``.topdeps`` and ``.topmsg`` files limited to commits that do NOT
665 contain changes to any other files.
667 This is a departure from previous TopGit versions that made no such effort.
669 Primarily this affects ``tg create`` and ``tg import`` (which makes use of
670 ``tg create``) as ``tg create`` will commit the initial versions of
671 ``.topdeps`` and ``.topmsg`` for a new TopGit-controlled branch in their own
672 commit instead of mixing them in with changes to other files.
674 The ``pre-commit`` hook will also attempt to separate out any ``.topdeps`` and
675 ``.topmsg`` changes from commits that include changes to other files.
677 It is possible to defeat these checks without much effort (``pre-commit`` hooks
678 can easily be bypassed, ``tg create`` has a ``--no-commit`` option, many Git
679 commands simply do not run the ``pre-commit`` hook, etc.).
681 If you really, really, really, really want to change the default back to the
682 old behavior of previous TopGit versions where no such sequestration took
683 place, then set the ``topgit.sequester`` config variable explicitly to the
684 value ``false``.  But this is not recommended.
687 AMENDING AND REBASING AND UPDATE-REF'ING
688 ----------------------------------------
690 In a word, "don't".
692 It is okay to manually update a top-bases/... ref when a) it has no depedencies
693 (i.e. it was created with the ``tg create`` ``--base`` option) and b) the
694 old top-bases/... ref value can be fast-forwarded to the new top-bases/...
695 value OR the new value contains ALL of the changes in the old value through
696 some other mechanism (perhaps they were cherry-picked or otherwise applied to
697 the new top-bases/... ref).  The same rules apply to non-TopGit-controlled
698 dependencies.  Use the ``tg update --base <branch> <new-ref>`` command to
699 safely make such an update while making it easy to set the merge commit
700 message at the same time.
702 Ignoring this rule and proceeding anyway with a non-fast-forward update to a
703 top-bases/... ref will result in changes present in the new value being merged
704 into the branch (at ``tg update`` time) as expected (possibly with conflicts),
705 but any changes that were contained in the old version of the top-bases/... ref
706 which have been dropped (i.e. are NOT contained in the new version of the
707 top-bases/... ref) will continue to be present in the branch!  To get rid of
708 the dropped commits, one or more "revert" commits will have to be manually
709 applied to the tip of the new top-bases/... value (which will then be merged
710 into the branch at next ``tg update`` time).
712 The only time it's safe to amend, rebase, filter or otherwise rewrite commits
713 contained in a TopGit controlled branch or non-TopGit branch is when those
714 commits are NOT reachable via any other ref!
716 Furthermore, while it is safe to rewrite merge commits (provided they meet the
717 same conditions) the merge commits themselves and the branches they are merging
718 in must be preserved during the rewrite and that can be rather tricky to get
719 right so it's not recommended.
721 For example, if, while working on a TopGit-controlled branch ``foo``, a bad
722 typo is noticed, it's okay to ammend/rebase to fix that provided neither
723 ``tg update`` nor ``tg create`` has already been used to cause some other ref
724 to be able to reach the commit with the typo.
726 If an amend or rewrite is done anyway even though the commit with the typo is
727 reachable from some other ref, the typo won't really be removed.  What will
728 happen instead is that the new version without the typo will ultimately be
729 merged into the other ref(s) (at ``tg update`` time) likely causing a conflict
730 that will have to be manually resolved and the commit with the typo will
731 continue to be reachable from those other refs!
733 Instead just make a new commit to fix the typo.  The end result will end up
734 being the same but without the merge conflicts.
736 See also the discussion in the `NO UNDO`_ section.
739 BARE BRANCHES
740 -------------
742 A "TopGit bare branch" (or just "bare branch" for short), refers to a TopGit
743 branch that has neither a ``.topdeps`` nor a ``.topmsg`` file stored in it.
744 And it's neither a new, still-empty empty branch nor an annihilated branch.
746 Such branches are not recommended but are reluctantly accomodated.
748 There are three situtations in which TopGit may encounter a TopGit branch
749 that has neither a ``.topdeps`` nor a ``.topmsg`` file.
751         1. Branch creation with ``--no-commit``
752                 Before the initial commit is made, the branch will still be
753                 pointing to the same commit as its "top-bases" ref.  Branches
754                 in this condition (where the branch and top-bases ref point to
755                 the same commit) show up as having "No commits" in listings.
757         2. Annihilated branches
758                 A branch is annihilated by making a new commit on the branch
759                 that makes its tree identical to the tree of its corresponding
760                 top-bases ref.  Although the trees will be the same, the
761                 commits will be different and annihilated branches are
762                 distinguished from "No commits" branches in this way.
763                 Annihilated branches are generally invisible and do not show up
764                 in listings or other status displays.  Intentionally so.
766         3. Bare branches
767                 Any TopGit branch with neither a ``.topdeps`` file nor a
768                 ``.topmsg`` file whose branch and top-bases trees differ falls
769                 into this category.  TopGit will not create such a branch
770                 itself nor does it provide any commands to do so.
772 Whenever possible, a TopGit "[BASE]" branch should be preferred to using a
773 "bare branch" because a) it can never be mistaken for an annihilated branch,
774 b) it has a nice subject attached (via its ``.topmsg`` file) that shows
775 up in listings and c) exactly when and which updates are taken can be planned.
777 Nevertheless, situations may arise where it's useful to have TopGit treat a
778 branch as a "TopGit branch" so that it fully participates in all update
779 activities (such as updating local branches based on their remote branches),
780 but it's not feasible to turn it into a real "TopGit branch" as it comes from
781 an external source and rather than controlling exactly when and what updates
782 are picked up from it by TopGit (the precise use case of a "[BASE]" branch),
783 all updates that appear on it are to be assimilated as soon as they occur.
785 For this reason, TopGit will accomodate such "bare branches" but it will not
786 create (nor provide the means to create) them itself.
788 In order to create a "bare branch" all that's required is to create the
789 necessary top-bases ref.  The choice of commit for the top-bases ref will
790 affect the output of the "files", "log" and "patch" commands most directly
791 (but all commands will be affected).
793 To work properly as a "bare branch", the commit the "bare branch"'s base points
794 to should be contained within the branch, be a different commit than the branch
795 tip itself and have a different tree than the branch tip.  Simply setting the
796 base to the parent commit of the "bare branch" will usually work, but should
797 that commit at the tip of the "bare branch" end up getting reverted as the next
798 commit, the trees would match and it would appear to be an annihilated branch
799 rather than a "bare branch".  That is one of the reasons these branches are not
800 recommended in the first place.
802 Setting the base to the root commit of the branch is more reliable and may
803 be accomplished like so for a local branch named "mybranch":
807         git update-ref $(tg --top-bases)/mybranch \
808           $(git rev-list --first-parent --max-parents=0 mybranch) ""
810 Typically though it's more likely a remote bare branch will be needed.  For
811 a remote named "origin" and a remote branch name of "vendor" this will do it:
815         git update-ref $(tg --top-bases -r origin)/vendor \
816           $(git rev-list --first-parent --max-parents=0 origin/vendor) ""
818 Such "bare branches" are not likely ever to receive any more direct support in
819 TopGit than acknowleging they can be useful in some situations and tolerating
820 their existence by functioning properly with them even to the point of the
821 ``pre-commit`` hook tacitly allowing continued commits on such branches without
822 complaints about missing ``.topdeps`` and ``.topmsg`` files.
824 Note, however, that creating a regular TopGit branch that has no changes of its
825 own with the "bare branch" as its single dependency provides a means to supply
826 some kind of documentation if all other uses of the "bare branch" depend on
827 this "wrapper" branch instead of directly on the "bare branch".
830 SPEED AND CACHING
831 -----------------
833 TopGit needs to check many things to determine whether a TopGit branch is
834 up-to-date or not.  This can involve a LOT of git commands for a complex
835 dependency tree.  In order to speed things up, TopGit keeps a cache of results
836 in a ``tg-cache`` subdirectory in the ``.git`` directory.
838 Results are tagged with the original hash values used to get that result so
839 that items which have not been changed return their results quickly and items
840 which have been changed compute their new result and cache it for future use.
842 The ``.git/tg-cache`` directory may be removed at any time and the cache will
843 simply be recreated in an on-demand fashion as needed, at some speed penalty,
844 until it's fully rebuilt.
846 To force the cache to be fully pre-loaded, run the ``tg summary`` command
847 without any arguments.  Otherwise, normal day-to-day TopGit operations should
848 keep it more-or-less up-to-date.
850 While each TopGit command is running, it uses a temporary subdirectory also
851 located in the ``.git`` directory.  These directories are named
852 ``tg-tmp.XXXXXX`` where the ``XXXXXX`` part will be random letters and digits.
854 These temporary directories should always be removed automatically after each
855 TopGit command finishes running.  As long as you are not in a subshell as a
856 result of a TopGit command stopping and waiting for a manual merge resolution,
857 it's safe to remove any of these directories that may have somehow accidentally
858 been left behind as a result of some failure that occurred while running a
859 TopGit command (provided, of course, it's not actually being used by a TopGit
860 command currently running in another terminal window or by another user on the
861 same repository).
864 USAGE
865 -----
866 ``tg [global options] <subcommand> [<subcommand option/argument>...]``
868 Global options:
870         ``[-C <dir>]... [-r <remote> | -u] [-c <name>=<val>]... [--[no-]pager]``
872         -C <dir>        Change directory to <dir> before doing anything more
873         -r <remote>     Pretend ``topgit.remote`` is set to <remote>
874         -u              Pretend ``topgit.remote`` is not set
875         -c <name=val>   Pass config option to git, may be repeated
876         -w <tgtag>      Activate `wayback machine`_ using the `tg tag`_ <tgtag>
877         --no-pager      Disable all pagers (by both TopGit and Git aka ``-P``)
878         --pager         Enable use of a pager (aka ``-p`` aka ``--paginate``)
879         --top-bases     Show full ``top-bases`` ref prefix and exit
880         --exec-path     Show path to subcommand scripts location and exit
881         --help          Show brief usage help and exit (aka ``-h``)
883 The ``tg`` tool has several subcommands:
885         :`tg annihilate`_:    Mark a TopGit-controlled branch as defunct
886         :`tg base`_:          Show base commit for one or more TopGit branches
887         :`tg checkout`_:      Shortcut for git checkout with name matching
888         :`tg contains`_:      Which TopGit-controlled branch contains the commit
889         :`tg create`_:        Create a new TopGit-controlled branch
890         :`tg delete`_:        Delete a TopGit-controlled branch cleanly
891         :`tg depend`_:        Add a new dependency to a TopGit-controlled branch
892         :`tg export`_:        Export TopGit branch patches to files or a branch
893         :`tg files`_:         Show files changed by a TopGit branch
894         :`tg help`_:          Show TopGit help optionally using a browser
895         :`tg import`_:        Import commit(s) to separate TopGit branches
896         :`tg info`_:          Show status information about a TopGit branch
897         :`tg log`_:           Run git log limiting revisions to a TopGit branch
898         :`tg mail`_:          Shortcut for git send-email with ``tg patch`` output
899         :`tg migrate-bases`_: Transition top-bases to new location
900         :`tg next`_:          Show next branch in the patch series
901         :`tg patch`_:         Generate a patch file for a TopGit branch
902         :`tg prev`_:          Show previous branch in the patch series
903         :`tg push`_:          Run git push on TopGit branch(es) and depedencies
904         :`tg rebase`_:        Auto continue git rebase if rerere resolves conflicts
905         :`tg remote`_:        Set up remote for fetching/pushing TopGit branches
906         :`tg revert`_:        Revert ref(s) to a state stored in a ``tg tag``
907         :`tg shell`_:         Extended `wayback machine`_ mode
908         :`tg status`_:        Show current TopGit status (e.g. in-progress update)
909         :`tg summary`_:       Show various information about TopGit branches
910         :`tg tag`_:           Create tag that records current TopGit branch state
911         :`tg update`_:        Update TopGit branch(es) with respect to dependencies
913 tg help
914 ~~~~~~~
915         Our sophisticated integrated help facility.  Mostly duplicates
916         what is below::
918          # to list commands:
919          $ tg help
920          # to get help for a particular command:
921          $ tg help <command>
922          # to get help for a particular command in a browser window:
923          $ tg help -w <command>
924          # to get help on TopGit itself
925          $ tg help tg
926          # to get help on TopGit itself in a browser
927          $ tg help -w tg
929 tg status
930 ~~~~~~~~~
931         Our sophisticated status facility.  Similar to Git's status command
932         but shows any in-progress update that's awaiting a merge resolution
933         or any other on-going TopGit activity (such as a branch creation).
935         With a single ``--verbose`` (or ``-v``) option include a short status
936         display for any dirty (but not untracked) files.  This also causes all
937         non file status lines to be prefixed with "## ".
939         With two (or more) ``--verbose`` (or ``-v``) options, additionally
940         show full symbolic ref names and unabbreviated hash values.
942         With the ``--exit-code`` option the exit code will be non-zero if any
943         TopGit or Git operation is currently in progress or the working
944         directory is unclean.
946 tg create
947 ~~~~~~~~~
948         Create a new TopGit-controlled topic branch of the given name
949         (required argument) and switch to it.  If no dependencies are
950         specified (by extra arguments passed after the first one), the
951         current branch is assumed to be the only dependency.
953         By default ``tg create`` opens an editor on the new ``.topmsg`` file
954         and then commits the new ``.topmsg`` and ``.topdeps`` files
955         automatically with a suitable default commit message.
957         The commit message can be changed with the ``-m`` (or ``--message``) or
958         ``-F`` (or ``--file``) option.  The automatic commit can be suppressed
959         by using the ``--no-commit`` (or ``-n``) option.  Running the editor on
960         the new ``.topmsg`` file can be suppressed by using ``--no-edit``
961         (which does *NOT* suppress the automatic commit unless ``--no-commit``
962         is also given) or by providing an explicit value for the new
963         ``.topmsg`` file using the ``--topmsg`` or ``--topmsg-file`` option.
964         In any case the ``.topmsg`` content will be automatically reformated to
965         have a ``Subject:`` header line if needed.
967         If the ``format.signoff`` config variable (see ``git help config``)
968         has been set to true then the ``Signed-off-by:`` header line added to
969         the end of the initial version of the ``.topmsg`` file will be
970         uncommented by default.  Otherwise it will still be there but will be
971         commented out and will be automatically stripped if no action is taken
972         to remove the comment character.
974         If more than one dependency is listed an automatic ``tg update`` runs
975         after the branch has been created to merge in the additional
976         dependencies and bring the branch up-to-date.  This can be suppressed
977         with the ``--no-commit`` option (which also suppresses the initial
978         commit) or the ``--no-update`` option (which allows the initial commit
979         while suppressing only the update operation portion).
981         Previous versions of TopGit behaved as though both the ``--no-edit``
982         and ``--no-commit`` options were always given on the command line.
984         The default behavior has been changed to promote a separation between
985         commits that modify ``.topmsg`` and/or ``.topdeps`` and commits that
986         modify other files.  This facilitates cleaner cherry picking and other
987         patch maintenance activities.
989         You should edit the patch description (contained in the ``.topmsg``
990         file) as appropriate.  It will already contain some prefilled bits.
991         You can set the ``topgit.to``, ``topgit.cc`` and ``topgit.bcc``
992         git configuration variables (see ``git help config``) in order to
993         have ``tg create`` add these headers with the given default values
994         to ``.topmsg`` before invoking the editor.  If the configuration
995         variable ``topgit.subjectPrefix`` is set its value will be inserted
996         *between* the initial ``[`` and the word ``PATCH`` in the subject
997         line (with a space added before the word ``PATCH`` of course).
999         The main task of ``tg create`` is to set up the topic branch base
1000         from the dependencies.  This may fail due to merge conflicts if more
1001         than one dependency is given.   In that case, after you commit the
1002         conflict resolution, you should call ``tg update --continue`` to
1003         finish merging the dependencies into the new topic branch base.
1005         With the ``--base`` (aka ``--no-deps``) option at most one dependency
1006         may be listed which may be any valid committish (instead of just
1007         refs/heads/...) and the newly created TopGit-controlled branch will
1008         have an empty ``.topdeps`` file.  This may be desirable in order to
1009         create a TopGit-controlled branch that has no changes of its own and
1010         serves merely to mark the common dependency that all other
1011         TopGit-controlled branches in some set of TopGit-controlled branches
1012         depend on.  A plain, non-TopGit-controlled branch can be used for the
1013         same purpose, but the advantage of a TopGit-controlled branch with no
1014         dependencies is that it will be pushed with ``tg push``, it will show
1015         up in the ``tg summary`` and ``tg info`` output with the subject from
1016         its ``.topmsg`` file thereby documenting what it's for and finally it
1017         can be set up with ``tg create -r`` and/or ``tg remote --populate`` to
1018         facilitate sharing.
1020         For example, ``tg create --base t/release v2.1`` will create a TopGit-
1021         controlled ``t/release`` branch based off the ``v2.1`` tag that can then
1022         be used as a base for creation of other TopGit-controlled branches.
1023         Then when the time comes to move the base for an entire set of changes
1024         up to ``v2.2`` the command ``tg update --base t/release v2.2`` can be
1025         used followed by ``tg update --all``.
1027         Using ``--base`` it's also possible to use ``tg create`` on an
1028         unborn branch (omit the dependency name or specify ``HEAD``).  The
1029         unborn branch itself can be made into the new TopGit branch (rather
1030         than being born empty and then having the new TopGit branch based off
1031         that) by specifying ``HEAD`` as the new branch's name (which is
1032         probably what you normally want to do in this case anyway so you can
1033         just run ``tg create --base HEAD`` to accomplish that).
1035         In an alternative use case, if ``-r <branch>`` is given instead of a
1036         dependency list, the topic branch is created based on the given
1037         remote branch.  With just ``-r`` the remote branch name is assumed
1038         to be the same as the local topic branch being created.  Since no
1039         new commits are created in this mode (only two refs will be updated)
1040         the editor will never be run for this use case.  Note that no other
1041         options may be combined with ``-r``.
1043         The ``--quiet`` (or ``-q``) option suppresses most informational
1044         messages.
1046 tg delete
1047 ~~~~~~~~~
1048         Remove a TopGit-controlled topic branch of the given name
1049         (required argument). Normally, this command will remove only an
1050         empty branch (base == head) without dependents; use ``-f`` to
1051         remove a non-empty branch or a branch that is depended upon by
1052         another branch.
1054         The ``-f`` option is also useful to force removal of a branch's
1055         base, if you used ``git branch -D B`` to remove branch B, and then
1056         certain TopGit commands complain, because the base of branch B
1057         is still there.
1059         Normally ``tg delete`` will refuse to delete the current branch.
1060         However, giving ``-f`` twice (or more) will force it to do so but it
1061         will first detach your HEAD.
1063         IMPORTANT: Currently, this command will *NOT* remove the branch
1064         from the dependency list in other branches. You need to take
1065         care of this *manually*.  This is even more complicated in
1066         combination with ``-f`` -- in that case, you need to manually
1067         unmerge the removed branch's changes from the branches depending
1068         on it.
1070         The same ``--stash`` and ``--no-stash`` options are accepted with
1071         the same exact semantics as for `tg update`_.
1073         See also ``tg annihilate``.
1075         | TODO: ``-a`` to delete all empty branches, depfix, revert
1077 tg annihilate
1078 ~~~~~~~~~~~~~
1079         Make a commit on the current or given TopGit-controlled topic
1080         branch that makes it equal to its base, including the presence or
1081         absence of .topmsg and .topdeps.  Annihilated branches are not
1082         displayed by ``tg summary``, so they effectively get out of your
1083         way.  However, the branch still exists, and ``tg push`` will
1084         push it (except if given the ``-a`` option).  This way, you can
1085         communicate that the branch is no longer wanted.
1087         When annihilating a branch that has dependents (i.e. branches
1088         that depend on it), those dependents have the dependencies of
1089         the branch being annihilated added to them if they do not already
1090         have them as dependencies.  Essentially the DAG is repaired to
1091         skip over the annihilated branch.
1093         Normally, this command will remove only an empty branch
1094         (base == head, except for changes to the .top* files); use
1095         ``-f`` to annihilate a non-empty branch.
1097         After completing the annihilation itself, normally ``tg update``
1098         is run on any modified dependents.  Use the ``--no-update`` option
1099         to suppress running ``tg update``.
1101         The same ``--stash`` and ``--no-stash`` options are accepted with
1102         the same exact semantics as for `tg update`_.
1104 tg depend
1105 ~~~~~~~~~
1106         Change the dependencies of a TopGit-controlled topic branch.
1107         This should have several subcommands, but only ``add`` is
1108         supported right now.
1110         The ``add`` subcommand takes an argument naming a topic branch to
1111         be added, adds it to ``.topdeps``, performs a commit and then
1112         updates your topic branch accordingly.  If you want to do other
1113         things related to the dependency addition, like adjusting
1114         ``.topmsg``, use the option ``--no-commit``.  Adding the
1115         ``--no-update`` (or ``--no-commit``) option will suppress the
1116         ``tg update`` normally performed after committing the change.
1118         It is safe to run ``tg depend add`` in a dirty worktree, but the
1119         normally performed ``tg update`` will be suppressed in that case
1120         (even if neither ``--no-update`` nor ``--no-commit`` is given).
1122         You have enabled ``git rerere`` haven't you?
1124         | TODO: Subcommand for removing dependencies, obviously
1126 tg files
1127 ~~~~~~~~
1128         List files changed by the current or specified topic branch.
1130         Options:
1131           -i            list files based on index instead of branch
1132           -w            list files based on working tree instead of branch
1134 tg info
1135 ~~~~~~~
1136         Show summary information about the current or specified topic
1137         branch.
1139         Numbers in parenthesis after a branch name such as "(11/3 commits)"
1140         indicate how many commits on the branch (11) and how many of those
1141         are non-merge commits (3).
1143         With ``--verbose`` (or ``-v``) include a list of dependents (i.e. other
1144         branches that depend on this one).  Another ``--verbose`` annotates
1145         them with "[needs merge]" if the current tip of branch for which info
1146         is being shown has not yet been merged into the base of the dependent.
1147         Two ``--verbose`` options also cause annihilated dependencies to be
1148         shown in the "Depends:" list.
1150         Alternatively, if ``--heads`` is used then which of the independent
1151         TopGit branch heads (as output by ``tg summary --topgit-heads``)
1152         logically contains the specified commit (which may be any committish --
1153         defaults to ``HEAD`` if not given).  Zero or more results will be
1154         output.  Note that "logically" means with regard to the TopGit
1155         dependency relationships as established by the ``.topdeps`` file(s).
1156         It's the answer that would be given when all the TopGit branches are
1157         up-to-date (even though they need not be to use this option) and the
1158         ``git branch --contains`` command is run and the output then filtered
1159         to only those branches that appear in ``tg summary --topgit-heads``.
1160         This computation may require several seconds on complex repositories.
1162         If ``--leaves`` is used then the unique list of leaves of the current
1163         or specified topic branch is shown as one fully-qualified ref per line.
1164         Duplicates are suppressed and a tag name will be used when appropriate.
1165         A "leaf" is any dependency that is either not a TopGit branch or is
1166         the base of a non-annihilated TopGit branch with no non-annihilated
1167         dependencies.
1169         The ``--deps`` option shows non-annihilated TopGit dependencies of the
1170         specified branch (default is ``HEAD``).  (It can also be spelled out
1171         as ``--dependencies`` for the pedantically inclined.)
1173         The ``--dependents`` option shows non-annihilated TopGit dependents
1174         (i.e. branches that depend on the specified branch).  The default
1175         branch to operate on is again ``HEAD``.
1177         A linearized patch series can only be automatically created for a
1178         TopGit topic branch (including its recursive dependencies) when exactly
1179         one line is output by ``tg info --leaves <topic-branch>``.
1181         With ``--series`` the list of TopGit branches in the order they would
1182         be linearized into a patch series is shown along with the description
1183         of each branch.  If the branch name passed to ``tg info`` is not the
1184         last branch in the series a marker column will be provided to quickly
1185         locate it in the list.  This same option can be used with `tg checkout`_.
1187         Some patches shown in the list may not actually end up introducing any
1188         changes if exported and will therefore end up being omitted.  The ``0``
1189         indicator in ``tg summary`` output can help to identify some of these.
1191         The patches shown in the series in the order they are shown form the
1192         basis for the ``tg next`` and ``tg prev`` operations with the first
1193         patch shown being considered the first and so on up to the last.
1195         Options:
1196           -i            Use TopGit metadata from the index instead of the branch
1197           -w            Use TopGit metadata from the working tree instead of the branch
1199 tg patch
1200 ~~~~~~~~
1201         Generate a patch from the current or specified topic branch.
1202         This means that the diff between the topic branch base and head
1203         (latest commit) is shown, appended to the description found in
1204         the ``.topmsg`` file.
1206         The patch is simply dumped to stdout.  In the future, ``tg patch``
1207         will be able to automatically send the patches by mail or save
1208         them to files. (TODO)
1210         Options:
1211           -i            base patch generation on index instead of branch
1212           -w            base patch generation on working tree instead of branch
1213           --binary      pass --binary to ``git diff-tree`` to enable generation
1214                         of binary patches
1215           --quiet       be quiet (aka ``-q``) about missing and unfixed From:
1216           --from        make sure patch has a From: line, if not add one
1217           --from=<a>    <a> or Signed-off-by value or ident value; ``git am``
1218                         really gets unhappy with patches missing From: lines;
1219                         will NOT replace an existing non-empty From: header
1220           --no-from     leave all From: lines alone, missing or not (default)
1221           --diff-opt    options after the branch name (and an optional ``--``)
1222                         are passed directly to ``git diff-tree``
1224         In order to pass a sole explicit ``-w`` through to ``git diff-tree`` it
1225         must be separated from the ``tg`` options by an explicit ``--``.
1226         Or it can be spelled as ``--ignore-all-space`` to distinguuish it from
1227         ``tg``'s ``-w`` option.
1229         If the config variable ``topgit.from`` is set to a boolean it can be
1230         used to enable or disable the ``--from`` option by default.  If it's
1231         set to the special value ``quiet`` the ``--quiet`` option is enabled
1232         and From: lines are left alone by default.  Any other non-empty value
1233         is taken as a default ``--from=<value>`` option.  The ``--no-from``
1234         option will temporarily disable use of the config value.
1236         If additional non-``tg`` options are passed through to
1237         ``git diff-tree`` (other than ``--binary`` which is fully supported)
1238         the resulting ``tg patch`` output may not be appliable.
1240 tg mail
1241 ~~~~~~~
1242         Send a patch from the current or specified topic branch as
1243         email(s).
1245         Takes the patch given on the command line and emails it out.
1246         Destination addresses such as To, Cc and Bcc are taken from the
1247         patch header.
1249         Since it actually boils down to ``git send-email``, please refer
1250         to the documentation for that for details on how to setup email
1251         for git.  You can pass arbitrary options to this command through
1252         the ``-s`` parameter, but you must double-quote everything.  The
1253         ``-r`` parameter with a msgid can be used to generate in-reply-to
1254         and reference headers to an earlier mail.
1256         WARNING: be careful when using this command.  It easily sends
1257         out several mails.  You might want to run::
1259                 git config sendemail.confirm always
1261         to let ``git send-email`` ask for confirmation before sending any
1262         mail.
1264         Options:
1265           -i            base patch generation on index instead of branch
1266           -w            base patch generation on working tree instead of branch
1268         | TODO: ``tg mail patchfile`` to mail an already exported patch
1269         | TODO: mailing patch series
1270         | TODO: specifying additional options and addresses on command line
1272 tg remote
1273 ~~~~~~~~~
1274         Register the given remote as TopGit-controlled. This will create
1275         the namespace for the remote branch bases and teach ``git fetch``
1276         to operate on them. However, from TopGit 0.8 onwards you need to
1277         use ``tg push``, or ``git push --mirror``, for pushing
1278         TopGit-controlled branches.
1280         ``tg remote`` takes an optional remote name argument, and an
1281         optional ``--populate`` switch.  Use ``--populate`` for your
1282         origin-style remotes: it will seed the local topic branch system
1283         based on the remote topic branches.  ``--populate`` will also make
1284         ``tg remote`` automatically fetch the remote, and ``tg update`` look
1285         at branches of this remote for updates by default.
1287         Using ``--populate`` with a remote name causes the ``topgit.remote``
1288         git configuration variable to be set to the given remote name.
1290 tg summary
1291 ~~~~~~~~~~
1292         Show overview of all TopGit-tracked topic branches and their
1293         up-to-date status.  With a branch name limit output to that branch.
1294         Using ``--deps-only`` or ``--rdeps`` changes the default from all
1295         branches to just the current ``HEAD`` branch but using ``--all`` as
1296         the branch name will show results for all branches instead of ``HEAD``.
1298                 ``>``
1299                         marks the current topic branch
1301                 ``0``
1302                         indicates that it introduces no changes of its own
1304                 ``l``/``r``
1305                         indicates respectively whether it is local-only
1306                         or has a remote mate
1308                 ``L``/``R``
1309                         indicates respectively if it is ahead or out-of-date
1310                         with respect to its remote mate
1312                 ``D``
1313                         indicates that it is out-of-date with respect to its
1314                         dependencies
1316                 ``!``
1317                         indicates that it has missing dependencies [even if
1318                         they are recursive ones]
1320                 ``B``
1321                         indicates that it is out-of-date with respect to
1322                         its base
1324                 ``*``
1325                         indicates it is ahead of (and needs to be merged into)
1326                         at least one of its dependents -- only computed when
1327                         showing all branches or using the (possibly implied)
1328                         ``--with-deps`` option.
1330         This can take a longish time to accurately determine all the
1331         relevant information about each branch; you can pass ``-t`` (or ``-l``
1332         or ``--list``) to get just a terse list of topic branch names quickly.
1333         Also adding ``--verbose`` (or ``-v``) includes the subjects too.
1334         Adding a second ``--verbose`` includes annihilated branches as well.
1336         Passing ``--heads`` shows independent topic branch names and when
1337         combined with ``--rdeps`` behaves as though ``--rdeps`` were run with
1338         the output of ``--heads``.
1340         The ``--heads-independent`` option works just like ``--heads`` except
1341         that it computes the heads using ``git merge-base --independent``
1342         rather than examining the TopGit ``.topdeps`` relationships.  If the
1343         TopGit branches are all up-to-date (as shown in ``tg summary``) then
1344         both ``--heads`` and ``--heads-independent`` should compute the same
1345         list of heads (unless some overlapping TopGit branches have been
1346         manually created).  If not all the TopGit branches are up-to-date then
1347         the ``--heads-independent`` results may have extra items in it, but
1348         occasionally that's what's needed; usually it's the wrong answer.
1349         (Note that ``--topgit-heads`` is accepted as an alias for ``--heads``
1350         as well.)
1352         Using ``--heads-only`` behaves as though the output of ``--heads`` was
1353         passed as the list of branches along with ``--without-deps``.
1355         Alternatively, you can pass ``--graphviz`` to get a dot-suitable output
1356         for drawing a dependency graph between the topic branches.
1358         You can also use the ``--sort`` option to sort the branches using
1359         a topological sort.  This is especially useful if each
1360         TopGit-tracked topic branch depends on a single parent branch,
1361         since it will then print the branches in the dependency order.
1362         In more complex scenarios, a text graph view would be much more
1363         useful, but that has not yet been implemented.
1365         The ``--deps`` option outputs dependency information between
1366         branches in a machine-readable format.  Feed this to ``tsort`` to
1367         get the output from --sort.
1369         The ``--deps-only`` option outputs a sorted list of the unique branch
1370         names given on the command line plus all of their recursive
1371         dependencies (subject to ``--exclude`` of course).  When
1372         ``--deps-only`` is given the default is to just display information for
1373         ``HEAD``, but that can be changed by using ``--all`` as the branch
1374         name.  Each branch name will appear only once in the output no matter
1375         how many times it's visited while tracing the dependency graph or how
1376         many branch names are given on the command line to process.
1378         The ``--rdeps`` option outputs dependency information in an indented
1379         text format that clearly shows all the dependencies and their
1380         relationships to one another.  When ``--rdeps`` is given the default is
1381         to just display information for ``HEAD``, but that can be changed by
1382         using ``--all`` as the branch name or by adding the ``--heads`` option.
1383         Note that ``tg summary --rdeps --heads`` can be particularly helpful in
1384         seeing all the TopGit-controlled branches in the repository and their
1385         relationships to one another.
1387         Note that ``--rdeps`` has two flavors.  The first (and default) is
1388         ``--rdeps-once`` which only shows the dependencies of a branch when
1389         it's first visited.  For example, if D depends on several other
1390         branches perhaps recursively and both branch A and B depend on D, then
1391         whichever of A or B is shown first will show the entire dependency
1392         chain for D underneath it and the other one will just show a line for
1393         D itself with a "^" appended to indicate that the rest of the deps for
1394         D can be found above.  This can make the output a bit more compact
1395         without actually losing any information which is why it's the default.
1396         However, using the ``--rdeps-full`` variant will repeat the full
1397         dependency chain every time it's encountered.
1399         Adding ``--with-deps`` replaces the given list of branches (which will
1400         default to ``HEAD`` if none are given) with the result of running
1401         ``tg summary --deps-only --tgish`` on the list of branches.  This can
1402         be helpful in limiting ``tg summary`` output to only the list of given
1403         branches and their dependencies when many TopGit-controlled branches
1404         are present in the repository.  Use ``--without-deps`` to switch back
1405         to the old behavior.
1407         The ``--with-related`` option extends (and therefore implies)
1408         ``--with-deps``.  First the list of branches (which will default to
1409         ``HEAD`` if none are given) is replaced with the result of running
1410         ``tg summary --heads`` (aka ``--topgit-heads``) and the result is then
1411         processed as though it had been specified using ``--with-deps``.
1413         When it would be allowed, ``--with-deps`` is now the default.  But,
1414         if in addition, exactly one branch is specified (either explicitly
1415         or implicitly) and it's spelled *exactly* as ``HEAD`` or ``@`` then
1416         the default ``--with-deps`` will be promoted to a default
1417         ``--with-related`` instead.  Since duplicate branches are removed
1418         before processing, explicitly listing ``@`` twice provides an easy way
1419         to defeat this automatic promotion and ask for ``--with-deps`` on the
1420         ``HEAD`` symbolic ref with minimal typing when ``--with-related`` isn't
1421         really wanted and typing the full ``--with-deps`` option is too hard.
1423         With ``--exclude branch``, branch can be excluded from the output
1424         meaning it will be skipped and its name will be omitted from any
1425         dependency output.  The ``--exclude`` option may be repeated to omit
1426         more than one branch from the output.  Limiting the output to a single
1427         branch that has been excluded will result in no output at all.
1429         The ``--tgish-only`` option behaves as though any non-TopGit-controlled
1430         dependencies encountered during processing had been listed after an
1431         ``--exclude`` option.
1433         Note that the branch name can be specified as ``HEAD`` or ``@`` as a
1434         shortcut for the TopGit-controlled branch that ``HEAD`` is a
1435         symbolic ref to.  The ``tg summary @`` and ``tg summary @ @`` commands
1436         can be quite useful.
1438         Options:
1439           -i            Use TopGit metadata from the index instead of the branch
1440           -w            Use TopGit metadata from the working tree instead of the branch
1442 tg contains
1443 ~~~~~~~~~~~
1444         Search all TopGit-controlled branches (and optionally their remotes)
1445         to find which TopGit-controlled branch contains the specified commit.
1447         This is more than just basic branch containment as provided for by the
1448         ``git branch --contains`` command.  While the shown branch name(s)
1449         will, indeed, be one (or more) of those output by the
1450         ``git branch --contains`` command, the result(s) will exclude any
1451         TopGit-controlled branches from the result(s) that have one (or more)
1452         of their TopGit dependencies (either direct or indirect) appearing in
1453         the ``git branch --contains`` output.
1455         Normally the result will be only the one, single TopGit-controlled
1456         branch for which the specified committish appears in the ``tg log``
1457         output for that branch (unless the committish lies outside the
1458         TopGit-controlled portion of the DAG and ``--no-strict`` was used).
1460         Unless ``--annihilated-okay`` (or ``--ann`` or ``--annihilated``) is
1461         used then annihilated branches will be immediately removed from the
1462         ``git branch --contains`` output before doing anything else.  This
1463         means a committish that was originally located in a now-annihilated
1464         branch will show up in whatever branch picked up the annihilated
1465         branch's changes (if there is one).  This is usually the correct
1466         answer, but occasionally it's not; hence this option.  If this option
1467         is used together with ``--verbose`` then annihilated branches will
1468         be shown as "[:annihilated:]".
1470         In other words, if a ``tg patch`` is generated for the found branch
1471         (assuming one was found and a subsequent commit in the same branch
1472         didn't then revert or otherwise back out the change), then that patch
1473         will include the changes introduced by the specified committish
1474         (unless, of course, that committish is outside the TopGit-controlled
1475         portion of the DAG and ``--no-strict`` was given).
1477         This can be very helpful when, for example, a bug is discovered and
1478         then after using ``git bisect`` (or some other tool) to find the
1479         offending commit it's time to commit the fix.  But because the
1480         TopGit merging history can be quite complicated and maybe the one
1481         doing the fix wasn't the bug's author (or the author's memory is just
1482         going), it can sometimes be rather tedious to figure out which
1483         TopGit branch the fix belongs in.  The ``tg contains`` command can
1484         quickly tell you the answer to that question.
1486         With the ``--remotes`` (or ``-r``) option a TopGit-controlled remote
1487         branch name may be reported as the result but only if there is no
1488         non-remote branch containing the committish (this can only happen
1489         if at least one of the TopGit-controlled local branches are not yet
1490         up-to-date with their remotes).
1492         With the ``--verbose`` option show which TopGit DAG head(s) (one or
1493         more of the TopGit-controlled branch names output by
1494         ``tg summary --heads``) have the result as a dependency (either direct
1495         or indirect).  Using this option will noticeably increase running time.
1497         With the default ``--strict`` option, results for which the base of the
1498         TopGit-controlled branch contains the committish will be suppressed.
1499         For example, if the committish was deep-down in the master branch
1500         history somewhere far outside of the TopGit-controlled portion of
1501         the DAG, with ``--no-strict``, whatever TopGit-controlled branch(es)
1502         first picked up history containing that committish will be shown.
1503         While this is a useful result it's usually not the desired result
1504         which is why it's not the default.
1506         To summarize, even with ``--remotes``, remote results are only shown
1507         if there are no non-remote results.  Without ``--no-strict`` (because
1508         ``--strict`` is the default) results outside the TopGit-controlled
1509         portion of the DAG are never shown and even with ``--no-strict`` they
1510         will only be shown if there are no ``--strict`` results.  Finally,
1511         the TopGit head info shown with ``--verbose`` only ever appears for
1512         local (i.e. not a remote branch) results.  Annihilated branches are
1513         never considered possible matches without ``--annihilated-okay``.
1515 tg checkout
1516 ~~~~~~~~~~~
1517         Switch to a topic branch.  You can use ``git checkout <branch>``
1518         to get the same effect, but this command helps you navigate
1519         the dependency graph, or allows you to match the topic branch
1520         name using a regular expression, so it can be more convenient.
1522         The ``--branch`` (or ``-b`` or ``--branch=<name>``) option changes
1523         the default starting point from ``HEAD`` to the specified branch.
1525         For the "next" and "previous" commands, the ``<steps>`` value may
1526         be ``--all`` (or ``-a``) to take "As many steps As possible" or
1527         "step ALL the way" or "ALL steps at once" (or make something better
1528         up yourself).
1530         The following subcommands are available:
1532             ``tg checkout next [<steps>]``
1533                                 Check out a branch that directly
1534                                 depends on your current branch.
1535                                 Move ``<steps>`` (default 1) step(s) in
1536                                 the "next" direction (AKA ``n``).
1538             ``tg checkout prev [<steps>]``
1539                                 Check out a branch that this branch
1540                                 directly depends on.  Move ``<steps>``
1541                                 (default 1) step(s) in the "previous"
1542                                 direction (AKA ``p`` or ``previous``).
1544             ``tg checkout [goto] [--] <pattern>``
1545                                 Check out a topic branch that
1546                                 matches ``<pattern>``.  ``<pattern>``
1547                                 is used as a grep ERE pattern to filter
1548                                 all the topic branches.  Both ``goto`` and
1549                                 ``--`` may be omitted provided ``<pattern>``
1550                                 is not ``-a``, ``--all``, ``-h``, ``--help``,
1551                                 ``goto``, ``--``, ``n``, ``next``, ``push``,
1552                                 ``child``, ``p``, ``prev``, ``previous``,
1553                                 ``pop``, ``parent``, ``+``, ``-`` or ``..``.
1555             ``tg checkout [goto] [--] --series[=<head>]``
1556                                 Check out a topic branch that belongs to
1557                                 the current (or ``<head>``) patch series.
1558                                 A list with descriptions (``tg info --series``)
1559                                 will be shown to choose from if more than one.
1561             ``tg checkout + [<steps>]``
1562                                 An alias for ``next``.
1564             ``tg checkout push [<steps>]``
1565                                 An alias for ``next``.
1567             ``tg checkout child [<steps>]``
1568                                 Deprecated alias for ``next``.
1570             ``tg checkout``
1571                                 Semi-deprecated alias for ``next``.
1573             ``tg checkout - [<steps>]``
1574                                 An alias for ``prev``.
1576             ``tg checkout pop [<steps>]``
1577                                 An alias for ``prev``.
1579             ``tg checkout parent [<steps>]``
1580                                 Deprecated alias for ``prev``.
1582             ``tg checkout .. [<steps>]``
1583                                 Semi-deprecated alias for ``prev``.
1585         If any of the above commands can find more than one possible
1586         branch to switch to, you will be presented with the matches
1587         and asked to select one of them.
1589         Note that unless overridden by an explicit alias (see ALIASES_),
1590         ``tg goto`` is an implicit alias for ``tg checkout goto``.
1592         If the ``--ignore-other-worktrees`` (or ``--iow``) option is given and
1593         the current Git version is at least 2.5.0 then the full
1594         ``--ignore-other-worktrees`` option will be passed along to the
1595         ``git checkout`` command when it's run (otherwise the option will be
1596         silently ignored and not passed to Git as it would cause an error).
1598         The ``--force`` (or ``-f``) option, when given, gets passed through to
1599         the ``git checkout`` command.
1601         The ``--merge`` (or ``-m``) option, when given, gets passed through to
1602         the ``git checkout`` command.
1604         The ``--quiet`` (or ``-q``) option, when given, gets passed through to
1605         the ``git checkout`` command.
1607         The ``<pattern>`` of ``tg checkout goto`` is optional.  If you don't
1608         supply it, all the available topic branches are listed and you
1609         can select one of them.
1611         Normally, the ``next`` and ``prev`` commands move one step in
1612         the dependency graph of the topic branches.  The ``-a`` option
1613         causes them (and their aliases) to move as far as possible.
1614         That is, ``tg checkout next -a`` moves to a topic branch that
1615         depends (directly or indirectly) on the current branch and
1616         that no other branch depends on.  ``tg checkout prev -a``
1617         moves to a topic branch that the current topic branch
1618         depends on (directly or indirectly).  If there is more than
1619         one possibility, you will be prompted for your selection.
1621         See also NAVIGATION_.
1623 tg export
1624 ~~~~~~~~~
1625         Export a tidied-up history of the current topic branch and its
1626         dependencies, suitable for feeding upstream.  Each topic branch
1627         corresponds to a single commit or patch in the cleaned up
1628         history (corresponding basically exactly to ``tg patch`` output
1629         for the topic branch).
1631         The command has three possible outputs now -- either a Git branch
1632         with the collapsed history, a Git branch with a linearized
1633         history, or a quilt series in new directory.
1635         In the case where you are producing collapsed history in a new
1636         branch, you can use this collapsed structure either for
1637         providing a pull source for upstream, or for further
1638         linearization e.g. for creation of a quilt series using git log::
1640                 git log --pretty=email -p --topo-order origin..exported
1642         To better understand the function of ``tg export``, consider this
1643         dependency structure::
1645          origin/master - t/foo/blue - t/foo/red - master
1646                       `- t/bar/good <,----------'
1647                       `- t/baz      ------------'
1649         (where each of the branches may have a hefty history). Then::
1651          master$ tg export for-linus
1653         will create this commit structure on the branch ``for-linus``::
1655          origin/master - t/foo/blue -. merge - t/foo/red -.. merge - master
1656                       `- t/bar/good <,-------------------'/
1657                       `- t/baz      ---------------------'
1659         In this mode, ``tg export`` works on the current topic branch, and
1660         can be called either without an option (in that case,
1661         ``--collapse`` is assumed), or with the ``--collapse`` option, and
1662         with one mandatory argument: the name of the branch where the
1663         exported result will be stored.
1665         Both the ``--collapse`` and ``--linearize`` modes also accept a
1666         ``-s <mode>`` option to specify subject handling behavior for the
1667         freshly created commits.  There are five possible modes:
1669                 :keep:          Like ``git mailinfo -k``
1670                 :mailinfo:      Like ``git mailinfo``
1671                 :patch:         Remove first [PATCH*] if any
1672                 :topgit:        Remove first [PATCH*], [BASE], [ROOT] or [STAGE]
1673                 :trim:          Trim runs of spaces/tabs to a single space
1675         The ``topgit`` (aka ``tg``) mode is the default (quelle surprise) and
1676         like the ``patch`` mode will only strip the first square brackets tag
1677         (if there is one) provided it's a TopGit-known tag (the ``patch``
1678         variation will only strip a "[PATCH*]" tag but still just the first
1679         one).  Note that TopGit does understand "[RELEASE]" in ``topgit`` mode.
1680         With ``trim`` (aka ``ws``) internal runs of spaces/tabs are converted
1681         to a single space, but no square brackets tags are removed.  The ``ws``
1682         mode should generally be preferred instead of using ``keep`` mode.
1683         All modes always remove leading/trailing spaces and tabs and if the
1684         ``topgit.subjectPrefix`` value (see `tg create`_) has been set both the
1685         ``topgit`` and ``patch`` modes will match tags with that prefix too.
1687         Setting the config variable ``topgit.subjectMode`` to one of the mode
1688         values shown above will change the default to that mode.
1690         Both the ``--collapse`` and ``--linearize`` modes also accept a
1691         ``--notes[=<ref>]`` option to export the portion of the .topmsg file
1692         following a ``---`` separator line to the specified notes ref.  If
1693         ``<ref>`` is omitted then ``refs/notes/commits`` will be used.  If
1694         ``<ref>`` does not start with ``refs/notes/`` then ``refs/notes/``
1695         will be prepended unless it starts with ``notes/`` in which case
1696         only ``refs/`` will be prepended.
1698         Setting the config variable ``topgit.notesExport`` to a boolean or
1699         to a ``<ref>`` name will set the default for the ``--notes`` option
1700         (with no config or ``--notes[=<ref>]`` option the ``---`` comment is
1701         discarded by default).  To override a ``topgit.notesExport`` option
1702         and discard any ``---`` comments, use ``--no-notes``.
1704         When using the linearize mode::
1706          master$ tg export --linearize for-linus
1708         you get a linear history respecting the dependencies of your
1709         patches in a new branch ``for-linus``.  The result should be more
1710         or less the same as using quilt mode and then reimporting it
1711         into a Git branch.  (More or less because the topological order
1712         can usually be extended in more than one way into a total order,
1713         and the two methods may choose different ones.)  The result
1714         might be more appropriate for merging upstream, as it contains
1715         fewer merges.
1717         Note that you might get conflicts during linearization because
1718         the patches are reordered to get a linear history.  If linearization
1719         would produce conflicts then using ``--quilt`` will also likely result
1720         in conflicts when the exported quilt series is applied.  Since the
1721         ``--quilt`` mode simply runs a series of ``tg patch`` commands to
1722         generate the patches in the exported quilt series and those patches
1723         will end up being applied linearly, the same conflicts that would be
1724         produced by the ``--linearize`` option will then occur at that time.
1726         To avoid conflicts produced by ``--linearize`` (or by applying the
1727         ``--quilt`` output), use the default ``--collapse`` mode and then use
1728         ``tg rebase`` (or ``git rebase -m`` directly) on the collapsed branch
1729         (with a suitable <upstream>) followed by ``git format-patch`` on the
1730         rebased result to produce a conflict-free patch set.  A suitable
1731         upstream may be determined with the ``tg info --leaves`` command (if
1732         it outputs more than one line, linearization will be problematic).
1734         You have enabled ``git rerere`` haven't you?
1736         When using the quilt mode::
1738          master$ tg export --quilt for-linus
1740         would create the following directory ``for-linus``::
1742          for-linus/t/foo/blue.diff
1743          for-linus/t/foo/red.diff
1744          for-linus/t/bar/good.diff
1745          for-linus/t/baz.diff
1746          for-linus/series:
1747                 t/foo/blue.diff -p1
1748                 t/bar/good.diff -p1
1749                 t/foo/red.diff -p1
1750                 t/baz.diff -p1
1752         With ``--quilt``, you can also pass the ``-b`` parameter followed
1753         by a comma-separated explicit list of branches to export, or
1754         the ``--all`` parameter (which can be shortened to ``-a``) to
1755         export them all.  The ``--binary`` option enables producing Git
1756         binary patches.  These options are currently only supported
1757         with ``--quilt``.
1759         In ``--quilt`` mode the patches are named like the originating
1760         topgit branch.  So usually they end up in subdirectories of the
1761         output directory.  With the ``--flatten`` option the names are
1762         mangled so that they end up directly in the output dir (slashes
1763         are replaced with underscores).  With the ``--strip[=N]`` option
1764         the first ``N`` subdirectories (all if no ``N`` is given) get
1765         stripped off.  Names are always ``--strip``'d before being
1766         ``--flatten``'d.  With the option ``--numbered`` (which implies
1767         ``--flatten``) the patch names get a number as prefix to allow
1768         getting the order without consulting the series file, which
1769         eases sending out the patches.
1771         Note that ``tg export`` is fully compatible with the `wayback machine`_
1772         and when used with the ``--collapse`` or ``--linearize`` options will
1773         "push" the resulting branch back into the main repository when used in
1774         wayback mode.
1776         | TODO: Make stripping of non-essential headers configurable
1777         | TODO: ``--mbox`` option to export instead as an mbox file
1778         | TODO: support ``--all`` option in other modes of operation
1779         | TODO: For quilt exporting, export the linearized history created in
1780                 a temporary branch--this would allow producing conflict-less
1781                 series
1783 tg import
1784 ~~~~~~~~~
1785         Import commits within the given revision range(s) into TopGit,
1786         creating one topic branch per commit. The dependencies are set
1787         up to form a linear sequence starting on your current branch --
1788         or a branch specified by the ``-d`` parameter, if present.
1790         The branch names are auto-guessed from the commit messages and
1791         prefixed by ``t/`` by default; use ``-p <prefix>`` to specify an
1792         alternative prefix (even an empty one).
1794         Each "<range>" must be of the form <rev1>..<rev2> where either
1795         <rev1> or <rev2> can be omitted to mean HEAD.  Additionally the
1796         shortcut <rev>^! (see ``git help revisions``) is permitted as a
1797         "<range>" to select the single commit <rev> but only if the
1798         commit <rev> has *exactly* one parent.  This is really just a
1799         shortcut for <rev>^..<rev> but somewhat safer since it will fail
1800         if <rev> has other than one parent.
1802         Alternatively, you can use the ``-s NAME`` parameter to specify
1803         the name of the target branch; the command will then take one
1804         more argument describing a *single* commit to import which must
1805         not be a merge commit.
1807         Use the ``--notes[=<ref>]`` option to import the ``git notes``
1808         associated with the commit being imported to the .topmsg file -- if
1809         non-empty notes are present, they will be appended to the generated
1810         .topmsg file preceded by a ``---`` separator line.  If ``<ref>`` is
1811         omitted then ``refs/notes/commits`` will be used.  If ``<ref>``
1812         does not start with ``refs/notes/`` then ``refs/notes/`` will be
1813         prepended unless it starts with ``notes/`` in which case only
1814         ``refs/`` will be prepended.
1816         Setting the config variable ``topgit.notesImport`` to a boolean or
1817         to a ``<ref>`` name will set the default for the ``--notes`` option
1818         (with no config or ``--notes[=<ref>]`` option no ``---`` comment is
1819         added to the generated .topmsg file by default).  To override a
1820         ``topgit.notesImport`` option and not add any ``---`` comments, use
1821         ``--no-notes``.
1823 tg update
1824 ~~~~~~~~~
1825         Update the current, specified or all topic branches with respect
1826         to changes in the branches they depend on and remote branches.
1827         This is performed in two phases -- first, changes within the
1828         dependencies are merged to the base, then the base is merged
1829         into the topic branch.  The output will guide you on what to do
1830         next in case of conflicts.
1832         You have enabled ``git rerere`` haven't you?
1834         Remember the default expiration time for resolved merge conflicts is
1835         only 60 days.  Increase their longevity by setting the Git
1836         configuration variable ``gc.rerereResolved`` to a higher number such
1837         as ``9999`` like so::
1839                 git config --global gc.rerereResolved 9999
1841         The ``--[no-]auto[-update]`` options together with the
1842         ``topgit.setAutoUpdate`` config item control whether or not TopGit
1843         will automatically temporarily set ``rerere.autoUpdate`` to true while
1844         running ``tg update``.  The default is true.  Note that this does not
1845         enable Git's ``rerere`` feature, it merely makes it automatically stage
1846         any previously resolved conflicts.  The ``rerere.enabled`` setting must
1847         still be separately enabled (i.e. set to ``true``) for the ``rerere``
1848         feature to do anything at all.
1850         Using ``--auto[-update]`` makes ``tg update`` always temporarily set
1851         ``rerere.autoUpdate`` to ``true`` while running ``tg update``.  The
1852         ``--no-auto[-update]`` option prevents ``tg update`` from changing the
1853         ``rerere.autoUpdate`` setting, but if ``rerere.autoUpdate`` has already
1854         been enabled in a config file, ``tg update`` never disables it even
1855         with ``--no-auto``.  If ``topgit.setAutoUpdate`` is unset or set to
1856         ``true`` then ``tg update`` implicitly does ``--auto``, otherwise it
1857         does ``--no-auto``.  An explicit command line ``--[no-]auto[-update]``
1858         option causes the ``topgit.setAutoUpdate`` setting to be ignored.
1860         When both ``rerere.enabled`` and ``rerere.autoUpdate`` are set to true
1861         then ``tg update`` will be able to automatically continue an update
1862         whenever ``git rerere`` resolves all the conflicts during a merge.
1863         This can be such a huge time saver.  That's why the default is to have
1864         TopGit automatically set ``rerere.autoUpdate`` to true while
1865         ``tg update`` is running (but remember, unless ``rerere.enabled`` has
1866         been set to ``true`` it won't make any difference).
1868         When ``-a`` (or ``--all``) is specified, updates all topic branches
1869         matched by ``<pattern>``'s (see ``git-for-each-ref(1)`` for details),
1870         or all if no ``<pattern>`` is given.  Any topic branches with missing
1871         dependencies will be skipped entirely unless ``--skip-missing`` is
1872         specified.
1874         When ``--skip-missing`` is specified, an attempt is made to update topic
1875         branches with missing dependencies by skipping only the dependencies
1876         that are missing.  Caveat utilitor.
1878         When ``--stash`` is specified (or the ``topgit.autostash`` config
1879         value is set to ``true``), a ref stash will be automatically created
1880         just before beginning updates if any are needed.  The ``--no-stash``
1881         option may be used to disable a ``topgit.autostash=true`` setting.
1882         See the ``tg tag`` ``--stash`` option for details.
1884         After the update, the branch which was current at the beginning of the
1885         update is returned to.
1887         If your dependencies are not up-to-date, ``tg update`` will first
1888         recurse into them and update them.
1890         If a remote branch update brings in dependencies on branches
1891         that are not yet instantiated locally, you can either bring
1892         in all the new branches from the remote using
1893         ``tg remote --populate``, or only pick out the missing ones using
1894         ``tg create -r`` (``tg summary`` will point out branches with incomplete
1895         dependencies by showing an ``!`` next to them).  TopGit will attempt to
1896         instantiate just the missing ones automatically for you, if possible,
1897         when ``tg update`` merges in the new dependencies from the remote.
1899         Using the alternative ``--base`` mode, ``tg update`` will update
1900         the base of a specified ``[BASE]`` branch (which is a branch created
1901         by ``tg create`` using the ``--base`` option) to the specified
1902         committish (the second argument) and then immediately merge that into
1903         the branch itself using the specified message for the merge commit.
1904         If no message is specified on the command line, an editor will open.
1905         Unless ``--force`` is used the new value for the base must contain
1906         the old value (i.e. be a fast-forward update).  This is for safety.
1908         This mode makes updates to ``[BASE]`` branches quick and easy.
1910         | TODO: ``tg update -a -c`` to autoremove (clean) up-to-date branches
1912 tg push
1913 ~~~~~~~
1914         If ``-a`` or ``--all`` was specified, pushes all non-annihilated
1915         TopGit-controlled topic branches, to a remote repository.
1916         Otherwise, pushes the specified topic branches -- or the
1917         current branch, if you don't specify which.  By default, the
1918         remote gets all the dependencies (both TopGit-controlled and
1919         non-TopGit-controlled) and bases pushed to it too.  If
1920         ``--tgish-only`` was specified, only TopGit-controlled
1921         dependencies will be pushed, and if ``--no-deps`` was specified,
1922         no dependencies at all will be pushed.
1924         All TopGit branches to be pushed must be up-to-date unless the
1925         ``--allow-outdated`` option is given.  Branches *are* checked against
1926         the configured TopGit remote (``topgit.remote``) if it's set (as
1927         modified by the global ``-u`` and ``-r <remote>`` options).
1929         The ``--dry-run``, ``--force``, ``--atomic``, ``--follow-tags``,
1930         ``--no-follow-tags``, ``--signed[=...]``, ``-4`` and ``-6`` options
1931         are passed through directly to ``git push`` if given.
1933         The push remote may be specified with the ``-r`` option. If no remote
1934         was specified, the configured default TopGit push remote will be
1935         used (``topgit.pushRemote``) or if that's unset the regular remote
1936         (``topgit.remote``).
1938         Note that when pushing to a configured Git remote (i.e. it appears in
1939         the ``git remote`` output) that appears to have local tracking branches
1940         set up for the remote TopGit branches and/or TopGit bases, ``tg push``
1941         will attempt to make sure the local tracking branches are updated to
1942         reflect the result of a successful ``tg push``.  This is the same as
1943         the normal Git behavior except that ``tg push`` will always attempt to
1944         make sure that *both* the local tracking branches for the remote TopGit
1945         branches *and* their bases are always updated together even if the
1946         configured Git remote only has a ``fetch`` refspec for one of them.  If
1947         the remote branches are being tracked by the configured Git remote in a
1948         non-standard local tracking branch location, it may be necessary to
1949         issue a subsequent ``git fetch`` on that remote after a successful
1950         ``tg push`` in order for them to be updated to reflect the ``tg push``.
1952         Use something like this to push to an ``origin`` remote when it's set
1953         as ``topgit.remote`` while only checking for local out-of-dateness:
1955             ``tg -u push -r origin <optional-branch-names-here>``
1957 tg base
1958 ~~~~~~~
1959         Prints the base commit of each of the named topic branches, or
1960         the current branch if no branches are named.  Prints an error
1961         message and exits with exit code 1 if the named branch is not
1962         a TopGit branch.
1964 tg log
1965 ~~~~~~
1966         Prints the git log of the named topgit branch -- or the current
1967         branch, if you don't specify a name.
1969         This is really just a convenient shortcut for:
1971             ``git log --first-parent --no-merges $(tg base <name>)..<name>``
1973         where ``<name>`` is the name of the TopGit topic branch (or omitted
1974         for the current branch).
1976         However, if ``<name>`` is a ``[BASE]`` branch the ``--no-merges``
1977         option is omitted.
1979         If ``--compact`` is used then ``git log-compact`` will be used instead
1980         of ``git log``.  The ``--command=<git-alias>`` option can be used to
1981         replace "log" with any non-whitespace-containing command alias name,
1982         ``--compact`` is just a shortcut for ``--command=log-compact``.  The
1983         ``git-log-compact`` tool may be found on its project page located at:
1985             https://mackyle.github.io/git-log-compact
1987         Note that the ``--compact`` or ``--command=`` option must be used
1988         before any ``--`` or ``git log`` options to be recognized.
1990         NOTE: if you have merged changes from a different repository, this
1991         command might not list all interesting commits.
1993 tg tag
1994 ~~~~~~
1995         Creates a TopGit annotated/signed tag or lists the reflog of one.
1997         A TopGit annotated tag records the current state of one or more TopGit
1998         branches and their dependencies and may be used to revert to the tagged
1999         state at any point in the future.
2001         When reflogs are enabled (the default in a non-bare repository) and
2002         combined with the ``--force`` option a single tag name may be used as a
2003         sort of TopGit branch state stash.  The special branch name ``--all``
2004         may be used to tag the state of all current TopGit branches to
2005         facilitate this function and has the side-effect of suppressing the
2006         out-of-date check allowing out-of-date branches to be included.
2008         As a special feature, ``--stash`` may be used as the tag name in which
2009         case ``--all`` is implied if no branch name is listed (instead of the
2010         normal default of ``HEAD``), ``--force`` and ``--no-edit`` (use
2011         ``--edit`` to change that) are automatically activated and the tag will
2012         be saved to ``refs/tgstash`` instead of ``refs/tags/<tagname>``.
2013         The ``--stash`` tag name may also be used with the ``-g``/``--reflog``
2014         option.
2016         The mostly undocumented option ``--allow-outdated`` will bypass the
2017         out-of-date check and is implied when ``--stash`` or ``--all`` is used.
2019         A TopGit annotated/signed tag is simply a Git annotated/signed tag with
2020         a "TOPGIT REFS" section appended to the end of the tag message (and
2021         preceding the signature for signed tags).  PEM-style begin and end
2022         lines surround one line per ref where the format of each line is
2023         full-hash SP ref-name.  A line will be included for each branch given
2024         on the command line and each ref they depend on either directly or
2025         indirectly.
2027         Note that when specifying branch names, if a given name is ambiguous
2028         but prefixing the branch name with ``refs/heads/`` successfully
2029         disambiguates it, then that will be the interpretation used.
2031         If more than one TopGit branch is given on the command line, a new
2032         commit will be created that has an empty tree and all of the given
2033         TopGit branches as parents and that commit will be tagged.  If a single
2034         TopGit branch is given, then it will be tagged.  If the ``--tree``
2035         option is used then it will be used instead of an empty tree (a new
2036         commit will be created if necessary to guarantee the specified tree is
2037         what's in the commit the newly created tag refers to).  The argument to
2038         the ``--tree`` option may be any valid treeish.
2040         If exactly one of the branches to be tagged is prefixed with a tilde
2041         (``~``) it will be made the first parent of a consolidation commit if
2042         it is not already the sole commit needing to be tagged.  If ``--tree``
2043         is NOT used, its tree will also be used instead of the empty tree for
2044         any new consolidation commit if one is created.  Note that if
2045         ``--tree`` is given explicitly its tree is always used but that does
2046         not in any way affect the choice of first parent.  Beware that the
2047         ``~`` may need to be quoted to prevent the shell from misinterpreting
2048         it into something else.
2050         All the options for creating a tag serve the same purpose as their Git
2051         equivalents except for two.  The ``--refs`` option suppresses tag
2052         creation entirely and emits the "TOPGIT REFS" section that would have
2053         been included with the tag.  If the ``--no-edit`` option is given and
2054         no message is supplied (via the ``-m`` or ``-F`` option) then the
2055         default message created by TopGit will be used without running the
2056         editor.
2058         With ``-g`` or ``--reflog`` show the reflog for a tag.  With the
2059         ``--reflog-message`` option the message from the reflog is shown.
2060         With the ``--commit-message`` option the first line of the tag's
2061         message (if the object is a tag) or the commit message (if the object
2062         is a commit) falling back to the reflog message for tree and blob
2063         objects is shown.  The default is ``--reflog-message`` unless the
2064         ``--stash`` (``refs/tgstash``) is being shown in which case the default
2065         is then ``--commit-message``.  Just add either option explicitly to
2066         override the default.
2068         When showing reflogs, non-tag entries are annotated with their type
2069         unless ``--no-type`` is given.  Custom colors can be set with these
2070         git config options:
2072           :``color.tgtag``:         enable/disable color, default is ``color.ui``
2073           :``color.tgtag.commit``:  hash color, dflt ``color.diff.commit``/yellow
2074           :``color.tgtag.date``:    date line color, default is bold blue
2075           :``color.tgtag.meta``:    object type "color", default is bold
2076           :``color.tgtag.time``:    time info color, default is green
2078         TopGit tags are created with a reflog if core.logallrefupdates is
2079         enabled (the default for non-bare repositories).  Unfortunately Git
2080         is incapable of showing an annotated/signed tag's reflog
2081         (using git log -g) as it will first resolve the tag before checking to
2082         see if it has a reflog.  Git can, however, show reflogs for lightweight
2083         tags (using git log -g) just fine but that's not helpful here.  Use
2084         ``tg tag`` with the ``-g`` or ``--reflog`` option to see the reflog for
2085         an actual tag object.  This also works on non-TopGit annotated/signed
2086         tags as well provided they have a reflog.
2088         Note that the time and date shown for reflog entries by ``tg tag -g``
2089         is the actual time and date recorded in that reflog entry itself which
2090         usually is the time and date that entry was added to the reflog, *not*
2091         the time and date of the commit it refers to.  Git itself will only
2092         ever show the time and date recorded in a reflog entry when given just
2093         the right arguments to ``git log``, but then the reflog entry's time
2094         and date are always shown *in place of* its index number.
2096         By contrast, ``tg tag -g`` always shows the reflog entry's time and
2097         date *together with* its reflog entry index number.
2099         The number of entries shown may be limited with the ``-n`` option.  If
2100         the tagname is omitted then ``--stash`` is assumed.
2102         The ``--delete`` option is a convenience option that runs the
2103         ``git update-ref --no-deref -d`` command on the specified tag removing
2104         it and its reflog (if it has one).  Note that `HEAD` cannot be removed.
2106         The ``--clear`` option clears all but the most recent (the ``@{0}``)
2107         reflog entry from the reflog for the specified tag.  It's equivalent
2108         to dropping all the higher numbered reflog entries.
2110         The ``--drop`` option drops the specified reflog entry and requires the
2111         given tagname to have an ``@{n}`` suffix where ``n`` is the reflog
2112         entry number to be dropped.   This is really just a convenience option
2113         that runs the appropriate ``git reflog delete`` command.  Note that
2114         even dropping the ...@{0} entry when it's the last entry of a
2115         non-symbolic ref will NOT delete the ref itself (unless the ref was
2116         already somehow set to an invalid object hash); but dropping @{0} of
2117         a non-symbolic ref may have the side effect of removing some stale
2118         reflog entries that were present in the reflog.
2120         Note that when combined with ``tg revert``, a tag created by ``tg tag``
2121         can be used to transfer TopGit branches.  Simply create the tag, push
2122         it somewhere and then have the recipient run ``tg revert`` to recreate
2123         the TopGit branches.  This may be helpful in situations where it's not
2124         feasible to push all the refs corresponding to the TopGit-controlled
2125         branches and their top-bases.
2127 tg rebase
2128 ~~~~~~~~~
2129         Provides a ``git rebase`` rerere auto continue function.  It may be
2130         used as a drop-in replacement front-end for ``git rebase -m`` that
2131         automatically continues the rebase when ``git rerere`` information is
2132         sufficient to resolve all conflicts.
2134         You have enabled ``git rerere`` haven't you?
2136         If the ``-m`` or ``--merge`` option is not present then ``tg rebase``
2137         will complain and not do anything.
2139         When ``git rerere`` is enabled, previously resolved conflicts are
2140         remembered and can be automatically staged (see ``rerere.autoUpdate``).
2142         However, even with auto staging, ``git rebase`` still stops and
2143         requires an explicit ``git rebase --continue`` to keep going.
2145         In the case where ``git rebase -m`` is being used to flatten history
2146         (such as after a ``tg export --collapse`` prior to a
2147         ``git format-patch``), there's a good chance all conflicts have already
2148         been resolved during normal merge maintenance operations so there's no
2149         reason ``git rebase`` could not automatically continue, but there's no
2150         option to make it do so.
2152         The ``tg rebase`` command provides a ``git rebase --auto-continue``
2153         function.
2155         All the same rebase options can be used (they are simply passed through
2156         to Git unchanged).  However, the ``rerere.autoUpdate`` option is
2157         automatically temporarily enabled while running ``git rebase`` and
2158         should ``git rebase`` stop, asking one to resolve and continue, but all
2159         conflicts have already been resolved and staged using rerere
2160         information, then ``git rebase --continue`` will be automatically run.
2162 tg revert
2163 ~~~~~~~~~
2164         Provides the ability to revert one or more TopGit branches and their
2165         dependencies to a previous state contained within a tag created using
2166         the ``tg tag`` command.  In addition to the actual revert mode
2167         operation a list mode operation is also provided to examine a tag's ref
2168         contents.
2170         The default mode (``-l`` or ``--list``) shows the state of one or more
2171         of the refs/branches stored in the tag data.  When no refs are given on
2172         the command line, all refs in the tag data are shown.  With the special
2173         ref name ``--heads`` then the indepedent heads contained in the tag
2174         data are shown.  The ``--deps`` option shows the specified refs and all
2175         of their dependencies in a single list with no duplicates.  The
2176         ``--rdeps`` option shows a display similar to ``tg summary --rdeps``
2177         for each ref or all TopGit heads if no ref is given on the command
2178         line.  The standard ``--no-short``, ``--short=n`` etc. options may be
2179         used to override the default ``--short`` output.  With ``--hash`` (or
2180         ``--hash-only``) show only the hash in ``--list`` mode in which case
2181         the default is ``--no-short``.   The ``--hash`` option can be used much
2182         like the ``git rev-parse --verify`` command to extract a specific hash
2183         value out of a TopGit tag.
2185         Note that unlike `tg summary`_, here ``--heads`` actually does mean the
2186         ``git merge-base --independent`` heads of the stored refs from the tag
2187         data.  To see only the independent TopGit topic branch heads stored in
2188         the tag data use the ``--topgit-heads`` option instead.  The default
2189         for the ``--rdeps`` option is ``--topgit-heads`` but ``--heads`` can
2190         be given explicitly to change that.  (Note that ``--heads-independent``
2191         is accepted as an alias for ``--heads`` as well.)
2193         The revert mode has three submodes, dry-run mode (``-n`` or
2194         ``--dry-run``), force mode (``-f`` or ``--force``) and interactive mode
2195         (``-i`` or ``--interactive``).  If ``--dry-run`` (or ``-n``) is given
2196         no ref updates will actually be performed but what would have been
2197         updated is shown instead.  If ``--interactive`` (or ``-i``) is given
2198         then the editor is invoked on an instruction sheet allowing manual
2199         selection of the refs to be updated before proceeding.  Since revert is
2200         potentially a destructive operation, at least one of the submodes must
2201         be specified explicitly.  If no refs are listed on the command line
2202         then all refs in the tag data are reverted.  Otherwise the listed refs
2203         and all of their dependencies (unless ``--no-deps`` is given) are
2204         reverted.  Unless ``--no-stash`` is given a new stash will be created
2205         using ``tg tag --stash`` (except, of course, in dry-run mode) just
2206         before actually performing the updates to facilitate recovery from
2207         accidents.
2209         Both modes accept fully-qualified (i.e. starts with ``refs/``) ref
2210         names as well as unqualified names (which will be assumed to be located
2211         under ``refs/heads/``).  In revert mode a tgish ref will always have
2212         both its ``refs/heads/`` and ``refs/top-bases/`` values included no
2213         matter how it's listed unless ``--no-deps`` is given and the ref is
2214         fully qualified (i.e. starts with ``refs/``) or one or the other of its
2215         values was removed from the instruction sheet in interactive mode.  In
2216         list mode a tgish ref will always have both its ``refs/heads/`` and
2217         ``refs/top-bases/`` values included only when using the ``--deps`` or
2218         ``--rdeps`` options.
2220         The ``--tgish-only`` option excludes non-tgish refs (i.e. refs that do
2221         not have a ``refs/heads/<name>``, ``refs/top-bases/<name>`` pair).
2223         The ``--exclude`` option (which can be repeated) excludes specific
2224         refs.  If the name given to ``--exclude`` is not fully-qualified (i.e.
2225         starts with ``refs/``) then it will exclude both members of a tgish ref
2226         pair.
2228         The ``--quiet`` (or ``-q``) option may be used in revert mode to
2229         suppress non-dry-run ref change status messages.
2231         The special tag name ``--stash`` (as well as with ``@{n}`` suffixes)
2232         can be used to refer to ``refs/tgstash``.
2234         The ``tg revert`` command supports tags of tags that contains TopGit
2235         refs.  So, for example, if you do this::
2237                 tg tag newtag --all
2238                 git tag -f -a -m "tag the tag" newtag newtag
2240         Then ``newtag`` will be a tag of a tag containing a ``TOPGIT REFS``
2241         section.  ``tg revert`` knows how to dereference the outermost
2242         tag to get to the next (and the next etc.) tag to find the
2243         ``TOPGIT REFS`` section so after the above sequence, the tag ``newtag``
2244         can still be used successfully with ``tg revert``.
2246         NOTE:  If HEAD points to a ref that is updated by a revert operation
2247         then NO WARNING whatsoever will be issued, but the index and working
2248         tree will always be left completely untouched (and the reflog for
2249         the pointed-to ref can always be used to find the previous value).
2251 tg shell
2252 ~~~~~~~~
2253         Enter extended `wayback machine`_ mode.
2255         The global ``-w <tgtag>`` option must be specified (but as a special
2256         case for the ``shell`` subcommand a <tgtag> destination of ``:`` may be
2257         used to get a shell with no wayback ref changes).
2259         The "<tgtag>" value must be the name of a tag created by (or known to)
2260         `tg tag`_.  However, it may also have a ``:`` prefixed to it to
2261         indicate that it should prune (making it into a "pruning wayback tag").
2262         Use of a "pruning wayback tag" results in a repository that contains
2263         exclusively those refs listed in the specified tag.  Otherwise the
2264         wayback repository will just revert those refs while keeping the others
2265         untouched (the default behavior).
2267         The `wayback machine`_ activates as normal for the specified
2268         destination but then a new ``${SHELL:-/bin/sh}`` is spawned in a
2269         temporary non-bare repository directory that shares all the same
2270         objects from the repository but has its own copy of the ref namespace
2271         where the refs specified in the wayback destination have all been
2272         changed to have their wayback values.
2274         If any arguments are given a POSIX shell will be spawned instead
2275         concatenating all the arguments together with a space and passing
2276         them to it via a ``-c`` option.  If ``-q`` (or ``--quote``) is given
2277         then each argument will first be separately "quoted" to protect it from
2278         the shell allowing something like this::
2280                 tg -w <tgtag> shell -q git for-each-ref --format="%(refname)"
2282         to work without needing to manually add the extra level of quoting that
2283         would otherwise be required due to the parentheses.
2285         Most of the repository configuration will be inherited, but some
2286         will be overridden for safety and for convenience.  All "gc" activity
2287         within the wayback repository will be suppressed to avoid accidents
2288         (i.e. no auto gc will run and "gc" commands will complain and not run).
2289         
2290         Override and/or bypass this safety protection at your own peril!
2291         Especially *do not run* the ``git prune`` plumbing command in the
2292         wayback repository!  If you do so (or bypass any of the other safeties)
2293         be prepared for corruption and loss of data in the repository.
2294         Just *don't do that* in the first place!
2296         Using ``git wayback-tag`` will show the tag used to enter the wayback
2297         machine.  Using ``git wayback-updates`` will show ref changes that have
2298         occurred since the wayback tag was created (it will not show refs that
2299         have since been created unless a pruning wayback tag was used).
2300         Finally, ``git wayback-repository`` will show the home repository but
2301         so will ``git remote -v`` in the output displayed for the ``wayback``
2302         remote.
2304         The special ``wayback`` remote refers to the original repository and
2305         can be used to push ref changes back to it.  Note, however, that all
2306         default push refspecs are disabled for safety and an explicit refspec
2307         will need to be used to do so.
2309         Unlike the normal `wayback machine`_ mode, ``HEAD`` will be detached
2310         to a new commit with an empty tree that contains the message and author
2311         from the wayback tag used.  This prevents ugly status displays while
2312         avoiding the need to checkout any files into the temporary working
2313         tree.  The parent of this commit will, however, be set to the wayback
2314         tag's commit making it easy to access if desired.
2316         Also unlike the normal `wayback machine`_ mode, there are no
2317         limitations on what can be done in the temporary repository.
2318         And since it will be non-bare and writable, commands that may not have
2319         been allowed in the original repository will work too.
2321         When the shell spawned by this subcommand exits, the temporary wayback
2322         repository and all newly created objects and ref changes made in it, if
2323         any, *will be lost*.  If work has been done in it that needs to be
2324         saved, it must be pushed somewhere (even if only back to the original
2325         repository using the special ``wayback`` remote).
2327         Lastly there's the ``--directory`` option.  If the ``--directory``
2328         option is used the temporary "wayback repository" will be created at
2329         the specified location (which must either not exist or must be an empty
2330         directory -- no force option available this time as too many things
2331         could easily go wrong in that case).  If the ``--directory`` option is
2332         used then the "wayback repository" *will persist* after ``tg shell``
2333         completes allowing it to continue to be used!  Be warned though, all
2334         the same warnings that apply to ``git clone --shared`` apply to such
2335         a repository.  If it's created using a ``tgstash`` tag those warnings
2336         are especially salient.  Use a single argument of either ``:`` (to
2337         just create with no output) or ``pwd`` (to show the full absolute path
2338         to the new "wayback repository") when using the ``--directory`` option
2339         if the sole purpose is just to create the wayback repository for use.
2340         Note that the ``--directory`` option *must* be listed as the first
2341         option after the ``shell`` subcommand name if used.
2343 tg prev
2344 ~~~~~~~
2345         Output the "previous" branch(es) in the patch series containing the
2346         current or named branch.  The "previous" branch(es) being one step
2347         away by default.
2349         Options:
2350           -i            show dependencies based on index instead of branch
2351           -w            show dependencies based on working tree instead of branch
2352           -n <steps>    take ``<steps>`` "previous" steps (default 1)
2353           --all         take as many "previous" steps as possible (aka ``-a``)
2354           --verbose     show containing series name(s) (aka ``-v``)
2356         The ``-n`` option may also be given as ``--count`` or ``--count=<n>``.
2358         To list all dependencies of a branch see the ``--deps`` option of
2359         the `tg info`_ command.
2361         See also NAVIGATION_ for full details on "previous" steps.
2363 tg next
2364 ~~~~~~~
2365         Output the "next" branch(es) in the patch series containing the current
2366         or named branch.  The "next" branch(es) being one step away by default.
2368         Options:
2369           -i            show dependencies based on index instead of branch
2370           -w            show dependencies based on working tree instead of branch
2371           -n <steps>    take ``<steps>`` "next" steps (default 1)
2372           --all         take as many "next" steps as possible (aka ``-a``)
2373           --verbose     show containing series name(s) (aka ``-v``)
2375         The ``-n`` option may also be given as ``--count`` or ``--count=<n>``.
2377         To list all dependents of a branch see the ``--dependents`` option of
2378         the `tg info`_ command.
2380         See also NAVIGATION_ for full details on "next" steps.
2382 tg migrate-bases
2383 ~~~~~~~~~~~~~~~~
2384         Transition top-bases from old location to new location.
2386         Beginning with TopGit release 0.19.4, TopGit has the ability to store
2387         the top-bases refs in either the old ``refs/top-bases/...`` location or
2388         the new ``refs/heads/{top-bases}/...`` location.  Starting with TopGit
2389         release 0.20.0, the default is the new location.
2391         By storing the top-bases under heads, Git is less likely to complain
2392         when manipulating them, hosting providers are more likely to provide
2393         access to them and Git prevents them from pointing at anything other
2394         than a commit object.  All in all a win for everyone.
2396         TopGit attempts to automatically detect whether the new or old location
2397         is being used for the top-bases and just do the right thing.  However,
2398         by explicitly setting the config value ``topgit.top-bases`` to either
2399         ``refs`` for the old location or ``heads`` for the new location the
2400         auto-detection can be bypassed.  If no top-bases refs are present in
2401         the repository the default prior to TopGit release 0.20.0 is to use the
2402         old location but starting with TopGit release 0.20.0 the default is to
2403         use the new location.
2405         The ``tg migrate-bases`` command may be used to migrate top-bases refs
2406         from the old location to the new location (or, by using the
2407         undocumented ``--reverse`` option, vice versa).
2409         With few exceptions (``tg create -r`` and ``tg revert``), all top-bases
2410         refs (both local *and* remote refs) are expected to be stored in the
2411         same location (either new or old).  A repository's current location for
2412         storing top-bases refs may be shown with the ``tg --top-bases`` command.
2414 TODO: tg rename
2415 ~~~~~~~~~~~~~~~
2417 IMPLEMENTATION
2418 --------------
2420 TopGit stores all the topic branches in the regular ``refs/heads/``
2421 namespace (so we recommend distinguishing them with the ``t/`` prefix).
2422 Apart from that, TopGit also maintains a set of auxiliary refs in
2423 ``refs/top-*``.  Currently, only ``refs/top-bases/`` is used, containing the
2424 current *base* of the given topic branch -- this is basically a merge of
2425 all the branches the topic branch depends on; it is updated during ``tg
2426 update`` and then merged to the topic branch, and it is the base of a
2427 patch generated from the topic branch by ``tg patch``.
2429 All the metadata is tracked within the source tree and history of the
2430 topic branch itself, in ``.top*`` files; these files are kept isolated
2431 within the topic branches during TopGit-controlled merges and are of
2432 course omitted during ``tg patch``.  The state of these files in base
2433 commits is undefined; look at them only in the topic branches
2434 themselves.  Currently, two files are defined:
2436         ``.topmsg``:
2437             Contains the description of the topic branch in a
2438             mail-like format, plus the author information, whatever
2439             Cc headers you choose or the post-three-dashes message.
2440             When mailing out your patch, basically only a few extra
2441             mail headers are inserted and then the patch itself is
2442             appended.  Thus, as your patches evolve, you can record
2443             nuances like whether the particular patch should have
2444             To-list / Cc-maintainer or vice-versa and similar
2445             nuances, if your project is into that.  ``From`` is
2446             prefilled from your current ``GIT_AUTHOR_IDENT``; other
2447             headers can be prefilled from various optional
2448             ``topgit.*`` git config options.
2450         ``.topdeps``:
2451             Contains the one-per-line list of branches this branch
2452             depends on, pre-seeded by ``tg create``. A (continuously
2453             updated) merge of these branches will be the *base* of
2454             your topic branch.
2456 IMPORTANT: DO NOT EDIT ``.topdeps`` MANUALLY!!! If you do so, you need to
2457 know exactly what you are doing, since this file must stay in sync with
2458 the Git history information, otherwise very bad things will happen.
2460 TopGit also automagically installs a bunch of custom commit-related
2461 hooks that will verify whether you are committing the ``.top*`` files in a
2462 sane state. It will add the hooks to separate files within the ``hooks/``
2463 subdirectory, and merely insert calls to them to the appropriate hooks
2464 and make them executable (but will make sure the original hook's code is
2465 not called if the hook was not executable beforehand).
2467 Another automagically installed piece is a ``.git/info/attributes``
2468 specifier for an ``ours`` merge strategy for the files ``.topmsg`` and
2469 ``.topdeps``, and the (intuitive) ``ours`` merge strategy definition in
2470 ``.git/config``.
2473 REMOTE HANDLING
2474 ---------------
2476 There are two remaining issues with accessing topic branches in remote
2477 repositories:
2479         (i) Referring to remote topic branches from your local repository
2480         (ii) Developing some of the remote topic branches locally
2482 There are two somewhat contradictory design considerations here:
2484         (a) Hacking on multiple independent TopGit remotes in a single
2485             repository
2486         (b) Having a self-contained topic system in local refs space
2488 To us, (a) does not appear to be very convincing, while (b) is quite
2489 desirable for ``git-log topic`` etc. working, and increased conceptual
2490 simplicity.
2492 Thus, we choose to instantiate all the topic branches of given remote
2493 locally; this is performed by ``tg remote --populate``. ``tg update``
2494 will also check if a branch can be updated from its corresponding remote
2495 branch.  The logic needs to be somewhat involved if we are to "do the
2496 right thing".  First, we update the base, handling the remote branch as
2497 if it was the first dependency; thus, conflict resolutions made in the
2498 remote branch will be carried over to our local base automagically.
2499 Then, the base is merged into the remote branch and the result is merged
2500 to the local branch -- again, to carry over remote conflict resolutions.
2501 In the future, this order might be adjustable on a per-update basis, in
2502 case local changes happen to be diverging more than the remote ones.
2503 (See the details in `The Update Process`_ for more in depth coverage.)
2505 All commands by default refer to the remote that ``tg remote --populate``
2506 was called on the last time (stored in the ``topgit.remote`` git
2507 configuration variable). You can manually run any command with a
2508 different base remote by passing ``-r REMOTE`` *before* the subcommand
2509 name or passing ``-u`` *before* the subcommand to run without one.
2512 TESTING TOPGIT
2513 --------------
2515 Running the TopGit test suite only requires POSIX compatibile utilities (just
2516 a POSIX compatibile ``make`` will do) AND a ``perl`` binary.
2518 It is *not* necessary to install TopGit in order to run the TopGit test suite.
2520 To run the TopGit test suite, simply execute this from the top-level of a
2521 TopGit checkout or expanded release tarball:
2525         make test
2527 Yup, that's it.  But you're probably thinking, "Why have a whole section just
2528 to say 'run make test'?"  Am I right?
2530 The simple ``make test`` command produces a lot of output and while it is
2531 summarized at the end there's a better way.
2533 Do you have the ``prove`` utility available?  You need ``perl`` to run the
2534 tests and ``prove`` comes with ``perl`` so you almost cerainly do.
2536 Try running the tests like so:
2540         make DEFAULT_TEST_TARGET=prove test
2543 (For reference, the default value of ``DEFAULT_TEST_TARGET`` is ``test`` which
2544 can be used to override a setting that's been altered using the instructions
2545 shown later on below.)
2547 If that works (you can interrupt it with ``Ctrl-C``), try this next:
2551         make DEFAULT_TEST_TARGET=prove TESTLIB_PROVE_OPTS="-j 4 --timer" test
2553 If that one works (again, you can interrupt it with ``Ctrl-C``) that may end
2554 up being the keeper for running the tests.
2556 However, if you don't have ``prove`` for some reason even though you do have
2557 ``perl``, there's still an alternative for briefer output.  Try this:
2561         make TESTLIB_TEST_OPTS=-q test
2563 Much of the normal testing output will be suppressed and there's still a
2564 summary at the end.  If you're stuck with this version but your make supports
2565 parallel operation (the ``-j`` *<n>*) option, then you might try this:
2569         make -j 4 TESTLIB_TEST_OPTS=-q test
2571 If your make *does* support the parallel ``-j`` option but still seems to be
2572 only running one test at a time try it like this instead:
2576         make TESTLIB_MAKE_OPTS="-j 4" TESTLIB_TEST_OPTS=-q test
2578 The difference is that ``make -j 4`` relies on make to properly pass down the
2579 parallel job option all the way down to the sub-make that runs the individual
2580 tests when not using prove.  Putting the options in ``TESTLIB_MAKE_OPTS``
2581 passes them directly to that (and only that) particular invocation of make.
2583 The final bit of advice for running the tests is that any of those ``make``
2584 variable settings can be enabled by default in a top-level ``config.mak`` file.
2586 For example, to make the ``prove -j 4 --timer`` (my personal favorite) the
2587 default when running the tests, add these lines (creating the file if it does
2588 not already exist) to the ``config.mak`` file located in the top-level of the
2589 TopGit checkout (or expanded release tarball):
2593         # config.mak file
2594         # comments are allowed (if preceded by '#')
2595         # so are blank lines
2597         DEFAULT_TEST_TARGET = prove
2598         TESTLIB_PROVE_OPTS = -j 4 --timer
2599         #TESTLIB_TEST_OPTS = --color # force colorized test output
2601 Now simply doing ``make test`` will use those options by default.
2603 There is copious documentation on the testing library and other options in
2604 the various ``README`` files located in the ``t`` subdirectory.  The
2605 ``Makefile.mak`` file in the ``t`` subdirectory contains plenty of comments
2606 about possible makefile variable settings as well.
2610 TECHNICAL
2611 ---------
2613 A familiarity with the terms in the GLOSSARY_ is helpful for understanding the
2614 content of this section.  See also the IMPLEMENTATION_ section.
2616 The Update Process
2617 ~~~~~~~~~~~~~~~~~~
2619 When a branch is "updated" using the ``tg update`` command the following steps
2620 are taken:
2622         1) The branch and all of its dependencies (and theirs recursively)
2623            are checked to see which ones are *out-of-date*.  See glossary_.
2625         2) Each of the branch's direct dependencies (i.e. they are listed in
2626            the branch's ``.topdeps`` file) which is out of date is updated
2627            before proceeding (yup, this is a recursive process).  If the
2628            branch has a corresponding remote branch and that remote branch
2629            has removed one or more direct dependencies, then those
2630            remote-removed dependencies are automatically skipped at this
2631            stage even though the remote branch's .topdeps file will not
2632            actually be merged into the local branch until step (5).
2634         3) Each of the branch's direct dependencies (i.e. they are listed in
2635            the branch's ``.topdeps`` file) that was updated in the previous
2636            step is now merged into the branch's corresponding base.  If a
2637            remote is involved, and the branch's corresponding base does NOT
2638            contain the remote branch's corresponding base that remote base
2639            is also merged into the branch's base at this time as well (it
2640            will be the first item merged into the branch's base).  As with
2641            the previous step, any remote-removed dependencies, if any, are
2642            automatically skipped at this stage.
2644         4) If the branch has a corresponding remote branch and the branch
2645            does not already contain it, the branch's base (which was possibly
2646            already updated in step (3) to contain the remote branch's base but
2647            not the remote branch itself) is merged into the remote branch on a
2648            detached HEAD.  Yup, this step can be a bit confusing and no, the
2649            updated base from step (3) has not yet been merged into the branch
2650            itself yet either.  If there is no remote branch this step does not
2651            apply.  Using a detached HEAD allows the contents of the base to be
2652            merged into the remote branch without actually perturbing the base's
2653            or remote branch's refs.
2655         5) If there is a remote branch present then use the result of step (4)
2656            otherwise use the branch's base and merge that into the branch
2657            itself.
2659 That's it!  Simple, right? ;)
2661 Unless the auto stash option has been disabled (see `no undo`_, `tg update`_
2662 and `tg tag`_), a copy of all the old refs values will be stashed away
2663 immediately after step (1) before starting step (2), but only if anything is
2664 actually found to be out-of-date.
2666 Merge Strategies
2667 ~~~~~~~~~~~~~~~~
2669 The ``tg update`` command regularly performs merges while executing an update
2670 operation.  In order to speed things up, it attempts to do in-index merges
2671 where possible.  It accomplishes this by using a separate, temporary index
2672 file and the ``git read-tree -m --aggressive`` command possibly assisted by
2673 the ``git merge-index`` and ``git merge-file`` commands.  This combination may
2674 be repeated more than once to perform an octopus in-index merge.  If this
2675 fails, the files are checked out and a normal ``git merge`` three-way merge is
2676 performed (possibly multiple times).  If the normal ``git merge`` fails then
2677 user intervention is required to resolve the merge conflict(s) and continue.
2679 Since the ``tg annihilate``, ``tg create`` and ``tg depend add`` commands may
2680 end up running the ``tg update`` machinery behind the scenes to complete their
2681 operation they may also result in any of these merge strategies being used.
2683 In addition to the normal Git merge strategies (if the in-index merging fails),
2684 there are four possible TopGit merge strategies that may be shown.  Since they
2685 all involve use of the ``git read-tree -m --aggressive`` command they are all
2686 variations of a "trivial aggressive" merge.  The "trivial" part because all of
2687 the merges done by ``git read-tree -m`` are described as "trivial" and the
2688 "aggressive" part because the ``--aggressive`` option is always used.
2690         1) "trivial aggressive"
2691                 Only two heads were involved and all merging was completed by
2692                 the ``git read-tree -m --aggressive`` command.
2694         2) "trivial aggressive automatic"
2695                 Only two heads were involved but after the
2696                 ``git read-tree -m --aggressive`` command completed there were
2697                 still unresolved items and ``git merge-index`` had to be run
2698                 (using the ``tg index-merge-one-file`` driver) which ultimately
2699                 ran ``git merge-file`` at least once to perform a simple
2700                 automatic three-way merge.  Hence the "automatic" description
2701                 and the "Auto-merging ..." output line(s).
2703         3) "trivial aggressive octopus"
2704                 This is the same as a "trivial aggressive" merge except that
2705                 more than two heads were involved and after merging the first
2706                 two heads, the ``git read-tree -m --aggressive`` step was
2707                 repeated again on the result for each additional head.  All
2708                 merging was completed via multiple
2709                 ``git read-tree -m --aggressive`` commands only.
2710                 This beast is relatively rare in the wild.
2712         4) "trivial aggressive automatic octopus"
2713                 This is very similar to the "trivial aggressive octopus"
2714                 except that at least one of the ``git read-tree -m --aggressive``
2715                 commands left unresolved items that were handled the same way
2716                 as the "trivial aggressive automatic" strategy.  This species
2717                 is commonly seen in the wild.
2720 GLOSSARY
2721 --------
2723         .topmsg
2724                 Version-controlled file stored at the root level of each
2725                 TopGit branch that contains the patch header for a TopGit
2726                 branch.  See also IMPLEMENTATION_.
2728         .topdeps
2729                 Version-controlled file stored at the root level of each
2730                 TopGit branch that lists the branch's dependencies one per
2731                 line omitting the leading ``refs/heads/`` part.  See also
2732                 IMPLEMENTATION_.
2734         3-way merge
2735                 See three-way merge.
2737         branch containment
2738                 Given two Git commit identifiers (e.g. hashes) C1 and C2,
2739                 commit C1 "contains" commit C2 if either they are the same
2740                 commit or C2 can be reached from C1 by following one or more
2741                 parent links from C1 (perhaps via one or more intermediate
2742                 commits along the way).  In other words, if C1 contains C2
2743                 then C2 is an ancestor of C1 or conversely C1 is a descendant
2744                 of C2.  Since a TopGit branch name is also the name of a Git
2745                 branch (something located under the ``refs/heads`` Git
2746                 namespace) and similarly for a TopGit base, they can both be
2747                 resolved to a Git commit identifier and then participate in
2748                 a branch containment test.  An easy mnemonic for this is
2749                 "children contain the genes of their parents."
2751         BRE pattern
2752                 A Basic Regular Expression (BRE) pattern.  These are older
2753                 style regular expressions but have the advantage that all
2754                 characters other than ``\``, ``.``, ``*`` and ``[``
2755                 automatically match themselves without need for backslash
2756                 quoting (well actually, ``^`` and ``$`` are special at the
2757                 beginning and end respectively but otherwise match themselves).
2759         contains
2760                 See branch containment.
2762         ERE pattern
2763                 An Extended Regular Expression (ERE) pattern.  These are newer
2764                 style regular expressions where all the regular expression
2765                 "operator" characters "operate" when NOT preceded by a
2766                 backslash and are turned into normal characters with a ``\``.
2767                 The backreference atom, however, may not work, but ``?``, ``+``
2768                 and ``|`` "operators" do; unlike BREs.
2770         TopGit
2771                 Excellent system for managing a history of changes to one
2772                 or more possibly interrelated patches.
2774         TopGit branch
2775                 A Git branch that has an associated TopGit base.  Conceptually
2776                 it represents a single patch that is the difference between
2777                 the associated TopGit base and the TopGit branch.  In other
2778                 words ``git diff-tree <TopGit base> <TopGit branch>`` except
2779                 that any ``.topdeps`` and/or ``.topmsg`` files are excluded
2780                 from the result and the contents of the ``.topmsg`` file from
2781                 the TopGit branch is prefixed to the result.
2783         TopGit bare branch
2784                 A Git branch whose tree does NOT contain any ``.topdeps`` or
2785                 ``.topmsg`` entries at the top-level of the tree.  It *does*
2786                 always have an associated "TopGit base" ref (otherwise it would
2787                 not be a "TopGit" branch).  See also `BARE BRANCHES`_.
2789         bare branch
2790                 In TopGit context, "bare branch" almost always refers to a
2791                 "TopGit bare branch" and should be understood to mean such even
2792                 if the leading "TopGit" has been left off.
2794         TopGit base
2795                 A Git branch that records the base upon which a TopGit branch's
2796                 single conceptual "patch" is built.  The name of the Git branch
2797                 is derived from the TopGit branch name by stripping off the
2798                 leading ``refs/heads/`` and appending the correct prefix where
2799                 all TopGit bases are stored (typically either
2800                 ``refs/top-bases/`` or ``refs/heads/{top-bases}/`` -- the
2801                 prefix for any given repository can be shown by using the
2802                 ``tg --top-bases`` command and updated using the
2803                 ``tg migrate-bases`` command).
2805                 All of a TopGit branch's dependencies are merged into the
2806                 corresponding TopGit base during a ``tg update`` of a branch.
2808         base
2809                 See TopGit base.
2811         TopGit ``[PATCH]`` branch
2812                 A TopGit branch whose subject starts with ``[PATCH]``.  By
2813                 convention these TopGit branches contain a single patch
2814                 (equivalent to a single patch file) and have at least one
2815                 dependency (i.e. their ``.topdeps`` files are never empty).
2817         TopGit ``[BASE]`` branch
2818                 A TopGit branch whose subject starts with ``[BASE]``.  By
2819                 convention these TopGit branches do not actually contain
2820                 any changes and their ``.topdeps`` files are empty.  They
2821                 are used to control a base dependency that another set of
2822                 branches depends on.  Sometimes these are named ``[RELEASE]``
2823                 instead because the base dependency they represent is actually
2824                 the formal release of something.
2826         TopGit ``[ROOT]`` branch
2827                 A TopGit branch whose subject starts with ``[ROOT]``.  By
2828                 convention these TopGit branches do not actually contain
2829                 any changes and their ``.topdeps`` files are empty.  They
2830                 are ``[BASE]`` branches where the base commit has no parent.
2831                 In other words, the base commit is a ``root`` commit.
2833         TopGit ``[STAGE]`` branch
2834                 A TopGit branch whose subject starts with ``[STAGE]``.  By
2835                 convention these TopGit branches do not actually contain any
2836                 changes of their own but do have one or (typically) more
2837                 dependencies in their ``.topdeps`` file.  These branches are
2838                 used to bring together one or (typically) more independent
2839                 TopGit ``[PATCH]`` branches into a single branch so that
2840                 testing and/or evaluation can be performed on the result.
2841                 Sometimes these are named ``[RELEASE]`` when a full release
2842                 is being made from the result.
2844         merge conflict
2845                 When merging two (or more) heads that touch the same lines in
2846                 the file but in different ways the result is a merge conflict
2847                 that requires manual intervention.  If a merge conflict occurs
2848                 with more than two heads (an octopus merge) it's generally
2849                 replaced by multiple three-way merges so that by the time a
2850                 user sees a merge conflict needing manual resolution, there
2851                 will be only two heads involved.
2853         merge strategy
2854                 A Git merge strategy (see the "MERGE STRATEGIES" section of
2855                 ``git help merge``) or one of the TopGit `merge strategies`_
2856                 used to merge two or more heads.
2858         TopGit merge strategy
2859                 See the `Merge Strategies`_ section above for details but
2860                 basically these are just in-index merges done using the
2861                 ``git read-tree -m --aggressive`` command one or more times
2862                 possibily assisted by the ``git merge-index`` and the
2863                 ``git merge-file`` commands.
2865         next branch
2866                 In TopGit context the "next" branch refers to the branch that
2867                 corresponds to the next (aka following) patch in an ordered
2868                 (aka linearized) list of patches created by exporting the
2869                 TopGit branches in patch application order.
2871         octopus merge
2872                 A merge involving more than two heads.  Note that if there are
2873                 less than three independent heads the resulting merge that
2874                 started out as an octopus will end up not actually being an
2875                 octopus after all.
2877         out-of-date branch
2878                 A TopGit branch is considered to be "out-of-date" when ANY of
2879                 the following are true:
2881                         a) The TopGit branch does NOT contain its
2882                            corresponding base.
2884                         b) The TopGit branch does NOT contain its
2885                            corresponding remote branch (there may not be
2886                            a remote branch in which case this does not apply).
2888                         c) The TopGit branch's base does NOT contain its
2889                            corresponding remote branch's base (there may not be
2890                            a remote branch in which case this does not apply).
2892                         d) Any of the TopGit branches listed in the branch's
2893                            ``.topdeps`` file are NOT contained by the branch's
2894                            base (see "branch containment" above).
2896                         e) Any of the TopGit branches listed in the branch's
2897                            ``.topdeps`` file are out-of-date.
2899                 Note that if a remote branch is present and is NOT out-of-date
2900                 then it will contain its own base and (c) is mostly redundant.
2902         previous branch
2903                 In TopGit context the "previous" (or "prev") branch refers to
2904                 the branch that corresponds to the previous (aka preceding)
2905                 patch in an ordered (aka linearized) list of patches created by
2906                 exporting the TopGit branches in patch application order.
2908         remote TopGit branch
2909                 A Git branch with the same branch name as a TopGit branch
2910                 but living under ``refs/remotes/<some remote>/`` instead
2911                 of just ``refs/heads/``.
2913         remote TopGit base
2914                 The TopGit base branch corresponding to a remote TopGit branch,
2915                 which lives under ``refs/remotes/`` somewhere (depending on
2916                 what the output of ``tg --top-bases`` is for that remote).
2918         three-way merge
2919                 A three-way merge takes a common base and two heads (call them
2920                 A and B) and creates a new file that is the common base plus
2921                 all of the changes made between the common base and head A
2922                 *AND* all of the changes made between the common base and
2923                 head B.  The technique used to accomplish this is called a
2924                 "merge strategy".
2927 REFERENCES
2928 ----------
2930 The following references are useful to understand the development of
2931 topgit and its subcommands.
2933 * tg depend:
2934   https://lore.kernel.org/git/36ca99e90904091034m4d4d31dct78acb333612e678@mail.gmail.com/T/#u
2937 THIRD-PARTY SOFTWARE
2938 --------------------
2940 The following software understands TopGit branches:
2942 * `Magit <https://github.com/magit/magit>`_ - a git mode for emacs
2943   with the `Magit TopGit mode <https://github.com/greenrd/magit-topgit>`_
2944   that may, perhaps, be a bit outdated.
2946 IMPORTANT: Magit requires its topgit mode to be enabled first, as
2947 described in its documentation, in the "Activating extensions"
2948 subsection.  If this is not done, it will not push TopGit branches
2949 correctly, so it's important to enable it even if you plan to mostly use
2950 TopGit from the command line.