chiark / gitweb /
tg-summary.sh: Add a 0 column denoting branch emptiness
[topgit.git] / README
1 TopGit - A different patch queue manager
2
3
4 DESCRIPTION
5 -----------
6
7 TopGit aims to make handling of large amount of interdependent topic
8 branches easier. In fact, it is designed especially for the case
9 when you maintain a queue of third-party patches on top of another
10 (perhaps Git-controlled) project and want to easily organize, maintain
11 and submit them - TopGit achieves that by keeping a separate topic
12 branch for each patch and providing few tools to maintain the branches.
13
14
15 RATIONALE
16 ---------
17
18 Why not use something like StGIT or Guilt or rebase -i for that?
19 The advantage of these tools is their simplicity; they work with patch
20 _series_ and defer to the reflog facility for version control of patches
21 (reordering of patches is not version-controlled at all). But there are
22 several disadvantages - for one, these tools (especially StGIT) do not
23 actually fit well with plain Git at all - it is basically impossible
24 to take advantage of index efectively when using StGIT. But more
25 importantly, these tools horribly fail in the face of distributed
26 environment.
27
28 TopGit has been designed around three main tenents:
29
30         (i) TopGit is as thin layer on top of Git as possible.
31 You still maintain your index and commit using Git, TopGit will
32 only automate few indispensable tasks.
33
34         (ii) TopGit is anxious about _keeping_ your history. It will
35 never rewrite your history and all metadata are also tracked by Git,
36 smoothly and non-obnoxiously. It is useful if there is a _single_
37 point when the history is cleaned up, and that is at the point of
38 inclusion in the upstream project; locally, you can see how your
39 patch has evolved and easily return to older versions.
40
41         (iii) TopGit is specifically designed to work in distributed
42 environment. You can have several instances of TopGit-aware repositories
43 and smoothly keep them all up-to-date and transfer your changes between
44 them.
45
46 As mentioned above, the main intended use-case for TopGit is tracking
47 third-party patches, where each patch is effectively a single topic
48 branch.  In order to flexibly accomodate even complex scenarios when
49 you track many patches where many are independent but some depend
50 on others, TopGit ignores the ancient Quilt heritage of patch series
51 and instead allows the patches to freely form graphs (DAGs just like
52 Git history itself, only "one lever higher"). For now, you have
53 to manually specify which patches does the current one depend
54 on, but TopGit might help you with that in the future in a darcs-like
55 fashion.
56
57 A glossary plug: The union (i.e. merge) of patch dependencies is
58 called a _base_ of the patch (topic branch).
59
60 Of course, TopGit is perhaps not the right tool for you:
61
62         (i) TopGit is not complicated, but StGIT et al. are somewhat
63 simpler, conceptually.  If you just want to make a linear purely-local
64 patch queue, deferring to StGIT instead might make more sense.
65
66         (ii) While keeping your history anxiously, in some extreme
67 cases the TopGit-generated history graph will perhaps be a little
68 too complex. ;-)
69
70
71 SYNOPSIS
72 --------
73
74         ## Create and evolve a topic branch
75         $ tg create t/gitweb/pathinfo-action
76         tg: Automatically marking dependency on master
77         tg: Creating t/gitweb/pathinfo-action base from master...
78         $ ..hack..
79         $ git commit
80         $ ..fix a mistake..
81         $ git commit
82
83         ## Create another topic branch on top of the former one
84         $ tg create t/gitweb/nifty-links
85         tg: Automatically marking dependency on t/gitweb/pathinfo-action
86         tg: Creating t/gitweb/nifty-links base from t/gitweb/pathinfo-action...
87         $ ..hack..
88         $ git commit
89
90         ## Create another topic branch on top of specified one and submit
91         ## the resulting patch upstream
92         $ tg create -d master t/revlist/author-fixed
93         tg: Creating t/revlist/author-fixed base from master...
94         $ ..hack..
95         $ git commit
96         $ tg patch -m
97         tg: Sent t/revlist/author-fixed
98         From: pasky@suse.cz
99         To: git@vger.kernel.org
100         Cc: gitster@pobox.com
101         Subject: [PATCH] Fix broken revlist --author when --fixed-string
102
103         ## Create another topic branch depending on two others non-trivially
104         $ tg create -d t/revlist/author-fixed,t/gitweb/nifty-links t/whatever
105         tg: Creating t/whatever base from t/revlist/author-fixed...
106         tg: Merging t/whatever base with t/gitweb/nifty-links...
107         Merge failed!
108         tg: Please commit merge resolution and call: tg create
109         tg: It is also safe to abort this operation using `git reset --hard`
110         tg: but please remember you are on the base branch now;
111         tg: you will want to switch to a different branch.
112         $ ..resolve..
113         $ git commit
114         tg: Resuming t/whatever setup...
115         $ tg create t/whatever
116         $ ..hack..
117         $ git commit
118
119         ## Update a single topic branch and propagate the changes to
120         ## a different one
121         $ git checkout t/gitweb/nifty-links
122         $ ..hack..
123         $ git commit
124         $ git checkout t/whatever
125         $ tg info
126         Topic Branch: t/whatever (1 commit)
127         Subject: [PATCH] Whatever patch
128         Base: 3f47ebc1
129         Depends: t/revlist/author-fixed t/gitweb/nifty-links
130         Needs update from:
131                 t/gitweb/nifty-links (1 commit)
132         $ tg update
133         tg: Updating base with t/gitweb/nifty-links changes...
134         Merge failed!
135         tg: Please commit merge resolution and call `tg update` again.
136         tg: It is also safe to abort this operation using `git reset --hard`,
137         tg: but please remember you are on the base branch now;
138         tg: you will want to switch to a different branch.
139         $ ..resolve..
140         $ git commit
141         $ tg update
142         tg: Updating t/whatever against new base...
143         Merge failed!
144         tg: Please resolve the merge and commit. No need to do anything else.
145         tg: You can abort this operation using `git reset --hard` now
146         tg: and retry this merge later using `tg update`.
147         $ ..resolve..
148         $ git commit
149
150         ## Update a single topic branch and propagate the changes
151         ## further through the dependency chain
152         $ git checkout t/gitweb/pathinfo-action
153         $ ..hack..
154         $ git commit
155         $ git checkout t/whatever
156         $ tg info
157         Topic Branch: t/whatever (1/2 commits)
158         Subject: [PATCH] Whatever patch
159         Base: 0ab2c9b3
160         Depends: t/revlist/author-fixed t/gitweb/nifty-links
161         Needs update from:
162                 t/gitweb/pathinfo-action (<= t/gitweb/nifty-links) (1 commit)
163         $ tg update
164         tg: Recursing to t/gitweb/nifty-links...
165         [t/gitweb/nifty-links] tg: Updating base with t/gitweb/pathinfo-action changes...
166         Merge failed!
167         [t/gitweb/nifty-links] tg: Please commit merge resolution and call `tg update` again.
168         [t/gitweb/nifty-links] tg: It is also safe to abort this operation using `git reset --hard`,
169         [t/gitweb/nifty-links] tg: but please remember you are on the base branch now;
170         [t/gitweb/nifty-links] tg: you will want to switch to a different branch.
171         [t/gitweb/nifty-links] tg: You are in a subshell. If you abort the merge,
172         [t/gitweb/nifty-links] tg: use `exit` to abort the recursive update altogether.
173         [t/gitweb/nifty-links] $ ..resolve..
174         [t/gitweb/nifty-links] $ git commit
175         [t/gitweb/nifty-links] $ tg update
176         [t/gitweb/nifty-links] tg: Updating t/gitweb/nifty-links against new base...
177         Merge failed!
178         [t/gitweb/nifty-links] tg: Please resolve the merge and commit.
179         [t/gitweb/nifty-links] tg: You can abort this operation using `git reset --hard`.
180         [t/gitweb/nifty-links] tg: You are in a subshell. After you either commit or abort
181         [t/gitweb/nifty-links] tg: your merge, use `exit` to proceed with the recursive update.
182         [t/gitweb/nifty-links] $ ..resolve..
183         [t/gitweb/nifty-links] $ git commit
184         [t/gitweb/nifty-links] $ exit
185         tg: Updating base with t/gitweb/nifty-links changes...
186         tg: Updating t/whatever against new base...
187
188
189 USAGE
190 -----
191
192 The 'tg' tool of TopGit has several subcommands:
193
194 tg help
195 ~~~~~~~
196         Our sophisticated integrated help facility. Doesn't do
197         a whole lot for now.
198
199 tg create
200 ~~~~~~~~~
201         Create a new TopGit-controlled topic branch of a given name
202         (required argument) and switch to it. If no dependencies
203         are specified using the '-d' paremeter, the current branch
204         is assumed to be the only dependency.
205
206         After `tg create`, you should insert the patch description
207         to the '.topmsg' file.
208
209         The main task of `tg create` is to set up the topic branch
210         base from the dependencies. This may fail due to merge conflicts.
211         In that case, after you commit the conflicts resolution,
212         you should call `tg create` again (without any arguments);
213         it will detect that you are on a topic branch base ref and
214         resume the topic branch creation operation.
215
216         '-d':
217                 Manually specified dependencies. A comma- or
218                 space-separated list of branch names.
219
220 tg delete
221 ~~~~~~~~~
222         Remove a TopGit-controlled topic branch of given name
223         (required argument). Normally, this command will remove
224         only empty branch (base == head); use '-f' to remove
225         non-empty branch.
226
227         Currently, this command will _NOT_ remove the branch from
228         the dependency list in other branches. You need to take
229         care of this _manually_. This is even more complicated
230         in combination with '-f', in that case you need to manually
231         unmerge the removed branch's changes from the branches
232         depending on it.
233
234         TODO: '-a' to delete all empty branches, depfix, revert
235
236 tg info
237 ~~~~~~~
238         Show a summary information about the current or specified
239         topic branch.
240
241 tg patch
242 ~~~~~~~~
243         Generate a patch from the current or specified topic branch.
244         This means that the diff between the topic branch base and
245         head (latest commit) is shown, appended to the description
246         found in the .topmsg file.
247
248         The patch is by default simply dumped to stdout. In the future,
249         tg patch will be able to automatically send the patches by mail
250         or save them to files.
251
252         TODO: tg patch -i to base at index instead of branch,
253                 -w for working tree
254
255 tg summary
256 ~~~~~~~~~~
257         Show overview of all TopGit-tracked topic branches and their
258         up-to-date status ('0' marks that it introduces no own changes,
259         'D' marks that it is out-of-date wrt. its dependencies,
260         'B' marks that it is out-of-date wrt. its base).
261
262 tg update
263 ~~~~~~~~~
264         Update the current topic branch wrt. changes in the branches
265         it depends on. This is made in two phases - first,
266         changes within the dependencies are merged to the base,
267         then the base is merged into the topic branch. The output
268         will guide you in case of conflicts.
269
270         In case your dependencies are not up-to-date, tg update
271         will first recurse into them and update these.
272
273         TODO: tg update -a for updating all topic branches
274
275 TODO: Some infrastructure for sharing topic branches between
276         repositories easily
277
278
279 IMPLEMENTATION
280 --------------
281
282 TopGit stores all the topic branches in the regular refs/heads/
283 namespace, (we recommend to mark them with the 't/' prefix).
284 Except that, TopGit also maintains a set of auxiliary refs in
285 refs/top-*. Currently, only refs/top-bases/ is used, containing
286 the current _base_ of the given topic branch - this is basically
287 a merge of all the branches the topic branch depends on; it is
288 updated during `tg update` and then merged to the topic branch,
289 and it is the base of a patch generated from the topic branch by
290 `tg patch`.
291
292 All the metadata is tracked within the source tree and history
293 of the topic branch itself, in .top* files; these files are kept
294 isolated within the topic branches during TopGit-controlled merges
295 and are of course omitted during `tg patch`. The state of these
296 files in base commits is undefined; look at them only in the topic
297 branches themselves.  Currently, two files are defined:
298
299         .topmsg: Contains the description of the topic branch
300 in a mail-like format, plus the author information,
301 whatever Cc headers you choose or the post-three-dashes message.
302 When mailing out your patch, basically only few extra headers
303 mail headers are inserted and the patch itself is appended.
304 Thus, as your patches evolve, you can record nuances like whether
305 the paricular patch should have To-list/Cc-maintainer or vice
306 versa and similar nuances, if your project is into that.
307
308         .topdeps: Contains the one-per-line list of branches
309 your patch depends on, pre-seeded with `tg create`. (Continuously
310 updated) merge of these branches will be the "base" of your topic
311 branch.
312
313 TopGit also automagically installs a bunch of custom commit-related
314 hooks that will verify if you are committing the .top* files in sane
315 state. It will add the hooks to separate files within the hooks/
316 subdirectory and merely insert calls of them to the appropriate hooks
317 and make them executable (but make sure the original hooks code
318 is not called if the hook was not executable beforehand).
319
320 Another automagically installed piece is .git/info/attributes specifier
321 for an 'ours' merge strategy for the files .topmsg and .topdeps, and
322 the (intuitive) 'ours' merge strategy definition in .git/config.