0525c8ce8bb5ca990b669c3771b8c01410a80cf7
[zfs.git] / GIT
1 =========================== WHY USE GIT+TOPGIT? ==========================
2
3 Three major concerns were on our mind when setting up this project.
4
5   o First we needed to structure the project in such a way that it would be
6     easy to rebase all of our changes on the latest official ZFS release
7     from Sun.  We absolutely need to be able to benefit from the upstream
8     improvements and not get locked in to an old version of the code base.
9
10   o Secondly, we wanted to be able to easily manage our changes in terms
11     of a patch stack or graph.  This allows us to easily isolate specific
12     changes and push them upstream for inclusion.  It also allows us to 
13     easily update or drop specific changes based on what occurs upstream.
14
15   o Thirdly we needed our DVCS to be integrated with the management of this
16     patch stack or graph.  We have tried other methods in the past such as
17     SVN+Quilt but have found managing the patch stack becomes cumbersome.
18     By using Git+TopGit to more tightly integrate our patches in to the repo
19     we expect several benefits.  One of the most important will be the
20     ability to easily work on the patch's with a distributed development
21     team, additionally the repo can track patch history, and we can utilize
22     Git to merge patches and resolve conflicts.
23
24 TopGit is designed to specifically address these concerns by providing 
25 tools to simplify the handling of large numbers of interdependent topic 
26 branches.  When using a TopGit aware repo every topic branch represents
27 a 'patch' and that branch references its dependent branches.  The union
28 of all these branches is your final source base.
29
30 ========================= SETTING UP GIT+TOPGIT ==========================
31
32 First off you need to install a Git package on your system.  For my
33 purposes I have been working on a RHEL5 system with git version 1.5.4.5
34 installed and it has been working well.  You will also need to go get
35 the latest version of TopGit which likely is not packaged nicely so you
36 will need to build it from source.  You can use Git to clone TopGit
37 from the official site here and your all set:
38
39         > git clone http://repo.or.cz/w/topgit.git
40         > make
41         > make install    # Default installs to $(HOME)
42
43 ========================== TOPGIT AND ZFS ================================
44
45 One you have Git and TopGit installed you will want to clone a copy of
46 the Linux ZFS repo.  While this project does not yet have a public home
47 it hopefully will some day.  In the meanwhile if you have VPN access to
48 LLNL you can clone the latest official repo here.  Cloning a TopGit
49 controlled repo is very similar to cloning a normal Git repo, but you
50 need to remember to use 'tg remote' to populate all topic branches.
51
52         > git clone http://eris.llnl.gov/git/zfs.git zfs
53         > cd zfs
54         > tg remote --populate origin
55
56 Now that you have the Linux ZFS repo the first thing you will probably 
57 want to do is have a look at all the topic branches.  TopGit provides
58 a summary command which shows all the branches and a brief summary for
59 each branch obtained from the .topmsg files.
60
61         > tg summary
62  0      feature-branch                  [PATCH] feature-branch
63         feature-commit-cb               [PATCH] feature commit cb
64         feature-zap-cursor-to-key       [PATCH] feature zap cursor to key
65         ...
66
67 By convention all TopGit branches are usually prefixed with 't/', however
68 I have chosen not to do this for simplicity.  A different convention I have
69 adopted is to tag the top most TopGit branch as 'top' for easy reference.
70 This provides a consistent label to be used when you need to reference the
71 branch which contains the union of all topic branches.
72
73 One thing you may also notice about the 'tg summary' command is it does
74 not show the branches in dependent order.  This is done because TopGit allows
75 each branch to express multiple dependencies as a DAC.  Initially this seemed
76 like an added complication which I planned to avoid by just implementing a
77 stack using the graph.   However, this ended up being problematic because
78 with a stack when a change was made to a branch near the base, it was a
79 very expensive operation to merge the change up to the top of the stack.
80 By defining the dependencies as a graph it is possible to keep the depth
81 much shallower thus minimizing the merging.  It has also proved insightful
82 as to each patches actual dependencies.
83
84 To see the dependencies you will need to use the --graphviz option and pipe
85 the result to dot for display.  The following command works fairly well for
86 me.  Longer term it would be nice to update this option to use a preferred
87 config options stored in the repo.
88
89         > tg summary --graphviz | dot -Txlib -Nfontsize=8
90
91 ========================= UPDATING A TOPIC BRANCH ========================
92
93 Updating a topic branch in TopGit is a pretty straight forward but there
94 are a few rules you need to be aware of.  The basic process involves 
95 checking out the relevant topic branch where the changes need to be made,
96 making the changes, committing the changes to the branch and then merging
97 those changes in to dependent branches.  TopGit provides some tools to make
98 this pretty easy, although it may be a little sluggish.  Here is an example:
99
100         > git checkout t/feature-commit-cb  # Checkout the proper branch
101         > ...update branch...               # Update the branch
102         > git commit -a                     # Commit your changes
103         > git checkout t/LAST               # Checkout the LAST branch
104         > tg update                         # Recursively merge in new branch
105
106 Assuming you change does not introduce any conflicts your done.  All branches
107 were dependent on your change will have had the changed merged in.  If your
108 change introduced a conflict you will need to resolve the conflict and then
109 continue on with the update.
110
111 ========================== ADDING A TOPIC BRANCH =========================
112
113 Adding a topic branch in TopGit is a little more complicated.  When adding
114 a new branch to the end of the patch graph things are pretty easy and TopGit
115 does all the work.  However, I expect out common case to be adding patches
116 to the middle of the graph.  TopGit will allow you to do this but you must
117 be careful to manually update the dependency information in the .topdeps
118 file.
119
120         > git co t/existing-topic-branch    # Checkout the branch to add after
121         > tg create t/new-topic-branch      # Create a new topic branch
122         > ...update .topmsg...              # Update the branch message
123         > ...create patch...                # Update with your changes
124         > git commit -a                     # Commit your changes
125         > git co t/dependent-topic-branch   # Checkout dependent branch
126         > ...update .topdeps...             # Manually update dependencies
127         > git commit -a                     # Commit your changes
128         > tg update                         # TopGit update
129         > git checkout t/LAST               # Checkout the LAST branch
130         > tg update                         # Recursively merge in new branch
131
132 ========================= REMOVING A TOPIC BRANCH ========================
133
134 Removing a topic branch in TopGit is also currently not very easy.  To remove
135 a dependent branch the basic process is to commit a patch which reverts all
136 changes on the branch.  Then that reversion must be merged in to all dependent
137 branches, the dependencies manually updated and finally the branch removed.
138 If the branch is not empty you will not be able to remove it.
139
140         > git co t/del-topic-branch         # Checkout the branch to delete
141         > tg patch | patch -R -p1           # Revert all branch changes
142         > git commit -a                     # Commit your changes
143         > git checkout t/LAST               # Checkout the LAST branch
144         > tg update                         # Recursively merge revert
145         > git co t/dependent-topic-branch   # Checkout dependent branch
146         > ...update .topdeps...             # Manually update dependencies
147         > git commit -a                     # Commit your changes
148         > tg delete t/del-topic-branch      # Delete empty topic branch
149
150 ============================ TOPGIT TODO =================================
151
152 TopGit is still a young package which seems to be under active development
153 by its author.  It provides the minimum set of commands needed but there
154 are clearly areas which simply have not yet been implemented.  My short
155 list of features includes:
156
157   o 'tg summary --deps', option to display a text version of the topic
158     branch dependency DAC.
159
160   o 'tg depend list', list all topic branch dependencies.
161
162   o 'tg depend delete', cleanly remove a topic branch dependency.
163
164   o 'tg create', cleanly insert a topic branch in the middle
165     of the graph and properly take care updating all dependencies.
166
167   o 'tg delete', cleanly delete a topic branch in the middle
168     of the graph and properly take care updating all dependencies.