d90230726489b4600a624e166f3c0c46bc65a102
[git.git] / Documentation / howto / maintain-git.txt
blobd90230726489b4600a624e166f3c0c46bc65a102
1 From: Junio C Hamano <gitster@pobox.com>
2 Date: Wed, 21 Nov 2007 16:32:55 -0800
3 Subject: Addendum to "MaintNotes"
4 Abstract: Imagine that git development is racing along as usual, when our friendly
5  neighborhood maintainer is struck down by a wayward bus. Out of the
6  hordes of suckers (loyal developers), you have been tricked (chosen) to
7  step up as the new maintainer. This howto will show you "how to" do it.
9 Activities
10 ----------
12 The maintainer's git time is spent on three activities.
14  - Communication (45%)
16    Mailing list discussions on general design, fielding user
17    questions, diagnosing bug reports; reviewing, commenting on,
18    suggesting alternatives to, and rejecting patches.
20  - Integration (50%)
22    Applying new patches from the contributors while spotting and
23    correcting minor mistakes, shuffling the integration and
24    testing branches, pushing the results out, cutting the
25    releases, and making announcements.
27  - Own development (5%)
29    Scratching my own itch and sending proposed patch series out.
31 The Policy
32 ----------
34 The policy on Integration is informally mentioned in "A Note
35 from the maintainer" message, which is periodically posted to
36 this mailing list after each feature release is made.
38  - Feature releases are numbered as vX.Y.Z and are meant to
39    contain bugfixes and enhancements in any area, including
40    functionality, performance and usability, without regression.
42  - One release cycle for a feature release is expected to last for
43    eight to ten weeks.
45  - Maintenance releases are numbered as vX.Y.Z.W and are meant
46    to contain only bugfixes for the corresponding vX.Y.Z feature
47    release and earlier maintenance releases vX.Y.Z.V (V < W).
49  - 'master' branch is used to prepare for the next feature
50    release. In other words, at some point, the tip of 'master'
51    branch is tagged with vX.Y.Z.
53  - 'maint' branch is used to prepare for the next maintenance
54    release.  After the feature release vX.Y.Z is made, the tip
55    of 'maint' branch is set to that release, and bugfixes will
56    accumulate on the branch, and at some point, the tip of the
57    branch is tagged with vX.Y.Z.1, vX.Y.Z.2, and so on.
59  - 'next' branch is used to publish changes (both enhancements
60    and fixes) that (1) have worthwhile goal, (2) are in a fairly
61    good shape suitable for everyday use, (3) but have not yet
62    demonstrated to be regression free.  New changes are tested
63    in 'next' before merged to 'master'.
65  - 'pu' branch is used to publish other proposed changes that do
66    not yet pass the criteria set for 'next'.
68  - The tips of 'master' and 'maint' branches will not be rewound to
69    allow people to build their own customization on top of them.
70    Early in a new development cycle, 'next' is rewound to the tip of
71    'master' once, but otherwise it will not be rewound until the end
72    of the cycle.
74  - Usually 'master' contains all of 'maint' and 'next' contains all
75    of 'master'.  'pu' contains all the topics merged to 'next', but
76    is rebuilt directly on 'master'.
78  - The tip of 'master' is meant to be more stable than any
79    tagged releases, and the users are encouraged to follow it.
81  - The 'next' branch is where new action takes place, and the
82    users are encouraged to test it so that regressions and bugs
83    are found before new topics are merged to 'master'.
86 A Typical Git Day
87 -----------------
89 A typical git day for the maintainer implements the above policy
90 by doing the following:
92  - Scan mailing list.  Respond with review comments, suggestions
93    etc.  Kibitz.  Collect potentially usable patches from the
94    mailing list.  Patches about a single topic go to one mailbox (I
95    read my mail in Gnus, and type \C-o to save/append messages in
96    files in mbox format).
98  - Write his own patches to address issues raised on the list but
99    nobody has stepped up solving.  Send it out just like other
100    contributors do, and pick them up just like patches from other
101    contributors (see above).
103  - Review the patches in the saved mailboxes.  Edit proposed log
104    message for typofixes and clarifications, and add Acks
105    collected from the list.  Edit patch to incorporate "Oops,
106    that should have been like this" fixes from the discussion.
108  - Classify the collected patches and handle 'master' and
109    'maint' updates:
111    - Obviously correct fixes that pertain to the tip of 'maint'
112      are directly applied to 'maint'.
114    - Obviously correct fixes that pertain to the tip of 'master'
115      are directly applied to 'master'.
117    - Other topics are not handled in this step.
119    This step is done with "git am".
121      $ git checkout master    ;# or "git checkout maint"
122      $ git am -sc3 mailbox
123      $ make test
125    In practice, almost no patch directly goes to 'master' or
126    'maint'.
128  - Review the last issue of "What's cooking" message, review the
129    topics ready for merging (topic->master and topic->maint).  Use
130    "Meta/cook -w" script (where Meta/ contains a checkout of the
131    'todo' branch) to aid this step.
133    And perform the merge.  Use "Meta/Reintegrate -e" script (see
134    later) to aid this step.
136      $ Meta/cook -w last-issue-of-whats-cooking.mbox
138      $ git checkout master    ;# or "git checkout maint"
139      $ echo ai/topic | Meta/Reintegrate -e ;# "git merge ai/topic"
140      $ git log -p ORIG_HEAD.. ;# final review
141      $ git diff ORIG_HEAD..   ;# final review
142      $ make test              ;# final review
144  - Handle the remaining patches:
146    - Anything unobvious that is applicable to 'master' (in other
147      words, does not depend on anything that is still in 'next'
148      and not in 'master') is applied to a new topic branch that
149      is forked from the tip of 'master'.  This includes both
150      enhancements and unobvious fixes to 'master'.  A topic
151      branch is named as ai/topic where "ai" is two-letter string
152      named after author's initial and "topic" is a descriptive name
153      of the topic (in other words, "what's the series is about").
155    - An unobvious fix meant for 'maint' is applied to a new
156      topic branch that is forked from the tip of 'maint'.  The
157      topic is named as ai/maint-topic.
159    - Changes that pertain to an existing topic are applied to
160      the branch, but:
162      - obviously correct ones are applied first;
164      - questionable ones are discarded or applied to near the tip;
166    - Replacement patches to an existing topic are accepted only
167      for commits not in 'next'.
169    The above except the "replacement" are all done with:
171      $ git checkout ai/topic ;# or "git checkout -b ai/topic master"
172      $ git am -sc3 mailbox
174    while patch replacement is often done by:
176      $ git format-patch ai/topic~$n..ai/topic ;# export existing
178    then replace some parts with the new patch, and reapplying:
180      $ git checkout ai/topic
181      $ git reset --hard ai/topic~$n
182      $ git am -sc3 -s 000*.txt
184    The full test suite is always run for 'maint' and 'master'
185    after patch application; for topic branches the tests are run
186    as time permits.
188  - Merge maint to master as needed:
190      $ git checkout master
191      $ git merge maint
192      $ make test
194  - Merge master to next as needed:
196      $ git checkout next
197      $ git merge master
198      $ make test
200  - Review the last issue of "What's cooking" again and see if topics
201    that are ready to be merged to 'next' are still in good shape
202    (e.g. has there any new issue identified on the list with the
203    series?)
205  - Prepare 'jch' branch, which is used to represent somewhere
206    between 'master' and 'pu' and often is slightly ahead of 'next'.
208      $ Meta/Reintegrate master..pu >Meta/redo-jch.sh
210    The result is a script that lists topics to be merged in order to
211    rebuild 'pu' as the input to Meta/Reintegrate script.  Remove
212    later topics that should not be in 'jch' yet.  Add a line that
213    consists of '###' before the name of the first topic in the output
214    that should be in 'jch' but not in 'next' yet.
216  - Now we are ready to start merging topics to 'next'.  For each
217    branch whose tip is not merged to 'next', one of three things can
218    happen:
220    - The commits are all next-worthy; merge the topic to next;
221    - The new parts are of mixed quality, but earlier ones are
222      next-worthy; merge the early parts to next;
223    - Nothing is next-worthy; do not do anything.
225    This step is aided with Meta/redo-jch.sh script created earlier.
226    If a topic that was already in 'next' gained a patch, the script
227    would list it as "ai/topic~1".  To include the new patch to the
228    updated 'next', drop the "~1" part; to keep it excluded, do not
229    touch the line.  If a topic that was not in 'next' should be
230    merged to 'next', add it at the end of the list.  Then:
232      $ git checkout -B jch master
233      $ Meta/redo-jch.sh -c1
235    to rebuild the 'jch' branch from scratch.  "-c1" tells the script
236    to stop merging at the '###' line you added earlier.
238    At this point, build-test the result.  It may reveal semantic
239    conflicts (e.g. a topic renamed a variable, another added a new
240    reference to the variable under its old name), in which case
241    prepare an appropriate merge-fix first (see appendix), and
242    rebuild the 'jch' branch from scratch, starting at the tip of
243    'master'.
245    Then do the same to 'next'
247      $ git checkout next
248      $ sh Meta/redo-jch.sh -c1 -e
250    The "-e" option allows the merge message that comes from the
251    history of the topic and the comments in the "What's cooking" to
252    be edited.  The resulting tree should match 'jch' as the same set
253    of topics are merged on 'master'; otherwise there is a mismerge.
254    Investigate why and do not proceed until the mismerge is found
255    and rectified.
257      $ git diff jch next
259    When all is well, clean up the redo-jch.sh script with
261      $ sh Meta/redo-jch.sh -u
263    This removes topics listed in the script that have already been
264    merged to 'master'.  This unfortunately loses the "###" marker,
265    so add it again to the appropriate place.
267  - Rebuild 'pu'.
269      $ Meta/Reintegrate master..pu >Meta/redo-pu.sh
271    Edit the result by adding new topics that are not still in 'pu'
272    in the script.  Then
274      $ git checkout -B pu jch
275      $ sh Meta/redo-pu.sh
277    When all is well, clean up the redo-pu.sh script with
279      $ sh Meta/redo-pu.sh -u
281    Double check by running
283      $ git branch --no-merged pu
285    to see there is no unexpected leftover topics.
287    At this point, build-test the result for semantic conflicts, and
288    if there are, prepare an appropriate merge-fix first (see
289    appendix), and rebuild the 'pu' branch from scratch, starting at
290    the tip of 'jch'.
292  - Update "What's cooking" message to review the updates to
293    existing topics, newly added topics and graduated topics.
295    This step is helped with Meta/cook script.
297      $ Meta/cook
299    This script inspects the history between master..pu, finds tips
300    of topic branches, compares what it found with the current
301    contents in Meta/whats-cooking.txt, and updates that file.
302    Topics not listed in the file but are found in master..pu are
303    added to the "New topics" section, topics listed in the file that
304    are no longer found in master..pu are moved to the "Graduated to
305    master" section, and topics whose commits changed their states
306    (e.g. used to be only in 'pu', now merged to 'next') are updated
307    with change markers "<<" and ">>".
309    Look for lines enclosed in "<<" and ">>"; they hold contents from
310    old file that are replaced by this integration round.  After
311    verifying them, remove the old part.  Review the description for
312    each topic and update its doneness and plan as needed.  To review
313    the updated plan, run
315      $ Meta/cook -w
317    which will pick up comments given to the topics, such as "Will
318    merge to 'next'", etc. (see Meta/cook script to learn what kind
319    of phrases are supported).
321  - Compile, test and install all four (five) integration branches;
322    Meta/Dothem script may aid this step.
324  - Format documentation if the 'master' branch was updated;
325    Meta/dodoc.sh script may aid this step.
327  - Push the integration branches out to public places; Meta/pushall
328    script may aid this step.
330 Observations
331 ------------
333 Some observations to be made.
335  * Each topic is tested individually, and also together with other
336    topics cooking first in 'pu', then in 'jch' and then in 'next'.
337    Until it matures, no part of it is merged to 'master'.
339  * A topic already in 'next' can get fixes while still in
340    'next'.  Such a topic will have many merges to 'next' (in
341    other words, "git log --first-parent next" will show many
342    "Merge branch 'ai/topic' to next" for the same topic.
344  * An unobvious fix for 'maint' is cooked in 'next' and then
345    merged to 'master' to make extra sure it is Ok and then
346    merged to 'maint'.
348  * Even when 'next' becomes empty (in other words, all topics
349    prove stable and are merged to 'master' and "git diff master
350    next" shows empty), it has tons of merge commits that will
351    never be in 'master'.
353  * In principle, "git log --first-parent master..next" should
354    show nothing but merges (in practice, there are fixup commits
355    and reverts that are not merges).
357  * Commits near the tip of a topic branch that are not in 'next'
358    are fair game to be discarded, replaced or rewritten.
359    Commits already merged to 'next' will not be.
361  * Being in the 'next' branch is not a guarantee for a topic to
362    be included in the next feature release.  Being in the
363    'master' branch typically is.
366 Appendix
367 --------
369 Preparing a "merge-fix"
370 ~~~~~~~~~~~~~~~~~~~~~~~
372 A merge of two topics may not textually conflict but still have
373 conflict at the semantic level. A classic example is for one topic
374 to rename an variable and all its uses, while another topic adds a
375 new use of the variable under its old name. When these two topics
376 are merged together, the reference to the variable newly added by
377 the latter topic will still use the old name in the result.
379 The Meta/Reintegrate script that is used by redo-jch and redo-pu
380 scripts implements a crude but usable way to work this issue around.
381 When the script merges branch $X, it checks if "refs/merge-fix/$X"
382 exists, and if so, the effect of it is squashed into the result of
383 the mechanical merge.  In other words,
385      $ echo $X | Meta/Reintegrate
387 is roughly equivalent to this sequence:
389      $ git merge --rerere-autoupdate $X
390      $ git commit
391      $ git cherry-pick -n refs/merge-fix/$X
392      $ git commit --amend
394 The goal of this "prepare a merge-fix" step is to come up with a
395 commit that can be squashed into a result of mechanical merge to
396 correct semantic conflicts.
398 After finding that the result of merging branch "ai/topic" to an
399 integration branch had such a semantic conflict, say pu~4, check the
400 problematic merge out on a detached HEAD, edit the working tree to
401 fix the semantic conflict, and make a separate commit to record the
402 fix-up:
404      $ git checkout pu~4
405      $ git show -s --pretty=%s ;# double check
406      Merge branch 'ai/topic' to pu
407      $ edit
408      $ git commit -m 'merge-fix/ai/topic' -a
410 Then make a reference "refs/merge-fix/ai/topic" to point at this
411 result:
413      $ git update-ref refs/merge-fix/ai/topic HEAD
415 Then double check the result by asking Meta/Reintegrate to redo the
416 merge:
418      $ git checkout pu~5 ;# the parent of the problem merge
419      $ echo ai/topic | Meta/Reintegrate
420      $ git diff pu~4
422 This time, because you prepared refs/merge-fix/ai/topic, the
423 resulting merge should have been tweaked to include the fix for the
424 semantic conflict.
426 Note that this assumes that the order in which conflicting branches
427 are merged does not change.  If the reason why merging ai/topic
428 branch needs this merge-fix is because another branch merged earlier
429 to the integration branch changed the underlying assumption ai/topic
430 branch made (e.g. ai/topic branch added a site to refer to a
431 variable, while the other branch renamed that variable and adjusted
432 existing use sites), and if you changed redo-jch (or redo-pu) script
433 to merge ai/topic branch before the other branch, then the above
434 merge-fix should not be applied while merging ai/topic, but should
435 instead be applied while merging the other branch.  You would need
436 to move the fix to apply to the other branch, perhaps like this:
438       $ mf=refs/merge-fix
439       $ git update-ref $mf/$the_other_branch $mf/ai/topic
440       $ git update-ref -d $mf/ai/topic