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