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 :GLOSSARY_: All the TopGit vocabulary in one place
27 :TECHNICAL_: How it works behind the scenes
28 :`TESTING TOPGIT`_: How to run the TopGit test suite
34 TopGit is a collection of POSIX shell scripts so a POSIX-compliant shell is
35 required along with some standard POSIX-compliant utilities (e.g. sed, awk,
36 cat, etc.). Git version 1.8.5 or later is also required.
38 To use TopGit with linked working trees (the ``git worktree add`` command),
39 at least Git version 2.5.0 (obviously, since that's when the ``git worktree``
40 command first appeared) is needed in which case linked working trees are then
41 fully supported for use with TopGit.
43 The scripts need to be preprocessed and installed. The Makefile that does
44 this only requires a POSIX make utility (using "``make``" and "``make install``").
45 Running the tests (see `TESTING TOPGIT`_) also requires only a POSIX make
46 utility ("``make test``") but does require a ``perl`` binary to be available.
48 It is possible to use the DESTDIR functionality to install TopGit to a
49 staging area on one machine, archive that and then unarchive it on another
50 machine to perform an install (provided the build prefix and other options are
51 compatible with the final installed location).
57 See the file ``INSTALL``.
63 The TopGit git repository can be found at <http://repo.or.cz/topgit/pro>.
69 Why not use something like StGIT or Guilt or ``rebase -i`` for maintaining
70 your patch queue? The advantage of these tools is their simplicity;
71 they work with patch *series* and defer to the reflog facility for
72 version control of patches (reordering of patches is not
73 version-controlled at all). But there are several disadvantages -- for
74 one, these tools (especially StGIT) do not actually fit well with plain
75 Git at all: it is basically impossible to take advantage of the index
76 effectively when using StGIT. But more importantly, these tools
77 horribly fail in the face of a distributed environment.
79 TopGit has been designed around three main tenets:
81 (i) TopGit is as thin a layer on top of Git as possible. You
82 still maintain your index and commit using Git; TopGit will only
83 automate a few indispensable tasks.
85 (ii) TopGit is anxious about *keeping* your history. It will
86 never rewrite your history, and all metadata is also tracked
87 by Git, smoothly and non-obnoxiously. It is good to have a
88 *single* point when the history is cleaned up, and that is at
89 the point of inclusion in the upstream project; locally, you
90 can see how your patch has evolved and easily return to older
93 (iii) TopGit is specifically designed to work in a
94 distributed environment. You can have several instances of
95 TopGit-aware repositories and smoothly keep them all
96 up-to-date and transfer your changes between them.
98 As mentioned above, the main intended use-case for TopGit is tracking
99 third-party patches, where each patch is effectively a single topic
100 branch. In order to flexibly accommodate even complex scenarios when
101 you track many patches where many are independent but some depend on
102 others, TopGit ignores the ancient Quilt heritage of patch series and
103 instead allows the patches to freely form graphs (DAGs just like Git
104 history itself, only "one level higher"). For now, you have to manually
105 specify which patches the current one depends on, but TopGit might help
106 you with that in the future in a darcs-like fashion.
108 A glossary_ plug: The union (i.e. merge) of patch dependencies is called
109 a *base* of the patch (topic branch).
111 Of course, TopGit is perhaps not the right tool for you:
113 (i) TopGit is not complicated, but StGIT et al. are somewhat
114 simpler, conceptually. If you just want to make a linear
115 purely-local patch queue, deferring to StGIT instead might
118 (ii) When using TopGit, your history can get a little hairy
119 over time, especially with all the merges rippling through.
128 ## Create and evolve a topic branch
129 $ tg create t/gitweb/pathinfo-action
130 tg: Automatically marking dependency on master
131 tg: Creating t/gitweb/pathinfo-action base from master...
137 ## Create another topic branch on top of the former one
138 $ tg create t/gitweb/nifty-links
139 tg: Automatically marking dependency on t/gitweb/pathinfo-action
140 tg: Creating t/gitweb/nifty-links base from t/gitweb/pathinfo-action...
144 ## Create another topic branch on top of master and submit
145 ## the resulting patch upstream
146 $ tg create t/revlist/author-fixed master
147 tg: Creating t/revlist/author-fixed base from master...
151 tg: Sent t/revlist/author-fixed
153 To: git@vger.kernel.org
154 Cc: gitster@pobox.com
155 Subject: [PATCH] Fix broken revlist --author when --fixed-string
157 ## Create another topic branch depending on two others non-trivially
158 $ tg create t/whatever t/revlist/author-fixed t/gitweb/nifty-links
159 tg: Creating t/whatever base from t/revlist/author-fixed...
160 tg: Merging t/whatever base with t/gitweb/nifty-links...
162 tg: Please commit merge resolution and call: tg update --continue
163 tg: It is also safe to abort this operation using `git reset --hard`
164 tg: but please remember you are on the base branch now;
165 tg: you will want to switch to a different branch.
168 $ tg update --continue
172 ## Update a single topic branch and propagate the changes to
174 $ git checkout t/gitweb/nifty-links
177 $ git checkout t/whatever
179 Topic Branch: t/whatever (1 commit)
180 Subject: [PATCH] Whatever patch
182 Depends: t/revlist/author-fixed t/gitweb/nifty-links
184 t/gitweb/nifty-links (1 commit)
186 tg: Updating base with t/gitweb/nifty-links changes...
188 tg: Please commit merge resolution and call `tg update --continue`
189 tg: (use `tg status` to see more options)
192 $ tg update --continue
193 tg: Updating t/whatever against new base...
195 tg: Please commit merge resolution and call `tg update --continue`
196 tg: (use `tg status` to see more options)
199 $ tg update --continue
201 ## Update a single topic branch and propagate the changes
202 ## further through the dependency chain
203 $ git checkout t/gitweb/pathinfo-action
206 $ git checkout t/whatever
208 Topic Branch: t/whatever (1/2 commits)
209 Subject: [PATCH] Whatever patch
211 Depends: t/revlist/author-fixed t/gitweb/nifty-links
213 t/gitweb/pathinfo-action (<= t/gitweb/nifty-links) (1 commit)
215 tg: Recursing to t/gitweb/nifty-links...
216 [t/gitweb/nifty-links] tg: Updating base with t/gitweb/pathinfo-action changes...
218 [t/gitweb/nifty-links] tg: Please commit merge resolution and call `tg update --continue`
219 [t/gitweb/nifty-links] tg: (use `tg status` to see more options)
222 $ tg update --continue
223 [t/gitweb/nifty-links] tg: Updating t/gitweb/nifty-links against new base...
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 tg: Updating base with t/gitweb/nifty-links changes...
231 tg: Updating t/whatever against new base...
233 ## Clone a TopGit-controlled repository
236 $ tg remote --populate origin
241 ## Add a TopGit remote to a repository and push to it
242 $ git remote add foo URL
246 ## Update from a non-default TopGit remote
255 When using TopGit there are several common conventions used when working with
256 TopGit branches. None of them are enforced, they are only suggestions.
258 There are three typical uses for a TopGit branch:
261 Normal TopGit branches that represent a single patch. These are known
262 as "patch" TopGit branches.
264 Empty TopGit branches with no dependencies (an empty ``.topdeps`` file)
265 that represent a base upon which other "normal" TopGit branches depend.
266 These are known as "base" TopGit branches (not to be confused with
267 the refs/top-bases/... refs).
269 Empty TopGit branches that serve as a staging area to bring together
270 several other TopGit branches into one place so they can be used/tested
271 all together. These are known as "stage" TopGit branches.
273 An "empty" TopGit branch is one that does not have any changes of its own --
274 it may still have dependencies though ("stage" branches do, "base" branches do
275 not). The ``tg summary`` output shows empty branches with a ``0`` in the
276 listing. Normal "patch" branches that have not been annihilated, "base" and
277 "stage" branches fall into this category. (Annihilated branches are normally
278 omitted from the ``tg summary`` output but can be shown if given explicitly as
279 an argument to the ``tg summary`` command. However, the message line will be
280 incorrect since an annihilated branch has no ``.topmsg`` file of its own.)
282 A "patch" branch name typically starts with ``t/`` whereas "base" and "stage"
283 branch names often do not.
285 A "base" branch is created by using the ``--base`` option of ``tg create``
286 (aka ``--no-deps``) which will automatically suggest a "[BASE]" message prefix
287 rather than "[PATCH]". A "stage" branch is created like a normal patch branch
288 except that the only changes that will ever be made to it are typically to
289 add/remove dependencies. Its subject prefix must be manually changed to
290 "[STAGE]" to reflect its purpose.
292 Since both "base" and "stage" branches typically only have a use for the
293 "Subject:" line from their ``.topmsg`` file, they are quite easily created
294 using the ``--topmsg`` option of ``tg create``.
296 Use of "stage" and "base" branches is completely optional. However, without
297 use of a "stage" branch it will be difficult to test multiple independent
298 patches together all at once. A "base" branch is merely a convenience that
299 provides more explicit control over when a common base for a set of patches
300 gets updated as well as providing a branch that shows in ``tg summary`` output
301 and participates in ``tg remote --populate`` setup.
303 Occasionally the functionality of a "base" branch is needed but it may not
304 be possible to add any `.topdeps` or `.topmsg` files to the desired branch
305 (perhaps it's externally controlled). `BARE BRANCHES`_ can be used in this
306 case, but while TopGit allows them it deliberately does not provide assistance
309 Another advantage to using a "stage" branch is that if a new "patch" branch
310 is created remotely and that new branch is added to a pre-existing "stage"
311 branch on the remote then when the local version of the "stage" branch is
312 updated (after fetching remote updates of course), that new dependency will
313 be merged into the local "stage" branch and the local version of the new remote
314 "patch" branch will be automatically set up at "tg update" time.
316 When using the ``tg tag`` command to create tags that record the current state
317 of one or more TopGit branches, the tags are often created with a name that
320 One last thing, you have enabled ``git rerere`` haven't you?
326 Beware, there is no "undo" after running a ``tg update``!
328 Well, that's not entirely correct. Since ``tg update`` never discards commits
329 an "undo" operation is technically feasible provided the old values of all the
330 refs that were affected by the ``tg update`` operation can be determined and
331 then they are simply changed back to their previous values.
333 In practice though, it can be extremely tedious and error prone looking through
334 log information to try and determine what the correct previous values were.
335 Although, since TopGit tries to make sure reflogs are enabled for top-bases
336 refs, using Git's ``@{date}`` notation on all the refs dumped out by a
337 ``tg tag --refs foo``, where "foo" is the branch that was updated whose update
338 needs to be undone, may work.
340 Alternatively, ``tg tag --stash`` can be used prior to the update and then
341 ``tg revert`` used after the update to restore the previous state. This
342 assumes, of course, that you remember to run ``tg tag --stash`` first.
344 The ``tg update`` command understands a ``--stash`` option that tells it to
345 automatically run ``tg tag --stash`` before it starts making changes (if
346 everything is up-to-date it won't run the stash command at all).
348 The ``--stash`` option is the default nowadays when running ``tg update``,
349 add the ``--no-stash`` option to turn it off.
351 There is a preference for this. Setting the config value ``topgit.autostash``
352 to ``false`` will implicitly add the ``--no-stash`` option to any ``tg update``
353 command unless an explicit ``--stash`` option is given.
355 If you are likely to ever want to undo a ``tg update``, setting
356 ``topgit.autostash`` to ``false`` is highly discouraged!
358 Note that the tags saved by ``tg tag --stash`` are stored in the
359 ``refs/tgstash`` ref and its reflog. Unfortunately, while Git is happy to
360 maintain the reflog (once it's been enabled which ``tg tag`` guarantees for
361 ``refs/tgstash``), Git is unable to view an annotated/signed tag's reflog!
362 Instead Git dereferences the tag and shows the wrong thing. Use the
363 ``tg tag -g`` command to view the ``refs/tgstash`` reflog instead.
369 TopGit supports various config settings:
371 :ALIASES_: ``topgit.alias.*`` for Git-like command aliases
372 :`tg update`_: ``topgit.autostash`` automatic stash control
373 :`tg create`_: ``topgit.bcc`` default "Bcc:" value for create
374 :`tg create`_: ``topgit.cc`` default "Cc:" value for create
375 :`tg patch`_: ``topgit.from`` "From:" fixups by ``tg patch``
376 :`REMOTE HANDLING`_: ``topgit.remote`` TopGit's default remote
377 :SEQUESTRATION_: ``topgit.sequester`` for sequestration control
378 :`tg update`_: ``topgit.setAutoUpdate`` => ``rerere.autoUpdate``
379 :`tg create`_: ``topgit.subjectPrefix`` "[$prefix PATCH] foo"
380 :`tg create`_: ``topgit.to`` default "To:" value for create
381 :`tg migrate-bases`_: ``topgit.top-bases`` for refs bases location
387 These work exactly like Git's aliases except they are stored under
388 ``topgit.alias.*`` instead. See the ``git help config`` output under
389 the ``alias.*`` section for details. Do note that while alias nesting is
390 explicitly permitted, a maximum nesting depth of 10 is enforced to help
391 detect accidental aliasing loops and keep them from wedging the machine.
393 For example, to create an ``lc`` alias for the ``tg log --compact`` command
394 this command may be used:
398 git config --global topgit.alias.lc "log --compact"
400 To make it specific to a particular repository just omit the ``--global``
401 option from the command.
406 From Previous to Next
407 ~~~~~~~~~~~~~~~~~~~~~
409 For this section, consider the following patch series, to be applied
410 in numerical order as shown:
414 0001-F_first-patch.diff
415 0002-G_second-builds-on-F.diff
416 0003-H_third-builds-on-G.diff
417 0004-I_fourth-builds-on-H.diff
418 0005-J_fifth-builds-on-I.diff
419 0006-K_sixth-builds-on-J.diff
420 0007-L_last-patch-needs-K.diff
422 If these were applied to some commit in a Git repository, say commit "A"
423 then a history that looks like this would be created:
427 A---F---G---H---I---J---K---L
429 Where the parent of commit "F" is "A" and so on to where the parent of
430 commit "L" is commit "K".
432 If that commit history, from A through L, was then imported into TopGit, one
433 TopGit branch would be created corresponding to each of the commits F
434 through L. This way, for example, if the fourth patch in the series
435 (``0004-I_...diff``) needs work, the TopGit branch corresponding to its patch
436 can be checked out and changes made and then a new version of its patch
437 created (using ``tg patch``) without disturbing the other patches in the series
438 and when ``tg update`` is run, the patches that "follow" the fourth patch
439 (i.e. 5, 6 and 7) will have their corresponding TopGit branches automatically
440 updated to take into account the changes made to the fourth patch.
442 Okay, enough with the review of TopGit systemology
443 ``````````````````````````````````````````````````
445 Imagine then that you are working on the fourth patch (i.e. you have its
446 branch checked out into the working tree) and you want to move to the following
447 patch in the series because you have a nit to pick with it too.
449 If you can't remember the exact name you might have to fumble around or, you
450 can display the name of the following or "next" patch's branch with the, you
451 guessed it, ``tg next`` command. Think of "next" as the "next" logical patch
452 in the series or the next following patch. If the patches are numbered as in
453 the list above, "next" corresponds to the "+1" (plus one) patch.
455 You might have already guessed there's a corresponding ``tg prev`` command
456 which displays the "-1" (minus one) patch. If these commands (``tg next``
457 and ``tg prev``) are not given a branch name to start at they start at the
458 patch corresponding to the current ``HEAD``.
460 Displaying, however, is not so helpful as actually going there. That's where
461 the ``tg checkout`` command comes in. ``tg checkout next`` does a
462 ``git checkout`` of the ``tg next`` branch and, not surprisingly,
463 ``tg checkout prev`` does a ``git checkout`` of the ``tg prev`` branch. For
464 the lazy a single ``n`` or ``p`` can be used with ``tg checkout`` instead of
465 typing out the entire ``next`` or ``prev``. Or, for the anal, ``previous``
466 will also be accepted for ``prev``.
468 Referring to the A...L commit graph shown above, I is the parent of J and,
469 conversely, J is the child of I. (Git only explicitly records the child to
470 parent links, in other words a "child" points to zero or more "parents", but
471 parents are completely clueless about their own children.)
473 For historical reasons, the ``tg checkout`` command accepts ``child`` as a
474 synonym for ``next`` and ``parent`` as a synonym for ``prev``. However, this
475 terminology can be confusing since Git has "parent" links but ``tg checkout``
476 is referring to the TopGit DAG, not Git's. Best to just avoid using ``child``
477 or ``parent`` to talk about navigating the TopGit DAG and reserve them
478 strictly for discussing the Git DAG.
480 There may be more than one
481 ``````````````````````````
483 In a simple linear history as shown above there's always only one "next" or
484 "prev" patch. However, TopGit does not restrict one to only a linear
485 history (although that can make patch exports just a bushel of fun).
487 Suffice it to say that there is always a single linearized ordering for any
488 TopGit patch series since it's always a DAG (Directed Acyclic Graph), but it
489 may not be immediately obvious to the casual observer what that is.
491 The ``tg checkout`` command will display a list to choose from if ``next``
492 or ``prev`` would be ambiguous.
494 Use the ``tg info/checkout --series`` command
495 `````````````````````````````````````````````
497 To see the full, linearized, list of patches with their summary displayed in
498 order from first to last patch in the series, just run the ``tg info --series``
499 command. It takes the name of any patch in the series automatically using
500 ``HEAD`` if none is given. It even provides a nice "YOU ARE HERE" mark in
501 the output list helpful to those who have been absent for a time engaging in
502 otherwise distracting activities and need to be reminded where they are.
504 Using ``tg checkout --series`` can take you there (picking from a list) if
505 you've forgotten the way back to wherever you're supposed to be.
507 Don't get pushy, there's just one more thing
508 ````````````````````````````````````````````
510 For historical reasons, ``tg checkout`` with no arguments whatsoever behaves
511 like ``tg checkout next``. For the same historical reasons, ``tg checkout ..``
512 behaves like ``tg checkout prev`` (think of ``..`` as the "parent" directory
513 and since "parent" means "prev" in this context it will then make sense).
515 Now, for that one more thing. Consider that you have a pristine "upstream"
516 tarball, repository, source dump or otherwise obtained set of unmodified
517 source files that need to be patched. View them like so:
521 +-------------------------------+
522 | Unmodified "upstream" source |
523 | files represented with "A" |
524 +-------------------------------+
526 Now, add the first patch, 0001, to them and view the result like so:
530 +--------------------------+----+
531 | Patch 0001 represented by "F" |
532 +-------------------------------+
533 | Unmodified "upstream" source |
534 | files represented with "A" |
535 +-------------------------------+
537 Not stopping there, "push" patches 2, 3 and 4 onto the stack as well like so:
541 +--------------------------+----+
542 | Patch 0004 represented by "I" |
543 +--------------------------+----+
544 | Patch 0003 represented by "H" |
545 +--------------------------+----+
546 | Patch 0002 represented by "G" |
547 +--------------------------+----+
548 | Patch 0001 represented by "F" |
549 +-------------------------------+
550 | Unmodified "upstream" source |
551 | files represented with "A" |
552 +-------------------------------+
554 In other words, to go to the "next" patch in the series it needs to be "push"ed
555 onto the stack. ``tg checkout`` accepts ``push`` as an alias for ``next``.
557 Similarly to go to the "previous" patch in the series the current one needs
558 to be "pop"ped off the stack. ``tg checkout`` accepts ``pop`` as an alias
561 Unfortunately for these aliases, in Git terminology a "push" has quite a
562 different meaning and the ``tg push`` command does something quite different
563 from ``tg checkout push``. Then there's the matter of using a single letter
564 abbreviation for the lazy -- ``p`` would mean what exactly?
566 ``tg checkout`` continues to accept the ``push`` and ``pop`` aliases for
567 ``next`` and ``prev`` respectively, but it's best to avoid them since
568 ``push`` has an alternate meaning everywhere else in TopGit and Git and that
569 leaves ``pop`` all alone in the dark.
575 No, this is not a section about budget nonsense. ;)
577 TopGit keeps its metadata in ``.topdeps`` and ``.topmsg`` files. In an effort
578 to facilitate cherry-picking and other Git activities on the patch changes
579 themselves while ignoring the TopGit metadata, TopGit attempts to keep all
580 changes to ``.topdeps`` and ``.topmsg`` files limited to commits that do NOT
581 contain changes to any other files.
583 This is a departure from previous TopGit versions that made no such effort.
585 Primarily this affects ``tg create`` and ``tg import`` (which makes use of
586 ``tg create``) as ``tg create`` will commit the initial versions of
587 ``.topdeps`` and ``.topmsg`` for a new TopGit-controlled branch in their own
588 commit instead of mixing them in with changes to other files.
590 The ``pre-commit`` hook will also attempt to separate out any ``.topdeps`` and
591 ``.topmsg`` changes from commits that include changes to other files.
593 It is possible to defeat these checks without much effort (``pre-commit`` hooks
594 can easily be bypassed, ``tg create`` has a ``--no-commit`` option, many Git
595 commands simply do not run the ``pre-commit`` hook, etc.).
597 If you really, really, really, really want to change the default back to the
598 old behavior of previous TopGit versions where no such sequestration took
599 place, then set the ``topgit.sequester`` config variable explicitly to the
600 value ``false``. But this is not recommended.
603 AMENDING AND REBASING AND UPDATE-REF'ING
604 ----------------------------------------
608 It is okay to manually update a top-bases/... ref when a) it has no depedencies
609 (i.e. it was created with the ``tg create`` ``--base`` option) and b) the
610 old top-bases/... ref value can be fast-forwarded to the new top-bases/...
611 value OR the new value contains ALL of the changes in the old value through
612 some other mechanism (perhaps they were cherry-picked or otherwise applied to
613 the new top-bases/... ref). The same rules apply to non-TopGit-controlled
614 dependencies. Use the ``tg update --base <branch> <new-ref>`` command to
615 safely make such an update while making it easy to set the merge commit
616 message at the same time.
618 Ignoring this rule and proceeding anyway with a non-fast-forward update to a
619 top-bases/... ref will result in changes present in the new value being merged
620 into the branch (at ``tg update`` time) as expected (possibly with conflicts),
621 but any changes that were contained in the old version of the top-bases/... ref
622 which have been dropped (i.e. are NOT contained in the new version of the
623 top-bases/... ref) will continue to be present in the branch! To get rid of
624 the dropped commits, one or more "revert" commits will have to be manually
625 applied to the tip of the new top-bases/... value (which will then be merged
626 into the branch at next ``tg update`` time).
628 The only time it's safe to amend, rebase, filter or otherwise rewrite commits
629 contained in a TopGit controlled branch or non-TopGit branch is when those
630 commits are NOT reachable via any other ref!
632 Furthermore, while it is safe to rewrite merge commits (provided they meet the
633 same conditions) the merge commits themselves and the branches they are merging
634 in must be preserved during the rewrite and that can be rather tricky to get
635 right so it's not recommended.
637 For example, if, while working on a TopGit-controlled branch ``foo``, a bad
638 typo is noticed, it's okay to ammend/rebase to fix that provided neither
639 ``tg update`` nor ``tg create`` has already been used to cause some other ref
640 to be able to reach the commit with the typo.
642 If an amend or rerwite is done anyway even though the commit with the typo is
643 reachable from some other ref, the typo won't really be removed. What will
644 happen instead is that the new version without the typo will ultimately be
645 merged into the other ref(s) (at ``tg update`` time) likely causing a conflict
646 that will have to be manually resolved and the commit with the typo will
647 continue to be reachable from those other refs!
649 Instead just make a new commit to fix the typo. The end result will end up
650 being the same but without the merge conflicts.
652 See also the discussion in the `NO UNDO`_ section.
658 A "TopGit bare branch" (or just "bare branch" for short), refers to a TopGit
659 branch that has neither a ``.topdeps`` nor a ``.topmsg`` file stored in it.
660 And it's neither a new, still-empty empty branch nor an annihilated branch.
662 Such branches are not recommended but are reluctantly accomodated.
664 There are three situtations in which TopGit may encounter a TopGit branch
665 that has neither a ``.topdeps`` nor a ``.topmsg`` file.
667 1. Branch creation with ``--no-commit``
668 Before the initial commit is made, the branch will still be
669 pointing to the same commit as its "top-bases" ref. Branches
670 in this condition (where the branch and top-bases ref point to
671 the same commit) show up as having "No commits" in listings.
673 2. Annihilated branches
674 A branch is annihilated by making a new commit on the branch
675 that makes its tree identical to the tree of its corresponding
676 top-bases ref. Although the trees will be the same, the
677 commits will be different and annihilated branches are
678 distinguished from "No commits" branches in this way.
679 Annihilated branches are generally invisible and do not show up
680 in listings or other status displays. Intentionally so.
683 Any TopGit branch with neither a ``.topdeps`` file nor a
684 ``.topmsg`` file whose branch and top-bases trees differ falls
685 into this category. TopGit will not create such a branch
686 itself nor does it provide any commands to do so.
688 Whenever possible, a TopGit "[BASE]" branch should be preferred to using a
689 "bare branch" because a) it can never be mistaken for an annihilated branch,
690 b) it has a nice subject attached (via its ``.topmsg`` file) that shows
691 up in listings and c) exactly when and which updates are taken can be planned.
693 Nevertheless, situations may arise where it's useful to have TopGit treat a
694 branch as a "TopGit branch" so that it fully participates in all update
695 activities (such as updating local branches based on their remote branches),
696 but it's not feasible to turn it into a real "TopGit branch" as it comes from
697 an external source and rather than controlling exactly when and what updates
698 are picked up from it by TopGit (the precise use case of a "[BASE]" branch),
699 all updates that appear on it are to be assimilated as soon as they occur.
701 For this reason, TopGit will accomodate such "bare branches" but it will not
702 create (nor provide the means to create) them itself.
704 In order to create a "bare branch" all that's required is to create the
705 necessary top-bases ref. The choice of commit for the top-bases ref will
706 affect the output of the "files", "log" and "patch" commands most directly
707 (but all commands will be affected).
709 To work properly as a "bare branch", the commit the "bare branch"'s base points
710 to should be contained within the branch, be a different commit than the branch
711 tip itself and have a different tree than the branch tip. Simply setting the
712 base to the parent commit of the "bare branch" will usually work, but should
713 that commit at the tip of the "bare branch" end up getting reverted as the next
714 commit, the trees would match and it would appear to be an annihilated branch
715 rather than a "bare branch". That is one of the reasons these branches are not
716 recommended in the first place.
718 Setting the base to the root commit of the branch is more reliable and may
719 be accomplished like so for a local branch named "mybranch":
723 git update-ref $(tg --top-bases)/mybranch \
724 $(git rev-list --first-parent --max-parents=0 mybranch) ""
726 Typically though it's more likely a remote bare branch will be needed. For
727 a remote named "origin" and a remote branch name of "vendor" this will do it:
731 git update-ref $(tg --top-bases -r origin)/vendor \
732 $(git rev-list --first-parent --max-parents=0 origin/vendor) ""
734 Such "bare branches" are not likely ever to receive any more direct support in
735 TopGit than acknowleging they can be useful in some situations and tolerating
736 their existence by functioning properly with them even to the point of the
737 ``pre-commit`` hook tacitly allowing continued commits on such branches without
738 complaints about missing ``.topdeps`` and ``.topmsg`` files.
740 Note, however, that creating a regular TopGit branch that has no changes of its
741 own with the "bare branch" as its single dependency provides a means to supply
742 some kind of documentation if all other uses of the "bare branch" depend on
743 this "wrapper" branch instead of directly on the "bare branch".
749 TopGit needs to check many things to determine whether a TopGit branch is
750 up-to-date or not. This can involve a LOT of git commands for a complex
751 dependency tree. In order to speed things up, TopGit keeps a cache of results
752 in a ``tg-cache`` subdirectory in the ``.git`` directory.
754 Results are tagged with the original hash values used to get that result so
755 that items which have not been changed return their results quickly and items
756 which have been changed compute their new result and cache it for future use.
758 The ``.git/tg-cache`` directory may be removed at any time and the cache will
759 simply be recreated in an on-demand fashion as needed, at some speed penalty,
760 until it's fully rebuilt.
762 To force the cache to be fully pre-loaded, run the ``tg summary`` command
763 without any arguments. Otherwise, normal day-to-day TopGit operations should
764 keep it more-or-less up-to-date.
766 While each TopGit command is running, it uses a temporary subdirectory also
767 located in the ``.git`` directory. These directories are named
768 ``tg-tmp.XXXXXX`` where the ``XXXXXX`` part will be random letters and digits.
770 These temporary directories should always be removed automatically after each
771 TopGit command finishes running. As long as you are not in a subshell as a
772 result of a TopGit command stopping and waiting for a manual merge resolution,
773 it's safe to remove any of these directories that may have somehow accidentally
774 been left behind as a result of some failure that occurred while running a
775 TopGit command (provided, of course, it's not actually being used by a TopGit
776 command currently running in another terminal window or by another user on the
782 ``tg [global options] <subcommand> [<subcommand option/argument>...]``
786 ``[-C <dir>]... [-r <remote> | -u] [-c <name>=<val>]... [--no-pager]``
788 -C <dir> Change directory to <dir> before doing anything more
789 -r <remote> Pretend ``topgit.remote`` is set to <remote>
790 -u Pretend ``topgit.remote`` is not set
791 -c <name=val> Pass config option to git, may be repeated
792 --no-pager Disable use of any pager (by both TopGit and Git)
793 --top-bases Show full ``top-bases`` ref prefix and exit
794 --exec-path Show path to subcommand scripts location and exit
795 --help Show brief usage help and exit (aka ``-h``)
797 The ``tg`` tool has several subcommands:
799 :`tg annihilate`_: Mark a TopGit-controlled branch as defunct
800 :`tg base`_: Show base commit for one or more TopGit branches
801 :`tg checkout`_: Shortcut for git checkout with name matching
802 :`tg contains`_: Which TopGit-controlled branch contains the commit
803 :`tg create`_: Create a new TopGit-controlled branch
804 :`tg delete`_: Delete a TopGit-controlled branch cleanly
805 :`tg depend`_: Add a new dependency to a TopGit-controlled branch
806 :`tg export`_: Export TopGit branch patches to files or a branch
807 :`tg files`_: Show files changed by a TopGit branch
808 :`tg help`_: Show TopGit help optionally using a browser
809 :`tg import`_: Import commit(s) to separate TopGit branches
810 :`tg info`_: Show status information about a TopGit branch
811 :`tg log`_: Run git log limiting revisions to a TopGit branch
812 :`tg mail`_: Shortcut for git send-email with ``tg patch`` output
813 :`tg migrate-bases`_: Transition top-bases to new location
814 :`tg next`_: Show branches directly depending on a TopGit branch
815 :`tg patch`_: Generate a patch file for a TopGit branch
816 :`tg prev`_: Show non-annihilated TopGit dependencies for a branch
817 :`tg push`_: Run git push on TopGit branch(es) and depedencies
818 :`tg rebase`_: Auto continue git rebase if rerere resolves conflicts
819 :`tg remote`_: Set up remote for fetching/pushing TopGit branches
820 :`tg revert`_: Revert ref(s) to a state stored in a ``tg tag``
821 :`tg status`_: Show current TopGit status (e.g. in-progress update)
822 :`tg summary`_: Show various information about TopGit branches
823 :`tg tag`_: Create tag that records current TopGit branch state
824 :`tg update`_: Update TopGit branch(es) with respect to dependencies
828 Our sophisticated integrated help facility. Mostly duplicates
833 # to get help for a particular command:
835 # to get help for a particular command in a browser window:
836 $ tg help -w <command>
837 # to get help on TopGit itself
839 # to get help on TopGit itself in a browser
844 Our sophisticated status facility. Similar to Git's status command
845 but shows any in-progress update that's awaiting a merge resolution
846 or any other on-going TopGit activity (such as a branch creation).
848 With a single ``--verbose`` (or ``-v``) option include a short status
849 display for any dirty (but not untracked) files. This also causes all
850 non file status lines to be prefixed with "## ".
852 With two (or more) ``--verbose`` (or ``-v``) options, additionally
853 show full symbolic ref names and unabbreviated hash values.
855 With the ``--exit-code`` option the exit code will be non-zero if any
856 TopGit or Git operation is currently in progress or the working
861 Create a new TopGit-controlled topic branch of the given name
862 (required argument) and switch to it. If no dependencies are
863 specified (by extra arguments passed after the first one), the
864 current branch is assumed to be the only dependency.
866 By default ``tg create`` opens an editor on the new ``.topmsg`` file
867 and then commits the new ``.topmsg`` and ``.topdeps`` files
868 automatically with a suitable default commit message.
870 The commit message can be changed with the ``-m`` (or ``--message``) or
871 ``-F`` (or ``--file``) option. The automatic commit can be suppressed
872 by using the ``--no-ccmmit`` option. Running the editor on the new
873 ``.topmsg`` file can be suppressed by using ``-n`` (or ``--no-edit``)
874 (which also suppresses the automatic commit) or by providing an
875 explicit value for the new ``.topmsg`` file using the ``--topmsg`` or
876 ``--topmsg-file`` option. In any case the ``.topmsg`` content will be
877 automatically reformated to have a ``Subject:`` header line if needed.
879 If more than one dependency is listed an automatic ``tg update`` runs
880 after the branch has been created to merge in the additional
881 dependencies and bring the branch up-to-date. This can be suppressed
882 with the ``--no-commit`` option (which also suppresses the initial
885 Previous versions of TopGit behaved as though the ``--no-edit`` option
886 was always given on the command line.
888 The default behavior has been changed to promote a separation between
889 commits that modify ``.topmsg`` and/or ``.topdeps`` and commits that
890 modify other files. This facilitates cleaner cherry picking and other
891 patch maintenance activities.
893 You should edit the patch description (contained in the ``.topmsg``
894 file) as appropriate. It will already contain some prefilled bits.
895 You can set the ``topgit.to``, ``topgit.cc`` and ``topgit.bcc``
896 git configuration variables (see ``man git-config``) in order to
897 have ``tg create`` add these headers with the given default values
898 to ``.topmsg`` before invoking the editor. If the configuration
899 variable ``topgit.subjectPrefix`` is set its value will be inserted
900 *between* the initial ``[`` and the word ``PATCH`` in the subject
901 line (with a space added before the word ``PATCH`` of course).
903 The main task of ``tg create`` is to set up the topic branch base
904 from the dependencies. This may fail due to merge conflicts if more
905 than one dependency is given. In that case, after you commit the
906 conflict resolution, you should call ``tg update --continue`` to
907 finish merging the dependencies into the new topic branch base.
909 With the ``--base`` (aka ``--no-deps``) option at most one dependency
910 may be listed which may be any valid committish (instead of just
911 refs/heads/...) and the newly created TopGit-controlled branch will
912 have an empty ``.topdeps`` file. This may be desirable in order to
913 create a TopGit-controlled branch that has no changes of its own and
914 serves merely to mark the common dependency that all other
915 TopGit-controlled branches in some set of TopGit-controlled branches
916 depend on. A plain, non-TopGit-controlled branch can be used for the
917 same purpose, but the advantage of a TopGit-controlled branch with no
918 dependencies is that it will be pushed with ``tg push``, it will show
919 up in the ``tg summary`` and ``tg info`` output with the subject from
920 its ``.topmsg`` file thereby documenting what it's for and finally it
921 can be set up with ``tg create -r`` and/or ``tg remote --populate`` to
924 For example, ``tg create --base release v2.1`` will create a TopGit-
925 controlled ``release`` branch based off the ``v2.1`` tag that can then
926 be used as a base for creation of other TopGit-controlled branches.
927 Then when the time comes to move the base for an entire set of changes
928 up to ``v2.2`` the command ``tg update --base release v2.2`` can be
929 used followed by ``tg update --all``.
931 Using ``--base`` it's also possible to use ``tg create`` on an
932 unborn branch (omit the dependency name or specify ``HEAD``). The
933 unborn branch itself can be made into the new TopGit branch (rather
934 than being born empty and then having the new TopGit branch based off
935 that) by specifying ``HEAD`` as the new branch's name (which is
936 probably what you normally want to do in this case anyway so you can
937 just run ``tg create --base HEAD`` to accomplish that).
939 In an alternative use case, if ``-r <branch>`` is given instead of a
940 dependency list, the topic branch is created based on the given
941 remote branch. With just ``-r`` the remote branch name is assumed
942 to be the same as the local topic branch being created. Since no
943 new commits are created in this mode (only two refs will be updated)
944 the editor will never be run for this use case. Note that no other
945 options may be combined with ``-r``.
947 The ``--quiet`` (or ``-q``) option suppresses most informational
952 Remove a TopGit-controlled topic branch of the given name
953 (required argument). Normally, this command will remove only an
954 empty branch (base == head) without dependents; use ``-f`` to
955 remove a non-empty branch or a branch that is depended upon by
958 The ``-f`` option is also useful to force removal of a branch's
959 base, if you used ``git branch -D B`` to remove branch B, and then
960 certain TopGit commands complain, because the base of branch B
963 Normally ``tg delete`` will refuse to delete the current branch.
964 However, giving ``-f`` twice (or more) will force it to do so but it
965 will first detach your HEAD.
967 IMPORTANT: Currently, this command will *NOT* remove the branch
968 from the dependency list in other branches. You need to take
969 care of this *manually*. This is even more complicated in
970 combination with ``-f`` -- in that case, you need to manually
971 unmerge the removed branch's changes from the branches depending
974 The same ``--stash`` and ``--no-stash`` options are accepted with
975 the same exact semantics as for `tg update`_.
977 See also ``tg annihilate``.
979 | TODO: ``-a`` to delete all empty branches, depfix, revert
983 Make a commit on the current or given TopGit-controlled topic
984 branch that makes it equal to its base, including the presence or
985 absence of .topmsg and .topdeps. Annihilated branches are not
986 displayed by ``tg summary``, so they effectively get out of your
987 way. However, the branch still exists, and ``tg push`` will
988 push it (except if given the ``-a`` option). This way, you can
989 communicate that the branch is no longer wanted.
991 When annihilating a branch that has dependents (i.e. branches
992 that depend on it), those dependents have the dependencies of
993 the branch being annihilated added to them if they do not already
994 have them as dependencies. Essentially the DAG is repaired to
995 skip over the annihilated branch.
997 Normally, this command will remove only an empty branch
998 (base == head, except for changes to the .top* files); use
999 ``-f`` to annihilate a non-empty branch.
1001 After completing the annihilation itself, normally ``tg update``
1002 is run on any modified dependents. Use the ``--no-update`` option
1003 to suppress running ``tg update``.
1005 The same ``--stash`` and ``--no-stash`` options are accepted with
1006 the same exact semantics as for `tg update`_.
1010 Change the dependencies of a TopGit-controlled topic branch.
1011 This should have several subcommands, but only ``add`` is
1012 supported right now.
1014 The ``add`` subcommand takes an argument naming a topic branch to
1015 be added, adds it to ``.topdeps``, performs a commit and then
1016 updates your topic branch accordingly. If you want to do other
1017 things related to the dependency addition, like adjusting
1018 ``.topmsg``, use the option ``--no-commit``. Adding the
1019 ``--no-update`` (or ``--no-commit``) option will suppress the
1020 ``tg update`` normally performed after committing the change.
1022 It is safe to run ``tg depend add`` in a dirty worktree, but the
1023 normally performed ``tg update`` will be suppressed in that case
1024 (even if neither ``--no-update`` nor ``--no-commit`` is given).
1026 You have enabled ``git rerere`` haven't you?
1028 | TODO: Subcommand for removing dependencies, obviously
1032 List files changed by the current or specified topic branch.
1035 -i list files based on index instead of branch
1036 -w list files based on working tree instead of branch
1040 Show summary information about the current or specified topic
1043 Numbers in parenthesis after a branch name such as "(11/3 commits)"
1044 indicate how many commits on the branch (11) and how many of those
1045 are non-merge commits (3).
1047 With ``--verbose`` (or ``-v``) include a list of dependents (i.e. other
1048 branches that depend on this one). Another ``--verbose`` annotates
1049 them with "[needs merge]" if the current tip of branch for which info
1050 is being shown has not yet been merged into the base of the dependent.
1052 Alternatively, if ``--heads`` is used then which of the independent
1053 TopGit branch heads (as output by ``tg summary --topgit-heads``)
1054 logically contains the specified commit (which may be any committish --
1055 defaults to ``HEAD`` if not given). Zero or more results will be
1056 output. Note that "logically" means with regard to the TopGit
1057 dependency relationships as established by the ``.topdeps`` file(s).
1058 It's the answer that would be given when all the TopGit branches are
1059 up-to-date (even though they need not be to use this option) and the
1060 ``git branch --contains`` command is run and the output then filtered
1061 to only those branches that appear in ``tg summary --topgit-heads``.
1062 This computation may require several seconds on complex repositories.
1064 If ``--leaves`` is used then the unique list of leaves of the current
1065 or specified topic branch is shown as one fully-qualified ref per line.
1066 Duplicates are suppressed and a tag name will be used when appropriate.
1067 A "leaf" is any dependency that is either not a TopGit branch or is
1068 the base of a non-annihilated TopGit branch with no non-annihilated
1071 The ``--deps`` option shows non-annihilated TopGit dependencies of the
1072 specified branch (default is ``HEAD``). (It can also be spelled out
1073 as ``--dependencies`` for the pedantically inclined.)
1075 The ``--dependents`` option shows non-annihilated TopGit dependents
1076 (i.e. branches that depend on the specified branch). The default
1077 branch to operate on is again ``HEAD``.
1079 A linearized patch series can only be automatically created for a
1080 TopGit topic branch (including its recursive dependencies) when exactly
1081 one line is output by ``tg info --leaves <topic-branch>``.
1083 With ``--series`` the list of TopGit branches in the order they would
1084 be linearized into a patch series is shown along with the description
1085 of each branch. If branch name passed to ``tg info`` is not the last
1086 branch in the series a marker column will be provided to quickly
1087 locate it in the list. This same option can be used with `tg checkout`_.
1089 Some patches shown in the list may not actually end up introducing any
1090 changes if exported and be therefore end up being omitted. The ``0``
1091 indicator in ``tg summary`` output can help to identify some of these.
1093 The patches shown in the series in the order they are shown form the
1094 basis for the ``tg next`` and ``tg prev`` operations with the first
1095 patch shown being considered the first and so on up to the last.
1099 Generate a patch from the current or specified topic branch.
1100 This means that the diff between the topic branch base and head
1101 (latest commit) is shown, appended to the description found in
1102 the ``.topmsg`` file.
1104 The patch is simply dumped to stdout. In the future, ``tg patch``
1105 will be able to automatically send the patches by mail or save
1106 them to files. (TODO)
1109 -i base patch generation on index instead of branch
1110 -w base patch generation on working tree instead of branch
1111 --binary pass --binary to ``git diff-tree`` to enable generation
1113 --quiet be quiet (aka ``-q``) about missing and unfixed From:
1114 --from make sure patch has a From: line, if not add one using
1115 --from=<a> <a> or Signed-off-by value or ident value; ``git am``
1116 really gets unhappy with patches missing From: lines;
1117 will NOT replace an existing non-empty From: header
1118 --no-from leave all From: lines alone, missing or not (default)
1119 --diff-opt options after the branch name (and an optional ``--``)
1120 are passed directly to ``git diff-tree``
1122 In order to pass a sole explicit ``-w`` through to ``git diff-tree`` it
1123 must be separated from the ``tg`` options by an explicit ``--``.
1124 Or it can be spelled as ``--ignore-all-space`` to distinguuish it from
1125 ``tg``'s ``-w`` option.
1127 If the config variable ``topgit.from`` is set to a boolean it can be
1128 used to enable or disable the ``--from`` option by default. If it's
1129 set to the speical value ``quiet`` the ``--quiet`` option is enabled
1130 and From: lines are left alone by default. Any other non-empty value
1131 is taken as a default ``--from=<value>`` option. The ``--no-from``
1132 option will temporarily disable use of the config value.
1134 If additional non-``tg`` options are passed through to
1135 ``git diff-tree`` (other than ``--binary`` which is fully supported)
1136 the resulting ``tg patch`` output may not be appliable.
1140 Send a patch from the current or specified topic branch as
1143 Takes the patch given on the command line and emails it out.
1144 Destination addresses such as To, Cc and Bcc are taken from the
1147 Since it actually boils down to ``git send-email``, please refer
1148 to the documentation for that for details on how to setup email
1149 for git. You can pass arbitrary options to this command through
1150 the ``-s`` parameter, but you must double-quote everything. The
1151 ``-r`` parameter with a msgid can be used to generate in-reply-to
1152 and reference headers to an earlier mail.
1154 WARNING: be careful when using this command. It easily sends
1155 out several mails. You might want to run::
1157 git config sendemail.confirm always
1159 to let ``git send-email`` ask for confirmation before sending any
1163 -i base patch generation on index instead of branch
1164 -w base patch generation on working tree instead of branch
1166 | TODO: ``tg mail patchfile`` to mail an already exported patch
1167 | TODO: mailing patch series
1168 | TODO: specifying additional options and addresses on command line
1172 Register the given remote as TopGit-controlled. This will create
1173 the namespace for the remote branch bases and teach ``git fetch``
1174 to operate on them. However, from TopGit 0.8 onwards you need to
1175 use ``tg push``, or ``git push --mirror``, for pushing
1176 TopGit-controlled branches.
1178 ``tg remote`` takes an optional remote name argument, and an
1179 optional ``--populate`` switch. Use ``--populate`` for your
1180 origin-style remotes: it will seed the local topic branch system
1181 based on the remote topic branches. ``--populate`` will also make
1182 ``tg remote`` automatically fetch the remote, and ``tg update`` look
1183 at branches of this remote for updates by default.
1185 Using ``--populate`` with a remote name causes the ``topgit.remote``
1186 git configuration variable to be set to the given remote name.
1190 Show overview of all TopGit-tracked topic branches and their
1191 up-to-date status. With a branch name limit output to that branch.
1192 Using ``--deps-only`` or ``--rdeps`` changes the default from all
1193 related branches to just the current ``HEAD`` branch but using
1194 ``--all`` as the branch name will show results for all branches
1195 instead of ``HEAD``.
1198 marks the current topic branch
1201 indicates that it introduces no changes of its own
1204 indicates respectively whether it is local-only
1205 or has a remote mate
1208 indicates respectively if it is ahead or out-of-date
1209 with respect to its remote mate
1212 indicates that it is out-of-date with respect to its
1216 indicates that it has missing dependencies [even if
1217 they are recursive ones]
1220 indicates that it is out-of-date with respect to
1224 indicates it is ahead of (and needs to be merged into)
1225 at least one of its dependents -- only computed when
1226 showing all branches or using the (possibly implied)
1227 ``--with-deps`` option.
1229 This can take a longish time to accurately determine all the
1230 relevant information about each branch; you can pass ``-t`` (or ``-l``
1231 or ``--list``) to get just a terse list of topic branch names quickly.
1232 Also adding ``--verbose`` (or ``-v``) includes the subjects too.
1234 If no options or arguments are passed, the default is not actually to
1235 show ``--all`` branches (that was the default once upon a time).
1236 Instead, the default is essentially ``--with-deps $(tg info --heads)``
1237 with a fallback to ``--all`` if ``tg info`` doesn't give up any heads.
1238 This usually provides a more intuitive result. Explicitly using
1239 ``--all`` will always show all branches (related or not to ``HEAD``).
1241 Passing ``--heads`` shows independent topic branch names and when
1242 combined with ``--rdeps`` behaves as though ``--rdeps`` were run with
1243 the output of ``--heads``.
1245 The ``--heads-independent`` option works just like ``--heads`` except
1246 that it computes the heads using ``git merge-base --independent``
1247 rather than examining the TopGit ``.topdeps`` relationships. If the
1248 TopGit branches are all up-to-date (as shown in ``tg summary``) then
1249 both ``--heads`` and ``--heads-independent`` should compute the same
1250 list of heads (unless some overlapping TopGit branches have been
1251 manually created). If not all the TopGit branches are up-to-date then
1252 the ``--heads-independent`` results may have extra items in it, but
1253 occasionally that's what's needed; usually it's the wrong answer.
1254 (Note that ``--topgit-heads`` is accepted as an alias for ``--heads``
1257 Using ``--heads-only`` behaves as though the output of ``--heads`` was
1258 passed as the list of branches along with ``--without-deps``.
1260 Alternatively, you can pass ``--graphviz`` to get a dot-suitable output
1261 for drawing a dependency graph between the topic branches.
1263 You can also use the ``--sort`` option to sort the branches using
1264 a topological sort. This is especially useful if each
1265 TopGit-tracked topic branch depends on a single parent branch,
1266 since it will then print the branches in the dependency order.
1267 In more complex scenarios, a text graph view would be much more
1268 useful, but that has not yet been implemented.
1270 The ``--deps`` option outputs dependency information between
1271 branches in a machine-readable format. Feed this to ``tsort`` to
1272 get the output from --sort.
1274 The ``--deps-only`` option outputs a sorted list of the unique branch
1275 names given on the command line plus all of their recursive
1276 dependencies (subject to ``--exclude`` of course). When
1277 ``--deps-only`` is given the default is to just display information for
1278 ``HEAD``, but that can be changed by using ``--all`` as the branch
1279 name. Each branch name will appear only once in the output no matter
1280 how many times it's visited while tracing the dependency graph or how
1281 many branch names are given on the command line to process.
1283 The ``--rdeps`` option outputs dependency information in an indented
1284 text format that clearly shows all the dependencies and their
1285 relationships to one another. When ``--rdeps`` is given the default is
1286 to just display information for ``HEAD``, but that can be changed by
1287 using ``--all`` as the branch name or by adding the ``--heads`` option.
1288 Note that ``tg summary --rdeps --heads`` can be particularly helpful in
1289 seeing all the TopGit-controlled branches in the repository and their
1290 relationships to one another.
1292 Note that ``--rdeps`` has two flavors. The first (and default) is
1293 ``--rdeps-once`` which only shows the dependencies of a branch when
1294 it's first visited. For example, if D depends on several other
1295 branches perhaps recursively and both branch A and B depend on D, then
1296 whichever of A or B is shown first will show the entire dependency
1297 chain for D underneath it and the other one will just show a line for
1298 D itself. This can make the output a bit more compact without actually
1299 losing any information which is why it's the default. However, using
1300 the ``--rdeps-full`` variant will repeat the full dependency chain
1301 every time it's encountered.
1303 Adding ``--with-deps`` replaces the given list of branches (which will
1304 default to ``HEAD`` if none are given) with the result of running
1305 ``tg summary --deps-only --tgish`` on the list of branches. This can
1306 be helpful in limiting ``tg summary`` output to only the list of given
1307 branches and their dependencies when many TopGit-controlled branches
1308 are present in the repository. When it would be allowed,
1309 ``--with-deps`` is now the default. Use ``--without-deps`` to switch
1310 back to the old behavior.
1312 With ``--exclude branch``, branch can be excluded from the output
1313 meaning it will be skipped and its name will be omitted from any
1314 dependency output. The ``--exclude`` option may be repeated to omit
1315 more than one branch from the output. Limiting the output to a single
1316 branch that has been excluded will result in no output at all.
1318 The ``--tgish-only`` option behaves as though any non-TopGit-controlled
1319 dependencies encountered during processing had been listed after an
1320 ``--exclude`` option.
1322 Note that the branch name can be specified as ``HEAD`` or ``@`` as a
1323 shortcut for the TopGit-controlled branch that ``HEAD`` is a
1324 symbolic ref to. The ``tg summary @`` command can be quite useful.
1327 -i Use TopGit metadata from the index instead of the branch
1328 -w Use TopGit metadata from the working tree instead of the branch
1332 Search all TopGit-controlled branches (and optionally their remotes)
1333 to find which TopGit-controlled branch contains the specified commit.
1335 This is more than just basic branch containment as provided for by the
1336 ``git branch --contains`` command. While the shown branch name(s)
1337 will, indeed, be one (or more) of those output by the
1338 ``git branch --contains`` command, the result(s) will exclude any
1339 TopGit-controlled branches from the result(s) that have one (or more)
1340 of their TopGit dependencies (either direct or indirect) appearing in
1341 the ``git branch --contains`` output.
1343 Normally the result will be only the one, single TopGit-controlled
1344 branch for which the specified committish appears in the ``tg log``
1345 output for that branch (unless the committish lies outside the
1346 TopGit-controlled portion of the DAG and ``--no-strict`` was used).
1348 Unless ``--annihilated-okay`` (or ``--ann`` or ``--annihilated``) is
1349 used then annihilated branches will be immediately removed from the
1350 ``git branch --contains`` output before doing anything else. This
1351 means a committish that was originally located in a now-annihilated
1352 branch will show up in whatever branch picked up the annihilated
1353 branch's changes (if there is one). This is usually the correct
1354 answer, but occasionally it's not; hence this option. If this option
1355 is used together with ``--verbose`` then annihilated branches will
1356 be shown as "[:annihilated:]".
1358 In other words, if a ``tg patch`` is generated for the found branch
1359 (assuming one was found and a subsequent commit in the same branch
1360 didn't then revert or otherwise back out the change), then that patch
1361 will include the changes introduced by the specified committish
1362 (unless, of course, that committish is outside the TopGit-controlled
1363 portion of the DAG and ``--no-strict`` was given).
1365 This can be very helpful when, for example, a bug is discovered and
1366 then after using ``git bisect`` (or some other tool) to find the
1367 offending commit it's time to commit the fix. But because the
1368 TopGit merging history can be quite complicated and maybe the one
1369 doing the fix wasn't the bug's author (or the author's memory is just
1370 going), it can sometimes be rather tedious to figure out which
1371 TopGit branch the fix belongs in. The ``tg contains`` command can
1372 quickly tell you the answer to that question.
1374 With the ``--remotes`` (or ``-r``) option a TopGit-controlled remote
1375 branch name may be reported as the result but only if there is no
1376 non-remote branch containing the committish (this can only happen
1377 if at least one of the TopGit-controlled local branches are not yet
1378 up-to-date with their remotes).
1380 With the ``--verbose`` option show which TopGit DAG head(s) (one or
1381 more of the TopGit-controlled branch names output by
1382 ``tg summary --heads``) have the result as a dependency (either direct
1383 or indirect). Using this option will noticeably increase running time.
1385 With the default ``--strict`` option, results for which the base of the
1386 TopGit-controlled branch contains the committish will be suppressed.
1387 For example, if the committish was deep-down in the master branch
1388 history somewhere far outside of the TopGit-controlled portion of
1389 the DAG, with ``--no-strict``, whatever TopGit-controlled branch(es)
1390 first picked up history containing that committish will be shown.
1391 While this is a useful result it's usually not the desired result
1392 which is why it's not the default.
1394 To summarize, even with ``--remotes``, remote results are only shown
1395 if there are no non-remote results. Without ``--no-strict`` (because
1396 ``--strict`` is the default) results outside the TopGit-controlled
1397 portion of the DAG are never shown and even with ``--no-strict`` they
1398 will only be shown if there are no ``--strict`` results. Finally,
1399 the TopGit head info shown with ``--verbose`` only ever appears for
1400 local (i.e. not a remote branch) results. Annihilated branches are
1401 never considered possible matches without ``--annihilated-okay``.
1405 Switch to a topic branch. You can use ``git checkout <branch>``
1406 to get the same effect, but this command helps you navigate
1407 the dependency graph, or allows you to match the topic branch
1408 name using a regular expression, so it can be more convenient.
1410 The ``--branch`` (or ``-b`` or ``--branch=<name>``) option changes
1411 the default starting point from ``HEAD`` to the specified branch.
1413 For the "next" and "previous" commands, the ``<steps>`` value may
1414 be ``--all`` (or ``-a``) to take "As many steps As possible" or
1415 "step ALL the way" or "ALL steps at once" (or make something better
1418 The following subcommands are available:
1420 ``tg checkout next [<steps>]``
1421 Check out a branch that directly
1422 depends on your current branch.
1423 Move ``<steps>`` (default 1) step(s) in
1424 the "next" direction (AKA ``n``).
1426 ``tg checkout prev [<steps>]``
1427 Check out a branch that this branch
1428 directly depends on. Move ``<steps>``
1429 (default 1) step(s) in the "previous"
1430 direction (AKA ``p`` or ``previous``).
1432 ``tg checkout [goto] [--] <pattern>``
1433 Check out a topic branch that
1434 matches ``<pattern>``. ``<pattern>``
1435 is used as a grep ERE pattern to filter
1436 all the topic branches. Both ``goto`` and
1437 ``--`` may be omitted provided ``<pattern>``
1438 is not ``-a``, ``--all``, ``-h``, ``--help``,
1439 ``goto``, ``--``, ``n``, ``next``, ``push``,
1440 ``child``, ``p``, ``prev``, ``previous``,
1441 ``pop``, ``parent`` or ``..``.
1443 ``tg checkout [goto] [--] --series[=<head>]``
1444 Check out a topic branch that belongs to
1445 the current (or ``<head>``) patch series.
1446 A list with descriptions (``tg info --series``)
1447 will be shown to choose from if more than one.
1449 ``tg checkout push [<steps>]``
1450 An alias for ``next``.
1452 ``tg checkout child [<steps>]``
1453 Deprecated alias for ``next``.
1456 Semi-deprecated alias for ``next``.
1458 ``tg checkout pop [<steps>]``
1459 An alias for ``prev``.
1461 ``tg checkout parent [<steps>]``
1462 Deprecated alias for ``prev``.
1464 ``tg checkout .. [<steps>]``
1465 Semi-deprecated alias for ``prev``.
1467 If any of the above commands can find more than one possible
1468 branch to switch to, you will be presented with the matches
1469 and asked to select one of them.
1471 If the ``--ignore-other-worktrees`` (or ``--iow``) option is given and
1472 the current Git version is at least 2.5.0 then the full
1473 ``--ignore-other-worktrees`` option will be passed along to the
1474 ``git checkout`` command when it's run (otherwise the option will be
1475 silently ignored and not passed to Git as it would cause an error).
1477 The ``--force`` (or ``-f``) option, when given, gets passed through to
1478 the ``git checkout`` command.
1480 The ``--merge`` (or ``-m``) option, when given, gets passed through to
1481 the ``git checkout`` command.
1483 The ``--quiet`` (or ``-q``) option, when given, gets passed through to
1484 the ``git checkout`` command.
1486 The ``<pattern>`` of ``tg checkout goto`` is optional. If you don't
1487 supply it, all the available topic branches are listed and you
1488 can select one of them.
1490 Normally, the ``next`` and ``prev`` commands moves one step in
1491 the dependency graph of the topic branches. The ``-a`` option
1492 causes them (and their aliases) to move as far as possible.
1493 That is, ``tg checkout next -a`` moves to a topic branch that
1494 depends (directly or indirectly) on the current branch and
1495 that no other branch depends on. ``tg checkout prev -a``
1496 moves to a topic branch that the current topic branch
1497 depends on (directly or indirectly). If there is more than
1498 one possibility, you will be prompted for your selection.
1500 See also NAVIGATION_.
1504 Export a tidied-up history of the current topic branch and its
1505 dependencies, suitable for feeding upstream. Each topic branch
1506 corresponds to a single commit or patch in the cleaned up
1507 history (corresponding basically exactly to ``tg patch`` output
1508 for the topic branch).
1510 The command has three possible outputs now -- either a Git branch
1511 with the collapsed history, a Git branch with a linearized
1512 history, or a quilt series in new directory.
1514 In the case where you are producing collapsed history in a new
1515 branch, you can use this collapsed structure either for
1516 providing a pull source for upstream, or for further
1517 linearization e.g. for creation of a quilt series using git log::
1519 git log --pretty=email -p --topo-order origin..exported
1521 To better understand the function of ``tg export``, consider this
1522 dependency structure::
1524 origin/master - t/foo/blue - t/foo/red - master
1525 `- t/bar/good <,----------'
1526 `- t/baz ------------'
1528 (where each of the branches may have a hefty history). Then::
1530 master$ tg export for-linus
1532 will create this commit structure on the branch ``for-linus``::
1534 origin/master - t/foo/blue -. merge - t/foo/red -.. merge - master
1535 `- t/bar/good <,-------------------'/
1536 `- t/baz ---------------------'
1538 In this mode, ``tg export`` works on the current topic branch, and
1539 can be called either without an option (in that case,
1540 ``--collapse`` is assumed), or with the ``--collapse`` option, and
1541 with one mandatory argument: the name of the branch where the
1542 exported result will be stored.
1544 When using the linearize mode::
1546 master$ tg export --linearize for-linus
1548 you get a linear history respecting the dependencies of your
1549 patches in a new branch ``for-linus``. The result should be more
1550 or less the same as using quilt mode and then reimporting it
1551 into a Git branch. (More or less because the topological order
1552 can usually be extended in more than one way into a total order,
1553 and the two methods may choose different ones.) The result
1554 might be more appropriate for merging upstream, as it contains
1557 Note that you might get conflicts during linearization because
1558 the patches are reordered to get a linear history. If linearization
1559 would produce conflicts then using ``--quilt`` will also likely result
1560 in conflicts when the exported quilt series is applied. Since the
1561 ``--quilt`` mode simply runs a series of ``tg patch`` commands to
1562 generate the patches in the exported quilt series and those patches
1563 will end up being applied linearly, the same conflicts that would be
1564 produced by the ``--linearize`` option will then occur at that time.
1566 To avoid conflicts produced by ``--linearize`` (or by applying the
1567 ``--quilt`` output), use the default ``--collapse`` mode and then use
1568 ``tg rebase`` (or ``git rebase -m`` directly) on the collapsed branch
1569 (with a suitable <upstream>) followed by ``git format-patch`` on the
1570 rebased result to produce a conflict-free patch set. A suitable
1571 upstream may be determined with the ``tg info --leaves`` command (if
1572 it outputs more than one line, linearization will be problematic).
1574 You have enabled ``git rerere`` haven't you?
1576 When using the quilt mode::
1578 master$ tg export --quilt for-linus
1580 would create the following directory ``for-linus``::
1582 for-linus/t/foo/blue.diff
1583 for-linus/t/foo/red.diff
1584 for-linus/t/bar/good.diff
1585 for-linus/t/baz.diff
1592 With ``--quilt``, you can also pass the ``-b`` parameter followed
1593 by a comma-separated explicit list of branches to export, or
1594 the ``--all`` parameter (which can be shortened to ``-a``) to
1595 export them all. The ``--binary`` option enables producing Git
1596 binary patches. These options are currently only supported
1599 In ``--quilt`` mode the patches are named like the originating
1600 topgit branch. So usually they end up in subdirectories of the
1601 output directory. With the ``--flatten`` option the names are
1602 mangled so that they end up directly in the output dir (slashes
1603 are replaced with underscores). With the ``--strip[=N]`` option
1604 the first ``N`` subdirectories (all if no ``N`` is given) get
1605 stripped off. Names are always ``--strip``'d before being
1606 ``--flatten``'d. With the option ``--numbered`` (which implies
1607 ``--flatten``) the patch names get a number as prefix to allow
1608 getting the order without consulting the series file, which
1609 eases sending out the patches.
1611 | TODO: Make stripping of non-essential headers configurable
1612 | TODO: Make stripping of [PATCH] and other prefixes configurable
1613 | TODO: ``--mbox`` option to export instead as an mbox file
1614 | TODO: support ``--all`` option in other modes of operation
1615 | TODO: For quilt exporting, export the linearized history created in
1616 a temporary branch--this would allow producing conflict-less
1621 Import commits within the given revision range into TopGit,
1622 creating one topic branch per commit. The dependencies are set
1623 up to form a linear sequence starting on your current branch --
1624 or a branch specified by the ``-d`` parameter, if present.
1626 The branch names are auto-guessed from the commit messages and
1627 prefixed by ``t/`` by default; use ``-p <prefix>`` to specify an
1628 alternative prefix (even an empty one).
1630 Alternatively, you can use the ``-s NAME`` parameter to specify
1631 the name of the target branch; the command will then take one
1632 more argument describing a *single* commit to import.
1636 Update the current, specified or all topic branches with respect
1637 to changes in the branches they depend on and remote branches.
1638 This is performed in two phases -- first, changes within the
1639 dependencies are merged to the base, then the base is merged
1640 into the topic branch. The output will guide you on what to do
1641 next in case of conflicts.
1643 You have enabled ``git rerere`` haven't you?
1645 The ``--[no-]auto[-update]`` options together with the
1646 ``topgit.setAutoUpdate`` config item control whether or not TopGit
1647 will automatically temporarily set ``rerere.autoUpdate`` to true while
1648 running ``tg update``. The default is true. Note that this does not
1649 enable Git's ``rerere`` feature, it merely makes it automatically stage
1650 any previously resolved conflicts. The ``rerere.enabled`` setting must
1651 still be separately enabled (i.e. set to ``true``) for the ``rerere``
1652 feature to do anything at all.
1654 Using ``--auto[-update]`` makes ``tg update`` always temporarily set
1655 ``rerere.autoUpdate`` to ``true`` while running ``tg update``. The
1656 ``--no-auto[-update]`` option prevents ``tg update`` from changing the
1657 ``rerere.autoUpdate`` setting, but if ``rerere.autoUpdate`` has already
1658 been enabled in a config file, ``tg update`` never disables it even
1659 with ``--no-auto``. If ``topgit.setAutoUpdate`` is unset or set to
1660 ``true`` then ``tg update`` implicitly does ``--auto``, otherwise it
1661 does ``--no-auto``. An explicit command line ``--[no-]auto[-update]``
1662 option causes the ``topgit.setAutoUpdate`` setting to be ignored.
1664 When both ``rerere.enabled`` and ``rerere.autoUpdate`` are set to true
1665 then ``tg update`` will be able to automatically continue an update
1666 whenever ``git rerere`` resolves all the conflicts during a merge.
1667 This can be such a huge time saver. That's why the default is to have
1668 TopGit automatically set ``rerere.autoUpdate`` to true while
1669 ``tg update`` is running (but remember, unless ``rerere.enabled`` has
1670 been set to ``true`` it won't make any difference).
1672 When ``-a`` (or ``--all``) is specified, updates all topic branches
1673 matched by ``<pattern>``'s (see ``git-for-each-ref(1)`` for details),
1674 or all if no ``<pattern>`` is given. Any topic branches with missing
1675 dependencies will be skipped entirely unless ``--skip-missing`` is
1678 When ``--skip-missing`` is specified, an attempt is made to update topic
1679 branches with missing dependencies by skipping only the dependencies
1680 that are missing. Caveat utilitor.
1682 When ``--stash`` is specified (or the ``topgit.autostash`` config
1683 value is set to ``true``), a ref stash will be automatically created
1684 just before beginning updates if any are needed. The ``--no-stash``
1685 option may be used to disable a ``topgit.autostash=true`` setting.
1686 See the ``tg tag`` ``--stash`` option for details.
1688 After the update, if a single topic branch was specified, it is
1689 left as the current one; if ``-a`` was specified, it returns to
1690 the branch which was current at the beginning.
1692 If your dependencies are not up-to-date, ``tg update`` will first
1693 recurse into them and update them.
1695 If a remote branch update brings in dependencies on branches
1696 that are not yet instantiated locally, you can either bring in
1697 all the new branches from the remote using ``tg remote
1698 --populate``, or only pick out the missing ones using ``tg create
1699 -r`` (``tg summary`` will point out branches with incomplete
1700 dependencies by showing an ``!`` next to them). TopGit will attempt to
1701 instantiate just the missing ones automatically for you, if possible,
1702 when ``tg update`` merges in the new dependencies from the remote.
1704 Using the alternative ``--base`` mode, ``tg update`` will update
1705 the base of a specified ``[BASE]`` branch (which is a branch created
1706 by ``tg create`` using the ``--base`` option) to the specified
1707 committish (the second argument) and then immediately merge that into
1708 the branch itself using the specified message for the merge commit.
1709 If no message is specified on the command line, an editor will open.
1710 Unless ``--force`` is used the new value for the base must contain
1711 the old value (i.e. be a fast-forward update). This is for safety.
1713 This mode makes updates to ``[BASE]`` branches quick and easy.
1715 | TODO: ``tg update -a -c`` to autoremove (clean) up-to-date branches
1719 If ``-a`` or ``--all`` was specified, pushes all non-annihilated
1720 TopGit-controlled topic branches, to a remote repository.
1721 Otherwise, pushes the specified topic branches -- or the
1722 current branch, if you don't specify which. By default, the
1723 remote gets all the dependencies (both TopGit-controlled and
1724 non-TopGit-controlled) and bases pushed to it too. If
1725 ``--tgish-only`` was specified, only TopGit-controlled
1726 dependencies will be pushed, and if ``--no-deps`` was specified,
1727 no dependencies at all will be pushed.
1729 The ``--dry-run`` and ``--force`` options are passed directly to
1730 ``git push`` if given.
1732 The remote may be specified with the ``-r`` option. If no remote
1733 was specified, the configured default TopGit remote will be
1738 Prints the base commit of each of the named topic branches, or
1739 the current branch if no branches are named. Prints an error
1740 message and exits with exit code 1 if the named branch is not
1745 Prints the git log of the named topgit branch -- or the current
1746 branch, if you don't specify a name.
1748 This is really just a convenient shortcut for:
1750 ``git log --first-parent --no-merges $(tg base <name>)..<name>``
1752 where ``<name>`` is the name of the TopGit topic branch (or omitted
1753 for the current branch).
1755 However, if ``<name>`` is a ``[BASE]`` branch the ``--no-merges``
1758 If ``--compact`` is used then ``git log-compact`` will be used instead
1759 of ``git log``. The ``--command=<git-alias>`` option can be used to
1760 replace "log" with any non-whitespace-containing command alias name,
1761 ``--compact`` is just a shortcut for ``--command=log-compact``. The
1762 ``git-log-compact`` tool may be found on its project page located at:
1764 https://mackyle.github.io/git-log-compact
1766 Note that the ``--compact`` or ``--command=`` option must be used
1767 before any ``--`` or ``git log`` options to be recognized.
1769 NOTE: if you have merged changes from a different repository, this
1770 command might not list all interesting commits.
1774 Creates a TopGit annotated/signed tag or lists the reflog of one.
1776 A TopGit annotated tag records the current state of one or more TopGit
1777 branches and their dependencies and may be used to revert to the tagged
1778 state at any point in the future.
1780 When reflogs are enabled (the default in a non-bare repository) and
1781 combined with the ``--force`` option a single tag name may be used as a
1782 sort of TopGit branch state stash. The special branch name ``--all``
1783 may be used to tag the state of all current TopGit branches to
1784 facilitate this function and has the side-effect of suppressing the
1785 out-of-date check allowing out-of-date branches to be included.
1787 As a special feature, ``--stash`` may be used as the tag name in which
1788 case ``--all`` is implied if no branch name is listed (instead of the
1789 normal default of ``HEAD``), ``--force`` and ``--no-edit`` (use
1790 ``--edit`` to change that) are automatically activated and the tag will
1791 be saved to ``refs/tgstash`` instead of ``refs/tags/<tagname>``.
1792 The ``--stash`` tag name may also be used with the ``-g``/``--reflog``
1795 The mostly undocumented option ``--allow-outdated`` will bypass the
1796 out-of-date check and is implied when ``--stash`` or ``--all`` is used.
1798 A TopGit annotated/signed tag is simply a Git annotated/signed tag with
1799 a "TOPGIT REFS" section appended to the end of the tag message (and
1800 preceding the signature for signed tags). PEM-style begin and end
1801 lines surround one line per ref where the format of each line is
1802 full-hash SP ref-name. A line will be included for each branch given
1803 on the command line and each ref they depend on either directly or
1806 If more than one TopGit branch is given on the command line, a new
1807 commit will be created that has an empty tree and all of the given
1808 TopGit branches as parents and that commit will be tagged. If a single
1809 TopGit branch is given, then it will be tagged. If the ``--tree``
1810 option is used then it will be used instead of an empty tree (a new
1811 commit will be created if necessary to guarantee the specified tree is
1812 what's in the commit the newly created tag refers to). The argument to
1813 the ``--tree`` option may be any valid treeish.
1815 If exactly one of the branches to be tagged is prefixed with a tilde
1816 (``~``) it will be made the first parent of a consolidation commit if
1817 it is not already the sole commit needing to be tagged. If ``--tree``
1818 is NOT used, its tree will also be used instead of the empty tree for
1819 any new consolidation commit if one is created. Note that if
1820 ``--tree`` is given explicitly it's tree is always used but that does
1821 not in any way affect the choice of first parent. Beware that the
1822 ``~`` may need to be quoted to prevent the shell from misinterpreting
1823 it into something else.
1825 All the options for creating a tag serve the same purpose as their Git
1826 equivalents except for two. The ``--refs`` option suppresses tag
1827 creation entirely and emits the "TOPGIT REFS" section that would have
1828 been included with the tag. If the ``--no-edit`` option is given and
1829 no message is supplied (via the ``-m`` or ``-F`` option) then the
1830 default message created by TopGit will be used without running the
1833 With ``-g`` or ``--reflog`` show the reflog for a tag. With the
1834 ``--reflog-message`` option the message from the reflog is shown.
1835 With the ``--commit-message`` option the first line of the tag's
1836 message (if the object is a tag) or the commit message (if the object
1837 is a commit) falling back to the reflog message for tree and blob
1838 objects is shown. The default is ``--reflog-message`` unless the
1839 ``--stash`` (``refs/tgstash``) is being shown in which case the default
1840 is then ``--commit-message``. Just add either option explicitly to
1841 override the default.
1843 When showing reflogs, non-tag entries are annotated with their type
1844 unless ``--no-type`` is given.
1846 TopGit tags are created with a reflog if core.logallrefupdates is
1847 enabled (the default for non-bare repositories). Unfortunately Git
1848 is incapable of showing an annotated/signed tag's reflog
1849 (using git log -g) as it will first resolve the tag before checking to
1850 see if it has a reflog. Git can, however, show reflogs for lightweight
1851 tags (using git log -g) just fine but that's not helpful here. Use
1852 ``tg tag`` with the ``-g`` or ``--reflog`` option to see the reflog for
1853 an actual tag object. This also works on non-TopGit annotated/signed
1854 tags as well provided they have a reflog.
1856 The number of entries shown may be limited with the ``-n`` option. If
1857 the tagname is omitted then ``--stash`` is assumed.
1859 The ``--delete`` option is a convenience option that runs the
1860 ``git update-ref -d`` command on the specified tag removing it and its
1861 reflog (if it has one).
1863 The ``--clear`` option clears all but the most recent (the ``@{0}``)
1864 reflog entries from the reflog for the specified tag. It's equivalent
1865 to dropping all the higher numbered reflog entries.
1867 The ``--drop`` option drops the specified reflog entry and requires the
1868 given tagname to have an ``@{n}`` suffix where ``n`` is the reflog
1869 entry number to be dropped. This is really just a convenience option
1870 that runs the appropriate ``git reflog delete`` command.
1872 Note that when combined with ``tg revert``, a tag created by ``tg tag``
1873 can be used to transfer TopGit branches. Simply create the tag, push
1874 it somewhere and then have the recipient run ``tg revert`` to recreate
1875 the TopGit branches. This may be helpful in situations where it's not
1876 feasible to push all the refs corresponding to the TopGit-controlled
1877 branches and their top-bases.
1881 Provides a ``git rebase`` rerere auto continue function. It may be
1882 used as a drop-in replacement front-end for ``git rebase -m`` that
1883 automatically continues the rebase when ``git rerere`` information is
1884 sufficient to resolve all conflicts.
1886 You have enabled ``git rerere`` haven't you?
1888 If the ``-m`` or ``--merge`` option is not present then ``tg rebase``
1889 will complain and not do anything.
1891 When ``git rerere`` is enabled, previously resolved conflicts are
1892 remembered and can be automatically staged (see ``rerere.autoUpdate``).
1894 However, even with auto staging, ``git rebase`` still stops and
1895 requires an explicit ``git rebase --continue`` to keep going.
1897 In the case where ``git rebase -m`` is being used to flatten history
1898 (such as after a ``tg export --collapse`` prior to a
1899 ``git format-patch``), there's a good chance all conflicts have already
1900 been resolved during normal merge maintenance operations so there's no
1901 reason ``git rebase`` could not automatically continue, but there's no
1902 option to make it do so.
1904 The ``tg rebase`` command provides a ``git rebase --auto-continue``
1907 All the same rebase options can be used (they are simply passed through
1908 to Git unchanged). However, the ``rerere.autoUpdate`` option is
1909 automatically temporarily enabled while running ``git rebase`` and
1910 should ``git rebase`` stop asking one to resolve and continue, but all
1911 conflicts have already been resolved and staged using rerere
1912 information, then ``git rebase --continue`` will be automatically run.
1916 Provides the ability to revert one or more TopGit branches and their
1917 dependencies to a previous state contained within a tag created using
1918 the ``tg tag`` command. In addition to the actual revert mode
1919 operation a list mode operation is also provided to examine a tag's ref
1922 The default mode (``-l`` or ``--list``) shows the state of one or more
1923 of the refs/branches stored in the tag data. When no refs are given on
1924 the command line, all refs in the tag data are shown. With the special
1925 ref name ``--heads`` then the indepedent heads contained in the tag
1926 data are shown. The ``--deps`` option shows the specified refs and all
1927 of their dependencies in a single list with no duplicates. The
1928 ``--rdeps`` option shows a display similar to ``tg summary --rdeps``
1929 for each ref or all TopGit heads if no ref is given on the command
1930 line. The standard ``--no-short``, ``--short=n`` etc. options may be
1931 used to override the default ``--short`` output. With ``--hash`` (or
1932 ``--hash-only``) show only the hash in ``--list`` mode in which case
1933 the default is ``--no-short``. The ``--hash`` option can be used much
1934 like the ``git rev-parse --verify`` command to extract a specific hash
1935 value out of a TopGit tag.
1937 Note that unlike `tg summary`_, here ``--heads`` actually does mean the
1938 ``git merge-base --independent`` heads of the stored refs from the tag
1939 data. To see only the independent TopGit topic branch heads stored in
1940 the tag data use the ``--topgit-heads`` option instead. The default
1941 for the ``--rdeps`` option is ``--topgit-heads`` but ``--heads`` can
1942 be given explicitly to change that. (Note that ``--heads-independent``
1943 is accepted as an alias for ``--heads`` as well.)
1945 The revert mode has three submodes, dry-run mode (``-n`` or
1946 ``--dry-run``), force mode (``-f`` or ``--force``) and interactive mode
1947 (``-i`` or ``--interactive``). If ``--dry-run`` (or ``-n``) is given
1948 no ref updates will actually be performed but what would have been
1949 updated is shown instead. If ``--interactive`` (or ``-i``) is given
1950 then the editor is invoked on an instruction sheet allowing manual
1951 selection of the refs to be updated before proceeding. Since revert is
1952 potentially a destructive operation, at least one of the submodes must
1953 be specified explicitly. If no refs are listed on the command line
1954 then all refs in the tag data are reverted. Otherwise the listed refs
1955 and all of their dependencies (unless ``--no-deps`` is given) are
1956 reverted. Unless ``--no-stash`` is given a new stash will be created
1957 using ``tg tag --stash`` (except, of course, in dry-run mode) just
1958 before actually performing the updates to facilitate recovery from
1961 Both modes accept fully-qualified (i.e. starts with ``refs/``) ref
1962 names as well as unqualified names (which will be assumed to be located
1963 under ``refs/heads/``). In revert mode a tgish ref will always have
1964 both its ``refs/heads/`` and ``refs/top-bases/`` values included no
1965 matter how it's listed unless ``--no-deps`` is given and the ref is
1966 fully qualified (i.e. starts with ``refs/``) or one or the other of its
1967 values was removed from the instruction sheet in interactive mode. In
1968 list mode a tgish ref will always have both its ``refs/heads/`` and
1969 ``refs/top-bases/`` values included only when using the ``--deps`` or
1970 ``--rdeps`` options.
1972 The ``--tgish-only`` option excludes non-tgish refs (i.e. refs that do
1973 not have a ``refs/heads/<name>``, ``refs/top-bases/<name>`` pair).
1975 The ``--exclude`` option (which can be repeated) excludes specific
1976 refs. If the name given to ``--exclude`` is not fully-qualified (i.e.
1977 starts with ``refs/``) then it will exclude both members of a tgish ref
1980 The ``--quiet`` (or ``-q``) option may be used in revert mode to
1981 suppress non-dry-run ref change status messages.
1983 The special tag name ``--stash`` (as well as with ``@{n}`` suffixes)
1984 can be used to refer to ``refs/tgstash``.
1986 The ``tg revert`` command supports tags of tags that contains TopGit
1987 refs. So, for example, if you do this::
1990 git tag -f -a -m "tag the tag" newtag newtag
1992 Then ``newtag`` will be a tag of a tag containing a ``TOPGIT REFS``
1993 section. ``tg revert`` knows how to dereference the outermost
1994 tag to get to the next (and the next etc.) tag to find the
1995 ``TOPGIT REFS`` section so after the above sequence, the tag ``newtag``
1996 can still be used successfully with ``tg revert``.
1998 NOTE: If HEAD points to a ref that is updated by a revert operation
1999 then NO WARNING whatsoever will be issued, but the index and working
2000 tree will always be left completely untouched (and the reflog for
2001 the pointed-to ref can always be used to find the previous value).
2005 Output the "previous" branch(es) in the patch series containing the
2006 current or named branch. The "previous" branch(es) being one step
2010 -i show dependencies based on index instead of branch
2011 -w show dependencies based on working tree instead of branch
2012 -n <steps> take ``<steps>`` "previous" steps (default 1)
2013 --all take as many "previous" steps as possible (aka ``-a``)
2014 --verbose show containing series name(s) (aka ``-v``)
2016 The ``-n`` option may also be given as ``--count`` or ``--count=<n>``.
2018 To list all dependencies of a branch see the ``--deps`` option of
2019 the `tg info`_ command.
2021 See also NAVIGATION_ for full details on "previous" steps.
2025 Output tne "next" branch(es) in the patch series containing the current
2026 or named branch. The "next" branch(es) being one step away by default.
2029 -i show dependencies based on index instead of branch
2030 -w show dependencies based on working tree instead of branch
2031 -n <steps> take ``<steps>`` "next" steps (default 1)
2032 --all take as many "next" steps as possible (aka ``-a``)
2033 --verbose show containing series name(s) (aka ``-v``)
2035 The ``-n`` option may also be given as ``--count`` or ``--count=<n>``.
2037 To list all dependents of a branch see the ``--dependents`` option of
2038 the `tg info`_ command.
2040 See also NAVIGATION_ for full details on "next" steps.
2044 Transition top-bases from old location to new location.
2046 Beginning with TopGit release 0.19.4, TopGit has the ability to store
2047 the top-bases refs in either the old ``ref/top-bases/...`` location or
2048 the new ``refs/heads/{top-bases}/...`` location. Starting with TopGit
2049 release 0.20.0, the default is the new location.
2051 By storing the top-bases under heads, Git is less likely to complain
2052 when manipulating them, hosting providers are more likely to provide
2053 access to them and Git prevents them from pointing at anything other
2054 than a commit object. All in all a win for everyone.
2056 TopGit attempts to automatically detect whether the new or old location
2057 is being used for the top-bases and just do the right thing. However,
2058 by explicitly setting the config value ``topgit.top-bases`` to either
2059 ``refs`` for the old location or ``heads`` for the new location the
2060 auto-detection can be bypassed. If no top-bases refs are present in
2061 the repository the default prior to TopGit release 0.20.0 is to use the
2062 old location but starting with TopGit release 0.20.0 the default is to
2063 use the new location.
2065 The ``tg migrate-bases`` command may be used to migrate top-bases refs
2066 from the old location to the new location (or, by using the
2067 undocumented ``--reverse`` option, vice versa).
2069 With few exceptions (``tg create -r`` and ``tg revert``), all top-bases
2070 refs (both local *and* remote refs) are expected to be stored in the
2071 same location (either new or old). A repository's current location for
2072 storing top-bases refs may be shown with the ``tg --top-bases`` command.
2080 TopGit stores all the topic branches in the regular ``refs/heads/``
2081 namespace (so we recommend distinguishing them with the ``t/`` prefix).
2082 Apart from that, TopGit also maintains a set of auxiliary refs in
2083 ``refs/top-*``. Currently, only ``refs/top-bases/`` is used, containing the
2084 current *base* of the given topic branch -- this is basically a merge of
2085 all the branches the topic branch depends on; it is updated during ``tg
2086 update`` and then merged to the topic branch, and it is the base of a
2087 patch generated from the topic branch by ``tg patch``.
2089 All the metadata is tracked within the source tree and history of the
2090 topic branch itself, in ``.top*`` files; these files are kept isolated
2091 within the topic branches during TopGit-controlled merges and are of
2092 course omitted during ``tg patch``. The state of these files in base
2093 commits is undefined; look at them only in the topic branches
2094 themselves. Currently, two files are defined:
2097 Contains the description of the topic branch in a
2098 mail-like format, plus the author information, whatever
2099 Cc headers you choose or the post-three-dashes message.
2100 When mailing out your patch, basically only a few extra
2101 mail headers are inserted and then the patch itself is
2102 appended. Thus, as your patches evolve, you can record
2103 nuances like whether the particular patch should have
2104 To-list / Cc-maintainer or vice-versa and similar
2105 nuances, if your project is into that. ``From`` is
2106 prefilled from your current ``GIT_AUTHOR_IDENT``; other
2107 headers can be prefilled from various optional
2108 ``topgit.*`` git config options.
2111 Contains the one-per-line list of branches this branch
2112 depends on, pre-seeded by ``tg create``. A (continuously
2113 updated) merge of these branches will be the *base* of
2116 IMPORTANT: DO NOT EDIT ``.topdeps`` MANUALLY!!! If you do so, you need to
2117 know exactly what you are doing, since this file must stay in sync with
2118 the Git history information, otherwise very bad things will happen.
2120 TopGit also automagically installs a bunch of custom commit-related
2121 hooks that will verify whether you are committing the ``.top*`` files in a
2122 sane state. It will add the hooks to separate files within the ``hooks/``
2123 subdirectory, and merely insert calls to them to the appropriate hooks
2124 and make them executable (but will make sure the original hook's code is
2125 not called if the hook was not executable beforehand).
2127 Another automagically installed piece is a ``.git/info/attributes``
2128 specifier for an ``ours`` merge strategy for the files ``.topmsg`` and
2129 ``.topdeps``, and the (intuitive) ``ours`` merge strategy definition in
2136 There are two remaining issues with accessing topic branches in remote
2139 (i) Referring to remote topic branches from your local repository
2140 (ii) Developing some of the remote topic branches locally
2142 There are two somewhat contradictory design considerations here:
2144 (a) Hacking on multiple independent TopGit remotes in a single
2146 (b) Having a self-contained topic system in local refs space
2148 To us, (a) does not appear to be very convincing, while (b) is quite
2149 desirable for ``git-log topic`` etc. working, and increased conceptual
2152 Thus, we choose to instantiate all the topic branches of given remote
2153 locally; this is performed by ``tg remote --populate``. ``tg update``
2154 will also check if a branch can be updated from its corresponding remote
2155 branch. The logic needs to be somewhat involved if we are to "do the
2156 right thing". First, we update the base, handling the remote branch as
2157 if it was the first dependency; thus, conflict resolutions made in the
2158 remote branch will be carried over to our local base automagically.
2159 Then, the base is merged into the remote branch and the result is merged
2160 to the local branch -- again, to carry over remote conflict resolutions.
2161 In the future, this order might be adjustable on a per-update basis, in
2162 case local changes happen to be diverging more than the remote ones.
2163 (See the details in `The Update Process`_ for more in depth coverage.)
2165 All commands by default refer to the remote that ``tg remote --populate``
2166 was called on the last time (stored in the ``topgit.remote`` git
2167 configuration variable). You can manually run any command with a
2168 different base remote by passing ``-r REMOTE`` *before* the subcommand
2169 name or passing ``-u`` *before* the subcommand to run without one.
2175 Running the TopGit test suite only requires POSIX compatibile utilities (just
2176 a POSIX compatibile ``make`` will do) AND a ``perl`` binary.
2178 It is *not* necessary to install TopGit in order to run the TopGit test suite.
2180 To run the TopGit test suite, simply execute this from the top-level of a
2181 TopGit checkout or expanded release tarball:
2187 Yup, that's it. But you're probably thinking, "Why have a whole section just
2188 to say 'run make test'?" Am I right?
2190 The simple ``make test`` command produces a lot of output and while it is
2191 summarized at the end there's a better way.
2193 Do you have the ``prove`` utility available? You need ``perl`` to run the
2194 tests and ``prove`` comes with ``perl`` so you almost cerainly do.
2196 Try running the tests like so:
2200 make DEFAULT_TEST_TARGET=prove test
2203 (For reference, the default value of ``DEFAULT_TEST_TARGET`` is ``test`` which
2204 can be used to override a setting that's been altered using the instructions
2205 shown later on below.)
2207 If that works (you can interrupt it with ``Ctrl-C``), try this next:
2211 make DEFAULT_TEST_TARGET=prove TESTLIB_PROVE_OPTS="-j 4 --timer" test
2213 If that one works (again, you can interrupt it with ``Ctrl-C``) that may end
2214 up being the keeper for running the tests.
2216 However, if you don't have ``prove`` for some reason even though you do have
2217 ``perl``, there's still an alternative for briefer output. Try this:
2221 make TESTLIB_TEST_OPTS=-q test
2223 Much of the normal testing output will be suppressed and there's still a
2224 summary at the end. If you're stuck with this version but your make supports
2225 parallel operation (the ``-j`` *<n>*) option, then you might try this:
2229 make -j 4 TESTLIB_TEST_OPTS=-q test
2231 If your make *does* support the parallel ``-j`` option but still seems to be
2232 only running one test at a time try it like this instead:
2236 make TESTLIB_MAKE_OPTS="-j 4" TESTLIB_TEST_OPTS=-q test
2238 The difference is that ``make -j 4`` relies on make to properly pass down the
2239 parallel job option all the way down to the sub-make that runs the individual
2240 tests when not using prove. Putting the options in ``TESTLIB_MAKE_OPTS``
2241 passes them directly to that (and only that) particular invocation of make.
2243 The final bit of advice for running the tests is that any of those ``make``
2244 variable settings can be enabled by default in a top-level ``config.mak`` file.
2246 For example, to make the ``prove -j 4 --timer`` (my personal favorite) the
2247 default when running the tests, add these lines (creating the file if it does
2248 not already exist) to the ``config.mak`` file located in the top-level of the
2249 TopGit checkout (or expanded release tarball):
2254 # comments are allowed (if preceded by '#')
2255 # so are blank lines
2257 DEFAULT_TEST_TARGET = prove
2258 TESTLIB_PROVE_OPTS = -j 4 --timer
2259 #TESTLIB_TEST_OPTS = --color # force colorized test output
2261 Now simply doing ``make test`` will use those options by default.
2263 There is copious documentation on the testing library and other options in
2264 the various ``README`` files located in the ``t`` subdirectory. The
2265 ``Makefile.mak`` file in the ``t`` subdirectory contains plenty of comments
2266 about possible makefile variable settings as well.
2273 A familiarity with the terms in the GLOSSARY_ is helpful for understanding the
2274 content of this sections. See also the IMPLEMENTATION_ section.
2279 When a branch is "updated" using the ``tg update`` command the following steps
2282 1) The branch and all of its dependencies (and theirs recursively)
2283 are checked to see which ones are *out-of-date*. See glossary_.
2285 2) Each of the branch's direct dependencies (i.e. they are listed in
2286 the branch's ``.topdeps`` file) which is out of date is updated
2287 before proceeding (yup, this is a recursive process).
2289 3) Each of the branch's direct dependencies (i.e. they are listed in
2290 the branch's ``.topdes`` file) that was updated in the previous
2291 step is now merged into the branch's corresponding base. If a
2292 remote is involved, and the branch's corresponding base does NOT
2293 contain the remote branch's corresponding base that remote base is
2294 also merged into the branch's base at this time as well (it will be
2295 the first item merged into the branch's base).
2297 4) If the branch has a corresponding remote branch and the branch
2298 does not already contain it, it's merged into the branch's base
2299 (which was possibly already updated in step (3) to contain the
2300 remote branch's base but not the remote branch itself) on a detached
2301 HEAD. Yup, this step can be a bit confusing and no, the updated
2302 base from step (3) has not yet been merged into the branch itself
2303 yet either. If there is no remote branch this step does not apply.
2304 Using a detached HEAD allows the remote branch to be merged into the
2305 contents of the base without actually perturbing the base's ref.
2307 5) If there is a remote branch present then use the result of step (4)
2308 otherwise use the branch's base and merge that into the branch
2311 That's it! Simple, right? ;)
2313 Unless the auto stash option has been disabled (see `no undo`_, `tg update`_
2314 and `tg tag`_), a copy of all the old refs values will be stashed away
2315 immediately after step (1) before starting step (2), but only if anything is
2316 actually found to be out-of-date.
2321 The ``tg update`` command regularly performs merges while executing an update
2322 operation. In order to speed things up, it attempts to do in-index merges
2323 where possible. It accomplishes this by using a separate, temporary index
2324 file and the ``git read-tree -m --aggressive`` command possibly assisted by
2325 the ``git merge-index`` and ``git merge-file`` commands. This combination may
2326 be repeated more than once to perform an octopus in-index merge. If this
2327 fails, the files are checked out and a normal ``git merge`` three-way merge is
2328 performed (possily multiple times). If the normal ``git merge`` fails then
2329 user intervention is required to resolve the merge conflict(s) and continue.
2331 Since the ``tg annihilate``, ``tg create`` and ``tg depend add`` commands may
2332 end up running the ``tg update`` machinery behind the scenes to complete their
2333 operation they may also result in any of these merge strategies being used.
2335 In addition to the normal Git merge strategies (if the in-index merging fails),
2336 there are four possible TopGit merge strategies that may be shown. Since they
2337 all involve use of the ``git read-tree -m --aggressive`` command they are all
2338 variations of a "trivial aggressive" merge. The "trivial" part because all of
2339 the merges done by ``git read-tree -m`` are described as "trivial" and the
2340 "aggressive" part because the ``--aggressive`` option is always used.
2342 1) "trivial aggressive"
2343 Only two heads were involved and all merging was completed by
2344 the ``git read-tree -m --aggressive`` command.
2346 2) "trivial aggressive automatic"
2347 Only two heads were involved but after the
2348 ``git read-tree -m --aggressive`` command completed there were
2349 still unresolved items and ``git merge-index`` had to be run
2350 (using the ``tg index-merge-one-file`` driver) which ultimately
2351 ran ``git merge-file`` at least once to perform a simple
2352 automatic three-way merge. Hence the "automatic" description
2353 and the "Auto-merging ..." output line(s).
2355 3) "trivial aggressive octopus"
2356 This is the same as a "trivial aggressive" merge except that
2357 more than two heads were involved and after merging the first
2358 two heads, the ``git read-tree -m --aggressive`` step was
2359 repeated again on the result for each additional head. All
2360 merging was completed via multiple
2361 ``git read-tree -m --aggressive`` commands only.
2362 This beast is relatively rare in the wild.
2364 4) "trivial aggressive automatic octopus"
2365 This is very similar to the "trivial aggressive octopus"
2366 except that at least one of the ``git read-tree -m --aggressive``
2367 commands left unresolved items that were handled the same way
2368 as the "trivial aggressive automatic" strategy. This species
2369 is commonly seen in the wild.
2376 Version-controlled file stored at the root level of each
2377 TopGit branch that contains the patch header for a TopGit
2378 branch. See also IMPLEMENTATION_;
2381 Version-controlled file stored at the root level of each
2382 TopGit branch that lists the branch's dependencies one per
2383 line omitting the leading ``refs/heads/`` part. See also
2387 Given two Git commit identifiers (e.g. hashes) C1 and C2,
2388 commit C1 "contains" commit C2 if either they are the same
2389 commit or C2 can be reached from C1 by following one or more
2390 parent links from C1 (perhaps via one or more intermediate
2391 commits along the way). In other words, if C1 contains C2
2392 then C2 is an ancestor of C1 or conversely C1 is a descendant
2393 of C2. Since a TopGit branch name is also the name of a Git
2394 branch (something located under the ``refs/heads`` Git
2395 namespace) and similarly for a TopGit base, they can both be
2396 resolved to a Git commit identifier and then participate in
2397 a branch containment test. An easy mnemonic for this is
2398 "children contain the genes of their parents."
2401 A Basic Regular Expression (BRE) pattern. These are older
2402 style regular expressions but have the advantage that all
2403 characters other than ``\``, ``.``, ``*`` and ``[``
2404 automatically match themselves without need for backslash
2405 quoting (well actually, ``^`` and ``$`` are special at the
2406 beginning and end respectively but otherwise match themselves).
2409 See branch containment.
2412 An Extended Regular Expression (ERE) pattern. These are newer
2413 style regular expressions where all the regular expression
2414 "operator" characters "operate" when NOT preceded by a
2415 backslash and are turned into normal characters with a ``\``.
2416 The backreference atom, however, may not work, but ``?``, ``+``
2417 and ``|`` "operators" do; unlike BREs.
2420 Excellent system for managing a history of changes to one
2421 or more possibly interrelated patches.
2424 A Git branch that has an associated TopGit base. Conceptually
2425 it represents a single patch that is the difference between
2426 the associated TopGit base and the TopGit branch. In other
2427 words ``git diff-tree <TopGit base> <TopGit branch>`` except
2428 that any ``.topdeps`` and/or ``.topmsg`` files are excluded
2429 from the result and the contents of the ``.topmsg`` file from
2430 the TopGit branch is prefixed to the result.
2433 A Git branch whose tree does NOT contain any `.topdeps` or
2434 `.topmsg` entries at the top-level of the tree. It *does*
2435 always have an associated "TopGit base" ref (otherwise it would
2436 not be a "TopGit" branch). See also `BARE BRANCHES`_.
2439 In TopGit context, "bare branch" almost always refers to a
2440 "TopGit bare branch" and should be understood to mean such even
2441 if the leading "TopGit" has been left off.
2444 A Git branch that records the base upon which a TopGit branch's
2445 single conceptual "patch" is built. The name of the Git branch
2446 is derived from the TopGit branch name by stripping off the
2447 leading ``refs/heads/`` and appending the correct prefix where
2448 all TopGit bases are stored (typically either
2449 ``refs/top-bases/`` or ``refs/heads/{top-bases}/`` -- the
2450 prefix for any given repository can be shown by using the
2451 ``tg --top-bases`` command and updated using the
2452 ``tg migrate-bases`` command).
2454 All of a TopGit branch's dependencies are merged into the
2455 corresponding TopGit base during a ``tg update`` of a branch.
2460 TopGit ``[PATCH]`` branch
2461 A TopGit branch whose subject starts with ``[PATCH]``. By
2462 convention these TopGit branches contain a single patch
2463 (equivalent to a single patch file) and have at least one
2464 dependency (i.e. their ``.topdeps`` files are never empty).
2466 TopGit ``[BASE]`` branch
2467 A TopGit branch whose subject starts with ``[BASE]``. By
2468 convention these TopGit branches do not actually contain
2469 any changes and their ``.topdeps`` files are empty. They
2470 are used to control a base dependency that another set of
2471 branches depends on.
2473 TopGit ``[STAGE]`` branch
2474 A TopGit branch whose subject starts with ``[STAGE]``. By
2475 convention these TopGit branches do not actually contain any
2476 changes of their own but do have one or (typically) more
2477 dependencies in their ``.topdeps`` file. These branches are
2478 used to bring together one or (typically) more independent
2479 TopGit ``[PATCH]`` branches into a single branch so that
2480 testing and/or evaluation can be performed on the result.
2483 When merging two (or more) heads that touch the same lines in
2484 the file but in different ways the result is a merge conflict
2485 that requires manual intervention. If a merge conflict occurs
2486 with more than two heads (an octopus merge) it's generally
2487 replaced by multiple three-way merges so that by the time a
2488 user sees a merge conflict needing manual resolution, there
2489 will be only two heads involved.
2492 A Git merge strategy (see the "MERGE STRATEGIES" section of
2493 ``git help merge``) or one of the TopGit `merge strategies`_
2494 used to merge two or more heads.
2496 TopGit merge strategy
2497 See the `Merge Strategies`_ section above for details but
2498 basically these are just in-index merges done using the
2499 ``git read-tree -m --aggressive`` command one or more times
2500 possibily assisted by the ``git merge-index`` and the
2501 ``git merge-file`` commands.
2504 In TopGit context the "next" branch refers to the branch that
2505 corresponds to the next (aka following) patch in an ordered
2506 (aka linearized) list of patches created by exporting the
2507 TopGit branches in patch application order.
2510 A merge involving more than two heads. Note that if there are
2511 less than three independent heads the resulting merge that
2512 started out as an octopus will end up not actually being an
2516 A TopGit branch is considered to be "out-of-date" when ANY of
2517 the following are true:
2519 a) The TopGit branch does NOT contain its
2522 b) The TopGit branch does NOT contain its
2523 corresponding remote branch (there may not be
2524 a remote branch in which case this does not apply)
2526 c) The TopGit branch's base does NOT contain its
2527 corresponding remote branch's base (there may not be
2528 a remote branch in which case this does not apply)
2530 d) Any of the TopGit branches listed in the branch's
2531 ``.topdeps`` file are NOT contained by the branch.
2532 (See "branch containment" above.)
2534 e) Any of the TopGit branches listed in the branch's
2535 ``.topdeps`` file are out-of-date.
2537 Note that if a remote branch is present and is NOT out-of-date
2538 then it will contain its own base and (c) is mostly redundant.
2541 In TopGit context the "previous" (or "prev") branch refers to
2542 the branch that corresponds to the previous (aka preceding)
2543 patch in an ordered (aka linearized) list of patches created by
2544 exporting the TopGit branches in patch application order.
2546 remote TopGit branch
2547 A Git branch with the same branch name as a TopGit branch
2548 but living under ``refs/remotes/<some remote>/`` instead
2549 of just ``refs/heads/``.
2552 The TopGit base branch corresponding to a remote TopGit branch,
2553 which lives under ``refs/remotes/`` somewhere (depending on
2554 what the output of ``tg --top-bases`` is for that remote).
2557 A three-way merge takes a common base and two heads (call them
2558 A and B) and creates a new file that is the common base plus
2559 all of the changes made between the common base and head A
2560 *AND* all of the changes made between the common base and
2561 head B. The technique used to accomplish this is called a
2568 The following references are useful to understand the development of
2569 topgit and its subcommands.
2572 http://public-inbox.org/git/36ca99e90904091034m4d4d31dct78acb333612e678@mail.gmail.com/T/#u
2575 THIRD-PARTY SOFTWARE
2576 --------------------
2578 The following software understands TopGit branches:
2580 * `magit <http://magit.github.io/>`_ -- a git mode for emacs
2582 IMPORTANT: Magit requires its topgit mode to be enabled first, as
2583 described in its documentation, in the "Activating extensions"
2584 subsection. If this is not done, it will not push TopGit branches
2585 correctly, so it's important to enable it even if you plan to mostly use
2586 TopGit from the command line.