pull-requests.rst 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. .. _pullrequests:
  2. Creating Pull Requests
  3. ======================
  4. This chapter describes how maintainers can create and submit pull requests
  5. to other maintainers. This is useful for transferring changes from one
  6. maintainers tree to another maintainers tree.
  7. This document was written by Tobin C. Harding (who at that time, was not an
  8. experienced maintainer) primarily from comments made by Greg Kroah-Hartman
  9. and Linus Torvalds on LKML. Suggestions and fixes by Jonathan Corbet and
  10. Mauro Carvalho Chehab. Misrepresentation was unintentional but inevitable,
  11. please direct abuse to Tobin C. Harding <me@tobin.cc>.
  12. Original email thread::
  13. http://lkml.kernel.org/r/20171114110500.GA21175@kroah.com
  14. Create Branch
  15. -------------
  16. To start with you will need to have all the changes you wish to include in
  17. the pull request on a separate branch. Typically you will base this branch
  18. off of a branch in the developers tree whom you intend to send the pull
  19. request to.
  20. In order to create the pull request you must first tag the branch that you
  21. have just created. It is recommended that you choose a meaningful tag name,
  22. in a way that you and others can understand, even after some time. A good
  23. practice is to include in the name an indicator of the subsystem of origin
  24. and the target kernel version.
  25. Greg offers the following. A pull request with miscellaneous stuff for
  26. drivers/char, to be applied at the Kernel version 4.15-rc1 could be named
  27. as ``char-misc-4.15-rc1``. If such tag would be produced from a branch
  28. named ``char-misc-next``, you would be using the following command::
  29. git tag -s char-misc-4.15-rc1 char-misc-next
  30. that will create a signed tag called ``char-misc-4.15-rc1`` based on the
  31. last commit in the ``char-misc-next`` branch, and sign it with your gpg key
  32. (see :ref:`Documentation/maintainer/configure-git.rst <configuregit>`).
  33. Linus will only accept pull requests based on a signed tag. Other
  34. maintainers may differ.
  35. When you run the above command ``git`` will drop you into an editor and ask
  36. you to describe the tag. In this case, you are describing a pull request,
  37. so outline what is contained here, why it should be merged, and what, if
  38. any, testing has been done. All of this information will end up in the tag
  39. itself, and then in the merge commit that the maintainer makes if/when they
  40. merge the pull request. So write it up well, as it will be in the kernel
  41. tree for forever.
  42. As said by Linus::
  43. Anyway, at least to me, the important part is the *message*. I want
  44. to understand what I'm pulling, and why I should pull it. I also
  45. want to use that message as the message for the merge, so it should
  46. not just make sense to me, but make sense as a historical record
  47. too.
  48. Note that if there is something odd about the pull request, that
  49. should very much be in the explanation. If you're touching files
  50. that you don't maintain, explain _why_. I will see it in the
  51. diffstat anyway, and if you didn't mention it, I'll just be extra
  52. suspicious. And when you send me new stuff after the merge window
  53. (or even bug-fixes, but ones that look scary), explain not just
  54. what they do and why they do it, but explain the _timing_. What
  55. happened that this didn't go through the merge window..
  56. I will take both what you write in the email pull request _and_ in
  57. the signed tag, so depending on your workflow, you can either
  58. describe your work in the signed tag (which will also automatically
  59. make it into the pull request email), or you can make the signed
  60. tag just a placeholder with nothing interesting in it, and describe
  61. the work later when you actually send me the pull request.
  62. And yes, I will edit the message. Partly because I tend to do just
  63. trivial formatting (the whole indentation and quoting etc), but
  64. partly because part of the message may make sense for me at pull
  65. time (describing the conflicts and your personal issues for sending
  66. it right now), but may not make sense in the context of a merge
  67. commit message, so I will try to make it all make sense. I will
  68. also fix any speeling mistaeks and bad grammar I notice,
  69. particularly for non-native speakers (but also for native ones
  70. ;^). But I may miss some, or even add some.
  71. Linus
  72. Greg gives, as an example pull request::
  73. Char/Misc patches for 4.15-rc1
  74. Here is the big char/misc patch set for the 4.15-rc1 merge window.
  75. Contained in here is the normal set of new functions added to all
  76. of these crazy drivers, as well as the following brand new
  77. subsystems:
  78. - time_travel_controller: Finally a set of drivers for the
  79. latest time travel bus architecture that provides i/o to
  80. the CPU before it asked for it, allowing uninterrupted
  81. processing
  82. - relativity_shifters: due to the affect that the
  83. time_travel_controllers have on the overall system, there
  84. was a need for a new set of relativity shifter drivers to
  85. accommodate the newly formed black holes that would
  86. threaten to suck CPUs into them. This subsystem handles
  87. this in a way to successfully neutralize the problems.
  88. There is a Kconfig option to force these to be enabled
  89. when needed, so problems should not occur.
  90. All of these patches have been successfully tested in the latest
  91. linux-next releases, and the original problems that it found have
  92. all been resolved (apologies to anyone living near Canberra for the
  93. lack of the Kconfig options in the earlier versions of the
  94. linux-next tree creations.)
  95. Signed-off-by: Your-name-here <your_email@domain>
  96. The tag message format is just like a git commit id. One line at the top
  97. for a "summary subject" and be sure to sign-off at the bottom.
  98. Now that you have a local signed tag, you need to push it up to where it
  99. can be retrieved::
  100. git push origin char-misc-4.15-rc1
  101. Create Pull Request
  102. -------------------
  103. The last thing to do is create the pull request message. ``git`` handily
  104. will do this for you with the ``git request-pull`` command, but it needs a
  105. bit of help determining what you want to pull, and on what to base the pull
  106. against (to show the correct changes to be pulled and the diffstat). The
  107. following command(s) will generate a pull request::
  108. git request-pull master git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/ char-misc-4.15-rc1
  109. Quoting Greg::
  110. This is asking git to compare the difference from the
  111. 'char-misc-4.15-rc1' tag location, to the head of the 'master'
  112. branch (which in my case points to the last location in Linus's
  113. tree that I diverged from, usually a -rc release) and to use the
  114. git:// protocol to pull from. If you wish to use https://, that
  115. can be used here instead as well (but note that some people behind
  116. firewalls will have problems with https git pulls).
  117. If the char-misc-4.15-rc1 tag is not present in the repo that I am
  118. asking to be pulled from, git will complain saying it is not there,
  119. a handy way to remember to actually push it to a public location.
  120. The output of 'git request-pull' will contain the location of the
  121. git tree and specific tag to pull from, and the full text
  122. description of that tag (which is why you need to provide good
  123. information in that tag). It will also create a diffstat of the
  124. pull request, and a shortlog of the individual commits that the
  125. pull request will provide.
  126. Linus responded that he tends to prefer the ``git://`` protocol. Other
  127. maintainers may have different preferences. Also, note that if you are
  128. creating pull requests without a signed tag then ``https://`` may be a
  129. better choice. Please see the original thread for the full discussion.
  130. Submit Pull Request
  131. -------------------
  132. A pull request is submitted in the same way as an ordinary patch. Send as
  133. inline email to the maintainer and CC LKML and any sub-system specific
  134. lists if required. Pull requests to Linus typically have a subject line
  135. something like::
  136. [GIT PULL] <subsystem> changes for v4.15-rc1