Back to home page

OSCL-LXR

 
 

    


0001 .. _pullrequests:
0002 
0003 Creating Pull Requests
0004 ======================
0005 
0006 This chapter describes how maintainers can create and submit pull requests
0007 to other maintainers. This is useful for transferring changes from one
0008 maintainers tree to another maintainers tree.
0009 
0010 This document was written by Tobin C. Harding (who at that time, was not an
0011 experienced maintainer) primarily from comments made by Greg Kroah-Hartman
0012 and Linus Torvalds on LKML. Suggestions and fixes by Jonathan Corbet and
0013 Mauro Carvalho Chehab.  Misrepresentation was unintentional but inevitable,
0014 please direct abuse to Tobin C. Harding <me@tobin.cc>.
0015 
0016 Original email thread::
0017 
0018         https://lore.kernel.org/r/20171114110500.GA21175@kroah.com
0019 
0020 
0021 Create Branch
0022 -------------
0023 
0024 To start with you will need to have all the changes you wish to include in
0025 the pull request on a separate branch. Typically you will base this branch
0026 off of a branch in the developers tree whom you intend to send the pull
0027 request to.
0028 
0029 In order to create the pull request you must first tag the branch that you
0030 have just created. It is recommended that you choose a meaningful tag name,
0031 in a way that you and others can understand, even after some time.  A good
0032 practice is to include in the name an indicator of the subsystem of origin
0033 and the target kernel version.
0034 
0035 Greg offers the following. A pull request with miscellaneous stuff for
0036 drivers/char, to be applied at the Kernel version 4.15-rc1 could be named
0037 as ``char-misc-4.15-rc1``. If such tag would be produced from a branch
0038 named ``char-misc-next``, you would be using the following command::
0039 
0040         git tag -s char-misc-4.15-rc1 char-misc-next
0041 
0042 that will create a signed tag called ``char-misc-4.15-rc1`` based on the
0043 last commit in the ``char-misc-next`` branch, and sign it with your gpg key
0044 (see :ref:`Documentation/maintainer/configure-git.rst <configuregit>`).
0045 
0046 Linus will only accept pull requests based on a signed tag. Other
0047 maintainers may differ.
0048 
0049 When you run the above command ``git`` will drop you into an editor and ask
0050 you to describe the tag.  In this case, you are describing a pull request,
0051 so outline what is contained here, why it should be merged, and what, if
0052 any, testing has been done.  All of this information will end up in the tag
0053 itself, and then in the merge commit that the maintainer makes if/when they
0054 merge the pull request. So write it up well, as it will be in the kernel
0055 tree for forever.
0056 
0057 As said by Linus::
0058 
0059         Anyway, at least to me, the important part is the *message*. I want
0060         to understand what I'm pulling, and why I should pull it. I also
0061         want to use that message as the message for the merge, so it should
0062         not just make sense to me, but make sense as a historical record
0063         too.
0064 
0065         Note that if there is something odd about the pull request, that
0066         should very much be in the explanation. If you're touching files
0067         that you don't maintain, explain _why_. I will see it in the
0068         diffstat anyway, and if you didn't mention it, I'll just be extra
0069         suspicious.  And when you send me new stuff after the merge window
0070         (or even bug-fixes, but ones that look scary), explain not just
0071         what they do and why they do it, but explain the _timing_. What
0072         happened that this didn't go through the merge window..
0073 
0074         I will take both what you write in the email pull request _and_ in
0075         the signed tag, so depending on your workflow, you can either
0076         describe your work in the signed tag (which will also automatically
0077         make it into the pull request email), or you can make the signed
0078         tag just a placeholder with nothing interesting in it, and describe
0079         the work later when you actually send me the pull request.
0080 
0081         And yes, I will edit the message. Partly because I tend to do just
0082         trivial formatting (the whole indentation and quoting etc), but
0083         partly because part of the message may make sense for me at pull
0084         time (describing the conflicts and your personal issues for sending
0085         it right now), but may not make sense in the context of a merge
0086         commit message, so I will try to make it all make sense. I will
0087         also fix any speeling mistaeks and bad grammar I notice,
0088         particularly for non-native speakers (but also for native ones
0089         ;^). But I may miss some, or even add some.
0090 
0091                         Linus
0092 
0093 Greg gives, as an example pull request::
0094 
0095         Char/Misc patches for 4.15-rc1
0096 
0097         Here is the big char/misc patch set for the 4.15-rc1 merge window.
0098         Contained in here is the normal set of new functions added to all
0099         of these crazy drivers, as well as the following brand new
0100         subsystems:
0101                 - time_travel_controller: Finally a set of drivers for the
0102                   latest time travel bus architecture that provides i/o to
0103                   the CPU before it asked for it, allowing uninterrupted
0104                   processing
0105                 - relativity_shifters: due to the affect that the
0106                   time_travel_controllers have on the overall system, there
0107                   was a need for a new set of relativity shifter drivers to
0108                   accommodate the newly formed black holes that would
0109                   threaten to suck CPUs into them.  This subsystem handles
0110                   this in a way to successfully neutralize the problems.
0111                   There is a Kconfig option to force these to be enabled
0112                   when needed, so problems should not occur.
0113 
0114         All of these patches have been successfully tested in the latest
0115         linux-next releases, and the original problems that it found have
0116         all been resolved (apologies to anyone living near Canberra for the
0117         lack of the Kconfig options in the earlier versions of the
0118         linux-next tree creations.)
0119 
0120         Signed-off-by: Your-name-here <your_email@domain>
0121 
0122 
0123 The tag message format is just like a git commit id.  One line at the top
0124 for a "summary subject" and be sure to sign-off at the bottom.
0125 
0126 Now that you have a local signed tag, you need to push it up to where it
0127 can be retrieved::
0128 
0129         git push origin char-misc-4.15-rc1
0130 
0131 
0132 Create Pull Request
0133 -------------------
0134 
0135 The last thing to do is create the pull request message.  ``git`` handily
0136 will do this for you with the ``git request-pull`` command, but it needs a
0137 bit of help determining what you want to pull, and on what to base the pull
0138 against (to show the correct changes to be pulled and the diffstat). The
0139 following command(s) will generate a pull request::
0140 
0141         git request-pull master git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/ char-misc-4.15-rc1
0142 
0143 Quoting Greg::
0144 
0145         This is asking git to compare the difference from the
0146         'char-misc-4.15-rc1' tag location, to the head of the 'master'
0147         branch (which in my case points to the last location in Linus's
0148         tree that I diverged from, usually a -rc release) and to use the
0149         git:// protocol to pull from.  If you wish to use https://, that
0150         can be used here instead as well (but note that some people behind
0151         firewalls will have problems with https git pulls).
0152 
0153         If the char-misc-4.15-rc1 tag is not present in the repo that I am
0154         asking to be pulled from, git will complain saying it is not there,
0155         a handy way to remember to actually push it to a public location.
0156 
0157         The output of 'git request-pull' will contain the location of the
0158         git tree and specific tag to pull from, and the full text
0159         description of that tag (which is why you need to provide good
0160         information in that tag).  It will also create a diffstat of the
0161         pull request, and a shortlog of the individual commits that the
0162         pull request will provide.
0163 
0164 Linus responded that he tends to prefer the ``git://`` protocol. Other
0165 maintainers may have different preferences. Also, note that if you are
0166 creating pull requests without a signed tag then ``https://`` may be a
0167 better choice. Please see the original thread for the full discussion.
0168 
0169 
0170 Submit Pull Request
0171 -------------------
0172 
0173 A pull request is submitted in the same way as an ordinary patch. Send as
0174 inline email to the maintainer and CC LKML and any sub-system specific
0175 lists if required. Pull requests to Linus typically have a subject line
0176 something like::
0177 
0178         [GIT PULL] <subsystem> changes for v4.15-rc1