177 lines · plain
1Creating Pull Requests2======================3 4This chapter describes how maintainers can create and submit pull requests5to other maintainers. This is useful for transferring changes from one6maintainers tree to another maintainers tree.7 8This document was written by Tobin C. Harding (who at that time, was not an9experienced maintainer) primarily from comments made by Greg Kroah-Hartman10and Linus Torvalds on LKML. Suggestions and fixes by Jonathan Corbet and11Mauro Carvalho Chehab. Misrepresentation was unintentional but inevitable,12please direct abuse to Tobin C. Harding <me@tobin.cc>.13 14Original email thread::15 16 https://lore.kernel.org/r/20171114110500.GA21175@kroah.com17 18 19Create Branch20-------------21 22To start with you will need to have all the changes you wish to include in23the pull request on a separate branch. Typically you will base this branch24off of a branch in the developers tree whom you intend to send the pull25request to.26 27In order to create the pull request you must first tag the branch that you28have just created. It is recommended that you choose a meaningful tag name,29in a way that you and others can understand, even after some time. A good30practice is to include in the name an indicator of the subsystem of origin31and the target kernel version.32 33Greg offers the following. A pull request with miscellaneous stuff for34drivers/char, to be applied at the Kernel version 4.15-rc1 could be named35as ``char-misc-4.15-rc1``. If such tag would be produced from a branch36named ``char-misc-next``, you would be using the following command::37 38 git tag -s char-misc-4.15-rc1 char-misc-next39 40that will create a signed tag called ``char-misc-4.15-rc1`` based on the41last commit in the ``char-misc-next`` branch, and sign it with your gpg key42(see Documentation/maintainer/configure-git.rst).43 44Linus will only accept pull requests based on a signed tag. Other45maintainers may differ.46 47When you run the above command ``git`` will drop you into an editor and ask48you to describe the tag. In this case, you are describing a pull request,49so outline what is contained here, why it should be merged, and what, if50any, testing has been done. All of this information will end up in the tag51itself, and then in the merge commit that the maintainer makes if/when they52merge the pull request. So write it up well, as it will be in the kernel53tree for forever.54 55As said by Linus::56 57 Anyway, at least to me, the important part is the *message*. I want58 to understand what I'm pulling, and why I should pull it. I also59 want to use that message as the message for the merge, so it should60 not just make sense to me, but make sense as a historical record61 too.62 63 Note that if there is something odd about the pull request, that64 should very much be in the explanation. If you're touching files65 that you don't maintain, explain _why_. I will see it in the66 diffstat anyway, and if you didn't mention it, I'll just be extra67 suspicious. And when you send me new stuff after the merge window68 (or even bug-fixes, but ones that look scary), explain not just69 what they do and why they do it, but explain the _timing_. What70 happened that this didn't go through the merge window..71 72 I will take both what you write in the email pull request _and_ in73 the signed tag, so depending on your workflow, you can either74 describe your work in the signed tag (which will also automatically75 make it into the pull request email), or you can make the signed76 tag just a placeholder with nothing interesting in it, and describe77 the work later when you actually send me the pull request.78 79 And yes, I will edit the message. Partly because I tend to do just80 trivial formatting (the whole indentation and quoting etc), but81 partly because part of the message may make sense for me at pull82 time (describing the conflicts and your personal issues for sending83 it right now), but may not make sense in the context of a merge84 commit message, so I will try to make it all make sense. I will85 also fix any speeling mistaeks and bad grammar I notice,86 particularly for non-native speakers (but also for native ones87 ;^). But I may miss some, or even add some.88 89 Linus90 91Greg gives, as an example pull request::92 93 Char/Misc patches for 4.15-rc194 95 Here is the big char/misc patch set for the 4.15-rc1 merge window.96 Contained in here is the normal set of new functions added to all97 of these crazy drivers, as well as the following brand new98 subsystems:99 - time_travel_controller: Finally a set of drivers for the100 latest time travel bus architecture that provides i/o to101 the CPU before it asked for it, allowing uninterrupted102 processing103 - relativity_shifters: due to the affect that the104 time_travel_controllers have on the overall system, there105 was a need for a new set of relativity shifter drivers to106 accommodate the newly formed black holes that would107 threaten to suck CPUs into them. This subsystem handles108 this in a way to successfully neutralize the problems.109 There is a Kconfig option to force these to be enabled110 when needed, so problems should not occur.111 112 All of these patches have been successfully tested in the latest113 linux-next releases, and the original problems that it found have114 all been resolved (apologies to anyone living near Canberra for the115 lack of the Kconfig options in the earlier versions of the116 linux-next tree creations.)117 118 Signed-off-by: Your-name-here <your_email@domain>119 120 121The tag message format is just like a git commit id. One line at the top122for a "summary subject" and be sure to sign-off at the bottom.123 124Now that you have a local signed tag, you need to push it up to where it125can be retrieved::126 127 git push origin char-misc-4.15-rc1128 129 130Create Pull Request131-------------------132 133The last thing to do is create the pull request message. ``git`` handily134will do this for you with the ``git request-pull`` command, but it needs a135bit of help determining what you want to pull, and on what to base the pull136against (to show the correct changes to be pulled and the diffstat). The137following command(s) will generate a pull request::138 139 git request-pull master git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/ char-misc-4.15-rc1140 141Quoting Greg::142 143 This is asking git to compare the difference from the144 'char-misc-4.15-rc1' tag location, to the head of the 'master'145 branch (which in my case points to the last location in Linus's146 tree that I diverged from, usually a -rc release) and to use the147 git:// protocol to pull from. If you wish to use https://, that148 can be used here instead as well (but note that some people behind149 firewalls will have problems with https git pulls).150 151 If the char-misc-4.15-rc1 tag is not present in the repo that I am152 asking to be pulled from, git will complain saying it is not there,153 a handy way to remember to actually push it to a public location.154 155 The output of 'git request-pull' will contain the location of the156 git tree and specific tag to pull from, and the full text157 description of that tag (which is why you need to provide good158 information in that tag). It will also create a diffstat of the159 pull request, and a shortlog of the individual commits that the160 pull request will provide.161 162Linus responded that he tends to prefer the ``git://`` protocol. Other163maintainers may have different preferences. Also, note that if you are164creating pull requests without a signed tag then ``https://`` may be a165better choice. Please see the original thread for the full discussion.166 167 168Submit Pull Request169-------------------170 171A pull request is submitted in the same way as an ordinary patch. Send as172inline email to the maintainer and CC LKML and any sub-system specific173lists if required. Pull requests to Linus typically have a subject line174something like::175 176 [GIT PULL] <subsystem> changes for v4.15-rc1177