1 =========================================
2 TopGit -- A different patch queue manager
3 =========================================
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.
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
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.8.5 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).
64 See the file ``INSTALL``.
70 The TopGit git repository can be found at <http://repo.or.cz/topgit/pro>.
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
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
125 (ii) When using TopGit, your history can get a little hairy
126 over time, especially with all the merges rippling through.
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...
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...
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...
158 tg: Sent t/revlist/author-fixed
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: Merging t/whatever base with t/gitweb/nifty-links...
169 tg: Please commit merge resolution and call: tg update --continue
170 tg: It is also safe to abort this operation using `git reset --hard`
171 tg: but please remember you are on the base branch now;
172 tg: you will want to switch to a different branch.
175 $ tg update --continue
179 ## Update a single topic branch and propagate the changes to
181 $ git checkout t/gitweb/nifty-links
184 $ git checkout t/whatever
186 Topic Branch: t/whatever (1 commit)
187 Subject: [PATCH] Whatever patch
189 Depends: t/revlist/author-fixed t/gitweb/nifty-links
191 t/gitweb/nifty-links (1 commit)
193 tg: Updating base with t/gitweb/nifty-links changes...
195 tg: Please commit merge resolution and call `tg update --continue`
196 tg: (use `tg status` to see more options)
199 $ tg update --continue
200 tg: Updating t/whatever against new base...
202 tg: Please commit merge resolution and call `tg update --continue`
203 tg: (use `tg status` to see more options)
206 $ tg update --continue
208 ## Update a single topic branch and propagate the changes
209 ## further through the dependency chain
210 $ git checkout t/gitweb/pathinfo-action
213 $ git checkout t/whatever
215 Topic Branch: t/whatever (1/2 commits)
216 Subject: [PATCH] Whatever patch
218 Depends: t/revlist/author-fixed t/gitweb/nifty-links
220 t/gitweb/pathinfo-action (<= t/gitweb/nifty-links) (1 commit)
222 tg: Recursing to t/gitweb/nifty-links...
223 [t/gitweb/nifty-links] tg: Updating base with t/gitweb/pathinfo-action changes...
225 [t/gitweb/nifty-links] tg: Please commit merge resolution and call `tg update --continue`
226 [t/gitweb/nifty-links] tg: (use `tg status` to see more options)
229 $ tg update --continue
230 [t/gitweb/nifty-links] tg: Updating t/gitweb/nifty-links against new base...
232 [t/gitweb/nifty-links] tg: Please commit merge resolution and call `tg update --continue`
233 [t/gitweb/nifty-links] tg: (use `tg status` to see more options)
236 $ tg update --continue
237 tg: Updating base with t/gitweb/nifty-links changes...
238 tg: Updating t/whatever against new base...
240 ## Clone a TopGit-controlled repository
243 $ tg remote --populate origin
248 ## Add a TopGit remote to a repository and push to it
249 $ git remote add foo URL
253 ## Update from a non-default TopGit remote
262 When using TopGit there are several common conventions used when working with
263 TopGit branches. None of them are enforced, they are only suggestions.
265 There are three typical uses for a TopGit branch:
268 Normal TopGit branches that represent a single patch. These are known
269 as "patch" TopGit branches.
271 Empty TopGit branches with no dependencies (an empty ``.topdeps`` file)
272 that represent a base upon which other "normal" TopGit branches depend.
273 These are known as "base" TopGit branches (not to be confused with
274 the refs/top-bases/... refs).
276 Empty TopGit branches that serve as a staging area to bring together
277 several other TopGit branches into one place so they can be used/tested
278 all together. These are known as "stage" TopGit branches.
280 An "empty" TopGit branch is one that does not have any changes of its own --
281 it may still have dependencies though ("stage" branches do, "base" branches do
282 not). The ``tg summary`` output shows empty branches with a ``0`` in the
283 listing. Normal "patch" branches that have not been annihilated, "base" and
284 "stage" branches fall into this category. (Annihilated branches are normally
285 omitted from the ``tg summary`` output but can be shown if given explicitly as
286 an argument to the ``tg summary`` command. However, the message line will be
287 incorrect since an annihilated branch has no ``.topmsg`` file of its own.)
289 A "patch" branch name typically starts with ``t/`` whereas "base" and "stage"
290 branch names often do not.
292 A "base" branch is created by using the ``--base`` option of ``tg create``
293 (aka ``--no-deps``) which will automatically suggest a "[BASE]" message prefix
294 rather than "[PATCH]". A "stage" branch is created like a normal patch branch
295 except that the only changes that will ever be made to it are typically to
296 add/remove dependencies. Its subject prefix must be manually changed to
297 "[STAGE]" to reflect its purpose.
299 Since both "base" and "stage" branches typically only have a use for the
300 "Subject:" line from their ``.topmsg`` file, they are quite easily created
301 using the ``--topmsg`` option of ``tg create``.
303 Use of "stage" and "base" branches is completely optional. However, without
304 use of a "stage" branch it will be difficult to test multiple independent
305 patches together all at once. A "base" branch is merely a convenience that
306 provides more explicit control over when a common base for a set of patches
307 gets updated as well as providing a branch that shows in ``tg summary`` output
308 and participates in ``tg remote --populate`` setup.
310 Occasionally the functionality of a "base" branch is needed but it may not
311 be possible to add any ``.topdeps`` or ``.topmsg`` files to the desired branch
312 (perhaps it's externally controlled). `BARE BRANCHES`_ can be used in this
313 case, but while TopGit allows them it deliberately does not provide assistance
316 Another advantage to using a "stage" branch is that if a new "patch" branch
317 is created remotely and that new branch is added to a pre-existing "stage"
318 branch on the remote then when the local version of the "stage" branch is
319 updated (after fetching remote updates of course), that new dependency will
320 be merged into the local "stage" branch and the local version of the new remote
321 "patch" branch will be automatically set up at "tg update" time.
323 When using the ``tg tag`` command to create tags that record the current state
324 of one or more TopGit branches, the tags are often created with a name that
327 One last thing, you have enabled ``git rerere`` haven't you?
333 Beware, there is no "undo" after running a ``tg update``!
335 Well, that's not entirely correct. Since ``tg update`` never discards commits
336 an "undo" operation is technically feasible provided the old values of all the
337 refs that were affected by the ``tg update`` operation can be determined and
338 then they are simply changed back to their previous values.
340 In practice though, it can be extremely tedious and error prone looking through
341 log information to try and determine what the correct previous values were.
342 Although, since TopGit tries to make sure reflogs are enabled for top-bases
343 refs, using Git's ``@{date}`` notation on all the refs dumped out by a
344 ``tg tag --refs foo``, where "foo" is the branch that was updated whose update
345 needs to be undone, may work.
347 Alternatively, ``tg tag --stash`` can be used prior to the update and then
348 ``tg revert`` used after the update to restore the previous state. This
349 assumes, of course, that you remember to run ``tg tag --stash`` first.
351 The ``tg update`` command understands a ``--stash`` option that tells it to
352 automatically run ``tg tag --stash`` before it starts making changes (if
353 everything is up-to-date it won't run the stash command at all).
355 The ``--stash`` option is the default nowadays when running ``tg update``,
356 add the ``--no-stash`` option to turn it off.
358 There is a preference for this. Setting the config value ``topgit.autostash``
359 to ``false`` will implicitly add the ``--no-stash`` option to any ``tg update``
360 command unless an explicit ``--stash`` option is given.
362 If you are likely to ever want to undo a ``tg update``, setting
363 ``topgit.autostash`` to ``false`` is highly discouraged!
365 Note that if you have foolishly disabled the autostash functionality and
366 suddenly find yourself in an emergency "WHERE'S THE UNDO???" situation you
367 *may* be able to use the special ``TG_STASH`` ref. But only if you're quick.
368 It's only set if you've foolishly disabled autostash and it always overwrites
369 the previous ``TG_STASH`` value if there was one (there's no reflog for it)
370 and it will most likely *not* survive a ``git gc`` (even an automatic one) no
371 matter what gc expiration values are used. However, as a last gasp attempt
372 to save your butt, a previously existing ``TG_STASH`` will first be renamed
373 to ``ORIG_TG_STASH`` immediately before a new ``TG_STASH`` gets written
374 (stepping on any previously existing ``ORIG_TG_STASH`` at that point).
376 Note that the tags saved by ``tg tag --stash`` are stored in the
377 ``refs/tgstash`` ref and its reflog. Unfortunately, while Git is happy to
378 maintain the reflog (once it's been enabled which ``tg tag`` guarantees for
379 ``refs/tgstash``), Git is unable to view an annotated/signed tag's reflog!
380 Instead Git dereferences the tag and shows the wrong thing.
382 Use the ``tg tag -g`` command to view the ``refs/tgstash`` reflog instead.
388 After reading about `NO UNDO`_ and the `tg tag`_ command used to provide a
389 semblance of undo in some cases, you have the foundation to understand the
392 The "wayback machine" provides a way to go back to a previous ref state as
393 stored in a TopGit tag created by `tg tag`_. It actually normally returns to a
394 hybrid state as it does not prune (unless you prefix the wayback tag with
395 a ``:``). In other words, any refs that have been newly created since the
396 target tag was made will continue to exist in the "wayback" view of things
397 (unless you used a pruning wayback tag -- one prefixed with a ``:``).
399 Any operations that are read-only and do not require working tree files (e.g.
400 the ``-i`` or ``-w`` options of `tg patch`_) are allowed using the wayback
401 machine. Simply add a global ``-w <tgtag>`` option to the command.
403 This functionality can be extremely useful for quickly examining/querying a
404 previous state recorded some time ago with a `tg tag`_.
406 As the wayback machine uses a separate caching area, expect initial operations
407 to be less speedy, but repeated wayback operations on the same wayback tag
408 should happen at normal speed.
410 One new command exists expressly for use with the wayback machine.
412 The `tg shell`_ command will spawn an interactive shell or run a specific shell
413 command in a temporary writable and non-bare repository that has its ref
414 namespace set to the (possibly pruned if it's a pruning wayback tag) wayback
415 tag's view of the world. This pretty much lifts all wayback restrictions, but
416 read the description for `tg shell`_ for more details. There is an option
417 available to specify the location where this "temporary" directory is created
418 thereby allowing it to persist, but the same warnings then apply as using the
419 ``git clone --shared`` command.
425 TopGit supports various config settings:
427 :`tg create`_: ``format.signoff`` template Signed-off-by line
428 :ALIASES_: ``topgit.alias.*`` for Git-like command aliases
429 :`tg update`_: ``topgit.autostash`` automatic stash control
430 :`tg create`_: ``topgit.bcc`` default "Bcc:" value for create
431 :`tg create`_: ``topgit.cc`` default "Cc:" value for create
432 :`tg patch`_: ``topgit.from`` "From:" fixups by ``tg patch``
433 :`tg push`_: ``topgit.pushRemote`` default push remote
434 :`REMOTE HANDLING`_: ``topgit.remote`` TopGit's default remote
435 :SEQUESTRATION_: ``topgit.sequester`` for sequestration control
436 :`tg update`_: ``topgit.setAutoUpdate`` => ``rerere.autoUpdate``
437 :`tg export`_: ``topgit.subjectMode`` export [...] tag removal
438 :`tg create`_: ``topgit.subjectPrefix`` "[$prefix PATCH] foo"
439 :`tg create`_: ``topgit.to`` default "To:" value for create
440 :`tg migrate-bases`_: ``topgit.top-bases`` for refs bases location
446 These work exactly like Git's aliases except they are stored under
447 ``topgit.alias.*`` instead. See the ``git help config`` output under
448 the ``alias.*`` section for details. Do note that while alias nesting is
449 explicitly permitted, a maximum nesting depth of 10 is enforced to help
450 detect accidental aliasing loops and keep them from wedging the machine.
452 For example, to create an ``lc`` alias for the ``tg log --compact`` command
453 this command may be used:
457 git config --global topgit.alias.lc "log --compact"
459 To make it specific to a particular repository just omit the ``--global``
460 option from the command.
465 From Previous to Next
466 ~~~~~~~~~~~~~~~~~~~~~
468 For this section, consider the following patch series, to be applied
469 in numerical order as shown:
473 0001-F_first-patch.diff
474 0002-G_second-builds-on-F.diff
475 0003-H_third-builds-on-G.diff
476 0004-I_fourth-builds-on-H.diff
477 0005-J_fifth-builds-on-I.diff
478 0006-K_sixth-builds-on-J.diff
479 0007-L_last-patch-needs-K.diff
481 If these were applied to some commit in a Git repository, say commit "A"
482 then a history that looks like this would be created:
486 A---F---G---H---I---J---K---L
488 Where the parent of commit "F" is "A" and so on to where the parent of
489 commit "L" is commit "K".
491 If that commit history, from A through L, was then imported into TopGit, one
492 TopGit branch would be created corresponding to each of the commits F
493 through L. This way, for example, if the fourth patch in the series
494 (``0004-I_...diff``) needs work, the TopGit branch corresponding to its patch
495 can be checked out and changes made and then a new version of its patch
496 created (using ``tg patch``) without disturbing the other patches in the series
497 and when ``tg update`` is run, the patches that "follow" the fourth patch
498 (i.e. 5, 6 and 7) will have their corresponding TopGit branches automatically
499 updated to take into account the changes made to the fourth patch.
501 Okay, enough with the review of TopGit systemology
502 ``````````````````````````````````````````````````
504 Imagine then that you are working on the fourth patch (i.e. you have its
505 branch checked out into the working tree) and you want to move to the following
506 patch in the series because you have a nit to pick with it too.
508 If you can't remember the exact name you might have to fumble around or, you
509 can display the name of the following or "next" patch's branch with the, you
510 guessed it, ``tg next`` command. Think of "next" as the "next" logical patch
511 in the series or the next following patch. If the patches are numbered as in
512 the list above, "next" corresponds to the "+1" (plus one) patch.
514 You might have already guessed there's a corresponding ``tg prev`` command
515 which displays the "-1" (minus one) patch. If these commands (``tg next``
516 and ``tg prev``) are not given a branch name to start at they start at the
517 patch corresponding to the current ``HEAD``.
519 Displaying, however, is not so helpful as actually going there. That's where
520 the ``tg checkout`` command comes in. ``tg checkout next`` does a
521 ``git checkout`` of the ``tg next`` branch and, not surprisingly,
522 ``tg checkout prev`` does a ``git checkout`` of the ``tg prev`` branch. For
523 the lazy a single ``n`` or ``p`` can be used with ``tg checkout`` instead of
524 typing out the entire ``next`` or ``prev``. Or, for the anal, ``previous``
525 will also be accepted for ``prev``.
527 Referring to the A...L commit graph shown above, I is the parent of J and,
528 conversely, J is the child of I. (Git only explicitly records the child to
529 parent links, in other words a "child" points to zero or more "parents", but
530 parents are completely clueless about their own children.)
532 For historical reasons, the ``tg checkout`` command accepts ``child`` as a
533 synonym for ``next`` and ``parent`` as a synonym for ``prev``. However, this
534 terminology can be confusing since Git has "parent" links but ``tg checkout``
535 is referring to the TopGit DAG, not Git's. Best to just avoid using ``child``
536 or ``parent`` to talk about navigating the TopGit DAG and reserve them
537 strictly for discussing the Git DAG.
539 There may be more than one
540 ``````````````````````````
542 In a simple linear history as shown above there's always only one "next" or
543 "prev" patch. However, TopGit does not restrict one to only a linear
544 history (although that can make patch exports just a bushel of fun).
546 Suffice it to say that there is always a single linearized ordering for any
547 TopGit patch series since it's always a DAG (Directed Acyclic Graph), but it
548 may not be immediately obvious to the casual observer what that is.
550 The ``tg checkout`` command will display a list to choose from if ``next``
551 or ``prev`` would be ambiguous.
553 Use the ``tg info/checkout --series`` command
554 `````````````````````````````````````````````
556 To see the full, linearized, list of patches with their summary displayed in
557 order from first to last patch in the series, just run the ``tg info --series``
558 command. It takes the name of any patch in the series automatically using
559 ``HEAD`` if none is given. It even provides a nice "YOU ARE HERE" mark in
560 the output list helpful to those who have been absent for a time engaging in
561 otherwise distracting activities and need to be reminded where they are.
563 Using ``tg checkout --series`` can take you there (picking from a list) if
564 you've forgotten the way back to wherever you're supposed to be.
566 Don't get pushy, there's just one more thing
567 ````````````````````````````````````````````
569 For historical reasons, ``tg checkout`` with no arguments whatsoever behaves
570 like ``tg checkout next``. For the same historical reasons, ``tg checkout ..``
571 behaves like ``tg checkout prev`` (think of ``..`` as the "parent" directory
572 and since "parent" means "prev" in this context it will then make sense).
574 Now, for that one more thing. Consider that you have a pristine "upstream"
575 tarball, repository, source dump or otherwise obtained set of unmodified
576 source files that need to be patched. View them like so:
580 +-------------------------------+
581 | Unmodified "upstream" source |
582 | files represented with "A" |
583 +-------------------------------+
585 Now, add the first patch, 0001, to them and view the result like so:
589 +--------------------------+----+
590 | Patch 0001 represented by "F" |
591 +-------------------------------+
592 | Unmodified "upstream" source |
593 | files represented with "A" |
594 +-------------------------------+
596 Not stopping there, "push" patches 2, 3 and 4 onto the stack as well like so:
600 +--------------------------+----+
601 | Patch 0004 represented by "I" |
602 +--------------------------+----+
603 | Patch 0003 represented by "H" |
604 +--------------------------+----+
605 | Patch 0002 represented by "G" |
606 +--------------------------+----+
607 | Patch 0001 represented by "F" |
608 +-------------------------------+
609 | Unmodified "upstream" source |
610 | files represented with "A" |
611 +-------------------------------+
613 In other words, to go to the "next" patch in the series it needs to be "push"ed
614 onto the stack. ``tg checkout`` accepts ``push`` as an alias for ``next``.
616 Similarly to go to the "previous" patch in the series the current one needs
617 to be "pop"ped off the stack. ``tg checkout`` accepts ``pop`` as an alias
620 Unfortunately for these aliases, in Git terminology a "push" has quite a
621 different meaning and the ``tg push`` command does something quite different
622 from ``tg checkout push``. Then there's the matter of using a single letter
623 abbreviation for the lazy -- ``p`` would mean what exactly?
625 ``tg checkout`` continues to accept the ``push`` and ``pop`` aliases for
626 ``next`` and ``prev`` respectively, but it's best to avoid them since
627 ``push`` has an alternate meaning everywhere else in TopGit and Git and that
628 leaves ``pop`` all alone in the dark.
634 No, this is not a section about budget nonsense. ;)
636 TopGit keeps its metadata in ``.topdeps`` and ``.topmsg`` files. In an effort
637 to facilitate cherry-picking and other Git activities on the patch changes
638 themselves while ignoring the TopGit metadata, TopGit attempts to keep all
639 changes to ``.topdeps`` and ``.topmsg`` files limited to commits that do NOT
640 contain changes to any other files.
642 This is a departure from previous TopGit versions that made no such effort.
644 Primarily this affects ``tg create`` and ``tg import`` (which makes use of
645 ``tg create``) as ``tg create`` will commit the initial versions of
646 ``.topdeps`` and ``.topmsg`` for a new TopGit-controlled branch in their own
647 commit instead of mixing them in with changes to other files.
649 The ``pre-commit`` hook will also attempt to separate out any ``.topdeps`` and
650 ``.topmsg`` changes from commits that include changes to other files.
652 It is possible to defeat these checks without much effort (``pre-commit`` hooks
653 can easily be bypassed, ``tg create`` has a ``--no-commit`` option, many Git
654 commands simply do not run the ``pre-commit`` hook, etc.).
656 If you really, really, really, really want to change the default back to the
657 old behavior of previous TopGit versions where no such sequestration took
658 place, then set the ``topgit.sequester`` config variable explicitly to the
659 value ``false``. But this is not recommended.
662 AMENDING AND REBASING AND UPDATE-REF'ING
663 ----------------------------------------
667 It is okay to manually update a top-bases/... ref when a) it has no depedencies
668 (i.e. it was created with the ``tg create`` ``--base`` option) and b) the
669 old top-bases/... ref value can be fast-forwarded to the new top-bases/...
670 value OR the new value contains ALL of the changes in the old value through
671 some other mechanism (perhaps they were cherry-picked or otherwise applied to
672 the new top-bases/... ref). The same rules apply to non-TopGit-controlled
673 dependencies. Use the ``tg update --base <branch> <new-ref>`` command to
674 safely make such an update while making it easy to set the merge commit
675 message at the same time.
677 Ignoring this rule and proceeding anyway with a non-fast-forward update to a
678 top-bases/... ref will result in changes present in the new value being merged
679 into the branch (at ``tg update`` time) as expected (possibly with conflicts),
680 but any changes that were contained in the old version of the top-bases/... ref
681 which have been dropped (i.e. are NOT contained in the new version of the
682 top-bases/... ref) will continue to be present in the branch! To get rid of
683 the dropped commits, one or more "revert" commits will have to be manually
684 applied to the tip of the new top-bases/... value (which will then be merged
685 into the branch at next ``tg update`` time).
687 The only time it's safe to amend, rebase, filter or otherwise rewrite commits
688 contained in a TopGit controlled branch or non-TopGit branch is when those
689 commits are NOT reachable via any other ref!
691 Furthermore, while it is safe to rewrite merge commits (provided they meet the
692 same conditions) the merge commits themselves and the branches they are merging
693 in must be preserved during the rewrite and that can be rather tricky to get
694 right so it's not recommended.
696 For example, if, while working on a TopGit-controlled branch ``foo``, a bad
697 typo is noticed, it's okay to ammend/rebase to fix that provided neither
698 ``tg update`` nor ``tg create`` has already been used to cause some other ref
699 to be able to reach the commit with the typo.
701 If an amend or rewrite is done anyway even though the commit with the typo is
702 reachable from some other ref, the typo won't really be removed. What will
703 happen instead is that the new version without the typo will ultimately be
704 merged into the other ref(s) (at ``tg update`` time) likely causing a conflict
705 that will have to be manually resolved and the commit with the typo will
706 continue to be reachable from those other refs!
708 Instead just make a new commit to fix the typo. The end result will end up
709 being the same but without the merge conflicts.
711 See also the discussion in the `NO UNDO`_ section.
717 A "TopGit bare branch" (or just "bare branch" for short), refers to a TopGit
718 branch that has neither a ``.topdeps`` nor a ``.topmsg`` file stored in it.
719 And it's neither a new, still-empty empty branch nor an annihilated branch.
721 Such branches are not recommended but are reluctantly accomodated.
723 There are three situtations in which TopGit may encounter a TopGit branch
724 that has neither a ``.topdeps`` nor a ``.topmsg`` file.
726 1. Branch creation with ``--no-commit``
727 Before the initial commit is made, the branch will still be
728 pointing to the same commit as its "top-bases" ref. Branches
729 in this condition (where the branch and top-bases ref point to
730 the same commit) show up as having "No commits" in listings.
732 2. Annihilated branches
733 A branch is annihilated by making a new commit on the branch
734 that makes its tree identical to the tree of its corresponding
735 top-bases ref. Although the trees will be the same, the
736 commits will be different and annihilated branches are
737 distinguished from "No commits" branches in this way.
738 Annihilated branches are generally invisible and do not show up
739 in listings or other status displays. Intentionally so.
742 Any TopGit branch with neither a ``.topdeps`` file nor a
743 ``.topmsg`` file whose branch and top-bases trees differ falls
744 into this category. TopGit will not create such a branch
745 itself nor does it provide any commands to do so.
747 Whenever possible, a TopGit "[BASE]" branch should be preferred to using a
748 "bare branch" because a) it can never be mistaken for an annihilated branch,
749 b) it has a nice subject attached (via its ``.topmsg`` file) that shows
750 up in listings and c) exactly when and which updates are taken can be planned.
752 Nevertheless, situations may arise where it's useful to have TopGit treat a
753 branch as a "TopGit branch" so that it fully participates in all update
754 activities (such as updating local branches based on their remote branches),
755 but it's not feasible to turn it into a real "TopGit branch" as it comes from
756 an external source and rather than controlling exactly when and what updates
757 are picked up from it by TopGit (the precise use case of a "[BASE]" branch),
758 all updates that appear on it are to be assimilated as soon as they occur.
760 For this reason, TopGit will accomodate such "bare branches" but it will not
761 create (nor provide the means to create) them itself.
763 In order to create a "bare branch" all that's required is to create the
764 necessary top-bases ref. The choice of commit for the top-bases ref will
765 affect the output of the "files", "log" and "patch" commands most directly
766 (but all commands will be affected).
768 To work properly as a "bare branch", the commit the "bare branch"'s base points
769 to should be contained within the branch, be a different commit than the branch
770 tip itself and have a different tree than the branch tip. Simply setting the
771 base to the parent commit of the "bare branch" will usually work, but should
772 that commit at the tip of the "bare branch" end up getting reverted as the next
773 commit, the trees would match and it would appear to be an annihilated branch
774 rather than a "bare branch". That is one of the reasons these branches are not
775 recommended in the first place.
777 Setting the base to the root commit of the branch is more reliable and may
778 be accomplished like so for a local branch named "mybranch":
782 git update-ref $(tg --top-bases)/mybranch \
783 $(git rev-list --first-parent --max-parents=0 mybranch) ""
785 Typically though it's more likely a remote bare branch will be needed. For
786 a remote named "origin" and a remote branch name of "vendor" this will do it:
790 git update-ref $(tg --top-bases -r origin)/vendor \
791 $(git rev-list --first-parent --max-parents=0 origin/vendor) ""
793 Such "bare branches" are not likely ever to receive any more direct support in
794 TopGit than acknowleging they can be useful in some situations and tolerating
795 their existence by functioning properly with them even to the point of the
796 ``pre-commit`` hook tacitly allowing continued commits on such branches without
797 complaints about missing ``.topdeps`` and ``.topmsg`` files.
799 Note, however, that creating a regular TopGit branch that has no changes of its
800 own with the "bare branch" as its single dependency provides a means to supply
801 some kind of documentation if all other uses of the "bare branch" depend on
802 this "wrapper" branch instead of directly on the "bare branch".
808 TopGit needs to check many things to determine whether a TopGit branch is
809 up-to-date or not. This can involve a LOT of git commands for a complex
810 dependency tree. In order to speed things up, TopGit keeps a cache of results
811 in a ``tg-cache`` subdirectory in the ``.git`` directory.
813 Results are tagged with the original hash values used to get that result so
814 that items which have not been changed return their results quickly and items
815 which have been changed compute their new result and cache it for future use.
817 The ``.git/tg-cache`` directory may be removed at any time and the cache will
818 simply be recreated in an on-demand fashion as needed, at some speed penalty,
819 until it's fully rebuilt.
821 To force the cache to be fully pre-loaded, run the ``tg summary`` command
822 without any arguments. Otherwise, normal day-to-day TopGit operations should
823 keep it more-or-less up-to-date.
825 While each TopGit command is running, it uses a temporary subdirectory also
826 located in the ``.git`` directory. These directories are named
827 ``tg-tmp.XXXXXX`` where the ``XXXXXX`` part will be random letters and digits.
829 These temporary directories should always be removed automatically after each
830 TopGit command finishes running. As long as you are not in a subshell as a
831 result of a TopGit command stopping and waiting for a manual merge resolution,
832 it's safe to remove any of these directories that may have somehow accidentally
833 been left behind as a result of some failure that occurred while running a
834 TopGit command (provided, of course, it's not actually being used by a TopGit
835 command currently running in another terminal window or by another user on the
841 ``tg [global options] <subcommand> [<subcommand option/argument>...]``
845 ``[-C <dir>]... [-r <remote> | -u] [-c <name>=<val>]... [--[no-]pager]``
847 -C <dir> Change directory to <dir> before doing anything more
848 -r <remote> Pretend ``topgit.remote`` is set to <remote>
849 -u Pretend ``topgit.remote`` is not set
850 -c <name=val> Pass config option to git, may be repeated
851 -w <tgtag> Activate `wayback machine`_ using the `tg tag`_ <tgtag>
852 --no-pager Disable use of any pager (by both TopGit and Git)
853 --pager Enable use of a pager (aka ``-p``)
854 --top-bases Show full ``top-bases`` ref prefix and exit
855 --exec-path Show path to subcommand scripts location and exit
856 --help Show brief usage help and exit (aka ``-h``)
858 The ``tg`` tool has several subcommands:
860 :`tg annihilate`_: Mark a TopGit-controlled branch as defunct
861 :`tg base`_: Show base commit for one or more TopGit branches
862 :`tg checkout`_: Shortcut for git checkout with name matching
863 :`tg contains`_: Which TopGit-controlled branch contains the commit
864 :`tg create`_: Create a new TopGit-controlled branch
865 :`tg delete`_: Delete a TopGit-controlled branch cleanly
866 :`tg depend`_: Add a new dependency to a TopGit-controlled branch
867 :`tg export`_: Export TopGit branch patches to files or a branch
868 :`tg files`_: Show files changed by a TopGit branch
869 :`tg help`_: Show TopGit help optionally using a browser
870 :`tg import`_: Import commit(s) to separate TopGit branches
871 :`tg info`_: Show status information about a TopGit branch
872 :`tg log`_: Run git log limiting revisions to a TopGit branch
873 :`tg mail`_: Shortcut for git send-email with ``tg patch`` output
874 :`tg migrate-bases`_: Transition top-bases to new location
875 :`tg next`_: Show branches directly depending on a TopGit branch
876 :`tg patch`_: Generate a patch file for a TopGit branch
877 :`tg prev`_: Show non-annihilated TopGit dependencies for a branch
878 :`tg push`_: Run git push on TopGit branch(es) and depedencies
879 :`tg rebase`_: Auto continue git rebase if rerere resolves conflicts
880 :`tg remote`_: Set up remote for fetching/pushing TopGit branches
881 :`tg revert`_: Revert ref(s) to a state stored in a ``tg tag``
882 :`tg shell`_: Extended `wayback machine`_ mode
883 :`tg status`_: Show current TopGit status (e.g. in-progress update)
884 :`tg summary`_: Show various information about TopGit branches
885 :`tg tag`_: Create tag that records current TopGit branch state
886 :`tg update`_: Update TopGit branch(es) with respect to dependencies
890 Our sophisticated integrated help facility. Mostly duplicates
895 # to get help for a particular command:
897 # to get help for a particular command in a browser window:
898 $ tg help -w <command>
899 # to get help on TopGit itself
901 # to get help on TopGit itself in a browser
906 Our sophisticated status facility. Similar to Git's status command
907 but shows any in-progress update that's awaiting a merge resolution
908 or any other on-going TopGit activity (such as a branch creation).
910 With a single ``--verbose`` (or ``-v``) option include a short status
911 display for any dirty (but not untracked) files. This also causes all
912 non file status lines to be prefixed with "## ".
914 With two (or more) ``--verbose`` (or ``-v``) options, additionally
915 show full symbolic ref names and unabbreviated hash values.
917 With the ``--exit-code`` option the exit code will be non-zero if any
918 TopGit or Git operation is currently in progress or the working
923 Create a new TopGit-controlled topic branch of the given name
924 (required argument) and switch to it. If no dependencies are
925 specified (by extra arguments passed after the first one), the
926 current branch is assumed to be the only dependency.
928 By default ``tg create`` opens an editor on the new ``.topmsg`` file
929 and then commits the new ``.topmsg`` and ``.topdeps`` files
930 automatically with a suitable default commit message.
932 The commit message can be changed with the ``-m`` (or ``--message``) or
933 ``-F`` (or ``--file``) option. The automatic commit can be suppressed
934 by using the ``--no-ccmmit`` (or ``-n``) option. Running the editor on
935 the new ``.topmsg`` file can be suppressed by using ``--no-edit``
936 (which does *NOT* suppress the automatic commit unless ``--no-commit``
937 is also given) or by providing an explicit value for the new
938 ``.topmsg`` file using the ``--topmsg`` or ``--topmsg-file`` option.
939 In any case the ``.topmsg`` content will be automatically reformated to
940 have a ``Subject:`` header line if needed.
942 If the ``format.signoff`` config variable (see ``git help config``)
943 has been set to true then the ``Signed-off-by:`` header line added to
944 the end of the initial version of the ``.topmsg`` file will be
945 uncommented by default. Otherwise it will still be there but will be
946 commented out and will be automatically stripped if no action is taken
947 to remove the comment character.
949 If more than one dependency is listed an automatic ``tg update`` runs
950 after the branch has been created to merge in the additional
951 dependencies and bring the branch up-to-date. This can be suppressed
952 with the ``--no-commit`` option (which also suppresses the initial
953 commit) or the ``--no-update`` option (which allows the initial commit
954 while suppressing only the update operation portion).
956 Previous versions of TopGit behaved as though both the ``--no-edit``
957 and ``--no-commit`` options were always given on the command line.
959 The default behavior has been changed to promote a separation between
960 commits that modify ``.topmsg`` and/or ``.topdeps`` and commits that
961 modify other files. This facilitates cleaner cherry picking and other
962 patch maintenance activities.
964 You should edit the patch description (contained in the ``.topmsg``
965 file) as appropriate. It will already contain some prefilled bits.
966 You can set the ``topgit.to``, ``topgit.cc`` and ``topgit.bcc``
967 git configuration variables (see ``man git-config``) in order to
968 have ``tg create`` add these headers with the given default values
969 to ``.topmsg`` before invoking the editor. If the configuration
970 variable ``topgit.subjectPrefix`` is set its value will be inserted
971 *between* the initial ``[`` and the word ``PATCH`` in the subject
972 line (with a space added before the word ``PATCH`` of course).
974 The main task of ``tg create`` is to set up the topic branch base
975 from the dependencies. This may fail due to merge conflicts if more
976 than one dependency is given. In that case, after you commit the
977 conflict resolution, you should call ``tg update --continue`` to
978 finish merging the dependencies into the new topic branch base.
980 With the ``--base`` (aka ``--no-deps``) option at most one dependency
981 may be listed which may be any valid committish (instead of just
982 refs/heads/...) and the newly created TopGit-controlled branch will
983 have an empty ``.topdeps`` file. This may be desirable in order to
984 create a TopGit-controlled branch that has no changes of its own and
985 serves merely to mark the common dependency that all other
986 TopGit-controlled branches in some set of TopGit-controlled branches
987 depend on. A plain, non-TopGit-controlled branch can be used for the
988 same purpose, but the advantage of a TopGit-controlled branch with no
989 dependencies is that it will be pushed with ``tg push``, it will show
990 up in the ``tg summary`` and ``tg info`` output with the subject from
991 its ``.topmsg`` file thereby documenting what it's for and finally it
992 can be set up with ``tg create -r`` and/or ``tg remote --populate`` to
995 For example, ``tg create --base release v2.1`` will create a TopGit-
996 controlled ``release`` branch based off the ``v2.1`` tag that can then
997 be used as a base for creation of other TopGit-controlled branches.
998 Then when the time comes to move the base for an entire set of changes
999 up to ``v2.2`` the command ``tg update --base release v2.2`` can be
1000 used followed by ``tg update --all``.
1002 Using ``--base`` it's also possible to use ``tg create`` on an
1003 unborn branch (omit the dependency name or specify ``HEAD``). The
1004 unborn branch itself can be made into the new TopGit branch (rather
1005 than being born empty and then having the new TopGit branch based off
1006 that) by specifying ``HEAD`` as the new branch's name (which is
1007 probably what you normally want to do in this case anyway so you can
1008 just run ``tg create --base HEAD`` to accomplish that).
1010 In an alternative use case, if ``-r <branch>`` is given instead of a
1011 dependency list, the topic branch is created based on the given
1012 remote branch. With just ``-r`` the remote branch name is assumed
1013 to be the same as the local topic branch being created. Since no
1014 new commits are created in this mode (only two refs will be updated)
1015 the editor will never be run for this use case. Note that no other
1016 options may be combined with ``-r``.
1018 The ``--quiet`` (or ``-q``) option suppresses most informational
1023 Remove a TopGit-controlled topic branch of the given name
1024 (required argument). Normally, this command will remove only an
1025 empty branch (base == head) without dependents; use ``-f`` to
1026 remove a non-empty branch or a branch that is depended upon by
1029 The ``-f`` option is also useful to force removal of a branch's
1030 base, if you used ``git branch -D B`` to remove branch B, and then
1031 certain TopGit commands complain, because the base of branch B
1034 Normally ``tg delete`` will refuse to delete the current branch.
1035 However, giving ``-f`` twice (or more) will force it to do so but it
1036 will first detach your HEAD.
1038 IMPORTANT: Currently, this command will *NOT* remove the branch
1039 from the dependency list in other branches. You need to take
1040 care of this *manually*. This is even more complicated in
1041 combination with ``-f`` -- in that case, you need to manually
1042 unmerge the removed branch's changes from the branches depending
1045 The same ``--stash`` and ``--no-stash`` options are accepted with
1046 the same exact semantics as for `tg update`_.
1048 See also ``tg annihilate``.
1050 | TODO: ``-a`` to delete all empty branches, depfix, revert
1054 Make a commit on the current or given TopGit-controlled topic
1055 branch that makes it equal to its base, including the presence or
1056 absence of .topmsg and .topdeps. Annihilated branches are not
1057 displayed by ``tg summary``, so they effectively get out of your
1058 way. However, the branch still exists, and ``tg push`` will
1059 push it (except if given the ``-a`` option). This way, you can
1060 communicate that the branch is no longer wanted.
1062 When annihilating a branch that has dependents (i.e. branches
1063 that depend on it), those dependents have the dependencies of
1064 the branch being annihilated added to them if they do not already
1065 have them as dependencies. Essentially the DAG is repaired to
1066 skip over the annihilated branch.
1068 Normally, this command will remove only an empty branch
1069 (base == head, except for changes to the .top* files); use
1070 ``-f`` to annihilate a non-empty branch.
1072 After completing the annihilation itself, normally ``tg update``
1073 is run on any modified dependents. Use the ``--no-update`` option
1074 to suppress running ``tg update``.
1076 The same ``--stash`` and ``--no-stash`` options are accepted with
1077 the same exact semantics as for `tg update`_.
1081 Change the dependencies of a TopGit-controlled topic branch.
1082 This should have several subcommands, but only ``add`` is
1083 supported right now.
1085 The ``add`` subcommand takes an argument naming a topic branch to
1086 be added, adds it to ``.topdeps``, performs a commit and then
1087 updates your topic branch accordingly. If you want to do other
1088 things related to the dependency addition, like adjusting
1089 ``.topmsg``, use the option ``--no-commit``. Adding the
1090 ``--no-update`` (or ``--no-commit``) option will suppress the
1091 ``tg update`` normally performed after committing the change.
1093 It is safe to run ``tg depend add`` in a dirty worktree, but the
1094 normally performed ``tg update`` will be suppressed in that case
1095 (even if neither ``--no-update`` nor ``--no-commit`` is given).
1097 You have enabled ``git rerere`` haven't you?
1099 | TODO: Subcommand for removing dependencies, obviously
1103 List files changed by the current or specified topic branch.
1106 -i list files based on index instead of branch
1107 -w list files based on working tree instead of branch
1111 Show summary information about the current or specified topic
1114 Numbers in parenthesis after a branch name such as "(11/3 commits)"
1115 indicate how many commits on the branch (11) and how many of those
1116 are non-merge commits (3).
1118 With ``--verbose`` (or ``-v``) include a list of dependents (i.e. other
1119 branches that depend on this one). Another ``--verbose`` annotates
1120 them with "[needs merge]" if the current tip of branch for which info
1121 is being shown has not yet been merged into the base of the dependent.
1122 Two ``--verbose`` options also cause annihilated dependencies to be
1123 shown in the "Depends:" list.
1125 Alternatively, if ``--heads`` is used then which of the independent
1126 TopGit branch heads (as output by ``tg summary --topgit-heads``)
1127 logically contains the specified commit (which may be any committish --
1128 defaults to ``HEAD`` if not given). Zero or more results will be
1129 output. Note that "logically" means with regard to the TopGit
1130 dependency relationships as established by the ``.topdeps`` file(s).
1131 It's the answer that would be given when all the TopGit branches are
1132 up-to-date (even though they need not be to use this option) and the
1133 ``git branch --contains`` command is run and the output then filtered
1134 to only those branches that appear in ``tg summary --topgit-heads``.
1135 This computation may require several seconds on complex repositories.
1137 If ``--leaves`` is used then the unique list of leaves of the current
1138 or specified topic branch is shown as one fully-qualified ref per line.
1139 Duplicates are suppressed and a tag name will be used when appropriate.
1140 A "leaf" is any dependency that is either not a TopGit branch or is
1141 the base of a non-annihilated TopGit branch with no non-annihilated
1144 The ``--deps`` option shows non-annihilated TopGit dependencies of the
1145 specified branch (default is ``HEAD``). (It can also be spelled out
1146 as ``--dependencies`` for the pedantically inclined.)
1148 The ``--dependents`` option shows non-annihilated TopGit dependents
1149 (i.e. branches that depend on the specified branch). The default
1150 branch to operate on is again ``HEAD``.
1152 A linearized patch series can only be automatically created for a
1153 TopGit topic branch (including its recursive dependencies) when exactly
1154 one line is output by ``tg info --leaves <topic-branch>``.
1156 With ``--series`` the list of TopGit branches in the order they would
1157 be linearized into a patch series is shown along with the description
1158 of each branch. If the branch name passed to ``tg info`` is not the
1159 last branch in the series a marker column will be provided to quickly
1160 locate it in the list. This same option can be used with `tg checkout`_.
1162 Some patches shown in the list may not actually end up introducing any
1163 changes if exported and will therefore end up being omitted. The ``0``
1164 indicator in ``tg summary`` output can help to identify some of these.
1166 The patches shown in the series in the order they are shown form the
1167 basis for the ``tg next`` and ``tg prev`` operations with the first
1168 patch shown being considered the first and so on up to the last.
1171 -i Use TopGit metadata from the index instead of the branch
1172 -w Use TopGit metadata from the working tree instead of the branch
1176 Generate a patch from the current or specified topic branch.
1177 This means that the diff between the topic branch base and head
1178 (latest commit) is shown, appended to the description found in
1179 the ``.topmsg`` file.
1181 The patch is simply dumped to stdout. In the future, ``tg patch``
1182 will be able to automatically send the patches by mail or save
1183 them to files. (TODO)
1186 -i base patch generation on index instead of branch
1187 -w base patch generation on working tree instead of branch
1188 --binary pass --binary to ``git diff-tree`` to enable generation
1190 --quiet be quiet (aka ``-q``) about missing and unfixed From:
1191 --from make sure patch has a From: line, if not add one
1192 --from=<a> <a> or Signed-off-by value or ident value; ``git am``
1193 really gets unhappy with patches missing From: lines;
1194 will NOT replace an existing non-empty From: header
1195 --no-from leave all From: lines alone, missing or not (default)
1196 --diff-opt options after the branch name (and an optional ``--``)
1197 are passed directly to ``git diff-tree``
1199 In order to pass a sole explicit ``-w`` through to ``git diff-tree`` it
1200 must be separated from the ``tg`` options by an explicit ``--``.
1201 Or it can be spelled as ``--ignore-all-space`` to distinguuish it from
1202 ``tg``'s ``-w`` option.
1204 If the config variable ``topgit.from`` is set to a boolean it can be
1205 used to enable or disable the ``--from`` option by default. If it's
1206 set to the special value ``quiet`` the ``--quiet`` option is enabled
1207 and From: lines are left alone by default. Any other non-empty value
1208 is taken as a default ``--from=<value>`` option. The ``--no-from``
1209 option will temporarily disable use of the config value.
1211 If additional non-``tg`` options are passed through to
1212 ``git diff-tree`` (other than ``--binary`` which is fully supported)
1213 the resulting ``tg patch`` output may not be appliable.
1217 Send a patch from the current or specified topic branch as
1220 Takes the patch given on the command line and emails it out.
1221 Destination addresses such as To, Cc and Bcc are taken from the
1224 Since it actually boils down to ``git send-email``, please refer
1225 to the documentation for that for details on how to setup email
1226 for git. You can pass arbitrary options to this command through
1227 the ``-s`` parameter, but you must double-quote everything. The
1228 ``-r`` parameter with a msgid can be used to generate in-reply-to
1229 and reference headers to an earlier mail.
1231 WARNING: be careful when using this command. It easily sends
1232 out several mails. You might want to run::
1234 git config sendemail.confirm always
1236 to let ``git send-email`` ask for confirmation before sending any
1240 -i base patch generation on index instead of branch
1241 -w base patch generation on working tree instead of branch
1243 | TODO: ``tg mail patchfile`` to mail an already exported patch
1244 | TODO: mailing patch series
1245 | TODO: specifying additional options and addresses on command line
1249 Register the given remote as TopGit-controlled. This will create
1250 the namespace for the remote branch bases and teach ``git fetch``
1251 to operate on them. However, from TopGit 0.8 onwards you need to
1252 use ``tg push``, or ``git push --mirror``, for pushing
1253 TopGit-controlled branches.
1255 ``tg remote`` takes an optional remote name argument, and an
1256 optional ``--populate`` switch. Use ``--populate`` for your
1257 origin-style remotes: it will seed the local topic branch system
1258 based on the remote topic branches. ``--populate`` will also make
1259 ``tg remote`` automatically fetch the remote, and ``tg update`` look
1260 at branches of this remote for updates by default.
1262 Using ``--populate`` with a remote name causes the ``topgit.remote``
1263 git configuration variable to be set to the given remote name.
1267 Show overview of all TopGit-tracked topic branches and their
1268 up-to-date status. With a branch name limit output to that branch.
1269 Using ``--deps-only`` or ``--rdeps`` changes the default from all
1270 branches to just the current ``HEAD`` branch but using ``--all`` as
1271 the branch name will show results for all branches instead of ``HEAD``.
1274 marks the current topic branch
1277 indicates that it introduces no changes of its own
1280 indicates respectively whether it is local-only
1281 or has a remote mate
1284 indicates respectively if it is ahead or out-of-date
1285 with respect to its remote mate
1288 indicates that it is out-of-date with respect to its
1292 indicates that it has missing dependencies [even if
1293 they are recursive ones]
1296 indicates that it is out-of-date with respect to
1300 indicates it is ahead of (and needs to be merged into)
1301 at least one of its dependents -- only computed when
1302 showing all branches or using the (possibly implied)
1303 ``--with-deps`` option.
1305 This can take a longish time to accurately determine all the
1306 relevant information about each branch; you can pass ``-t`` (or ``-l``
1307 or ``--list``) to get just a terse list of topic branch names quickly.
1308 Also adding ``--verbose`` (or ``-v``) includes the subjects too.
1309 Adding a second ``--verbose`` includes annihilated branches as well.
1311 Passing ``--heads`` shows independent topic branch names and when
1312 combined with ``--rdeps`` behaves as though ``--rdeps`` were run with
1313 the output of ``--heads``.
1315 The ``--heads-independent`` option works just like ``--heads`` except
1316 that it computes the heads using ``git merge-base --independent``
1317 rather than examining the TopGit ``.topdeps`` relationships. If the
1318 TopGit branches are all up-to-date (as shown in ``tg summary``) then
1319 both ``--heads`` and ``--heads-independent`` should compute the same
1320 list of heads (unless some overlapping TopGit branches have been
1321 manually created). If not all the TopGit branches are up-to-date then
1322 the ``--heads-independent`` results may have extra items in it, but
1323 occasionally that's what's needed; usually it's the wrong answer.
1324 (Note that ``--topgit-heads`` is accepted as an alias for ``--heads``
1327 Using ``--heads-only`` behaves as though the output of ``--heads`` was
1328 passed as the list of branches along with ``--without-deps``.
1330 Alternatively, you can pass ``--graphviz`` to get a dot-suitable output
1331 for drawing a dependency graph between the topic branches.
1333 You can also use the ``--sort`` option to sort the branches using
1334 a topological sort. This is especially useful if each
1335 TopGit-tracked topic branch depends on a single parent branch,
1336 since it will then print the branches in the dependency order.
1337 In more complex scenarios, a text graph view would be much more
1338 useful, but that has not yet been implemented.
1340 The ``--deps`` option outputs dependency information between
1341 branches in a machine-readable format. Feed this to ``tsort`` to
1342 get the output from --sort.
1344 The ``--deps-only`` option outputs a sorted list of the unique branch
1345 names given on the command line plus all of their recursive
1346 dependencies (subject to ``--exclude`` of course). When
1347 ``--deps-only`` is given the default is to just display information for
1348 ``HEAD``, but that can be changed by using ``--all`` as the branch
1349 name. Each branch name will appear only once in the output no matter
1350 how many times it's visited while tracing the dependency graph or how
1351 many branch names are given on the command line to process.
1353 The ``--rdeps`` option outputs dependency information in an indented
1354 text format that clearly shows all the dependencies and their
1355 relationships to one another. When ``--rdeps`` is given the default is
1356 to just display information for ``HEAD``, but that can be changed by
1357 using ``--all`` as the branch name or by adding the ``--heads`` option.
1358 Note that ``tg summary --rdeps --heads`` can be particularly helpful in
1359 seeing all the TopGit-controlled branches in the repository and their
1360 relationships to one another.
1362 Note that ``--rdeps`` has two flavors. The first (and default) is
1363 ``--rdeps-once`` which only shows the dependencies of a branch when
1364 it's first visited. For example, if D depends on several other
1365 branches perhaps recursively and both branch A and B depend on D, then
1366 whichever of A or B is shown first will show the entire dependency
1367 chain for D underneath it and the other one will just show a line for
1368 D itself with a "^" appended to indicate that the rest of the deps for
1369 D can be found above. This can make the output a bit more compact
1370 without actually losing any information which is why it's the default.
1371 However, using the ``--rdeps-full`` variant will repeat the full
1372 dependency chain every time it's encountered.
1374 Adding ``--with-deps`` replaces the given list of branches (which will
1375 default to ``HEAD`` if none are given) with the result of running
1376 ``tg summary --deps-only --tgish`` on the list of branches. This can
1377 be helpful in limiting ``tg summary`` output to only the list of given
1378 branches and their dependencies when many TopGit-controlled branches
1379 are present in the repository. Use ``--without-deps`` to switch back
1380 to the old behavior.
1382 The ``--with-related`` option extends (and therefore implies)
1383 ``--with-deps``. First the list of branches (which will default to
1384 ``HEAD`` if none are given) is replaced with the result of running
1385 ``tg summary --heads`` (aka ``--topgit-heads``) and the result is then
1386 processed as though it had been specified using ``--with-deps``.
1388 When it would be allowed, ``--with-deps`` is now the default. But,
1389 if in addition, exactly one branch is specified (either explicitly
1390 or implicitly) and it's spelled *exactly* as ``HEAD`` or ``@`` then
1391 the default ``--with-deps`` will be promoted to a default
1392 ``--with-related`` instead. Since duplicate branches are removed
1393 before processing, explicitly listing ``@`` twice provides an easy way
1394 to defeat this automatic promotion and ask for ``--with-deps`` on the
1395 ``HEAD`` symbolic ref with minimal typing when ``--with-related`` isn't
1396 really wanted and typing the full ``--with-deps`` option is too hard.
1398 With ``--exclude branch``, branch can be excluded from the output
1399 meaning it will be skipped and its name will be omitted from any
1400 dependency output. The ``--exclude`` option may be repeated to omit
1401 more than one branch from the output. Limiting the output to a single
1402 branch that has been excluded will result in no output at all.
1404 The ``--tgish-only`` option behaves as though any non-TopGit-controlled
1405 dependencies encountered during processing had been listed after an
1406 ``--exclude`` option.
1408 Note that the branch name can be specified as ``HEAD`` or ``@`` as a
1409 shortcut for the TopGit-controlled branch that ``HEAD`` is a
1410 symbolic ref to. The ``tg summary @`` and ``tg summary @ @`` commands
1411 can be quite useful.
1414 -i Use TopGit metadata from the index instead of the branch
1415 -w Use TopGit metadata from the working tree instead of the branch
1419 Search all TopGit-controlled branches (and optionally their remotes)
1420 to find which TopGit-controlled branch contains the specified commit.
1422 This is more than just basic branch containment as provided for by the
1423 ``git branch --contains`` command. While the shown branch name(s)
1424 will, indeed, be one (or more) of those output by the
1425 ``git branch --contains`` command, the result(s) will exclude any
1426 TopGit-controlled branches from the result(s) that have one (or more)
1427 of their TopGit dependencies (either direct or indirect) appearing in
1428 the ``git branch --contains`` output.
1430 Normally the result will be only the one, single TopGit-controlled
1431 branch for which the specified committish appears in the ``tg log``
1432 output for that branch (unless the committish lies outside the
1433 TopGit-controlled portion of the DAG and ``--no-strict`` was used).
1435 Unless ``--annihilated-okay`` (or ``--ann`` or ``--annihilated``) is
1436 used then annihilated branches will be immediately removed from the
1437 ``git branch --contains`` output before doing anything else. This
1438 means a committish that was originally located in a now-annihilated
1439 branch will show up in whatever branch picked up the annihilated
1440 branch's changes (if there is one). This is usually the correct
1441 answer, but occasionally it's not; hence this option. If this option
1442 is used together with ``--verbose`` then annihilated branches will
1443 be shown as "[:annihilated:]".
1445 In other words, if a ``tg patch`` is generated for the found branch
1446 (assuming one was found and a subsequent commit in the same branch
1447 didn't then revert or otherwise back out the change), then that patch
1448 will include the changes introduced by the specified committish
1449 (unless, of course, that committish is outside the TopGit-controlled
1450 portion of the DAG and ``--no-strict`` was given).
1452 This can be very helpful when, for example, a bug is discovered and
1453 then after using ``git bisect`` (or some other tool) to find the
1454 offending commit it's time to commit the fix. But because the
1455 TopGit merging history can be quite complicated and maybe the one
1456 doing the fix wasn't the bug's author (or the author's memory is just
1457 going), it can sometimes be rather tedious to figure out which
1458 TopGit branch the fix belongs in. The ``tg contains`` command can
1459 quickly tell you the answer to that question.
1461 With the ``--remotes`` (or ``-r``) option a TopGit-controlled remote
1462 branch name may be reported as the result but only if there is no
1463 non-remote branch containing the committish (this can only happen
1464 if at least one of the TopGit-controlled local branches are not yet
1465 up-to-date with their remotes).
1467 With the ``--verbose`` option show which TopGit DAG head(s) (one or
1468 more of the TopGit-controlled branch names output by
1469 ``tg summary --heads``) have the result as a dependency (either direct
1470 or indirect). Using this option will noticeably increase running time.
1472 With the default ``--strict`` option, results for which the base of the
1473 TopGit-controlled branch contains the committish will be suppressed.
1474 For example, if the committish was deep-down in the master branch
1475 history somewhere far outside of the TopGit-controlled portion of
1476 the DAG, with ``--no-strict``, whatever TopGit-controlled branch(es)
1477 first picked up history containing that committish will be shown.
1478 While this is a useful result it's usually not the desired result
1479 which is why it's not the default.
1481 To summarize, even with ``--remotes``, remote results are only shown
1482 if there are no non-remote results. Without ``--no-strict`` (because
1483 ``--strict`` is the default) results outside the TopGit-controlled
1484 portion of the DAG are never shown and even with ``--no-strict`` they
1485 will only be shown if there are no ``--strict`` results. Finally,
1486 the TopGit head info shown with ``--verbose`` only ever appears for
1487 local (i.e. not a remote branch) results. Annihilated branches are
1488 never considered possible matches without ``--annihilated-okay``.
1492 Switch to a topic branch. You can use ``git checkout <branch>``
1493 to get the same effect, but this command helps you navigate
1494 the dependency graph, or allows you to match the topic branch
1495 name using a regular expression, so it can be more convenient.
1497 The ``--branch`` (or ``-b`` or ``--branch=<name>``) option changes
1498 the default starting point from ``HEAD`` to the specified branch.
1500 For the "next" and "previous" commands, the ``<steps>`` value may
1501 be ``--all`` (or ``-a``) to take "As many steps As possible" or
1502 "step ALL the way" or "ALL steps at once" (or make something better
1505 The following subcommands are available:
1507 ``tg checkout next [<steps>]``
1508 Check out a branch that directly
1509 depends on your current branch.
1510 Move ``<steps>`` (default 1) step(s) in
1511 the "next" direction (AKA ``n``).
1513 ``tg checkout prev [<steps>]``
1514 Check out a branch that this branch
1515 directly depends on. Move ``<steps>``
1516 (default 1) step(s) in the "previous"
1517 direction (AKA ``p`` or ``previous``).
1519 ``tg checkout [goto] [--] <pattern>``
1520 Check out a topic branch that
1521 matches ``<pattern>``. ``<pattern>``
1522 is used as a grep ERE pattern to filter
1523 all the topic branches. Both ``goto`` and
1524 ``--`` may be omitted provided ``<pattern>``
1525 is not ``-a``, ``--all``, ``-h``, ``--help``,
1526 ``goto``, ``--``, ``n``, ``next``, ``push``,
1527 ``child``, ``p``, ``prev``, ``previous``,
1528 ``pop``, ``parent``, ``+``, ``-`` or ``..``.
1530 ``tg checkout [goto] [--] --series[=<head>]``
1531 Check out a topic branch that belongs to
1532 the current (or ``<head>``) patch series.
1533 A list with descriptions (``tg info --series``)
1534 will be shown to choose from if more than one.
1536 ``tg checkout + [<steps>]``
1537 An alias for ``next``.
1539 ``tg checkout push [<steps>]``
1540 An alias for ``next``.
1542 ``tg checkout child [<steps>]``
1543 Deprecated alias for ``next``.
1546 Semi-deprecated alias for ``next``.
1548 ``tg checkout - [<steps>]``
1549 An alias for ``prev``.
1551 ``tg checkout pop [<steps>]``
1552 An alias for ``prev``.
1554 ``tg checkout parent [<steps>]``
1555 Deprecated alias for ``prev``.
1557 ``tg checkout .. [<steps>]``
1558 Semi-deprecated alias for ``prev``.
1560 If any of the above commands can find more than one possible
1561 branch to switch to, you will be presented with the matches
1562 and asked to select one of them.
1564 If the ``--ignore-other-worktrees`` (or ``--iow``) option is given and
1565 the current Git version is at least 2.5.0 then the full
1566 ``--ignore-other-worktrees`` option will be passed along to the
1567 ``git checkout`` command when it's run (otherwise the option will be
1568 silently ignored and not passed to Git as it would cause an error).
1570 The ``--force`` (or ``-f``) option, when given, gets passed through to
1571 the ``git checkout`` command.
1573 The ``--merge`` (or ``-m``) option, when given, gets passed through to
1574 the ``git checkout`` command.
1576 The ``--quiet`` (or ``-q``) option, when given, gets passed through to
1577 the ``git checkout`` command.
1579 The ``<pattern>`` of ``tg checkout goto`` is optional. If you don't
1580 supply it, all the available topic branches are listed and you
1581 can select one of them.
1583 Normally, the ``next`` and ``prev`` commands move one step in
1584 the dependency graph of the topic branches. The ``-a`` option
1585 causes them (and their aliases) to move as far as possible.
1586 That is, ``tg checkout next -a`` moves to a topic branch that
1587 depends (directly or indirectly) on the current branch and
1588 that no other branch depends on. ``tg checkout prev -a``
1589 moves to a topic branch that the current topic branch
1590 depends on (directly or indirectly). If there is more than
1591 one possibility, you will be prompted for your selection.
1593 See also NAVIGATION_.
1597 Export a tidied-up history of the current topic branch and its
1598 dependencies, suitable for feeding upstream. Each topic branch
1599 corresponds to a single commit or patch in the cleaned up
1600 history (corresponding basically exactly to ``tg patch`` output
1601 for the topic branch).
1603 The command has three possible outputs now -- either a Git branch
1604 with the collapsed history, a Git branch with a linearized
1605 history, or a quilt series in new directory.
1607 In the case where you are producing collapsed history in a new
1608 branch, you can use this collapsed structure either for
1609 providing a pull source for upstream, or for further
1610 linearization e.g. for creation of a quilt series using git log::
1612 git log --pretty=email -p --topo-order origin..exported
1614 To better understand the function of ``tg export``, consider this
1615 dependency structure::
1617 origin/master - t/foo/blue - t/foo/red - master
1618 `- t/bar/good <,----------'
1619 `- t/baz ------------'
1621 (where each of the branches may have a hefty history). Then::
1623 master$ tg export for-linus
1625 will create this commit structure on the branch ``for-linus``::
1627 origin/master - t/foo/blue -. merge - t/foo/red -.. merge - master
1628 `- t/bar/good <,-------------------'/
1629 `- t/baz ---------------------'
1631 In this mode, ``tg export`` works on the current topic branch, and
1632 can be called either without an option (in that case,
1633 ``--collapse`` is assumed), or with the ``--collapse`` option, and
1634 with one mandatory argument: the name of the branch where the
1635 exported result will be stored.
1637 Both the ``--collapse`` and ``--linearize`` modes also accept a
1638 ``-s <mode>`` option to specify subject handling behavior for the
1639 freshly created commits. There are five possible modes:
1641 :keep: Like ``git mailinfo -k``
1642 :mailinfo: Like ``git mailinfo``
1643 :patch: Remove first ``[PATCH*]`` if any
1644 :topgit: Remove first [PATCH*], [BASE], [ROOT] or [STAGE]
1645 :trim: Trim runs of spaces/tabs to a single space
1647 The ``topgit`` (aka ``tg``) mode is the default (quelle surprise) and
1648 like the ``patch`` mode will only strip the first square brackets tag
1649 (if there is one) provided it's a TopGit-known tag (the ``patch``
1650 variation will only strip a PATCH tag but still just the first one).
1651 Note that TopGit does understand ``[RELEASE]`` in ``topgit`` mode.
1652 With ``trim`` (aka ``ws``) internal runs of spaces/tabs are converted
1653 to a single space, but no square brackets tags are removed. The ``ws``
1654 mode should generally be preferred instead of using ``keep`` mode.
1655 All modes always remove leading/trailing spaces and tabs and if the
1656 ``topgit.subjectPrefix`` value (see `tg create`_) has been set both the
1657 ``topgit`` and ``patch`` modes will match tags with that prefix too.
1659 Setting the config variable ``topgit.subjectMode`` to one of the mode
1660 values shown above will change the default to that mode.
1662 When using the linearize mode::
1664 master$ tg export --linearize for-linus
1666 you get a linear history respecting the dependencies of your
1667 patches in a new branch ``for-linus``. The result should be more
1668 or less the same as using quilt mode and then reimporting it
1669 into a Git branch. (More or less because the topological order
1670 can usually be extended in more than one way into a total order,
1671 and the two methods may choose different ones.) The result
1672 might be more appropriate for merging upstream, as it contains
1675 Note that you might get conflicts during linearization because
1676 the patches are reordered to get a linear history. If linearization
1677 would produce conflicts then using ``--quilt`` will also likely result
1678 in conflicts when the exported quilt series is applied. Since the
1679 ``--quilt`` mode simply runs a series of ``tg patch`` commands to
1680 generate the patches in the exported quilt series and those patches
1681 will end up being applied linearly, the same conflicts that would be
1682 produced by the ``--linearize`` option will then occur at that time.
1684 To avoid conflicts produced by ``--linearize`` (or by applying the
1685 ``--quilt`` output), use the default ``--collapse`` mode and then use
1686 ``tg rebase`` (or ``git rebase -m`` directly) on the collapsed branch
1687 (with a suitable <upstream>) followed by ``git format-patch`` on the
1688 rebased result to produce a conflict-free patch set. A suitable
1689 upstream may be determined with the ``tg info --leaves`` command (if
1690 it outputs more than one line, linearization will be problematic).
1692 You have enabled ``git rerere`` haven't you?
1694 When using the quilt mode::
1696 master$ tg export --quilt for-linus
1698 would create the following directory ``for-linus``::
1700 for-linus/t/foo/blue.diff
1701 for-linus/t/foo/red.diff
1702 for-linus/t/bar/good.diff
1703 for-linus/t/baz.diff
1710 With ``--quilt``, you can also pass the ``-b`` parameter followed
1711 by a comma-separated explicit list of branches to export, or
1712 the ``--all`` parameter (which can be shortened to ``-a``) to
1713 export them all. The ``--binary`` option enables producing Git
1714 binary patches. These options are currently only supported
1717 In ``--quilt`` mode the patches are named like the originating
1718 topgit branch. So usually they end up in subdirectories of the
1719 output directory. With the ``--flatten`` option the names are
1720 mangled so that they end up directly in the output dir (slashes
1721 are replaced with underscores). With the ``--strip[=N]`` option
1722 the first ``N`` subdirectories (all if no ``N`` is given) get
1723 stripped off. Names are always ``--strip``'d before being
1724 ``--flatten``'d. With the option ``--numbered`` (which implies
1725 ``--flatten``) the patch names get a number as prefix to allow
1726 getting the order without consulting the series file, which
1727 eases sending out the patches.
1729 Note that ``tg export`` is fully compatible with the `wayback machine`_
1730 and when used with the ``--collapse`` or ``--linearize`` options will
1731 "push" the resulting branch back into the main repository when used in
1734 | TODO: Make stripping of non-essential headers configurable
1735 | TODO: ``--mbox`` option to export instead as an mbox file
1736 | TODO: support ``--all`` option in other modes of operation
1737 | TODO: For quilt exporting, export the linearized history created in
1738 a temporary branch--this would allow producing conflict-less
1743 Import commits within the given revision range(s) into TopGit,
1744 creating one topic branch per commit. The dependencies are set
1745 up to form a linear sequence starting on your current branch --
1746 or a branch specified by the ``-d`` parameter, if present.
1748 The branch names are auto-guessed from the commit messages and
1749 prefixed by ``t/`` by default; use ``-p <prefix>`` to specify an
1750 alternative prefix (even an empty one).
1752 Each "<range>" must be of the form <rev1>..<rev2> where either
1753 <rev1> or <rev2> can be omitted to mean HEAD. Additionally the
1754 shortcut <rev>^! (see ``git help revisions``) is permitted as a
1755 "<range>" to select the single commit <rev> but only if the
1756 commit <rev> has *exactly* one parent. This is really just a
1757 shortcut for <rev>^..<rev> but somewhat safer since it will fail
1758 if <rev> has other than one parent.
1760 Alternatively, you can use the ``-s NAME`` parameter to specify
1761 the name of the target branch; the command will then take one
1762 more argument describing a *single* commit to import (which may
1763 have any number of parents).
1767 Update the current, specified or all topic branches with respect
1768 to changes in the branches they depend on and remote branches.
1769 This is performed in two phases -- first, changes within the
1770 dependencies are merged to the base, then the base is merged
1771 into the topic branch. The output will guide you on what to do
1772 next in case of conflicts.
1774 You have enabled ``git rerere`` haven't you?
1776 The ``--[no-]auto[-update]`` options together with the
1777 ``topgit.setAutoUpdate`` config item control whether or not TopGit
1778 will automatically temporarily set ``rerere.autoUpdate`` to true while
1779 running ``tg update``. The default is true. Note that this does not
1780 enable Git's ``rerere`` feature, it merely makes it automatically stage
1781 any previously resolved conflicts. The ``rerere.enabled`` setting must
1782 still be separately enabled (i.e. set to ``true``) for the ``rerere``
1783 feature to do anything at all.
1785 Using ``--auto[-update]`` makes ``tg update`` always temporarily set
1786 ``rerere.autoUpdate`` to ``true`` while running ``tg update``. The
1787 ``--no-auto[-update]`` option prevents ``tg update`` from changing the
1788 ``rerere.autoUpdate`` setting, but if ``rerere.autoUpdate`` has already
1789 been enabled in a config file, ``tg update`` never disables it even
1790 with ``--no-auto``. If ``topgit.setAutoUpdate`` is unset or set to
1791 ``true`` then ``tg update`` implicitly does ``--auto``, otherwise it
1792 does ``--no-auto``. An explicit command line ``--[no-]auto[-update]``
1793 option causes the ``topgit.setAutoUpdate`` setting to be ignored.
1795 When both ``rerere.enabled`` and ``rerere.autoUpdate`` are set to true
1796 then ``tg update`` will be able to automatically continue an update
1797 whenever ``git rerere`` resolves all the conflicts during a merge.
1798 This can be such a huge time saver. That's why the default is to have
1799 TopGit automatically set ``rerere.autoUpdate`` to true while
1800 ``tg update`` is running (but remember, unless ``rerere.enabled`` has
1801 been set to ``true`` it won't make any difference).
1803 When ``-a`` (or ``--all``) is specified, updates all topic branches
1804 matched by ``<pattern>``'s (see ``git-for-each-ref(1)`` for details),
1805 or all if no ``<pattern>`` is given. Any topic branches with missing
1806 dependencies will be skipped entirely unless ``--skip-missing`` is
1809 When ``--skip-missing`` is specified, an attempt is made to update topic
1810 branches with missing dependencies by skipping only the dependencies
1811 that are missing. Caveat utilitor.
1813 When ``--stash`` is specified (or the ``topgit.autostash`` config
1814 value is set to ``true``), a ref stash will be automatically created
1815 just before beginning updates if any are needed. The ``--no-stash``
1816 option may be used to disable a ``topgit.autostash=true`` setting.
1817 See the ``tg tag`` ``--stash`` option for details.
1819 After the update, if a single topic branch was specified, it is
1820 left as the current one; if ``-a`` was specified, it returns to
1821 the branch which was current at the beginning.
1823 If your dependencies are not up-to-date, ``tg update`` will first
1824 recurse into them and update them.
1826 If a remote branch update brings in dependencies on branches
1827 that are not yet instantiated locally, you can either bring in
1828 all the new branches from the remote using ``tg remote
1829 --populate``, or only pick out the missing ones using ``tg create
1830 -r`` (``tg summary`` will point out branches with incomplete
1831 dependencies by showing an ``!`` next to them). TopGit will attempt to
1832 instantiate just the missing ones automatically for you, if possible,
1833 when ``tg update`` merges in the new dependencies from the remote.
1835 Using the alternative ``--base`` mode, ``tg update`` will update
1836 the base of a specified ``[BASE]`` branch (which is a branch created
1837 by ``tg create`` using the ``--base`` option) to the specified
1838 committish (the second argument) and then immediately merge that into
1839 the branch itself using the specified message for the merge commit.
1840 If no message is specified on the command line, an editor will open.
1841 Unless ``--force`` is used the new value for the base must contain
1842 the old value (i.e. be a fast-forward update). This is for safety.
1844 This mode makes updates to ``[BASE]`` branches quick and easy.
1846 | TODO: ``tg update -a -c`` to autoremove (clean) up-to-date branches
1850 If ``-a`` or ``--all`` was specified, pushes all non-annihilated
1851 TopGit-controlled topic branches, to a remote repository.
1852 Otherwise, pushes the specified topic branches -- or the
1853 current branch, if you don't specify which. By default, the
1854 remote gets all the dependencies (both TopGit-controlled and
1855 non-TopGit-controlled) and bases pushed to it too. If
1856 ``--tgish-only`` was specified, only TopGit-controlled
1857 dependencies will be pushed, and if ``--no-deps`` was specified,
1858 no dependencies at all will be pushed.
1860 All TopGit branches to be pushed must be up-to-date unless the
1861 ``--allow-outdated`` option is given. Branches `are` checked against
1862 the configured TopGit remote (``topgit.remote``) if it's set (as
1863 modified by the global ``-u`` and ``-r <remote>`` options).
1865 The ``--dry-run``, ``--force``, ``--atomic``, ``--signed[=...]``,
1866 ``-4`` and ``-6`` options are passed through directly to ``git push``
1867 if given. Note that in the highly unlikely event that the branch names
1868 of all the branches being pushed do not fit on a single command line,
1869 multiple ``git push`` commands will be issued which would have the side
1870 effect of rendering ``--atomic`` not so atomic and cause more than
1871 one signature to be needed if ``--signed[=...]`` is used.
1873 The push remote may be specified with the ``-r`` option. If no remote
1874 was specified, the configured default TopGit push remote will be
1875 used (``topgit.pushRemote``) or if that's unset the regular remote
1876 (``topgit.remote``).
1878 Use something like this to push to an ``origin`` remote when it's set
1879 as ``topgit.remote`` while only checking for local out-of-dateness:
1881 ``tg -u push -r origin <optional-branch-names-here>``
1885 Prints the base commit of each of the named topic branches, or
1886 the current branch if no branches are named. Prints an error
1887 message and exits with exit code 1 if the named branch is not
1892 Prints the git log of the named topgit branch -- or the current
1893 branch, if you don't specify a name.
1895 This is really just a convenient shortcut for:
1897 ``git log --first-parent --no-merges $(tg base <name>)..<name>``
1899 where ``<name>`` is the name of the TopGit topic branch (or omitted
1900 for the current branch).
1902 However, if ``<name>`` is a ``[BASE]`` branch the ``--no-merges``
1905 If ``--compact`` is used then ``git log-compact`` will be used instead
1906 of ``git log``. The ``--command=<git-alias>`` option can be used to
1907 replace "log" with any non-whitespace-containing command alias name,
1908 ``--compact`` is just a shortcut for ``--command=log-compact``. The
1909 ``git-log-compact`` tool may be found on its project page located at:
1911 https://mackyle.github.io/git-log-compact
1913 Note that the ``--compact`` or ``--command=`` option must be used
1914 before any ``--`` or ``git log`` options to be recognized.
1916 NOTE: if you have merged changes from a different repository, this
1917 command might not list all interesting commits.
1921 Creates a TopGit annotated/signed tag or lists the reflog of one.
1923 A TopGit annotated tag records the current state of one or more TopGit
1924 branches and their dependencies and may be used to revert to the tagged
1925 state at any point in the future.
1927 When reflogs are enabled (the default in a non-bare repository) and
1928 combined with the ``--force`` option a single tag name may be used as a
1929 sort of TopGit branch state stash. The special branch name ``--all``
1930 may be used to tag the state of all current TopGit branches to
1931 facilitate this function and has the side-effect of suppressing the
1932 out-of-date check allowing out-of-date branches to be included.
1934 As a special feature, ``--stash`` may be used as the tag name in which
1935 case ``--all`` is implied if no branch name is listed (instead of the
1936 normal default of ``HEAD``), ``--force`` and ``--no-edit`` (use
1937 ``--edit`` to change that) are automatically activated and the tag will
1938 be saved to ``refs/tgstash`` instead of ``refs/tags/<tagname>``.
1939 The ``--stash`` tag name may also be used with the ``-g``/``--reflog``
1942 The mostly undocumented option ``--allow-outdated`` will bypass the
1943 out-of-date check and is implied when ``--stash`` or ``--all`` is used.
1945 A TopGit annotated/signed tag is simply a Git annotated/signed tag with
1946 a "TOPGIT REFS" section appended to the end of the tag message (and
1947 preceding the signature for signed tags). PEM-style begin and end
1948 lines surround one line per ref where the format of each line is
1949 full-hash SP ref-name. A line will be included for each branch given
1950 on the command line and each ref they depend on either directly or
1953 Note that when specifying branch names, if a given name is ambiguous
1954 but prefixing the branch name with ``refs/heads/`` successfully
1955 disambiguates it, then that will be the interpretation used.
1957 If more than one TopGit branch is given on the command line, a new
1958 commit will be created that has an empty tree and all of the given
1959 TopGit branches as parents and that commit will be tagged. If a single
1960 TopGit branch is given, then it will be tagged. If the ``--tree``
1961 option is used then it will be used instead of an empty tree (a new
1962 commit will be created if necessary to guarantee the specified tree is
1963 what's in the commit the newly created tag refers to). The argument to
1964 the ``--tree`` option may be any valid treeish.
1966 If exactly one of the branches to be tagged is prefixed with a tilde
1967 (``~``) it will be made the first parent of a consolidation commit if
1968 it is not already the sole commit needing to be tagged. If ``--tree``
1969 is NOT used, its tree will also be used instead of the empty tree for
1970 any new consolidation commit if one is created. Note that if
1971 ``--tree`` is given explicitly its tree is always used but that does
1972 not in any way affect the choice of first parent. Beware that the
1973 ``~`` may need to be quoted to prevent the shell from misinterpreting
1974 it into something else.
1976 All the options for creating a tag serve the same purpose as their Git
1977 equivalents except for two. The ``--refs`` option suppresses tag
1978 creation entirely and emits the "TOPGIT REFS" section that would have
1979 been included with the tag. If the ``--no-edit`` option is given and
1980 no message is supplied (via the ``-m`` or ``-F`` option) then the
1981 default message created by TopGit will be used without running the
1984 With ``-g`` or ``--reflog`` show the reflog for a tag. With the
1985 ``--reflog-message`` option the message from the reflog is shown.
1986 With the ``--commit-message`` option the first line of the tag's
1987 message (if the object is a tag) or the commit message (if the object
1988 is a commit) falling back to the reflog message for tree and blob
1989 objects is shown. The default is ``--reflog-message`` unless the
1990 ``--stash`` (``refs/tgstash``) is being shown in which case the default
1991 is then ``--commit-message``. Just add either option explicitly to
1992 override the default.
1994 When showing reflogs, non-tag entries are annotated with their type
1995 unless ``--no-type`` is given.
1997 TopGit tags are created with a reflog if core.logallrefupdates is
1998 enabled (the default for non-bare repositories). Unfortunately Git
1999 is incapable of showing an annotated/signed tag's reflog
2000 (using git log -g) as it will first resolve the tag before checking to
2001 see if it has a reflog. Git can, however, show reflogs for lightweight
2002 tags (using git log -g) just fine but that's not helpful here. Use
2003 ``tg tag`` with the ``-g`` or ``--reflog`` option to see the reflog for
2004 an actual tag object. This also works on non-TopGit annotated/signed
2005 tags as well provided they have a reflog.
2007 The number of entries shown may be limited with the ``-n`` option. If
2008 the tagname is omitted then ``--stash`` is assumed.
2010 The ``--delete`` option is a convenience option that runs the
2011 ``git update-ref --no-deref -d`` command on the specified tag removing
2012 it and its reflog (if it has one). Note that `HEAD` cannot be removed.
2014 The ``--clear`` option clears all but the most recent (the ``@{0}``)
2015 reflog entries from the reflog for the specified tag. It's equivalent
2016 to dropping all the higher numbered reflog entries.
2018 The ``--drop`` option drops the specified reflog entry and requires the
2019 given tagname to have an ``@{n}`` suffix where ``n`` is the reflog
2020 entry number to be dropped. This is really just a convenience option
2021 that runs the appropriate ``git reflog delete`` command. Note that
2022 even dropping the ...@{0} entry when it's the last entry of a
2023 non-symbolic ref will NOT delete the ref itself (unless the ref was
2024 already somehow set to an invalid object hash); but dropping @{0} of
2025 a non-symbolic ref may have the side effect of removing some stale
2026 reflog entries that were present in the reflog.
2028 Note that when combined with ``tg revert``, a tag created by ``tg tag``
2029 can be used to transfer TopGit branches. Simply create the tag, push
2030 it somewhere and then have the recipient run ``tg revert`` to recreate
2031 the TopGit branches. This may be helpful in situations where it's not
2032 feasible to push all the refs corresponding to the TopGit-controlled
2033 branches and their top-bases.
2037 Provides a ``git rebase`` rerere auto continue function. It may be
2038 used as a drop-in replacement front-end for ``git rebase -m`` that
2039 automatically continues the rebase when ``git rerere`` information is
2040 sufficient to resolve all conflicts.
2042 You have enabled ``git rerere`` haven't you?
2044 If the ``-m`` or ``--merge`` option is not present then ``tg rebase``
2045 will complain and not do anything.
2047 When ``git rerere`` is enabled, previously resolved conflicts are
2048 remembered and can be automatically staged (see ``rerere.autoUpdate``).
2050 However, even with auto staging, ``git rebase`` still stops and
2051 requires an explicit ``git rebase --continue`` to keep going.
2053 In the case where ``git rebase -m`` is being used to flatten history
2054 (such as after a ``tg export --collapse`` prior to a
2055 ``git format-patch``), there's a good chance all conflicts have already
2056 been resolved during normal merge maintenance operations so there's no
2057 reason ``git rebase`` could not automatically continue, but there's no
2058 option to make it do so.
2060 The ``tg rebase`` command provides a ``git rebase --auto-continue``
2063 All the same rebase options can be used (they are simply passed through
2064 to Git unchanged). However, the ``rerere.autoUpdate`` option is
2065 automatically temporarily enabled while running ``git rebase`` and
2066 should ``git rebase`` stop asking one to resolve and continue, but all
2067 conflicts have already been resolved and staged using rerere
2068 information, then ``git rebase --continue`` will be automatically run.
2072 Provides the ability to revert one or more TopGit branches and their
2073 dependencies to a previous state contained within a tag created using
2074 the ``tg tag`` command. In addition to the actual revert mode
2075 operation a list mode operation is also provided to examine a tag's ref
2078 The default mode (``-l`` or ``--list``) shows the state of one or more
2079 of the refs/branches stored in the tag data. When no refs are given on
2080 the command line, all refs in the tag data are shown. With the special
2081 ref name ``--heads`` then the indepedent heads contained in the tag
2082 data are shown. The ``--deps`` option shows the specified refs and all
2083 of their dependencies in a single list with no duplicates. The
2084 ``--rdeps`` option shows a display similar to ``tg summary --rdeps``
2085 for each ref or all TopGit heads if no ref is given on the command
2086 line. The standard ``--no-short``, ``--short=n`` etc. options may be
2087 used to override the default ``--short`` output. With ``--hash`` (or
2088 ``--hash-only``) show only the hash in ``--list`` mode in which case
2089 the default is ``--no-short``. The ``--hash`` option can be used much
2090 like the ``git rev-parse --verify`` command to extract a specific hash
2091 value out of a TopGit tag.
2093 Note that unlike `tg summary`_, here ``--heads`` actually does mean the
2094 ``git merge-base --independent`` heads of the stored refs from the tag
2095 data. To see only the independent TopGit topic branch heads stored in
2096 the tag data use the ``--topgit-heads`` option instead. The default
2097 for the ``--rdeps`` option is ``--topgit-heads`` but ``--heads`` can
2098 be given explicitly to change that. (Note that ``--heads-independent``
2099 is accepted as an alias for ``--heads`` as well.)
2101 The revert mode has three submodes, dry-run mode (``-n`` or
2102 ``--dry-run``), force mode (``-f`` or ``--force``) and interactive mode
2103 (``-i`` or ``--interactive``). If ``--dry-run`` (or ``-n``) is given
2104 no ref updates will actually be performed but what would have been
2105 updated is shown instead. If ``--interactive`` (or ``-i``) is given
2106 then the editor is invoked on an instruction sheet allowing manual
2107 selection of the refs to be updated before proceeding. Since revert is
2108 potentially a destructive operation, at least one of the submodes must
2109 be specified explicitly. If no refs are listed on the command line
2110 then all refs in the tag data are reverted. Otherwise the listed refs
2111 and all of their dependencies (unless ``--no-deps`` is given) are
2112 reverted. Unless ``--no-stash`` is given a new stash will be created
2113 using ``tg tag --stash`` (except, of course, in dry-run mode) just
2114 before actually performing the updates to facilitate recovery from
2117 Both modes accept fully-qualified (i.e. starts with ``refs/``) ref
2118 names as well as unqualified names (which will be assumed to be located
2119 under ``refs/heads/``). In revert mode a tgish ref will always have
2120 both its ``refs/heads/`` and ``refs/top-bases/`` values included no
2121 matter how it's listed unless ``--no-deps`` is given and the ref is
2122 fully qualified (i.e. starts with ``refs/``) or one or the other of its
2123 values was removed from the instruction sheet in interactive mode. In
2124 list mode a tgish ref will always have both its ``refs/heads/`` and
2125 ``refs/top-bases/`` values included only when using the ``--deps`` or
2126 ``--rdeps`` options.
2128 The ``--tgish-only`` option excludes non-tgish refs (i.e. refs that do
2129 not have a ``refs/heads/<name>``, ``refs/top-bases/<name>`` pair).
2131 The ``--exclude`` option (which can be repeated) excludes specific
2132 refs. If the name given to ``--exclude`` is not fully-qualified (i.e.
2133 starts with ``refs/``) then it will exclude both members of a tgish ref
2136 The ``--quiet`` (or ``-q``) option may be used in revert mode to
2137 suppress non-dry-run ref change status messages.
2139 The special tag name ``--stash`` (as well as with ``@{n}`` suffixes)
2140 can be used to refer to ``refs/tgstash``.
2142 The ``tg revert`` command supports tags of tags that contains TopGit
2143 refs. So, for example, if you do this::
2146 git tag -f -a -m "tag the tag" newtag newtag
2148 Then ``newtag`` will be a tag of a tag containing a ``TOPGIT REFS``
2149 section. ``tg revert`` knows how to dereference the outermost
2150 tag to get to the next (and the next etc.) tag to find the
2151 ``TOPGIT REFS`` section so after the above sequence, the tag ``newtag``
2152 can still be used successfully with ``tg revert``.
2154 NOTE: If HEAD points to a ref that is updated by a revert operation
2155 then NO WARNING whatsoever will be issued, but the index and working
2156 tree will always be left completely untouched (and the reflog for
2157 the pointed-to ref can always be used to find the previous value).
2161 Enter extended `wayback machine`_ mode.
2163 The global ``-w <tgtag>`` option must be specified (but as a special
2164 case for the ``shell`` subcommand a <tgtag> destination of ``:`` may be
2165 used to get a shell with no wayback ref changes).
2167 The "<tgtag>" value must be the name of a tag created by (or known to)
2168 `tg tag`_. However, it may also have a ``:`` prefixed to it to
2169 indicate that it should prune (making it into a "pruning wayback tag").
2170 Use of a "pruning wayback tag" results in a repository that contains
2171 exclusively those refs listed in the specified tag. Otherwise the
2172 wayback repository will just revert those refs while keeping the others
2173 untouched (the default behavior).
2175 The `wayback machine`_ activates as normal for the specified
2176 destination but then a new ``${SHELL:-/bin/sh}`` is spawned in a
2177 temporary non-bare repository directory that shares all the same
2178 objects from the repository but has its own copy of the ref namespace
2179 where the refs specified in the wayback destination have all been
2180 changed to have their wayback values.
2182 If any arguments are given a POSIX shell will be spawned instead
2183 concatenating all the arguments together with a space and passing
2184 them to it via a ``-c`` option. If ``-q`` (or ``--quote``) is given
2185 then each argument will first be separately "quoted" to protect it from
2186 the shell allowing something like this::
2188 tg -w <tgtag> shell -q git for-each-ref --format="%(refname)"
2190 to work without needing to manually add the extra level of quoting that
2191 would otherwise be required due to the parentheses.
2193 Most of the repository configuration will be inherited, but some
2194 will be overridden for safety and for convenience. All "gc" activity
2195 within the wayback repository will be suppressed to avoid accidents
2196 (i.e. no auto gc will run and "gc" commands will complain and not run).
2198 Override and/or bypass this safety protection at your own peril!
2199 Especially *do not run* the ``git prune`` plumbing command in the
2200 wayback repository! If you do so (or bypass any of the other safeties)
2201 be prepared for corruption and loss of data in the repository.
2202 Just *don't do that* in the first place!
2204 Using ``git wayback-tag`` will show the tag used to enter the wayback
2205 machine. Using ``git wayback-updates`` will show ref changes that have
2206 occurred since the wayback tag was created (it will not show refs that
2207 have since been created unless a pruning wayback tag was used).
2208 Finally, ``git wayback-repository`` will show the home repository but
2209 so will ``git remote -v`` in the output displayed for the ``wayback``
2212 The special ``wayback`` remote refers to the original repository and
2213 can be used to push ref changes back to it. Note, however, that all
2214 default push refspecs are disabled for safety and an explicit refspec
2215 will need to be used to do so.
2217 Unlike the normal `wayback machine`_ mode, ``HEAD`` will be detached
2218 to a new commit with an empty tree that contains the message and author
2219 from the wayback tag used. This prevents ugly status displays while
2220 avoiding the need to checkout any files into the temporary working
2221 tree. The parent of this commit will, however, be set to the wayback
2222 tag's commit making it easy to access if desired.
2224 Also unlike the normal `wayback machine`_ mode, there are no
2225 limitations on what can be done in the temporary repository.
2226 And since it will be non-bare and writable, commands that may not have
2227 been allowed in the original repository will work too.
2229 When the shell spawned by this subcommand exits, the temporary wayback
2230 repository and all newly created objects and ref changes made in it, if
2231 any, *will be lost*. If work has been done in it that needs to be
2232 saved, it must be pushed somewhere (even if only back to the original
2233 repository using the special ``wayback`` remote).
2235 Lastly there's the ``--directory`` option. If the ``--directory``
2236 option is used the temporary "wayback repository" will be created at
2237 the specified location (which must either not exist or must be an empty
2238 directory -- no force option available this time as too many things
2239 could easily go wrong in that case). If the ``--directory`` option is
2240 used then the "wayback repository" *will persist* after ``tg shell``
2241 completes allowing it to continue to be used! Be warned though, all
2242 the same warnings that apply to ``git clone --shared`` apply to such
2243 a repository. If it's created using a ``tgstash`` tag those warnings
2244 are especially salient. Use a single argument of either ``:`` (to
2245 just create with no output) or ``pwd`` (to show the full absolute path
2246 to the new "wayback repository") when using the ``--directory`` option
2247 if the sole purpose is just to create the wayback repository for use.
2248 Note that the ``--directory`` option *must* be listed as the first
2249 option after the ``shell`` subcommand name if used.
2253 Output the "previous" branch(es) in the patch series containing the
2254 current or named branch. The "previous" branch(es) being one step
2258 -i show dependencies based on index instead of branch
2259 -w show dependencies based on working tree instead of branch
2260 -n <steps> take ``<steps>`` "previous" steps (default 1)
2261 --all take as many "previous" steps as possible (aka ``-a``)
2262 --verbose show containing series name(s) (aka ``-v``)
2264 The ``-n`` option may also be given as ``--count`` or ``--count=<n>``.
2266 To list all dependencies of a branch see the ``--deps`` option of
2267 the `tg info`_ command.
2269 See also NAVIGATION_ for full details on "previous" steps.
2273 Output tne "next" branch(es) in the patch series containing the current
2274 or named branch. The "next" branch(es) being one step away by default.
2277 -i show dependencies based on index instead of branch
2278 -w show dependencies based on working tree instead of branch
2279 -n <steps> take ``<steps>`` "next" steps (default 1)
2280 --all take as many "next" steps as possible (aka ``-a``)
2281 --verbose show containing series name(s) (aka ``-v``)
2283 The ``-n`` option may also be given as ``--count`` or ``--count=<n>``.
2285 To list all dependents of a branch see the ``--dependents`` option of
2286 the `tg info`_ command.
2288 See also NAVIGATION_ for full details on "next" steps.
2292 Transition top-bases from old location to new location.
2294 Beginning with TopGit release 0.19.4, TopGit has the ability to store
2295 the top-bases refs in either the old ``ref/top-bases/...`` location or
2296 the new ``refs/heads/{top-bases}/...`` location. Starting with TopGit
2297 release 0.20.0, the default is the new location.
2299 By storing the top-bases under heads, Git is less likely to complain
2300 when manipulating them, hosting providers are more likely to provide
2301 access to them and Git prevents them from pointing at anything other
2302 than a commit object. All in all a win for everyone.
2304 TopGit attempts to automatically detect whether the new or old location
2305 is being used for the top-bases and just do the right thing. However,
2306 by explicitly setting the config value ``topgit.top-bases`` to either
2307 ``refs`` for the old location or ``heads`` for the new location the
2308 auto-detection can be bypassed. If no top-bases refs are present in
2309 the repository the default prior to TopGit release 0.20.0 is to use the
2310 old location but starting with TopGit release 0.20.0 the default is to
2311 use the new location.
2313 The ``tg migrate-bases`` command may be used to migrate top-bases refs
2314 from the old location to the new location (or, by using the
2315 undocumented ``--reverse`` option, vice versa).
2317 With few exceptions (``tg create -r`` and ``tg revert``), all top-bases
2318 refs (both local *and* remote refs) are expected to be stored in the
2319 same location (either new or old). A repository's current location for
2320 storing top-bases refs may be shown with the ``tg --top-bases`` command.
2328 TopGit stores all the topic branches in the regular ``refs/heads/``
2329 namespace (so we recommend distinguishing them with the ``t/`` prefix).
2330 Apart from that, TopGit also maintains a set of auxiliary refs in
2331 ``refs/top-*``. Currently, only ``refs/top-bases/`` is used, containing the
2332 current *base* of the given topic branch -- this is basically a merge of
2333 all the branches the topic branch depends on; it is updated during ``tg
2334 update`` and then merged to the topic branch, and it is the base of a
2335 patch generated from the topic branch by ``tg patch``.
2337 All the metadata is tracked within the source tree and history of the
2338 topic branch itself, in ``.top*`` files; these files are kept isolated
2339 within the topic branches during TopGit-controlled merges and are of
2340 course omitted during ``tg patch``. The state of these files in base
2341 commits is undefined; look at them only in the topic branches
2342 themselves. Currently, two files are defined:
2345 Contains the description of the topic branch in a
2346 mail-like format, plus the author information, whatever
2347 Cc headers you choose or the post-three-dashes message.
2348 When mailing out your patch, basically only a few extra
2349 mail headers are inserted and then the patch itself is
2350 appended. Thus, as your patches evolve, you can record
2351 nuances like whether the particular patch should have
2352 To-list / Cc-maintainer or vice-versa and similar
2353 nuances, if your project is into that. ``From`` is
2354 prefilled from your current ``GIT_AUTHOR_IDENT``; other
2355 headers can be prefilled from various optional
2356 ``topgit.*`` git config options.
2359 Contains the one-per-line list of branches this branch
2360 depends on, pre-seeded by ``tg create``. A (continuously
2361 updated) merge of these branches will be the *base* of
2364 IMPORTANT: DO NOT EDIT ``.topdeps`` MANUALLY!!! If you do so, you need to
2365 know exactly what you are doing, since this file must stay in sync with
2366 the Git history information, otherwise very bad things will happen.
2368 TopGit also automagically installs a bunch of custom commit-related
2369 hooks that will verify whether you are committing the ``.top*`` files in a
2370 sane state. It will add the hooks to separate files within the ``hooks/``
2371 subdirectory, and merely insert calls to them to the appropriate hooks
2372 and make them executable (but will make sure the original hook's code is
2373 not called if the hook was not executable beforehand).
2375 Another automagically installed piece is a ``.git/info/attributes``
2376 specifier for an ``ours`` merge strategy for the files ``.topmsg`` and
2377 ``.topdeps``, and the (intuitive) ``ours`` merge strategy definition in
2384 There are two remaining issues with accessing topic branches in remote
2387 (i) Referring to remote topic branches from your local repository
2388 (ii) Developing some of the remote topic branches locally
2390 There are two somewhat contradictory design considerations here:
2392 (a) Hacking on multiple independent TopGit remotes in a single
2394 (b) Having a self-contained topic system in local refs space
2396 To us, (a) does not appear to be very convincing, while (b) is quite
2397 desirable for ``git-log topic`` etc. working, and increased conceptual
2400 Thus, we choose to instantiate all the topic branches of given remote
2401 locally; this is performed by ``tg remote --populate``. ``tg update``
2402 will also check if a branch can be updated from its corresponding remote
2403 branch. The logic needs to be somewhat involved if we are to "do the
2404 right thing". First, we update the base, handling the remote branch as
2405 if it was the first dependency; thus, conflict resolutions made in the
2406 remote branch will be carried over to our local base automagically.
2407 Then, the base is merged into the remote branch and the result is merged
2408 to the local branch -- again, to carry over remote conflict resolutions.
2409 In the future, this order might be adjustable on a per-update basis, in
2410 case local changes happen to be diverging more than the remote ones.
2411 (See the details in `The Update Process`_ for more in depth coverage.)
2413 All commands by default refer to the remote that ``tg remote --populate``
2414 was called on the last time (stored in the ``topgit.remote`` git
2415 configuration variable). You can manually run any command with a
2416 different base remote by passing ``-r REMOTE`` *before* the subcommand
2417 name or passing ``-u`` *before* the subcommand to run without one.
2423 Running the TopGit test suite only requires POSIX compatibile utilities (just
2424 a POSIX compatibile ``make`` will do) AND a ``perl`` binary.
2426 It is *not* necessary to install TopGit in order to run the TopGit test suite.
2428 To run the TopGit test suite, simply execute this from the top-level of a
2429 TopGit checkout or expanded release tarball:
2435 Yup, that's it. But you're probably thinking, "Why have a whole section just
2436 to say 'run make test'?" Am I right?
2438 The simple ``make test`` command produces a lot of output and while it is
2439 summarized at the end there's a better way.
2441 Do you have the ``prove`` utility available? You need ``perl`` to run the
2442 tests and ``prove`` comes with ``perl`` so you almost cerainly do.
2444 Try running the tests like so:
2448 make DEFAULT_TEST_TARGET=prove test
2451 (For reference, the default value of ``DEFAULT_TEST_TARGET`` is ``test`` which
2452 can be used to override a setting that's been altered using the instructions
2453 shown later on below.)
2455 If that works (you can interrupt it with ``Ctrl-C``), try this next:
2459 make DEFAULT_TEST_TARGET=prove TESTLIB_PROVE_OPTS="-j 4 --timer" test
2461 If that one works (again, you can interrupt it with ``Ctrl-C``) that may end
2462 up being the keeper for running the tests.
2464 However, if you don't have ``prove`` for some reason even though you do have
2465 ``perl``, there's still an alternative for briefer output. Try this:
2469 make TESTLIB_TEST_OPTS=-q test
2471 Much of the normal testing output will be suppressed and there's still a
2472 summary at the end. If you're stuck with this version but your make supports
2473 parallel operation (the ``-j`` *<n>*) option, then you might try this:
2477 make -j 4 TESTLIB_TEST_OPTS=-q test
2479 If your make *does* support the parallel ``-j`` option but still seems to be
2480 only running one test at a time try it like this instead:
2484 make TESTLIB_MAKE_OPTS="-j 4" TESTLIB_TEST_OPTS=-q test
2486 The difference is that ``make -j 4`` relies on make to properly pass down the
2487 parallel job option all the way down to the sub-make that runs the individual
2488 tests when not using prove. Putting the options in ``TESTLIB_MAKE_OPTS``
2489 passes them directly to that (and only that) particular invocation of make.
2491 The final bit of advice for running the tests is that any of those ``make``
2492 variable settings can be enabled by default in a top-level ``config.mak`` file.
2494 For example, to make the ``prove -j 4 --timer`` (my personal favorite) the
2495 default when running the tests, add these lines (creating the file if it does
2496 not already exist) to the ``config.mak`` file located in the top-level of the
2497 TopGit checkout (or expanded release tarball):
2502 # comments are allowed (if preceded by '#')
2503 # so are blank lines
2505 DEFAULT_TEST_TARGET = prove
2506 TESTLIB_PROVE_OPTS = -j 4 --timer
2507 #TESTLIB_TEST_OPTS = --color # force colorized test output
2509 Now simply doing ``make test`` will use those options by default.
2511 There is copious documentation on the testing library and other options in
2512 the various ``README`` files located in the ``t`` subdirectory. The
2513 ``Makefile.mak`` file in the ``t`` subdirectory contains plenty of comments
2514 about possible makefile variable settings as well.
2521 A familiarity with the terms in the GLOSSARY_ is helpful for understanding the
2522 content of this section. See also the IMPLEMENTATION_ section.
2527 When a branch is "updated" using the ``tg update`` command the following steps
2530 1) The branch and all of its dependencies (and theirs recursively)
2531 are checked to see which ones are *out-of-date*. See glossary_.
2533 2) Each of the branch's direct dependencies (i.e. they are listed in
2534 the branch's ``.topdeps`` file) which is out of date is updated
2535 before proceeding (yup, this is a recursive process).
2537 3) Each of the branch's direct dependencies (i.e. they are listed in
2538 the branch's ``.topdeps`` file) that was updated in the previous
2539 step is now merged into the branch's corresponding base. If a
2540 remote is involved, and the branch's corresponding base does NOT
2541 contain the remote branch's corresponding base that remote base is
2542 also merged into the branch's base at this time as well (it will be
2543 the first item merged into the branch's base).
2545 4) If the branch has a corresponding remote branch and the branch
2546 does not already contain it, the branch's base (which was possibly
2547 already updated in step (3) to contain the remote branch's base but
2548 not the remote branch itself) is merged into the remote branch on a
2549 detached HEAD. Yup, this step can be a bit confusing and no, the
2550 updated base from step (3) has not yet been merged into the branch
2551 itself yet either. If there is no remote branch this step does not
2552 apply. Using a detached HEAD allows the contents of the base to be
2553 merged into the remote branch without actually perturbing the base's
2554 or remote branch's refs.
2556 5) If there is a remote branch present then use the result of step (4)
2557 otherwise use the branch's base and merge that into the branch
2560 That's it! Simple, right? ;)
2562 Unless the auto stash option has been disabled (see `no undo`_, `tg update`_
2563 and `tg tag`_), a copy of all the old refs values will be stashed away
2564 immediately after step (1) before starting step (2), but only if anything is
2565 actually found to be out-of-date.
2570 The ``tg update`` command regularly performs merges while executing an update
2571 operation. In order to speed things up, it attempts to do in-index merges
2572 where possible. It accomplishes this by using a separate, temporary index
2573 file and the ``git read-tree -m --aggressive`` command possibly assisted by
2574 the ``git merge-index`` and ``git merge-file`` commands. This combination may
2575 be repeated more than once to perform an octopus in-index merge. If this
2576 fails, the files are checked out and a normal ``git merge`` three-way merge is
2577 performed (possibly multiple times). If the normal ``git merge`` fails then
2578 user intervention is required to resolve the merge conflict(s) and continue.
2580 Since the ``tg annihilate``, ``tg create`` and ``tg depend add`` commands may
2581 end up running the ``tg update`` machinery behind the scenes to complete their
2582 operation they may also result in any of these merge strategies being used.
2584 In addition to the normal Git merge strategies (if the in-index merging fails),
2585 there are four possible TopGit merge strategies that may be shown. Since they
2586 all involve use of the ``git read-tree -m --aggressive`` command they are all
2587 variations of a "trivial aggressive" merge. The "trivial" part because all of
2588 the merges done by ``git read-tree -m`` are described as "trivial" and the
2589 "aggressive" part because the ``--aggressive`` option is always used.
2591 1) "trivial aggressive"
2592 Only two heads were involved and all merging was completed by
2593 the ``git read-tree -m --aggressive`` command.
2595 2) "trivial aggressive automatic"
2596 Only two heads were involved but after the
2597 ``git read-tree -m --aggressive`` command completed there were
2598 still unresolved items and ``git merge-index`` had to be run
2599 (using the ``tg index-merge-one-file`` driver) which ultimately
2600 ran ``git merge-file`` at least once to perform a simple
2601 automatic three-way merge. Hence the "automatic" description
2602 and the "Auto-merging ..." output line(s).
2604 3) "trivial aggressive octopus"
2605 This is the same as a "trivial aggressive" merge except that
2606 more than two heads were involved and after merging the first
2607 two heads, the ``git read-tree -m --aggressive`` step was
2608 repeated again on the result for each additional head. All
2609 merging was completed via multiple
2610 ``git read-tree -m --aggressive`` commands only.
2611 This beast is relatively rare in the wild.
2613 4) "trivial aggressive automatic octopus"
2614 This is very similar to the "trivial aggressive octopus"
2615 except that at least one of the ``git read-tree -m --aggressive``
2616 commands left unresolved items that were handled the same way
2617 as the "trivial aggressive automatic" strategy. This species
2618 is commonly seen in the wild.
2625 Version-controlled file stored at the root level of each
2626 TopGit branch that contains the patch header for a TopGit
2627 branch. See also IMPLEMENTATION_.
2630 Version-controlled file stored at the root level of each
2631 TopGit branch that lists the branch's dependencies one per
2632 line omitting the leading ``refs/heads/`` part. See also
2636 Given two Git commit identifiers (e.g. hashes) C1 and C2,
2637 commit C1 "contains" commit C2 if either they are the same
2638 commit or C2 can be reached from C1 by following one or more
2639 parent links from C1 (perhaps via one or more intermediate
2640 commits along the way). In other words, if C1 contains C2
2641 then C2 is an ancestor of C1 or conversely C1 is a descendant
2642 of C2. Since a TopGit branch name is also the name of a Git
2643 branch (something located under the ``refs/heads`` Git
2644 namespace) and similarly for a TopGit base, they can both be
2645 resolved to a Git commit identifier and then participate in
2646 a branch containment test. An easy mnemonic for this is
2647 "children contain the genes of their parents."
2650 A Basic Regular Expression (BRE) pattern. These are older
2651 style regular expressions but have the advantage that all
2652 characters other than ``\``, ``.``, ``*`` and ``[``
2653 automatically match themselves without need for backslash
2654 quoting (well actually, ``^`` and ``$`` are special at the
2655 beginning and end respectively but otherwise match themselves).
2658 See branch containment.
2661 An Extended Regular Expression (ERE) pattern. These are newer
2662 style regular expressions where all the regular expression
2663 "operator" characters "operate" when NOT preceded by a
2664 backslash and are turned into normal characters with a ``\``.
2665 The backreference atom, however, may not work, but ``?``, ``+``
2666 and ``|`` "operators" do; unlike BREs.
2669 Excellent system for managing a history of changes to one
2670 or more possibly interrelated patches.
2673 A Git branch that has an associated TopGit base. Conceptually
2674 it represents a single patch that is the difference between
2675 the associated TopGit base and the TopGit branch. In other
2676 words ``git diff-tree <TopGit base> <TopGit branch>`` except
2677 that any ``.topdeps`` and/or ``.topmsg`` files are excluded
2678 from the result and the contents of the ``.topmsg`` file from
2679 the TopGit branch is prefixed to the result.
2682 A Git branch whose tree does NOT contain any ``.topdeps`` or
2683 ``.topmsg`` entries at the top-level of the tree. It *does*
2684 always have an associated "TopGit base" ref (otherwise it would
2685 not be a "TopGit" branch). See also `BARE BRANCHES`_.
2688 In TopGit context, "bare branch" almost always refers to a
2689 "TopGit bare branch" and should be understood to mean such even
2690 if the leading "TopGit" has been left off.
2693 A Git branch that records the base upon which a TopGit branch's
2694 single conceptual "patch" is built. The name of the Git branch
2695 is derived from the TopGit branch name by stripping off the
2696 leading ``refs/heads/`` and appending the correct prefix where
2697 all TopGit bases are stored (typically either
2698 ``refs/top-bases/`` or ``refs/heads/{top-bases}/`` -- the
2699 prefix for any given repository can be shown by using the
2700 ``tg --top-bases`` command and updated using the
2701 ``tg migrate-bases`` command).
2703 All of a TopGit branch's dependencies are merged into the
2704 corresponding TopGit base during a ``tg update`` of a branch.
2709 TopGit ``[PATCH]`` branch
2710 A TopGit branch whose subject starts with ``[PATCH]``. By
2711 convention these TopGit branches contain a single patch
2712 (equivalent to a single patch file) and have at least one
2713 dependency (i.e. their ``.topdeps`` files are never empty).
2715 TopGit ``[BASE]`` branch
2716 A TopGit branch whose subject starts with ``[BASE]``. By
2717 convention these TopGit branches do not actually contain
2718 any changes and their ``.topdeps`` files are empty. They
2719 are used to control a base dependency that another set of
2720 branches depends on. Sometimes these are named ``[RELEASE]``
2721 instead because the base dependency they represent is actually
2722 the formal release of something.
2724 TopGit ``[STAGE]`` branch
2725 A TopGit branch whose subject starts with ``[STAGE]``. By
2726 convention these TopGit branches do not actually contain any
2727 changes of their own but do have one or (typically) more
2728 dependencies in their ``.topdeps`` file. These branches are
2729 used to bring together one or (typically) more independent
2730 TopGit ``[PATCH]`` branches into a single branch so that
2731 testing and/or evaluation can be performed on the result.
2734 When merging two (or more) heads that touch the same lines in
2735 the file but in different ways the result is a merge conflict
2736 that requires manual intervention. If a merge conflict occurs
2737 with more than two heads (an octopus merge) it's generally
2738 replaced by multiple three-way merges so that by the time a
2739 user sees a merge conflict needing manual resolution, there
2740 will be only two heads involved.
2743 A Git merge strategy (see the "MERGE STRATEGIES" section of
2744 ``git help merge``) or one of the TopGit `merge strategies`_
2745 used to merge two or more heads.
2747 TopGit merge strategy
2748 See the `Merge Strategies`_ section above for details but
2749 basically these are just in-index merges done using the
2750 ``git read-tree -m --aggressive`` command one or more times
2751 possibily assisted by the ``git merge-index`` and the
2752 ``git merge-file`` commands.
2755 In TopGit context the "next" branch refers to the branch that
2756 corresponds to the next (aka following) patch in an ordered
2757 (aka linearized) list of patches created by exporting the
2758 TopGit branches in patch application order.
2761 A merge involving more than two heads. Note that if there are
2762 less than three independent heads the resulting merge that
2763 started out as an octopus will end up not actually being an
2767 A TopGit branch is considered to be "out-of-date" when ANY of
2768 the following are true:
2770 a) The TopGit branch does NOT contain its
2773 b) The TopGit branch does NOT contain its
2774 corresponding remote branch (there may not be
2775 a remote branch in which case this does not apply)
2777 c) The TopGit branch's base does NOT contain its
2778 corresponding remote branch's base (there may not be
2779 a remote branch in which case this does not apply)
2781 d) Any of the TopGit branches listed in the branch's
2782 ``.topdeps`` file are NOT contained by the branch.
2783 (See "branch containment" above.)
2785 e) Any of the TopGit branches listed in the branch's
2786 ``.topdeps`` file are out-of-date.
2788 Note that if a remote branch is present and is NOT out-of-date
2789 then it will contain its own base and (c) is mostly redundant.
2792 In TopGit context the "previous" (or "prev") branch refers to
2793 the branch that corresponds to the previous (aka preceding)
2794 patch in an ordered (aka linearized) list of patches created by
2795 exporting the TopGit branches in patch application order.
2797 remote TopGit branch
2798 A Git branch with the same branch name as a TopGit branch
2799 but living under ``refs/remotes/<some remote>/`` instead
2800 of just ``refs/heads/``.
2803 The TopGit base branch corresponding to a remote TopGit branch,
2804 which lives under ``refs/remotes/`` somewhere (depending on
2805 what the output of ``tg --top-bases`` is for that remote).
2808 A three-way merge takes a common base and two heads (call them
2809 A and B) and creates a new file that is the common base plus
2810 all of the changes made between the common base and head A
2811 *AND* all of the changes made between the common base and
2812 head B. The technique used to accomplish this is called a
2819 The following references are useful to understand the development of
2820 topgit and its subcommands.
2823 http://public-inbox.org/git/36ca99e90904091034m4d4d31dct78acb333612e678@mail.gmail.com/T/#u
2826 THIRD-PARTY SOFTWARE
2827 --------------------
2829 The following software understands TopGit branches:
2831 * `Magit <https://github.com/magit/magit>`_ - a git mode for emacs
2832 with the `Magit TopGit mode <https://github.com/greenrd/magit-topgit>`_
2833 that may, perhaps, be a bit outdated.
2835 IMPORTANT: Magit requires its topgit mode to be enabled first, as
2836 described in its documentation, in the "Activating extensions"
2837 subsection. If this is not done, it will not push TopGit branches
2838 correctly, so it's important to enable it even if you plan to mostly use
2839 TopGit from the command line.