patch 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. .TH PATCH 1
  2. .SH NAME
  3. patch \- simple patch creation and tracking system
  4. .SH SYNOPSIS
  5. .B patch/create
  6. [
  7. .B -f
  8. ]
  9. .I name
  10. .I email
  11. .I files ...
  12. [
  13. .B <
  14. .I description
  15. ]
  16. .PP
  17. .B patch/list
  18. [
  19. .B -av
  20. ]
  21. [
  22. .I name ...
  23. ]
  24. .PP
  25. .B patch/pull
  26. .PP
  27. .B patch/pullbin
  28. .PP
  29. .B patch/diff
  30. .I name
  31. .PP
  32. .B patch/apply
  33. .I name
  34. .PP
  35. .B patch/Apply
  36. .I name
  37. .PP
  38. .B patch/undo
  39. .I name
  40. .PP
  41. .B patch/applied
  42. .I name
  43. .PP
  44. .B patch/notify
  45. .SH DESCRIPTION
  46. These scripts are a simple patch submission and tracking system
  47. used to propose additions or changes to Nix. They are similar to Plan 9
  48. .IR patch (1)
  49. tools but there are important differences.
  50. .PP
  51. Each patch has a
  52. .I name
  53. (lowercase letters, numbers, dash, dot, and underscore only)
  54. and is stored in
  55. .BI /n/patches.lsub.org/patch/ name.
  56. .PP
  57. Users are expected to use only
  58. .I patch/create
  59. to create patches and
  60. .I patch/pull
  61. to pull (apply) new patches that have been applied to the main distribution.
  62. All other tools are for contributors and maintainers.
  63. .PP
  64. .I Patch/pull
  65. applies to the tree mounted at
  66. .I /n/dist
  67. all patches applied to the main nix tree but not yet applied
  68. to that tree.
  69. If there is no tree mounted at
  70. .I /n/dist
  71. then
  72. .I patch/pull
  73. will bind
  74. .B /
  75. there, and apply patches to the tree you are using.
  76. The history of patches applied to a tree is always kept at
  77. .B /dist/patch/applied
  78. within that tree.
  79. .PP
  80. To use this tool it is important that
  81. .I patch/applied
  82. is either not used (from outside this tool) or is used to apply
  83. the patches in exactly the same order used by the main tree.
  84. .PP
  85. .I Patch/pullbin
  86. relies on
  87. .IR up (1)
  88. to suggest commands to update
  89. .B /386/bin
  90. and
  91. .B /386/lib
  92. with those found in the distribution.
  93. No remove command will be issued if a binary is
  94. removed from the distribution, and newer local binaries
  95. will be left alone.
  96. .PP
  97. .I Patch/create
  98. creates a new patch (or redefines an existing one) consisting of the changes to
  99. the listed files from the distribution, reading
  100. a description of the patch from standard input:
  101. please provide an explanation of what the change is supposed to do,
  102. some context, and a rationale for the change.
  103. Test data or pointers to same to verify that the fix works are also welcome.
  104. When sending a patch, follow these guidelines:
  105. .IP • 3
  106. Before preparing the patch, run
  107. .I patch/pull
  108. and base your patch on current distribution source code.
  109. .IP •
  110. If this is a bug fix, explain the bug clearly.
  111. Don't assume the bug is obvious from the fix.
  112. .IP •
  113. If this is a new feature, explain it clearly.
  114. Don't assume it is obvious from the change.
  115. .IP •
  116. Make the new code look as much like the old code as possible:
  117. don't make gratuitous changes, and do follow the style of the old code.
  118. See
  119. .IR style (6)
  120. for the canonical Plan 9 coding style, used in Nix.
  121. .IP •
  122. If your patch changes externally-visible behaviour,
  123. update the manual page.
  124. .PP
  125. The
  126. .I email
  127. address, if not
  128. .LR - ,
  129. will be included in the mail to notify that the patch has been created. All
  130. patch discussion will proceed in the same mail thread, until the patch
  131. is accepted or rejected. If it is rejected, the usual course of action is to
  132. create
  133. a new patch using the same name, after having addressed the comments
  134. discussed by mail.
  135. .PP
  136. When you run
  137. .I patch/create
  138. to create a patch, the tree you are using considers the patch as applied, so that
  139. further
  140. .I patch/pull
  141. calls in that tree will not try to apply an already applied patch.
  142. .PP
  143. Running
  144. .I patch/create
  145. with the name of an existing patch can be used to modify a not yet
  146. applied patch. In this case, flag
  147. .B -f
  148. must be supplied or the tool will refuse to continue, to prevent accidental
  149. redefinition of existing patches.
  150. .PP
  151. .I Patch/list
  152. displays information about the named patches,
  153. or all currently pending patches if none are specified. Under flag
  154. .B -a
  155. it list all existing patches.
  156. Flag
  157. .B -v
  158. makes the tool verbose.
  159. .PP
  160. .I Patch/diff
  161. shows a patch as diffs between the original
  162. source files and the patched source files.
  163. .PP
  164. .I Patch/apply
  165. applies the patch to the current source tree mounted on
  166. .B /n/dist
  167. (the current tree if none is mounted there).
  168. If the source has changed since the patch was
  169. created,
  170. .I apply
  171. will report the conflict and not change any files.
  172. Before changing any files,
  173. .I patch/apply
  174. makes backup copies of the current source tree's
  175. files. The backups are stored in the patch directory created at
  176. .B /dist/patch
  177. for processing the patch.
  178. .PP
  179. After applying a patch, one of
  180. .I patch/undo
  181. and
  182. .I patch/applied
  183. must be executed:
  184. .I Patch/undo
  185. will copy the backups saved by
  186. .I patch/apply
  187. back into the source tree.
  188. .I Patch/applied
  189. records the patch as applied.
  190. .PP
  191. .I Patch/Apply
  192. is used by the main tree maintainers to apply patches to it.
  193. It is exactly
  194. .I patch/apply
  195. with a few changes to operate on the main Nix tree.
  196. .PP
  197. .I Patch/notify
  198. is run frequently close to the main distribution to notify by mail of patch creations.
  199. .PP
  200. If there are conflicts you can resolve them by manually updating your local files
  201. as you please and then running
  202. .IR patch/appied ,
  203. which declares the patch as applied. To update your local files you can refer to the
  204. .BI /dist/patch/ patchname
  205. directory which keeps the list of files affected as well as their old and new versions.
  206. .SH EXAMPLES
  207. Propose a change to
  208. .IR pwd ,
  209. which you have modified locally:
  210. .IP
  211. .EX
  212. % patch/create pwd-errors user@host.dom /sys/src/cmd/pwd.c
  213. Fix pwd to print errors to fd 2 rather than 1.
  214. ^D
  215. %
  216. .EE
  217. .PP
  218. Then the distribution maintainers and patch reviewers run
  219. .IP
  220. .EX
  221. patch/diff pwd-errors
  222. .EE
  223. .PP
  224. to inspect the change (possibly viewing
  225. .B /n/patches.lsub.org/patch/pwd-errors/pwd.c
  226. to see the larger context).
  227. To try the change, they run
  228. .IP
  229. .EX
  230. patch/apply pwd-errors
  231. .EE
  232. .LP
  233. After that, they run
  234. .IP
  235. .EX
  236. % patch/undo pwd-errors
  237. %
  238. .EE
  239. .PP
  240. to end the trial. Should the patch be accepted, maintainers run
  241. .IP
  242. .EX
  243. patch/Apply pwd-errors
  244. .EE
  245. .PP
  246. to apply it to the main distribution. After that, those that run
  247. .IP
  248. .EX
  249. patch/pull
  250. .EE
  251. .PP
  252. will get the new patch (as well as any other ones applied to the
  253. main distribution, but not yet locally applied).
  254. .PP
  255. To ignore a patch and skip it from pull you can
  256. .EX
  257. echo patchname >>/dist/patch/applied
  258. .EE
  259. .SH FILES
  260. .B /n/patches.lsub.org/patch
  261. .B /n/sources.lsub.org/nix
  262. .B /dist/patch
  263. .SH SOURCE
  264. .B /rc/bin/patch
  265. .SH SEE ALSO
  266. .IR diff (1)