Autogenerated HTML docs for v2.46.0-164-g477ce
[git-htmldocs.git] / howto / maintain-git.txt
blob41f54050f84e0e8d9da8f1f4c5641b85354ec5ae
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.
8 Content-type: text/asciidoc
10 How to maintain Git
11 ===================
13 Activities
14 ----------
16 The maintainer's Git time is spent on three activities.
18  - Communication (45%)
20    Mailing list discussions on general design, fielding user
21    questions, diagnosing bug reports; reviewing, commenting on,
22    suggesting alternatives to, and rejecting patches.
24  - Integration (50%)
26    Applying new patches from the contributors while spotting and
27    correcting minor mistakes, shuffling the integration and
28    testing branches, pushing the results out, cutting the
29    releases, and making announcements.
31  - Own development (5%)
33    Scratching my own itch and sending proposed patch series out.
35 The Policy
36 ----------
38 The policy on Integration is informally mentioned in "A Note
39 from the maintainer" message, which is periodically posted to
40 the mailing list after each feature release is made:
42  - Feature releases are numbered as vX.Y.0 and are meant to
43    contain bugfixes and enhancements in any area, including
44    functionality, performance and usability, without regression.
46  - Maintenance releases are numbered as vX.Y.Z (0 < Z) and are meant
47    to contain only bugfixes for the corresponding vX.Y.0 feature
48    release and earlier maintenance releases vX.Y.W (W < Z).
50  - The 'master' branch is used to prepare for the next feature
51    release. In other words, at some point, the tip of 'master'
52    branch is tagged as vX.(Y+1).0, when vX.Y.0 is the latest
53    feature release.
55  - 'maint' branch is used to prepare for the next maintenance
56    release.  After the feature release vX.Y.0 is made, the tip
57    of 'maint' branch is set to that release, and bugfixes will
58    accumulate on the branch, and at some point, the tip of the
59    branch is tagged with vX.Y.1, vX.Y.2, and so on.
61  - 'next' branch is used to publish changes (both enhancements
62    and fixes) that (1) have worthwhile goal, (2) are in a fairly
63    good shape suitable for everyday use, (3) but have not yet
64    demonstrated to be regression free.  Reviews from contributors on
65    the mailing list help to make the determination.  After a topic
66    is merged to 'next', it is tested for at least 7 calendar days
67    before getting merged to 'master'.
69  - 'seen' branch is used to publish other proposed changes that do
70    not yet pass the criteria set for 'next' (see above).
72  - The tips of 'master' and 'maint' branches will not be rewound to
73    allow people to build their own customization on top of them.
74    Early in a new development cycle, 'next' is rewound to the tip of
75    'master' once, but otherwise it will not be rewound until the end
76    of the cycle.
78  - Usually 'master' contains all of 'maint' and 'next' contains all
79    of 'master'.  'seen' contains all the topics merged to 'next', but
80    is rebuilt directly on 'master'.
82  - The tip of 'master' is meant to be more stable than any
83    tagged releases, and the users are encouraged to follow it.
85  - The 'next' branch is where new action takes place, and the
86    users are encouraged to test it so that regressions and bugs
87    are found before new topics are merged to 'master'.
89  - When a problem is found in a topic in 'next', the topic is marked
90    not to be merged to 'master'.  Follow-up patches are discussed on
91    the mailing list and applied to the topic after being reviewed and
92    then the topic is merged (again) to 'next'.  After going through
93    the usual testing in 'next', the entire (fixed) topic is merged
94    to 'master'.
96  - One release cycle for a feature release is expected to last for
97    eight to ten weeks.  A few "release candidate" releases are
98    expected to be tagged about a week apart before the final
99    release, and a "preview" release is tagged about a week before
100    the first release candidate gets tagged.
102  - After the preview release is tagged, topics that were well
103    reviewed may be merged to 'master' before spending the usual 7
104    calendar days in 'next', with the expectation that any bugs in
105    them can be caught and fixed in the release candidates before
106    the final release.
108  - After the first release candidate is tagged, the contributors are
109    strongly encouraged to focus on finding and fixing new regressions
110    introduced during the cycle, over addressing old bugs and any new
111    features.  Topics stop getting merged down from 'next' to 'master',
112    and new topics stop getting merged to 'next'. Unless they are fixes
113    to new regressions in the cycle, that is.
115  - Soon after a feature release is made, the tip of 'maint' gets
116    fast-forwarded to point at the release.  Topics that have been
117    kept in 'next' are merged down to 'master' and a new development
118    cycle starts.
121 Note that before v1.9.0 release, the version numbers used to be
122 structured slightly differently.  vX.Y.Z were feature releases while
123 vX.Y.Z.W were maintenance releases for vX.Y.Z.
126 A Typical Git Day
127 -----------------
129 A typical Git day for the maintainer implements the above policy
130 by doing the following:
132  - Scan mailing list.  Respond with review comments, suggestions
133    etc.  Kibitz.  Collect potentially usable patches from the
134    mailing list.  Patches about a single topic go to one mailbox (I
135    read my mail in Gnus, and type \C-o to save/append messages in
136    files in mbox format).
138  - Write his own patches to address issues raised on the list but
139    nobody has stepped up to solve.  Send it out just like other
140    contributors do, and pick them up just like patches from other
141    contributors (see above).
143  - Review the patches in the saved mailboxes.  Edit proposed log
144    message for typofixes and clarifications, and add Acks
145    collected from the list.  Edit patch to incorporate "Oops,
146    that should have been like this" fixes from the discussion.
148  - Classify the collected patches and handle 'master' and
149    'maint' updates:
151    - Obviously correct fixes that pertain to the tip of 'maint'
152      are directly applied to 'maint'.
154    - Obviously correct fixes that pertain to the tip of 'master'
155      are directly applied to 'master'.
157    - Other topics are not handled in this step.
159    This step is done with "git am".
161      $ git checkout master    ;# or "git checkout maint"
162      $ git am -sc3 mailbox
163      $ make test
165    In practice, almost no patch directly goes to 'master' or
166    'maint'.
168  - Review the last issue of "What's cooking" message, review the
169    topics ready for merging (topic->master and topic->maint).  Use
170    "Meta/cook -w" script (where Meta/ contains a checkout of the
171    'todo' branch) to aid this step.
173    And perform the merge.  Use "Meta/Reintegrate -e" script (see
174    later) to aid this step.
176      $ Meta/cook -w last-issue-of-whats-cooking.mbox
178      $ git checkout master    ;# or "git checkout maint"
179      $ echo ai/topic | Meta/Reintegrate -e ;# "git merge ai/topic"
180      $ git log -p ORIG_HEAD.. ;# final review
181      $ git diff ORIG_HEAD..   ;# final review
182      $ make test              ;# final review
184  - Handle the remaining patches:
186    - Anything unobvious that is applicable to 'master' (in other
187      words, does not depend on anything that is still in 'next'
188      and not in 'master') is applied to a new topic branch that
189      is forked from the tip of 'master' (or the last feature release,
190      which is a bit older than 'master').  This includes both
191      enhancements and unobvious fixes to 'master'.  A topic
192      branch is named as ai/topic where "ai" is two-letter string
193      named after author's initial and "topic" is a descriptive name
194      of the topic (in other words, "what's the series is about").
196    - An unobvious fix meant for 'maint' is applied to a new
197      topic branch that is forked from the tip of 'maint' (or the
198      oldest and still relevant maintenance branch).  The
199      topic may be named as ai/maint-topic.
201    - Changes that pertain to an existing topic are applied to
202      the branch, but:
204      - obviously correct ones are applied first;
206      - questionable ones are discarded or applied to near the tip;
208    - Replacement patches to an existing topic are accepted only
209      for commits not in 'next'.
211    The initial round is done with:
213      $ git checkout ai/topic ;# or "git checkout -b ai/topic master"
214      $ git am -sc3 --whitespace=warn mailbox
216    and replacing an existing topic with subsequent round is done with:
218      $ git checkout master...ai/topic ;# try to reapply to the same base
219      $ git am -sc3 --whitespace=warn mailbox
221    to prepare the new round on a detached HEAD, and then
223      $ git range-diff @{-1}...
224      $ git diff @{-1}
226    to double check what changed since the last round, and finally
228      $ git checkout -B @{-1}
230    to conclude (the last step is why a topic already in 'next' is
231    not replaced but updated incrementally).
233    Whether it is the initial round or a subsequent round, the topic
234    may not build even in isolation, or may break the build when
235    merged to integration branches due to bugs.  There may already
236    be obvious and trivial improvements suggested on the list.  The
237    maintainer often adds an extra commit, with "SQUASH???" in its
238    title, to fix things up, before publishing the integration
239    branches to make it usable by other developers for testing.
240    These changes are what the maintainer is not 100% committed to
241    (trivial typofixes etc. are often squashed directly into the
242    patches that need fixing, without being applied as a separate
243    "SQUASH???" commit), so that they can be removed easily as needed.
244    The expectation is that the original author will make corrections
245    in a reroll.
247  - By now, new topic branches are created and existing topic
248    branches are updated.  The integration branches 'next', 'jch',
249    and 'seen' need to be updated to contain them.
251  - If there are topics that have been merged to 'master' and should
252    be merged to 'maint', merge them to 'maint', and update the
253    release notes to the next maintenance release.
255  - Review the latest issue of "What's cooking" again.  Are topics
256    that have been sufficiently long in 'next' ready to be merged to
257    'master'?  Are topics we saw earlier and are in 'seen' now got
258    positive reviews and are ready to be merged to 'next'?
260  - If there are topics that have been cooking in 'next' long enough
261    and should be merged to 'master', merge them to 'master', and
262    update the release notes to the next feature release.
264  - If there were patches directly made on 'maint', merge 'maint' to
265    'master'; make sure that the result is what you want.
267      $ git checkout master
268      $ git merge -m "Sync with 'maint'" --no-log maint
269      $ git log -p --first-parent ORIG_HEAD..
270      $ make test
272  - Prepare to update the 'jch' branch, which is used to represent
273    somewhere between 'master' and 'seen' and often is slightly ahead
274    of 'next', and the 'seen' branch, which is used to hold the rest.
276      $ Meta/Reintegrate master..jch >Meta/redo-jch.sh
278    The result is a script that lists topics to be merged in order to
279    rebuild the current 'jch'.  Do the same for 'seen'.
281  - Review the Meta/redo-jch.sh and Meta/redo-seen.sh scripts.  The
282    former should have a line '### match next'---the idea is that
283    merging the topics listed before the line on top of 'master'
284    should result in a tree identical to that of 'next'.
286  - As newly created topics are usually merged near the tip of
287    'seen', add them to the end of the Meta/redo-seen.sh script.
288    Among the topics that were in 'seen', there may be ones that
289    are not quite ready for 'next' but are getting there.  Move
290    them from Meta/redo-seen.sh to the end of Meta/redo-jch.sh.
291    The expectation is that you'd use 'jch' as your daily driver
292    as the first guinea pig, so you should choose carefully.
294  - Now we are ready to start rebuilding 'jch' and merging topics to
295    'next'.  For each branch whose tip is not merged to 'next', one
296    of three things can happen:
298    - The commits are all next-worthy; merge the topic to next;
299    - The new parts are of mixed quality, but earlier ones are
300      next-worthy; merge the early parts to next;
301    - Nothing is next-worthy; do not do anything.
303    This step is aided with Meta/redo-jch.sh script created earlier.
304    If a topic that was already in 'next' gained a patch, the script
305    would list it as "ai/topic~1".  To include the new patch to the
306    updated 'next', drop the "~1" part; to keep it excluded, do not
307    touch the line.
309    If a topic that was not in 'next' should be merged to 'next', add
310    it before the '### match next' line.  Then:
312      $ git checkout --detach master
313      $ sh Meta/redo-jch.sh -c1
315    to rebuild the 'jch' branch from scratch.  "-c1" tells the script
316    to stop merging at the first line that begins with '###'
317    (i.e. the "### match next" line you added earlier).
319    At this point, build-test the result.  It may reveal semantic
320    conflicts (e.g. a topic renamed a variable, another added a new
321    reference to the variable under its old name), in which case
322    prepare an appropriate merge-fix first (see appendix), and
323    rebuild the 'jch' branch from scratch, starting at the tip of
324    'master', this time without using "-c1" to merge all topics.
326    Then do the same to 'next'.
328      $ git checkout next
329      $ sh Meta/redo-jch.sh -c1 -e
331    The "-e" option allows the merge message that comes from the
332    history of the topic and the comments in the "What's cooking" to
333    be edited.  The resulting tree should match 'jch^{/^### match next'}'
334    as the same set of topics are merged on 'master'; otherwise there
335    is a mismerge. Investigate why and do not proceed until the mismerge
336    is found and rectified.
338    If 'master' was updated before you started redoing 'next', then
340      $ git diff 'jch^{/^### match next}' next
342    would show differences that went into 'master' (which 'jch' has,
343    but 'next' does not yet---often it is updates to the release
344    notes).  Merge 'master' back to 'next' if that is the case.
346      $ git merge -m "Sync with 'master'" --no-log master
348    When all is well, clean up the redo-jch.sh script with
350      $ sh Meta/redo-jch.sh -u
352    This removes topics listed in the script that have already been
353    merged to 'master'.  This may lose '### match next' marker;
354    add it again to the appropriate place when it happens.
356  - Rebuild 'seen' on top of 'jch'.
358      $ git checkout -B seen jch
359      $ sh Meta/redo-seen.sh
361    When all is well, clean up the redo-seen.sh script with
363      $ sh Meta/redo-seen.sh -u
365    Double check by running
367      $ git branch --no-merged seen '??/*'
369    to see there is no unexpected leftover topics.
371    At this point, build-test the result for semantic conflicts, and
372    if there are, prepare an appropriate merge-fix first (see
373    appendix), and rebuild the 'seen' branch from scratch, starting at
374    the tip of 'jch'.
376  - Update "What's cooking" message to review the updates to
377    existing topics, newly added topics and graduated topics.
379    This step is helped with Meta/cook script.
381      $ Meta/cook
383    This script inspects the history between master..seen, finds tips
384    of topic branches, compares what it found with the current
385    contents in Meta/whats-cooking.txt, and updates that file.
386    Topics not listed in the file but are found in master..seen are
387    added to the "New topics" section, topics listed in the file that
388    are no longer found in master..seen are moved to the "Graduated to
389    master" section, and topics whose commits changed their states
390    (e.g. used to be only in 'seen', now merged to 'next') are updated
391    with change markers "<<" and ">>".
393    Look for lines enclosed in "<<" and ">>"; they hold contents from
394    old file that are replaced by this integration round.  After
395    verifying them, remove the old part.  Review the description for
396    each topic and update its doneness and plan as needed.  To review
397    the updated plan, run
399      $ Meta/cook -w
401    which will pick up comments given to the topics, such as "Will
402    merge to 'next'", etc. (see Meta/cook script to learn what kind
403    of phrases are supported).
405  - Compile, test and install all four (five) integration branches;
406    Meta/Dothem script may aid this step.
408  - Format documentation if the 'master' branch was updated;
409    Meta/dodoc.sh script may aid this step.
411  - Push the integration branches out to public places; Meta/pushall
412    script may aid this step.
414 Observations
415 ------------
417 Some observations to be made.
419  * Each topic is tested individually, and also together with other
420    topics cooking first in 'seen', then in 'jch' and then in 'next'.
421    Until it matures, no part of it is merged to 'master'.
423  * A topic already in 'next' can get fixes while still in
424    'next'.  Such a topic will have many merges to 'next' (in
425    other words, "git log --first-parent next" will show many
426    "Merge branch 'ai/topic' to next" for the same topic.
428  * An unobvious fix for 'maint' is cooked in 'next' and then
429    merged to 'master' to make extra sure it is Ok and then
430    merged to 'maint'.
432  * Even when 'next' becomes empty (in other words, all topics
433    prove stable and are merged to 'master' and "git diff master
434    next" shows empty), it has tons of merge commits that will
435    never be in 'master'.
437  * In principle, "git log --first-parent master..next" should
438    show nothing but merges (in practice, there are fixup commits
439    and reverts that are not merges).
441  * Commits near the tip of a topic branch that are not in 'next'
442    are fair game to be discarded, replaced or rewritten.
443    Commits already merged to 'next' will not be.
445  * Being in the 'next' branch is not a guarantee for a topic to
446    be included in the next feature release.  Being in the
447    'master' branch typically is.
449  * Due to the nature of "SQUASH???" fix-ups, if the original author
450    agrees with the suggested changes, it is OK to squash them to
451    appropriate patches in the next round (when the suggested change
452    is small enough, the author should not even bother with
453    "Helped-by").  It is also OK to drop them from the next round
454    when the original author does not agree with the suggestion, but
455    the author is expected to say why somewhere in the discussion.
458 Appendix
459 --------
461 Preparing a "merge-fix"
462 ~~~~~~~~~~~~~~~~~~~~~~~
464 A merge of two topics may not textually conflict but still have
465 conflict at the semantic level. A classic example is for one topic
466 to rename a variable and all its uses, while another topic adds a
467 new use of the variable under its old name. When these two topics
468 are merged together, the reference to the variable newly added by
469 the latter topic will still use the old name in the result.
471 The Meta/Reintegrate script that is used by redo-jch and redo-seen
472 scripts implements a crude but usable way to work around this issue.
473 When the script merges branch $X, it checks if "refs/merge-fix/$X"
474 exists, and if so, the effect of it is squashed into the result of
475 the mechanical merge.  In other words,
477      $ echo $X | Meta/Reintegrate
479 is roughly equivalent to this sequence:
481      $ git merge --rerere-autoupdate $X
482      $ git commit
483      $ git cherry-pick -n refs/merge-fix/$X
484      $ git commit --amend
486 The goal of this "prepare a merge-fix" step is to come up with a
487 commit that can be squashed into a result of mechanical merge to
488 correct semantic conflicts.
490 After finding that the result of merging branch "ai/topic" to an
491 integration branch had such a semantic conflict, say seen~4, check the
492 problematic merge out on a detached HEAD, edit the working tree to
493 fix the semantic conflict, and make a separate commit to record the
494 fix-up:
496      $ git checkout seen~4
497      $ git show -s --pretty=%s ;# double check
498      Merge branch 'ai/topic' to seen
499      $ edit
500      $ git commit -m 'merge-fix/ai/topic' -a
502 Then make a reference "refs/merge-fix/ai/topic" to point at this
503 result:
505      $ git update-ref refs/merge-fix/ai/topic HEAD
507 Then double check the result by asking Meta/Reintegrate to redo the
508 merge:
510      $ git checkout seen~5 ;# the parent of the problem merge
511      $ echo ai/topic | Meta/Reintegrate
512      $ git diff seen~4
514 This time, because you prepared refs/merge-fix/ai/topic, the
515 resulting merge should have been tweaked to include the fix for the
516 semantic conflict.
518 Note that this assumes that the order in which conflicting branches
519 are merged does not change.  If the reason why merging ai/topic
520 branch needs this merge-fix is because another branch merged earlier
521 to the integration branch changed the underlying assumption ai/topic
522 branch made (e.g. ai/topic branch added a site to refer to a
523 variable, while the other branch renamed that variable and adjusted
524 existing use sites), and if you changed redo-jch (or redo-seen) script
525 to merge ai/topic branch before the other branch, then the above
526 merge-fix should not be applied while merging ai/topic, but should
527 instead be applied while merging the other branch.  You would need
528 to move the fix to apply to the other branch, perhaps like this:
530       $ mf=refs/merge-fix
531       $ git update-ref $mf/$the_other_branch $mf/ai/topic
532       $ git update-ref -d $mf/ai/topic