chiark / gitweb /
tg.sh: it's info/attributes not info/gitattributes
[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 maintaining
19 your patch queue?  The advantage of these tools is their simplicity;
20 they work with patch _series_ and defer to the reflog facility for
21 version control of patches (reordering of patches is not
22 version-controlled at all). But there are several disadvantages -
23 for one, these tools (especially StGIT) do not actually fit well
24 with plain Git at all: it is basically impossible to take advantage
25 of the index efectively when using StGIT. But more importantly,
26 these tools horribly fail in the face of distributed environment.
27
28 TopGit has been designed around three main tenets:
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 is also tracked by Git,
36 smoothly and non-obnoxiously. It is good to have a _single_ point
37 when the history is cleaned up, and that is at the point of inclusion
38 in the upstream project; locally, you can see how your patch has evolved
39 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) When using TopGit, your history can get a little hairy
67 over time, especially with all the merges rippling through. ;-)
68
69
70 SYNOPSIS
71 --------
72
73         ## Create and evolve a topic branch
74         $ tg create t/gitweb/pathinfo-action
75         tg: Automatically marking dependency on master
76         tg: Creating t/gitweb/pathinfo-action base from master...
77         $ ..hack..
78         $ git commit
79         $ ..fix a mistake..
80         $ git commit
81
82         ## Create another topic branch on top of the former one
83         $ tg create t/gitweb/nifty-links
84         tg: Automatically marking dependency on t/gitweb/pathinfo-action
85         tg: Creating t/gitweb/nifty-links base from t/gitweb/pathinfo-action...
86         $ ..hack..
87         $ git commit
88
89         ## Create another topic branch on top of master and submit
90         ## the resulting patch upstream
91         $ tg create t/revlist/author-fixed master
92         tg: Creating t/revlist/author-fixed base from master...
93         $ ..hack..
94         $ git commit
95         $ tg patch -m
96         tg: Sent t/revlist/author-fixed
97         From: pasky@suse.cz
98         To: git@vger.kernel.org
99         Cc: gitster@pobox.com
100         Subject: [PATCH] Fix broken revlist --author when --fixed-string
101
102         ## Create another topic branch depending on two others non-trivially
103         $ tg create t/whatever t/revlist/author-fixed t/gitweb/nifty-links
104         tg: Creating t/whatever base from t/revlist/author-fixed...
105         tg: Merging t/whatever base with t/gitweb/nifty-links...
106         Merge failed!
107         tg: Please commit merge resolution and call: tg create
108         tg: It is also safe to abort this operation using `git reset --hard`
109         tg: but please remember you are on the base branch now;
110         tg: you will want to switch to a different branch.
111         $ ..resolve..
112         $ git commit
113         $ tg create
114         tg: Resuming t/whatever setup...
115         $ ..hack..
116         $ git commit
117
118         ## Update a single topic branch and propagate the changes to
119         ## a different one
120         $ git checkout t/gitweb/nifty-links
121         $ ..hack..
122         $ git commit
123         $ git checkout t/whatever
124         $ tg info
125         Topic Branch: t/whatever (1 commit)
126         Subject: [PATCH] Whatever patch
127         Base: 3f47ebc1
128         Depends: t/revlist/author-fixed t/gitweb/nifty-links
129         Needs update from:
130                 t/gitweb/nifty-links (1 commit)
131         $ tg update
132         tg: Updating base with t/gitweb/nifty-links changes...
133         Merge failed!
134         tg: Please commit merge resolution and call `tg update` again.
135         tg: It is also safe to abort this operation using `git reset --hard`,
136         tg: but please remember you are on the base branch now;
137         tg: you will want to switch to a different branch.
138         $ ..resolve..
139         $ git commit
140         $ tg update
141         tg: Updating t/whatever against new base...
142         Merge failed!
143         tg: Please resolve the merge and commit. No need to do anything else.
144         tg: You can abort this operation using `git reset --hard` now
145         tg: and retry this merge later using `tg update`.
146         $ ..resolve..
147         $ git commit
148
149         ## Update a single topic branch and propagate the changes
150         ## further through the dependency chain
151         $ git checkout t/gitweb/pathinfo-action
152         $ ..hack..
153         $ git commit
154         $ git checkout t/whatever
155         $ tg info
156         Topic Branch: t/whatever (1/2 commits)
157         Subject: [PATCH] Whatever patch
158         Base: 0ab2c9b3
159         Depends: t/revlist/author-fixed t/gitweb/nifty-links
160         Needs update from:
161                 t/gitweb/pathinfo-action (<= t/gitweb/nifty-links) (1 commit)
162         $ tg update
163         tg: Recursing to t/gitweb/nifty-links...
164         [t/gitweb/nifty-links] tg: Updating base with t/gitweb/pathinfo-action changes...
165         Merge failed!
166         [t/gitweb/nifty-links] tg: Please commit merge resolution and call `tg update` again.
167         [t/gitweb/nifty-links] tg: It is also safe to abort this operation using `git reset --hard`,
168         [t/gitweb/nifty-links] tg: but please remember you are on the base branch now;
169         [t/gitweb/nifty-links] tg: you will want to switch to a different branch.
170         [t/gitweb/nifty-links] tg: You are in a subshell. If you abort the merge,
171         [t/gitweb/nifty-links] tg: use `exit` to abort the recursive update altogether.
172         [t/gitweb/nifty-links] $ ..resolve..
173         [t/gitweb/nifty-links] $ git commit
174         [t/gitweb/nifty-links] $ tg update
175         [t/gitweb/nifty-links] tg: Updating t/gitweb/nifty-links against new base...
176         Merge failed!
177         [t/gitweb/nifty-links] tg: Please resolve the merge and commit.
178         [t/gitweb/nifty-links] tg: You can abort this operation using `git reset --hard`.
179         [t/gitweb/nifty-links] tg: You are in a subshell. After you either commit or abort
180         [t/gitweb/nifty-links] tg: your merge, use `exit` to proceed with the recursive update.
181         [t/gitweb/nifty-links] $ ..resolve..
182         [t/gitweb/nifty-links] $ git commit
183         [t/gitweb/nifty-links] $ exit
184         tg: Updating base with t/gitweb/nifty-links changes...
185         tg: Updating t/whatever against new base...
186
187
188 USAGE
189 -----
190
191 The 'tg' tool of TopGit has several subcommands:
192
193 tg help
194 ~~~~~~~
195         Our sophisticated integrated help facility. Doesn't do
196         a whole lot for now.
197
198 tg create
199 ~~~~~~~~~
200         Create a new TopGit-controlled topic branch of a given name
201         (required argument) and switch to it. If no dependencies
202         are specified (by extra arguments passed after the first one),
203         the current branch is assumed to be the only dependency.
204
205         After `tg create`, you should insert the patch description
206         to the '.topmsg' file, which will already contain some
207         pre-filled bits. You can set topgit.to, topgit.cc and topgit.bcc
208         configuration variables in order to have `tg create`
209         add these headers with given default values to '.topmsg'.
210
211         The main task of `tg create` is to set up the topic branch
212         base from the dependencies. This may fail due to merge conflicts.
213         In that case, after you commit the conflicts resolution,
214         you should call `tg create` again (without any arguments);
215         it will detect that you are on a topic branch base ref and
216         resume the topic branch creation operation.
217
218 tg delete
219 ~~~~~~~~~
220         Remove a TopGit-controlled topic branch of given name
221         (required argument). Normally, this command will remove
222         only empty branch (base == head); use '-f' to remove
223         non-empty branch.
224
225         Currently, this command will _NOT_ remove the branch from
226         the dependency list in other branches. You need to take
227         care of this _manually_. This is even more complicated
228         in combination with '-f', in that case you need to manually
229         unmerge the removed branch's changes from the branches
230         depending on it.
231
232         TODO: '-a' to delete all empty branches, depfix, revert
233
234 tg info
235 ~~~~~~~
236         Show a summary information about the current or specified
237         topic branch.
238
239 tg patch
240 ~~~~~~~~
241         Generate a patch from the current or specified topic branch.
242         This means that the diff between the topic branch base and
243         head (latest commit) is shown, appended to the description
244         found in the .topmsg file.
245
246         The patch is by default simply dumped to stdout. In the future,
247         tg patch will be able to automatically send the patches by mail
248         or save them to files. (TODO)
249
250         TODO: tg patch -i to base at index instead of branch,
251                 -w for working tree
252
253 tg summary
254 ~~~~~~~~~~
255         Show overview of all TopGit-tracked topic branches and their
256         up-to-date status ('0' marks that it introduces no own changes,
257         'D' marks that it is out-of-date wrt. its dependencies,
258         '!' marks that it has missing dependencies (even recursively),
259         'B' marks that it is out-of-date wrt. its base).
260
261         TODO: Speed up by an order of magnitude
262         TODO: Graph view
263
264 tg update
265 ~~~~~~~~~
266         Update the current topic branch wrt. changes in the branches
267         it depends on. This is made in two phases - first,
268         changes within the dependencies are merged to the base,
269         then the base is merged into the topic branch. The output
270         will guide you in case of conflicts.
271
272         In case your dependencies are not up-to-date, tg update
273         will first recurse into them and update these.
274
275         TODO: tg update -a for updating all topic branches
276
277 TODO: Some infrastructure for sharing topic branches between
278         repositories easily
279 TODO: tg depend for adding/removing dependencies smoothly
280 TODO: tg collapse for creating a one-commit-per-patch tidied up
281         history (for pulling by upstream)
282
283
284 IMPLEMENTATION
285 --------------
286
287 TopGit stores all the topic branches in the regular refs/heads/
288 namespace, (we recommend to mark them with the 't/' prefix).
289 Except that, TopGit also maintains a set of auxiliary refs in
290 refs/top-*. Currently, only refs/top-bases/ is used, containing
291 the current _base_ of the given topic branch - this is basically
292 a merge of all the branches the topic branch depends on; it is
293 updated during `tg update` and then merged to the topic branch,
294 and it is the base of a patch generated from the topic branch by
295 `tg patch`.
296
297 All the metadata is tracked within the source tree and history
298 of the topic branch itself, in .top* files; these files are kept
299 isolated within the topic branches during TopGit-controlled merges
300 and are of course omitted during `tg patch`. The state of these
301 files in base commits is undefined; look at them only in the topic
302 branches themselves.  Currently, two files are defined:
303
304         .topmsg: Contains the description of the topic branch
305 in a mail-like format, plus the author information,
306 whatever Cc headers you choose or the post-three-dashes message.
307 When mailing out your patch, basically only few extra headers
308 mail headers are inserted and the patch itself is appended.
309 Thus, as your patches evolve, you can record nuances like whether
310 the paricular patch should have To-list/Cc-maintainer or vice
311 versa and similar nuances, if your project is into that.
312 From is prefilled from your current GIT_AUTHOR_IDENT, other headers
313 can be prefilled from various optional topgit.* config options.
314
315         .topdeps: Contains the one-per-line list of branches
316 your patch depends on, pre-seeded with `tg create`. (Continuously
317 updated) merge of these branches will be the "base" of your topic
318 branch.
319
320 TopGit also automagically installs a bunch of custom commit-related
321 hooks that will verify if you are committing the .top* files in sane
322 state. It will add the hooks to separate files within the hooks/
323 subdirectory and merely insert calls of them to the appropriate hooks
324 and make them executable (but make sure the original hooks code
325 is not called if the hook was not executable beforehand).
326
327 Another automagically installed piece is .git/info/attributes specifier
328 for an 'ours' merge strategy for the files .topmsg and .topdeps, and
329 the (intuitive) 'ours' merge strategy definition in .git/config.