topgit: version 0.19.13
[topgit/pro.git] / README
blobec9c0df4cfc1fba62f5de8d25aafb4bd5a0187f4
1 TopGit -- A Different Patch Queue Manager
2 =========================================
4 Overview
5 --------
7 TopGit manages one or more "patch queue"s (aka "patch set"s) using
8 Git.
10 Whereas a utility such as `quilt` maintains each individual patch
11 as a "diff" file on disk, TopGit (the `tg` command) maintains each
12 individual patch as _two_ branches in Git -- the patch's "branch"
13 and the patch's "base branch".  The patch itself is simply the
14 "diff" from the patch's "base branch" to the patch's "branch".
16 Whereas a utilty such as `quilt` maintains the list of active patch
17 "diff" files and the correct order to apply them in a file (the
18 `series` file), TopGit maintains this information in a `.topdeps`
19 file that is part of each patch's "branch".
21 TopGit maintains any desired "documentation" (aka the patch header)
22 in a `.topmsg` file that is also part of each patch's "branch" and
23 prepends it when generating a patch "diff".
26 Simplistic Quilt vs. TopGit Example
27 -----------------------------------
29 Consider the following files:
31     frabjous.tar.gz    # tarball of "frabjous" sources
32     0001-brillig.diff  # first patch to apply
33     0002-gimble.diff   # second patch to apply
35 With Quilt they might be used like so:
37     $ tar -xzf frabjous.tar.gz
38     $ cd frabjous
39     $ quilt import ../0001-brillig.diff && quilt push
40     $ quilt import ../0002-gimble.diff && quilt push
41     $ quilt applied
42     patches/0001-brillig.diff
43     patches/0002-gimble.diff
45 With TopGit they might be used like so:
47     $ tar -xzf frabjous.tar.gz
48     $ cd frabjous
49     $ git -c init.defaultBranch=master init && git add -A
50     $ git -c user.name=- -c user.email=- commit -qm frabjous
51     $ git checkout -b patches
52     $ git -c user.name=- -c user.email=- am ../0001-brillig.diff
53     $ git -c user.name=- -c user.email=- am ../0002-gimble.diff
54     $ git checkout master
55     $ git config topgit.top-bases heads # not the default...yet!
56     $ tg -c user.name=- -c user.email=- import ..patches
57     $ git branch
58       master
59       patches
60       t/brillig
61     * t/gimble
62       {top-bases}/t/brillig
63       {top-bases}/t/gimble
64     $ tg summary
65       t/brillig  [PATCH] brillig
66     > t/gimble   [PATCH] gimble
67     $ tg summary --rdeps --heads
68     t/gimble
69       t/brillig
70         master
72 Whereas with Quilt, the "0001-brillig.diff" patch is maintained as
73 the original patch file (in `patches/0001-brillig.diff`), with
74 TopGit, the "0001-brillig.diff" patch becomes _two_ Git branches,
75 `{top-bases}/t/brillig` which represents the sources before the
76 "0001-brillig.diff" patch has been applied and `t/brillig` which
77 represents the sources after the "0001-brillig.diff" patch has been
78 applied.
80 The original "0001-brillig.diff" patch can be re-generated with this
81 TopGit command:
83     $ tg patch t/brillig
85 And is roughly equivalent to the diff from the `{top-bases}/t/brillig`
86 branch to the `t/brillig` branch.  (It's the diff excluding the two
87 TopGit metadata files with the patch header prepended to the result.)
89 To work on the "brillig" patch, one simply does a checkout of the
90 `t/brillig` branch and makes and commits changes as normal using
91 regular Git commands.  After the changes have been made, the "gimble"
92 patch may need updating if any of the changes made to the "brillig"
93 patch modified the same files affected by the "gimble" patch.  That
94 can be accomplished with this command:
96     $ tg update --all
98 Finally, when a new set of ".diff" patch files needs to be generated,
99 these commands can be used:
101     $ git checkout t/gimble
102     $ tg export --quilt --strip --numbered patchdir
103     $ ls -1 patchdir
104     0001-brillig.diff
105     0002-gimble.diff
106     series
109 TopGit Advantages
110 -----------------
112 ### Patch Dependency Topology
114 Whereas the `series` file in Quilt is (obviously) limited to a
115 "linear" topology, TopGit's `.topdeps` file is not.
117 For example, consider that you have three patches:
119  1. add "feature A"
120  2. add "feature B"
121  3. add "feature C" that requires both feature A and feature B
123 If "feature A" and "feature B" are completely independent features,
124 then the order that the "feature A" and "feature B" patches are
125 applied does not matter as long as they are both applied before the
126 "feature C" patch.
128 TopGit can represent this by listing both the "feature A" and
129 "feature B" patches in the `.topdeps` file for the "feature C"
130 patch.
132 ### Patch Change History
134 Whereas with Quilt there is no history of changes (aka edits) to a
135 patch (unless explicit backups are made along the way), all changes
136 to a patch in TopGit are made via regular Git commands.
138 This means all the standard Git introspection commands (e.g. "log",
139 "diff", "bisect", "blame", etc.) are available to view the history
140 of an individual patch.
142 ### Patch Updating
144 With Quilt when the "upstream" sources are updated (or even an early
145 patch in the series is updated) in such a way as to cause a patch
146 to no longer apply cleanly, the patch must be fixed by hand.
148 With TopGit, the full Git merge machinery is used to merge the
149 "upstream" changes (or changes to an earlier patch) into the patches
150 in dependency topological order.  This can often avoid patch
151 conflicts.
153 In the case where a patch must be fixed by hand (yes, this still
154 can happen in TopGit), the Git `rerere` (reuse recorded resolution)
155 mechanism can be used to record the hand-crafted fix and later
156 automatically reuse that fix when needed.
158 ### Patch Identification
160 When there are a very large number of patches in a patch set, it
161 may be difficult to remember (especially if you're not the original
162 author) which individual patch of a "patch set" contains a particular
163 change.
165 After using the various Git introspection commands (e.g. "log",
166 "diff", "bisect", "blame", etc.) to locate a commit containing a
167 particular change, the TopGit `tg contains` command can be used to
168 identify the individual patch of a "patch set" that logically
169 contains that commit.
171 In other words, `tg contains` identifies which TopGit branch would
172 produce a patch "diff" file that makes the change introduced by the
173 given commit.
175 ### Collaboration
177 Because TopGit stores all information directly in Git, all of Git's
178 normal push/pull/remote functionality can be used to collaborate
179 on and/or share TopGit "patch set"s with others.  The `tg push`
180 command facilitates pushing all branches in one or more TopGit
181 "patch set"s at once.
184 TopGit Features
185 ---------------
187 ### Multiple Patch Sets
189 With Quilt it is possible to use different `series` files to combine
190 patch "diff" files into different arrangements (e.g. for different
191 machine architectures or development branches).
193 TopGit also allows multiple "patch set"s to exist at the same time
194 where a single "patch" may be used by more than one "patch set".
196 ### Patch Set History
198 As an alternative to maintaining two or more different versions of
199 the same patch (e.g. for different development branches) under
200 different names such as, for example, "patch1-oldstable", "patch1-stable"
201 and "patch1-unstable", it's possible to use a TopGit tag to record
202 the state of a "patch set" (via the `tg tag` command) and then later
203 go back to that state (via the `tg shell` command) to, for example,
204 produce an updated patch set for an older software version and
205 record that new state of the older software version "patch set"
206 without disturbing the current version of the "patch set".
208 The advantage of using this mechanism is that the branch names for
209 the individual patches always remain the same no matter how many
210 different versions are being kept.
212 ### Import and Export
214 TopGit can import and export "patch set"s to other formats.  This
215 includes the one "diff" file per patch and one "commit" per patch
216 formats.
218 This makes it easy to produce a set of "diff" patch files on demand
219 for external (e.g. non-Git) use for a "patch set".
222 TopGit Downsides
223 ----------------
225 Forget about using `git rebase` on a TopGit branch (either a patch's
226 "branch" or its "base branch").  With the exception being commits
227 that have not yet been merged into any other patch's "branch" or
228 "base branch".  (TopGit does, however, have its own `tgstash` that
229 provides a kind of "undo" after unfortunate update accidents.)
231 The merge history for a "patch set" can become rather complex as a
232 "patch set" is maintained over time (via the `tg update` command)
233 since nothing is ever thrown away.
235 TopGit has a learning curve and those unfamiliar with Git will need
236 to become comfortable with Git too.
239 Additional Information
240 ----------------------
242 [Full documentation][1] is available including a [fully formatted
243 version of the manual][2] (created from `README_DOCS.rst` which
244 incorporates a few [examples][3]) and the [TopGit changelog][4].
247 [1]: https://mackyle.github.io/topgit
248 [2]: https://mackyle.github.io/topgit/topgit.html
249 [3]: https://mackyle.github.io/topgit/topgit.html#synopsis
250 [4]: https://mackyle.github.io/topgit/changelog.html