.. | .. |
---|
10 | 10 | |
---|
11 | 11 | This document contains a large number of suggestions in a relatively terse |
---|
12 | 12 | format. For detailed information on how the kernel development process |
---|
13 | | -works, see :ref:`Documentation/process <development_process_main>`. |
---|
14 | | -Also, read :ref:`Documentation/process/submit-checklist.rst <submitchecklist>` |
---|
15 | | -for a list of items to check before |
---|
16 | | -submitting code. If you are submitting a driver, also read |
---|
17 | | -:ref:`Documentation/process/submitting-drivers.rst <submittingdrivers>`; |
---|
18 | | -for device tree binding patches, read |
---|
19 | | -Documentation/devicetree/bindings/submitting-patches.txt. |
---|
| 13 | +works, see :doc:`development-process`. Also, read :doc:`submit-checklist` |
---|
| 14 | +for a list of items to check before submitting code. If you are submitting |
---|
| 15 | +a driver, also read :doc:`submitting-drivers`; for device tree binding patches, |
---|
| 16 | +read :doc:`submitting-patches`. |
---|
20 | 17 | |
---|
21 | | -Many of these steps describe the default behavior of the ``git`` version |
---|
22 | | -control system; if you use ``git`` to prepare your patches, you'll find much |
---|
23 | | -of the mechanical work done for you, though you'll still need to prepare |
---|
24 | | -and document a sensible set of patches. In general, use of ``git`` will make |
---|
25 | | -your life as a kernel developer easier. |
---|
| 18 | +This documentation assumes that you're using ``git`` to prepare your patches. |
---|
| 19 | +If you're unfamiliar with ``git``, you would be well-advised to learn how to |
---|
| 20 | +use it, it will make your life as a kernel developer and in general much |
---|
| 21 | +easier. |
---|
26 | 22 | |
---|
27 | | -0) Obtain a current source tree |
---|
28 | | -------------------------------- |
---|
| 23 | +Obtain a current source tree |
---|
| 24 | +---------------------------- |
---|
29 | 25 | |
---|
30 | 26 | If you do not have a repository with the current kernel source handy, use |
---|
31 | 27 | ``git`` to obtain one. You'll want to start with the mainline repository, |
---|
.. | .. |
---|
39 | 35 | in the MAINTAINERS file to find that tree, or simply ask the maintainer if |
---|
40 | 36 | the tree is not listed there. |
---|
41 | 37 | |
---|
42 | | -It is still possible to download kernel releases via tarballs (as described |
---|
43 | | -in the next section), but that is the hard way to do kernel development. |
---|
44 | | - |
---|
45 | | -1) ``diff -up`` |
---|
46 | | ---------------- |
---|
47 | | - |
---|
48 | | -If you must generate your patches by hand, use ``diff -up`` or ``diff -uprN`` |
---|
49 | | -to create patches. Git generates patches in this form by default; if |
---|
50 | | -you're using ``git``, you can skip this section entirely. |
---|
51 | | - |
---|
52 | | -All changes to the Linux kernel occur in the form of patches, as |
---|
53 | | -generated by :manpage:`diff(1)`. When creating your patch, make sure to |
---|
54 | | -create it in "unified diff" format, as supplied by the ``-u`` argument |
---|
55 | | -to :manpage:`diff(1)`. |
---|
56 | | -Also, please use the ``-p`` argument which shows which C function each |
---|
57 | | -change is in - that makes the resultant ``diff`` a lot easier to read. |
---|
58 | | -Patches should be based in the root kernel source directory, |
---|
59 | | -not in any lower subdirectory. |
---|
60 | | - |
---|
61 | | -To create a patch for a single file, it is often sufficient to do:: |
---|
62 | | - |
---|
63 | | - SRCTREE= linux |
---|
64 | | - MYFILE= drivers/net/mydriver.c |
---|
65 | | - |
---|
66 | | - cd $SRCTREE |
---|
67 | | - cp $MYFILE $MYFILE.orig |
---|
68 | | - vi $MYFILE # make your change |
---|
69 | | - cd .. |
---|
70 | | - diff -up $SRCTREE/$MYFILE{.orig,} > /tmp/patch |
---|
71 | | - |
---|
72 | | -To create a patch for multiple files, you should unpack a "vanilla", |
---|
73 | | -or unmodified kernel source tree, and generate a ``diff`` against your |
---|
74 | | -own source tree. For example:: |
---|
75 | | - |
---|
76 | | - MYSRC= /devel/linux |
---|
77 | | - |
---|
78 | | - tar xvfz linux-3.19.tar.gz |
---|
79 | | - mv linux-3.19 linux-3.19-vanilla |
---|
80 | | - diff -uprN -X linux-3.19-vanilla/Documentation/dontdiff \ |
---|
81 | | - linux-3.19-vanilla $MYSRC > /tmp/patch |
---|
82 | | - |
---|
83 | | -``dontdiff`` is a list of files which are generated by the kernel during |
---|
84 | | -the build process, and should be ignored in any :manpage:`diff(1)`-generated |
---|
85 | | -patch. |
---|
86 | | - |
---|
87 | | -Make sure your patch does not include any extra files which do not |
---|
88 | | -belong in a patch submission. Make sure to review your patch -after- |
---|
89 | | -generating it with :manpage:`diff(1)`, to ensure accuracy. |
---|
90 | | - |
---|
91 | | -If your changes produce a lot of deltas, you need to split them into |
---|
92 | | -individual patches which modify things in logical stages; see |
---|
93 | | -:ref:`split_changes`. This will facilitate review by other kernel developers, |
---|
94 | | -very important if you want your patch accepted. |
---|
95 | | - |
---|
96 | | -If you're using ``git``, ``git rebase -i`` can help you with this process. If |
---|
97 | | -you're not using ``git``, ``quilt`` <http://savannah.nongnu.org/projects/quilt> |
---|
98 | | -is another popular alternative. |
---|
99 | | - |
---|
100 | 38 | .. _describe_changes: |
---|
101 | 39 | |
---|
102 | | -2) Describe your changes |
---|
103 | | ------------------------- |
---|
| 40 | +Describe your changes |
---|
| 41 | +--------------------- |
---|
104 | 42 | |
---|
105 | 43 | Describe your problem. Whether your patch is a one-line bug fix or |
---|
106 | 44 | 5000 lines of a new feature, there must be an underlying problem that |
---|
.. | .. |
---|
133 | 71 | |
---|
134 | 72 | The maintainer will thank you if you write your patch description in a |
---|
135 | 73 | form which can be easily pulled into Linux's source code management |
---|
136 | | -system, ``git``, as a "commit log". See :ref:`explicit_in_reply_to`. |
---|
| 74 | +system, ``git``, as a "commit log". See :ref:`the_canonical_patch_format`. |
---|
137 | 75 | |
---|
138 | 76 | Solve only one problem per patch. If your description starts to get |
---|
139 | 77 | long, that's a sign that you probably need to split up your patch. |
---|
.. | .. |
---|
182 | 120 | |
---|
183 | 121 | If your patch fixes a bug in a specific commit, e.g. you found an issue using |
---|
184 | 122 | ``git bisect``, please use the 'Fixes:' tag with the first 12 characters of |
---|
185 | | -the SHA-1 ID, and the one line summary. For example:: |
---|
| 123 | +the SHA-1 ID, and the one line summary. Do not split the tag across multiple |
---|
| 124 | +lines, tags are exempt from the "wrap at 75 columns" rule in order to simplify |
---|
| 125 | +parsing scripts. For example:: |
---|
186 | 126 | |
---|
187 | | - Fixes: e21d2170f366 ("video: remove unnecessary platform_set_drvdata()") |
---|
| 127 | + Fixes: 54a4f0239f2e ("KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freed") |
---|
188 | 128 | |
---|
189 | 129 | The following ``git config`` settings can be used to add a pretty format for |
---|
190 | 130 | outputting the above style in the ``git log`` or ``git show`` commands:: |
---|
.. | .. |
---|
194 | 134 | [pretty] |
---|
195 | 135 | fixes = Fixes: %h (\"%s\") |
---|
196 | 136 | |
---|
| 137 | +An example call:: |
---|
| 138 | + |
---|
| 139 | + $ git log -1 --pretty=fixes 54a4f0239f2e |
---|
| 140 | + Fixes: 54a4f0239f2e ("KVM: MMU: make kvm_mmu_zap_page() return the number of pages it actually freed") |
---|
| 141 | + |
---|
197 | 142 | .. _split_changes: |
---|
198 | 143 | |
---|
199 | | -3) Separate your changes |
---|
200 | | ------------------------- |
---|
| 144 | +Separate your changes |
---|
| 145 | +--------------------- |
---|
201 | 146 | |
---|
202 | 147 | Separate each **logical change** into a separate patch. |
---|
203 | 148 | |
---|
.. | .. |
---|
229 | 174 | |
---|
230 | 175 | |
---|
231 | 176 | |
---|
232 | | -4) Style-check your changes |
---|
233 | | ---------------------------- |
---|
| 177 | +Style-check your changes |
---|
| 178 | +------------------------ |
---|
234 | 179 | |
---|
235 | 180 | Check your patch for basic style violations, details of which can be |
---|
236 | 181 | found in |
---|
.. | .. |
---|
260 | 205 | patch. |
---|
261 | 206 | |
---|
262 | 207 | |
---|
263 | | -5) Select the recipients for your patch |
---|
264 | | ---------------------------------------- |
---|
| 208 | +Select the recipients for your patch |
---|
| 209 | +------------------------------------ |
---|
265 | 210 | |
---|
266 | 211 | You should always copy the appropriate subsystem maintainer(s) on any patch |
---|
267 | 212 | to code that they maintain; look through the MAINTAINERS file and the |
---|
.. | .. |
---|
292 | 237 | If you have a patch that fixes an exploitable security bug, send that patch |
---|
293 | 238 | to security@kernel.org. For severe bugs, a short embargo may be considered |
---|
294 | 239 | to allow distributors to get the patch out to users; in such cases, |
---|
295 | | -obviously, the patch should not be sent to any public lists. |
---|
| 240 | +obviously, the patch should not be sent to any public lists. See also |
---|
| 241 | +:doc:`/admin-guide/security-bugs`. |
---|
296 | 242 | |
---|
297 | 243 | Patches that fix a severe bug in a released kernel should be directed |
---|
298 | 244 | toward the stable maintainers by putting a line like this:: |
---|
.. | .. |
---|
303 | 249 | should also read |
---|
304 | 250 | :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>` |
---|
305 | 251 | in addition to this file. |
---|
306 | | - |
---|
307 | | -Note, however, that some subsystem maintainers want to come to their own |
---|
308 | | -conclusions on which patches should go to the stable trees. The networking |
---|
309 | | -maintainer, in particular, would rather not see individual developers |
---|
310 | | -adding lines like the above to their patches. |
---|
311 | 252 | |
---|
312 | 253 | If changes affect userland-kernel interfaces, please send the MAN-PAGES |
---|
313 | 254 | maintainer (as listed in the MAINTAINERS file) a man-pages patch, or at |
---|
.. | .. |
---|
335 | 276 | |
---|
336 | 277 | |
---|
337 | 278 | |
---|
338 | | -6) No MIME, no links, no compression, no attachments. Just plain text |
---|
339 | | ----------------------------------------------------------------------- |
---|
| 279 | +No MIME, no links, no compression, no attachments. Just plain text |
---|
| 280 | +------------------------------------------------------------------- |
---|
340 | 281 | |
---|
341 | 282 | Linus and other kernel developers need to be able to read and comment |
---|
342 | 283 | on the changes you are submitting. It is important for a kernel |
---|
343 | 284 | developer to be able to "quote" your changes, using standard e-mail |
---|
344 | 285 | tools, so that they may comment on specific portions of your code. |
---|
345 | 286 | |
---|
346 | | -For this reason, all patches should be submitted by e-mail "inline". |
---|
| 287 | +For this reason, all patches should be submitted by e-mail "inline". The |
---|
| 288 | +easiest way to do this is with ``git send-email``, which is strongly |
---|
| 289 | +recommended. An interactive tutorial for ``git send-email`` is available at |
---|
| 290 | +https://git-send-email.io. |
---|
| 291 | + |
---|
| 292 | +If you choose not to use ``git send-email``: |
---|
347 | 293 | |
---|
348 | 294 | .. warning:: |
---|
349 | 295 | |
---|
.. | .. |
---|
359 | 305 | Exception: If your mailer is mangling patches then someone may ask |
---|
360 | 306 | you to re-send them using MIME. |
---|
361 | 307 | |
---|
362 | | -See :ref:`Documentation/process/email-clients.rst <email_clients>` |
---|
363 | | -for hints about configuring your e-mail client so that it sends your patches |
---|
364 | | -untouched. |
---|
| 308 | +See :doc:`/process/email-clients` for hints about configuring your e-mail |
---|
| 309 | +client so that it sends your patches untouched. |
---|
365 | 310 | |
---|
366 | | -7) E-mail size |
---|
367 | | --------------- |
---|
368 | | - |
---|
369 | | -Large changes are not appropriate for mailing lists, and some |
---|
370 | | -maintainers. If your patch, uncompressed, exceeds 300 kB in size, |
---|
371 | | -it is preferred that you store your patch on an Internet-accessible |
---|
372 | | -server, and provide instead a URL (link) pointing to your patch. But note |
---|
373 | | -that if your patch exceeds 300 kB, it almost certainly needs to be broken up |
---|
374 | | -anyway. |
---|
375 | | - |
---|
376 | | -8) Respond to review comments |
---|
377 | | ------------------------------ |
---|
| 311 | +Respond to review comments |
---|
| 312 | +-------------------------- |
---|
378 | 313 | |
---|
379 | 314 | Your patch will almost certainly get comments from reviewers on ways in |
---|
380 | | -which the patch can be improved. You must respond to those comments; |
---|
381 | | -ignoring reviewers is a good way to get ignored in return. Review comments |
---|
382 | | -or questions that do not lead to a code change should almost certainly |
---|
| 315 | +which the patch can be improved, in the form of a reply to your email. You must |
---|
| 316 | +respond to those comments; ignoring reviewers is a good way to get ignored in |
---|
| 317 | +return. You can simply reply to their emails to answer their comments. Review |
---|
| 318 | +comments or questions that do not lead to a code change should almost certainly |
---|
383 | 319 | bring about a comment or changelog entry so that the next reviewer better |
---|
384 | 320 | understands what is going on. |
---|
385 | 321 | |
---|
.. | .. |
---|
388 | 324 | reviewers sometimes get grumpy. Even in that case, though, respond |
---|
389 | 325 | politely and address the problems they have pointed out. |
---|
390 | 326 | |
---|
| 327 | +See :doc:`email-clients` for recommendations on email |
---|
| 328 | +clients and mailing list etiquette. |
---|
391 | 329 | |
---|
392 | | -9) Don't get discouraged - or impatient |
---|
393 | | ---------------------------------------- |
---|
| 330 | + |
---|
| 331 | +Don't get discouraged - or impatient |
---|
| 332 | +------------------------------------ |
---|
394 | 333 | |
---|
395 | 334 | After you have submitted your change, be patient and wait. Reviewers are |
---|
396 | 335 | busy people and may not get to your patch right away. |
---|
.. | .. |
---|
403 | 342 | busy times like merge windows. |
---|
404 | 343 | |
---|
405 | 344 | |
---|
406 | | -10) Include PATCH in the subject |
---|
407 | | --------------------------------- |
---|
| 345 | +Include PATCH in the subject |
---|
| 346 | +----------------------------- |
---|
408 | 347 | |
---|
409 | 348 | Due to high e-mail traffic to Linus, and to linux-kernel, it is common |
---|
410 | 349 | convention to prefix your subject line with [PATCH]. This lets Linus |
---|
411 | 350 | and other kernel developers more easily distinguish patches from other |
---|
412 | 351 | e-mail discussions. |
---|
413 | 352 | |
---|
| 353 | +``git send-email`` will do this for you automatically. |
---|
414 | 354 | |
---|
415 | 355 | |
---|
416 | | -11) Sign your work - the Developer's Certificate of Origin |
---|
417 | | ----------------------------------------------------------- |
---|
| 356 | +Sign your work - the Developer's Certificate of Origin |
---|
| 357 | +------------------------------------------------------ |
---|
418 | 358 | |
---|
419 | 359 | To improve tracking of who did what, especially with patches that can |
---|
420 | 360 | percolate to their final resting place in the kernel through several |
---|
.. | .. |
---|
458 | 398 | Signed-off-by: Random J Developer <random@developer.example.org> |
---|
459 | 399 | |
---|
460 | 400 | using your real name (sorry, no pseudonyms or anonymous contributions.) |
---|
| 401 | +This will be done for you automatically if you use ``git commit -s``. |
---|
461 | 402 | |
---|
462 | 403 | Some people also put extra tags at the end. They'll just be ignored for |
---|
463 | 404 | now, but you can do this to mark internal company procedures or just |
---|
464 | 405 | point out some special detail about the sign-off. |
---|
465 | 406 | |
---|
466 | | -If you are a subsystem or branch maintainer, sometimes you need to slightly |
---|
467 | | -modify patches you receive in order to merge them, because the code is not |
---|
468 | | -exactly the same in your tree and the submitters'. If you stick strictly to |
---|
469 | | -rule (c), you should ask the submitter to rediff, but this is a totally |
---|
470 | | -counter-productive waste of time and energy. Rule (b) allows you to adjust |
---|
471 | | -the code, but then it is very impolite to change one submitter's code and |
---|
472 | | -make him endorse your bugs. To solve this problem, it is recommended that |
---|
473 | | -you add a line between the last Signed-off-by header and yours, indicating |
---|
474 | | -the nature of your changes. While there is nothing mandatory about this, it |
---|
475 | | -seems like prepending the description with your mail and/or name, all |
---|
476 | | -enclosed in square brackets, is noticeable enough to make it obvious that |
---|
477 | | -you are responsible for last-minute changes. Example:: |
---|
478 | 407 | |
---|
479 | | - Signed-off-by: Random J Developer <random@developer.example.org> |
---|
480 | | - [lucky@maintainer.example.org: struct foo moved from foo.c to foo.h] |
---|
481 | | - Signed-off-by: Lucky K Maintainer <lucky@maintainer.example.org> |
---|
482 | | - |
---|
483 | | -This practice is particularly helpful if you maintain a stable branch and |
---|
484 | | -want at the same time to credit the author, track changes, merge the fix, |
---|
485 | | -and protect the submitter from complaints. Note that under no circumstances |
---|
486 | | -can you change the author's identity (the From header), as it is the one |
---|
487 | | -which appears in the changelog. |
---|
488 | | - |
---|
489 | | -Special note to back-porters: It seems to be a common and useful practice |
---|
490 | | -to insert an indication of the origin of a patch at the top of the commit |
---|
491 | | -message (just after the subject line) to facilitate tracking. For instance, |
---|
492 | | -here's what we see in a 3.x-stable release:: |
---|
493 | | - |
---|
494 | | - Date: Tue Oct 7 07:26:38 2014 -0400 |
---|
495 | | - |
---|
496 | | - libata: Un-break ATA blacklist |
---|
497 | | - |
---|
498 | | - commit 1c40279960bcd7d52dbdf1d466b20d24b99176c8 upstream. |
---|
499 | | - |
---|
500 | | -And here's what might appear in an older kernel once a patch is backported:: |
---|
501 | | - |
---|
502 | | - Date: Tue May 13 22:12:27 2008 +0200 |
---|
503 | | - |
---|
504 | | - wireless, airo: waitbusy() won't delay |
---|
505 | | - |
---|
506 | | - [backport of 2.6 commit b7acbdfbd1f277c1eb23f344f899cfa4cd0bf36a] |
---|
507 | | - |
---|
508 | | -Whatever the format, this information provides a valuable help to people |
---|
509 | | -tracking your trees, and to people trying to troubleshoot bugs in your |
---|
510 | | -tree. |
---|
511 | | - |
---|
512 | | - |
---|
513 | | -12) When to use Acked-by:, Cc:, and Co-Developed-by: |
---|
514 | | -------------------------------------------------------- |
---|
| 408 | +When to use Acked-by:, Cc:, and Co-developed-by: |
---|
| 409 | +------------------------------------------------ |
---|
515 | 410 | |
---|
516 | 411 | The Signed-off-by: tag indicates that the signer was involved in the |
---|
517 | 412 | development of the patch, or that he/she was in the patch's delivery path. |
---|
.. | .. |
---|
543 | 438 | patch. This tag documents that potentially interested parties |
---|
544 | 439 | have been included in the discussion. |
---|
545 | 440 | |
---|
546 | | -A Co-Developed-by: states that the patch was also created by another developer |
---|
547 | | -along with the original author. This is useful at times when multiple people |
---|
548 | | -work on a single patch. Note, this person also needs to have a Signed-off-by: |
---|
549 | | -line in the patch as well. |
---|
| 441 | +Co-developed-by: states that the patch was co-created by multiple developers; |
---|
| 442 | +it is a used to give attribution to co-authors (in addition to the author |
---|
| 443 | +attributed by the From: tag) when several people work on a single patch. Since |
---|
| 444 | +Co-developed-by: denotes authorship, every Co-developed-by: must be immediately |
---|
| 445 | +followed by a Signed-off-by: of the associated co-author. Standard sign-off |
---|
| 446 | +procedure applies, i.e. the ordering of Signed-off-by: tags should reflect the |
---|
| 447 | +chronological history of the patch insofar as possible, regardless of whether |
---|
| 448 | +the author is attributed via From: or Co-developed-by:. Notably, the last |
---|
| 449 | +Signed-off-by: must always be that of the developer submitting the patch. |
---|
| 450 | + |
---|
| 451 | +Note, the From: tag is optional when the From: author is also the person (and |
---|
| 452 | +email) listed in the From: line of the email header. |
---|
| 453 | + |
---|
| 454 | +Example of a patch submitted by the From: author:: |
---|
| 455 | + |
---|
| 456 | + <changelog> |
---|
| 457 | + |
---|
| 458 | + Co-developed-by: First Co-Author <first@coauthor.example.org> |
---|
| 459 | + Signed-off-by: First Co-Author <first@coauthor.example.org> |
---|
| 460 | + Co-developed-by: Second Co-Author <second@coauthor.example.org> |
---|
| 461 | + Signed-off-by: Second Co-Author <second@coauthor.example.org> |
---|
| 462 | + Signed-off-by: From Author <from@author.example.org> |
---|
| 463 | + |
---|
| 464 | +Example of a patch submitted by a Co-developed-by: author:: |
---|
| 465 | + |
---|
| 466 | + From: From Author <from@author.example.org> |
---|
| 467 | + |
---|
| 468 | + <changelog> |
---|
| 469 | + |
---|
| 470 | + Co-developed-by: Random Co-Author <random@coauthor.example.org> |
---|
| 471 | + Signed-off-by: Random Co-Author <random@coauthor.example.org> |
---|
| 472 | + Signed-off-by: From Author <from@author.example.org> |
---|
| 473 | + Co-developed-by: Submitting Co-Author <sub@coauthor.example.org> |
---|
| 474 | + Signed-off-by: Submitting Co-Author <sub@coauthor.example.org> |
---|
550 | 475 | |
---|
551 | 476 | |
---|
552 | | -13) Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes: |
---|
553 | | --------------------------------------------------------------------------- |
---|
| 477 | +Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes: |
---|
| 478 | +---------------------------------------------------------------------- |
---|
554 | 479 | |
---|
555 | 480 | The Reported-by tag gives credit to people who find bugs and report them and it |
---|
556 | 481 | hopefully inspires them to help us again in the future. Please note that if |
---|
.. | .. |
---|
597 | 522 | understand the subject area and to perform thorough reviews, will normally |
---|
598 | 523 | increase the likelihood of your patch getting into the kernel. |
---|
599 | 524 | |
---|
| 525 | +Both Tested-by and Reviewed-by tags, once received on mailing list from tester |
---|
| 526 | +or reviewer, should be added by author to the applicable patches when sending |
---|
| 527 | +next versions. However if the patch has changed substantially in following |
---|
| 528 | +version, these tags might not be applicable anymore and thus should be removed. |
---|
| 529 | +Usually removal of someone's Tested-by or Reviewed-by tags should be mentioned |
---|
| 530 | +in the patch changelog (after the '---' separator). |
---|
| 531 | + |
---|
600 | 532 | A Suggested-by: tag indicates that the patch idea is suggested by the person |
---|
601 | 533 | named and ensures credit to the person for the idea. Please note that this |
---|
602 | 534 | tag should not be added without the reporter's permission, especially if the |
---|
.. | .. |
---|
613 | 545 | |
---|
614 | 546 | .. _the_canonical_patch_format: |
---|
615 | 547 | |
---|
616 | | -14) The canonical patch format |
---|
617 | | ------------------------------- |
---|
| 548 | +The canonical patch format |
---|
| 549 | +-------------------------- |
---|
618 | 550 | |
---|
619 | 551 | This section describes how the patch itself should be formatted. Note |
---|
620 | 552 | that, if you have your patches stored in a ``git`` repository, proper patch |
---|
.. | .. |
---|
694 | 626 | The ``from`` line must be the very first line in the message body, |
---|
695 | 627 | and has the form: |
---|
696 | 628 | |
---|
697 | | - From: Original Author <author@example.com> |
---|
| 629 | + From: Patch Author <author@example.com> |
---|
698 | 630 | |
---|
699 | 631 | The ``from`` line specifies who will be credited as the author of the |
---|
700 | 632 | patch in the permanent changelog. If the ``from`` line is missing, |
---|
.. | .. |
---|
736 | 668 | |
---|
737 | 669 | .. _explicit_in_reply_to: |
---|
738 | 670 | |
---|
739 | | -15) Explicit In-Reply-To headers |
---|
740 | | --------------------------------- |
---|
| 671 | +Explicit In-Reply-To headers |
---|
| 672 | +---------------------------- |
---|
741 | 673 | |
---|
742 | 674 | It can be helpful to manually add In-Reply-To: headers to a patch |
---|
743 | 675 | (e.g., when using ``git send-email``) to associate the patch with |
---|
.. | .. |
---|
750 | 682 | the cover email text) to link to an earlier version of the patch series. |
---|
751 | 683 | |
---|
752 | 684 | |
---|
753 | | -16) Sending ``git pull`` requests |
---|
754 | | ---------------------------------- |
---|
| 685 | +Providing base tree information |
---|
| 686 | +------------------------------- |
---|
755 | 687 | |
---|
756 | | -If you have a series of patches, it may be most convenient to have the |
---|
757 | | -maintainer pull them directly into the subsystem repository with a |
---|
758 | | -``git pull`` operation. Note, however, that pulling patches from a developer |
---|
759 | | -requires a higher degree of trust than taking patches from a mailing list. |
---|
760 | | -As a result, many subsystem maintainers are reluctant to take pull |
---|
761 | | -requests, especially from new, unknown developers. If in doubt you can use |
---|
762 | | -the pull request as the cover letter for a normal posting of the patch |
---|
763 | | -series, giving the maintainer the option of using either. |
---|
| 688 | +When other developers receive your patches and start the review process, |
---|
| 689 | +it is often useful for them to know where in the tree history they |
---|
| 690 | +should place your work. This is particularly useful for automated CI |
---|
| 691 | +processes that attempt to run a series of tests in order to establish |
---|
| 692 | +the quality of your submission before the maintainer starts the review. |
---|
764 | 693 | |
---|
765 | | -A pull request should have [GIT PULL] in the subject line. The |
---|
766 | | -request itself should include the repository name and the branch of |
---|
767 | | -interest on a single line; it should look something like:: |
---|
| 694 | +If you are using ``git format-patch`` to generate your patches, you can |
---|
| 695 | +automatically include the base tree information in your submission by |
---|
| 696 | +using the ``--base`` flag. The easiest and most convenient way to use |
---|
| 697 | +this option is with topical branches:: |
---|
768 | 698 | |
---|
769 | | - Please pull from |
---|
| 699 | + $ git checkout -t -b my-topical-branch master |
---|
| 700 | + Branch 'my-topical-branch' set up to track local branch 'master'. |
---|
| 701 | + Switched to a new branch 'my-topical-branch' |
---|
770 | 702 | |
---|
771 | | - git://jdelvare.pck.nerim.net/jdelvare-2.6 i2c-for-linus |
---|
| 703 | + [perform your edits and commits] |
---|
772 | 704 | |
---|
773 | | - to get these changes: |
---|
| 705 | + $ git format-patch --base=auto --cover-letter -o outgoing/ master |
---|
| 706 | + outgoing/0000-cover-letter.patch |
---|
| 707 | + outgoing/0001-First-Commit.patch |
---|
| 708 | + outgoing/... |
---|
774 | 709 | |
---|
775 | | -A pull request should also include an overall message saying what will be |
---|
776 | | -included in the request, a ``git shortlog`` listing of the patches |
---|
777 | | -themselves, and a ``diffstat`` showing the overall effect of the patch series. |
---|
778 | | -The easiest way to get all this information together is, of course, to let |
---|
779 | | -``git`` do it for you with the ``git request-pull`` command. |
---|
| 710 | +When you open ``outgoing/0000-cover-letter.patch`` for editing, you will |
---|
| 711 | +notice that it will have the ``base-commit:`` trailer at the very |
---|
| 712 | +bottom, which provides the reviewer and the CI tools enough information |
---|
| 713 | +to properly perform ``git am`` without worrying about conflicts:: |
---|
780 | 714 | |
---|
781 | | -Some maintainers (including Linus) want to see pull requests from signed |
---|
782 | | -commits; that increases their confidence that the request actually came |
---|
783 | | -from you. Linus, in particular, will not pull from public hosting sites |
---|
784 | | -like GitHub in the absence of a signed tag. |
---|
| 715 | + $ git checkout -b patch-review [base-commit-id] |
---|
| 716 | + Switched to a new branch 'patch-review' |
---|
| 717 | + $ git am patches.mbox |
---|
| 718 | + Applying: First Commit |
---|
| 719 | + Applying: ... |
---|
785 | 720 | |
---|
786 | | -The first step toward creating such tags is to make a GNUPG key and get it |
---|
787 | | -signed by one or more core kernel developers. This step can be hard for |
---|
788 | | -new developers, but there is no way around it. Attending conferences can |
---|
789 | | -be a good way to find developers who can sign your key. |
---|
| 721 | +Please see ``man git-format-patch`` for more information about this |
---|
| 722 | +option. |
---|
790 | 723 | |
---|
791 | | -Once you have prepared a patch series in ``git`` that you wish to have somebody |
---|
792 | | -pull, create a signed tag with ``git tag -s``. This will create a new tag |
---|
793 | | -identifying the last commit in the series and containing a signature |
---|
794 | | -created with your private key. You will also have the opportunity to add a |
---|
795 | | -changelog-style message to the tag; this is an ideal place to describe the |
---|
796 | | -effects of the pull request as a whole. |
---|
| 724 | +.. note:: |
---|
797 | 725 | |
---|
798 | | -If the tree the maintainer will be pulling from is not the repository you |
---|
799 | | -are working from, don't forget to push the signed tag explicitly to the |
---|
800 | | -public tree. |
---|
| 726 | + The ``--base`` feature was introduced in git version 2.9.0. |
---|
801 | 727 | |
---|
802 | | -When generating your pull request, use the signed tag as the target. A |
---|
803 | | -command like this will do the trick:: |
---|
804 | | - |
---|
805 | | - git request-pull master git://my.public.tree/linux.git my-signed-tag |
---|
| 728 | +If you are not using git to format your patches, you can still include |
---|
| 729 | +the same ``base-commit`` trailer to indicate the commit hash of the tree |
---|
| 730 | +on which your work is based. You should add it either in the cover |
---|
| 731 | +letter or in the first patch of the series and it should be placed |
---|
| 732 | +either below the ``---`` line or at the very bottom of all other |
---|
| 733 | +content, right before your email signature. |
---|
806 | 734 | |
---|
807 | 735 | |
---|
808 | 736 | References |
---|
809 | 737 | ---------- |
---|
810 | 738 | |
---|
811 | 739 | Andrew Morton, "The perfect patch" (tpp). |
---|
812 | | - <http://www.ozlabs.org/~akpm/stuff/tpp.txt> |
---|
| 740 | + <https://www.ozlabs.org/~akpm/stuff/tpp.txt> |
---|
813 | 741 | |
---|
814 | 742 | Jeff Garzik, "Linux kernel patch submission format". |
---|
815 | | - <http://linux.yyz.us/patch-format.html> |
---|
| 743 | + <https://web.archive.org/web/20180829112450/http://linux.yyz.us/patch-format.html> |
---|
816 | 744 | |
---|
817 | 745 | Greg Kroah-Hartman, "How to piss off a kernel subsystem maintainer". |
---|
818 | 746 | <http://www.kroah.com/log/linux/maintainer.html> |
---|