You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

173 lines
6.8 KiB

  1. /** @page primerpatches Patch Primer
  2. This page provides an introduction to patching that may be useful
  3. for OpenOCD contributors who are unfamiliar with the process.
  4. @section primerpatchintro Introduction to Patching
  5. The standard method for creating patches requires developers to:
  6. - checkout the git repository (or bring a copy up-to-date),
  7. - make the necessary modifications to a working copy,
  8. - check with 'git status' to see which files will be modified/added, and
  9. - use 'git diff' to review the changes and produce a patch.
  10. It is important to minimize the changes to only those lines that contain
  11. important differences; do not allow stray whitespace changes into your
  12. patches, and keep the focus to a single logical change.
  13. @section primerpatchcreate Creating Patches
  14. You can create a patch (from the root of your working copy) with a
  15. command like the following example: @par
  16. @verbatim
  17. git diff > patch-name.patch
  18. @endverbatim
  19. where @a patch-name should be something that is descriptive and unique.
  20. The above command will create a patch containing all of the changes in
  21. the working copy; if you want to obtain a subset, simply provide the
  22. list of files to the command: @par
  23. @verbatim
  24. git diff doc > <patch-name>-doc.patch
  25. git diff src > <patch-name>-src.patch
  26. @endverbatim
  27. This will create two patches, each containing only those changes present
  28. in the subdirectory specified.
  29. @subsection primerpatchcreate Naming Patches
  30. One developer has evolved an informal standard for naming his patches: @par
  31. @verbatim
  32. <project>-<lod>-<action>-<task>.patch
  33. @endverbatim
  34. where @a project is @c openocd, @a lod (line-of-development) could be a
  35. subsystem (e.g. @c jtag, @c jlink, etc.) or other group identifier,
  36. @a action is @c add, @c change, @c fix, @c update, etc., and @a task is
  37. whatever the patch will accomplish (in 2-4 words).
  38. This scheme does not need to be followed, but it is helpful for
  39. maintainers that receive many patches. You do not want your own
  40. @c openocd.patch file to be accidentally overwritten by another
  41. submission, sending your patch to the bit bucket on accident.
  42. @section primerpatchpreflight Developer Review
  43. Before sending in patches, please make sure you have updated to the
  44. latest version of the trunk (using <code>git pull</code>) before creating
  45. your patch. This helps to increase the chances that it will apply
  46. cleanly to the trunk. However, the content matters most.
  47. When creating a patch using "<code>git diff</code>", git will
  48. produce a patch that contains all of the changes in your working copy.
  49. To manage multiple changes at once, you either need one working copy per
  50. patch, or you can specified specific files and directories when using
  51. <code>git diff</code>. Overlapping patches will be discussed in the
  52. next section.
  53. @todo Does git's treatment of line-endings behave sanely?
  54. Basically, the repository should use newlines internally,
  55. and convert to/from CRLF on Windows etc.
  56. @section primerpatchseries Patch Series
  57. As was mentioned above, each patch should contain one logical @c task,
  58. and multiple logical tasks should be split into a series of patches.
  59. There are no hard guidelines for how that is to be done; it's an art
  60. form. Many simple changes should not have to worry about being split,
  61. as they will naturally represent a single task.
  62. When working on several different non-intersecting lines of development,
  63. a combination of multiple working copies and patch series management
  64. techniques can become critical to efficiently managing change. This
  65. again is an area where developers have favorite methodologies that are
  66. simply a matter of taste or familiarity; your mileage may vary.
  67. Packages such as @c patchutils, @c diffutils, and @c quilt are among
  68. those that have proved themselves invaluable for these type of tasks.
  69. Others take their patch management a step further, using stkgit or
  70. some other framework on top of git.
  71. @subsection primerpatchseriesinterdiff Using @c interdiff
  72. The @c patchutils package includes the @c interdiff command, which
  73. produces a patch that contains the changes made between two other
  74. patches. This command can be used to manage the creation of trivial
  75. patch series. For example, the following sequence of commands will
  76. produce three patches: @par
  77. @verbatim
  78. $ cd openocd/
  79. $ git pull
  80. ...
  81. $ <<<start changes for patch #1>>>
  82. ...
  83. $ <<<finish changes for patch #1>>>
  84. $ git diff > series-1.patch # patch #1 is easy
  85. $ <<<start changes for patch #2>>>
  86. ...
  87. $ <<<finish changes for patch #2>>>
  88. $ git diff > series-1+2.patch # create patch 1+2
  89. $ interdiff series-1{,+2}.patch > series-2.patch # 1 ~ 1+2 => #2
  90. $ <<<start changes for patch #3>>>
  91. ...
  92. $ <<<finish changes for patch #3>>>
  93. $ git diff > series-1+2+3.patch # create patch 1+2+3
  94. $ interdiff series-1+2{,+3}.patch > series-3.patch # 1+2 ~ 1+2+3 => 3
  95. @endverbatim
  96. This technique falls apart when the repository changes, but this may be
  97. suitable for small series of patches.
  98. @subsection primerpatchseriesquilt Using @c quilt
  99. The @c quilt package provides scripts to manage series of patches more
  100. efficiently than can be managed by hand. For out-of-tree work projects
  101. that require such patch management, @c quilt provides an indispensable
  102. tool for solving the problem.
  103. @section primerpatchsubmit Submitting Patches
  104. Write access to the OpenOCD git repository is limited to
  105. contributors that have demonstrated the ability to produce clear,
  106. consistent, and frequent patches. These individuals are responsible
  107. for maintaining the integrity of the repository for the community.
  108. Thus, commits to the git repository must be handled by one of
  109. these maintainers.
  110. Patches must be sent to the OpenOCD developer mailing list:
  111. @par
  112. openocd-development@lists.berlios.de
  113. They will be reviewed and committed if the changes are found to be
  114. acceptable. If there are problems, you will receive feedback via the
  115. mailing list; in general, the maintainers prefer all communication to go
  116. through the list, as the entire community needs to judge contributions
  117. for possible merits and mistakes.
  118. Contributors may be asked to address certain issues and submit a new
  119. patch. In the event that it gets overlooked, you may need to resubmit
  120. it or prompt for feedback. Please have patience, as many maintainers
  121. work on the project voluntarily and without compensation for the time
  122. that they spend doing these tasks.
  123. @section primerpatchguide Guidelines for Submitting Patches
  124. - Each patch file should contain:
  125. - A commit description that describes all of the changes.
  126. - A separator line that contains three hyphens: <code>---</code>
  127. - A summary of the changes produced by diffstat (optional)
  128. - Another separator line (optional)
  129. - The actual patch contents, containing a single change.
  130. - Each patch series should include:
  131. - A summary of the patches in the series.
  132. - Logically-related patches that contain incremental changes.
  133. */
  134. /** @file
  135. This file contains the @ref primerpatches page.
  136. */