162306a36Sopenharmony_ciCreating Pull Requests
262306a36Sopenharmony_ci======================
362306a36Sopenharmony_ci
462306a36Sopenharmony_ciThis chapter describes how maintainers can create and submit pull requests
562306a36Sopenharmony_cito other maintainers. This is useful for transferring changes from one
662306a36Sopenharmony_cimaintainers tree to another maintainers tree.
762306a36Sopenharmony_ci
862306a36Sopenharmony_ciThis document was written by Tobin C. Harding (who at that time, was not an
962306a36Sopenharmony_ciexperienced maintainer) primarily from comments made by Greg Kroah-Hartman
1062306a36Sopenharmony_ciand Linus Torvalds on LKML. Suggestions and fixes by Jonathan Corbet and
1162306a36Sopenharmony_ciMauro Carvalho Chehab.  Misrepresentation was unintentional but inevitable,
1262306a36Sopenharmony_ciplease direct abuse to Tobin C. Harding <me@tobin.cc>.
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciOriginal email thread::
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci	https://lore.kernel.org/r/20171114110500.GA21175@kroah.com
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciCreate Branch
2062306a36Sopenharmony_ci-------------
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciTo start with you will need to have all the changes you wish to include in
2362306a36Sopenharmony_cithe pull request on a separate branch. Typically you will base this branch
2462306a36Sopenharmony_cioff of a branch in the developers tree whom you intend to send the pull
2562306a36Sopenharmony_cirequest to.
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ciIn order to create the pull request you must first tag the branch that you
2862306a36Sopenharmony_cihave just created. It is recommended that you choose a meaningful tag name,
2962306a36Sopenharmony_ciin a way that you and others can understand, even after some time.  A good
3062306a36Sopenharmony_cipractice is to include in the name an indicator of the subsystem of origin
3162306a36Sopenharmony_ciand the target kernel version.
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ciGreg offers the following. A pull request with miscellaneous stuff for
3462306a36Sopenharmony_cidrivers/char, to be applied at the Kernel version 4.15-rc1 could be named
3562306a36Sopenharmony_cias ``char-misc-4.15-rc1``. If such tag would be produced from a branch
3662306a36Sopenharmony_cinamed ``char-misc-next``, you would be using the following command::
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci        git tag -s char-misc-4.15-rc1 char-misc-next
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_cithat will create a signed tag called ``char-misc-4.15-rc1`` based on the
4162306a36Sopenharmony_cilast commit in the ``char-misc-next`` branch, and sign it with your gpg key
4262306a36Sopenharmony_ci(see Documentation/maintainer/configure-git.rst).
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ciLinus will only accept pull requests based on a signed tag. Other
4562306a36Sopenharmony_cimaintainers may differ.
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ciWhen you run the above command ``git`` will drop you into an editor and ask
4862306a36Sopenharmony_ciyou to describe the tag.  In this case, you are describing a pull request,
4962306a36Sopenharmony_ciso outline what is contained here, why it should be merged, and what, if
5062306a36Sopenharmony_ciany, testing has been done.  All of this information will end up in the tag
5162306a36Sopenharmony_ciitself, and then in the merge commit that the maintainer makes if/when they
5262306a36Sopenharmony_cimerge the pull request. So write it up well, as it will be in the kernel
5362306a36Sopenharmony_citree for forever.
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciAs said by Linus::
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci	Anyway, at least to me, the important part is the *message*. I want
5862306a36Sopenharmony_ci	to understand what I'm pulling, and why I should pull it. I also
5962306a36Sopenharmony_ci	want to use that message as the message for the merge, so it should
6062306a36Sopenharmony_ci	not just make sense to me, but make sense as a historical record
6162306a36Sopenharmony_ci	too.
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci	Note that if there is something odd about the pull request, that
6462306a36Sopenharmony_ci	should very much be in the explanation. If you're touching files
6562306a36Sopenharmony_ci	that you don't maintain, explain _why_. I will see it in the
6662306a36Sopenharmony_ci	diffstat anyway, and if you didn't mention it, I'll just be extra
6762306a36Sopenharmony_ci	suspicious.  And when you send me new stuff after the merge window
6862306a36Sopenharmony_ci	(or even bug-fixes, but ones that look scary), explain not just
6962306a36Sopenharmony_ci	what they do and why they do it, but explain the _timing_. What
7062306a36Sopenharmony_ci	happened that this didn't go through the merge window..
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci	I will take both what you write in the email pull request _and_ in
7362306a36Sopenharmony_ci	the signed tag, so depending on your workflow, you can either
7462306a36Sopenharmony_ci	describe your work in the signed tag (which will also automatically
7562306a36Sopenharmony_ci	make it into the pull request email), or you can make the signed
7662306a36Sopenharmony_ci	tag just a placeholder with nothing interesting in it, and describe
7762306a36Sopenharmony_ci	the work later when you actually send me the pull request.
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci	And yes, I will edit the message. Partly because I tend to do just
8062306a36Sopenharmony_ci	trivial formatting (the whole indentation and quoting etc), but
8162306a36Sopenharmony_ci	partly because part of the message may make sense for me at pull
8262306a36Sopenharmony_ci	time (describing the conflicts and your personal issues for sending
8362306a36Sopenharmony_ci	it right now), but may not make sense in the context of a merge
8462306a36Sopenharmony_ci	commit message, so I will try to make it all make sense. I will
8562306a36Sopenharmony_ci	also fix any speeling mistaeks and bad grammar I notice,
8662306a36Sopenharmony_ci	particularly for non-native speakers (but also for native ones
8762306a36Sopenharmony_ci	;^). But I may miss some, or even add some.
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci			Linus
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ciGreg gives, as an example pull request::
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci	Char/Misc patches for 4.15-rc1
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci	Here is the big char/misc patch set for the 4.15-rc1 merge window.
9662306a36Sopenharmony_ci	Contained in here is the normal set of new functions added to all
9762306a36Sopenharmony_ci	of these crazy drivers, as well as the following brand new
9862306a36Sopenharmony_ci	subsystems:
9962306a36Sopenharmony_ci		- time_travel_controller: Finally a set of drivers for the
10062306a36Sopenharmony_ci		  latest time travel bus architecture that provides i/o to
10162306a36Sopenharmony_ci		  the CPU before it asked for it, allowing uninterrupted
10262306a36Sopenharmony_ci		  processing
10362306a36Sopenharmony_ci		- relativity_shifters: due to the affect that the
10462306a36Sopenharmony_ci		  time_travel_controllers have on the overall system, there
10562306a36Sopenharmony_ci		  was a need for a new set of relativity shifter drivers to
10662306a36Sopenharmony_ci		  accommodate the newly formed black holes that would
10762306a36Sopenharmony_ci		  threaten to suck CPUs into them.  This subsystem handles
10862306a36Sopenharmony_ci		  this in a way to successfully neutralize the problems.
10962306a36Sopenharmony_ci		  There is a Kconfig option to force these to be enabled
11062306a36Sopenharmony_ci		  when needed, so problems should not occur.
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci	All of these patches have been successfully tested in the latest
11362306a36Sopenharmony_ci	linux-next releases, and the original problems that it found have
11462306a36Sopenharmony_ci	all been resolved (apologies to anyone living near Canberra for the
11562306a36Sopenharmony_ci	lack of the Kconfig options in the earlier versions of the
11662306a36Sopenharmony_ci	linux-next tree creations.)
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci	Signed-off-by: Your-name-here <your_email@domain>
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ciThe tag message format is just like a git commit id.  One line at the top
12262306a36Sopenharmony_cifor a "summary subject" and be sure to sign-off at the bottom.
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ciNow that you have a local signed tag, you need to push it up to where it
12562306a36Sopenharmony_cican be retrieved::
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci	git push origin char-misc-4.15-rc1
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ciCreate Pull Request
13162306a36Sopenharmony_ci-------------------
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ciThe last thing to do is create the pull request message.  ``git`` handily
13462306a36Sopenharmony_ciwill do this for you with the ``git request-pull`` command, but it needs a
13562306a36Sopenharmony_cibit of help determining what you want to pull, and on what to base the pull
13662306a36Sopenharmony_ciagainst (to show the correct changes to be pulled and the diffstat). The
13762306a36Sopenharmony_cifollowing command(s) will generate a pull request::
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci	git request-pull master git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/ char-misc-4.15-rc1
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ciQuoting Greg::
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci	This is asking git to compare the difference from the
14462306a36Sopenharmony_ci	'char-misc-4.15-rc1' tag location, to the head of the 'master'
14562306a36Sopenharmony_ci	branch (which in my case points to the last location in Linus's
14662306a36Sopenharmony_ci	tree that I diverged from, usually a -rc release) and to use the
14762306a36Sopenharmony_ci	git:// protocol to pull from.  If you wish to use https://, that
14862306a36Sopenharmony_ci	can be used here instead as well (but note that some people behind
14962306a36Sopenharmony_ci	firewalls will have problems with https git pulls).
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci	If the char-misc-4.15-rc1 tag is not present in the repo that I am
15262306a36Sopenharmony_ci	asking to be pulled from, git will complain saying it is not there,
15362306a36Sopenharmony_ci	a handy way to remember to actually push it to a public location.
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci	The output of 'git request-pull' will contain the location of the
15662306a36Sopenharmony_ci	git tree and specific tag to pull from, and the full text
15762306a36Sopenharmony_ci	description of that tag (which is why you need to provide good
15862306a36Sopenharmony_ci	information in that tag).  It will also create a diffstat of the
15962306a36Sopenharmony_ci	pull request, and a shortlog of the individual commits that the
16062306a36Sopenharmony_ci	pull request will provide.
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ciLinus responded that he tends to prefer the ``git://`` protocol. Other
16362306a36Sopenharmony_cimaintainers may have different preferences. Also, note that if you are
16462306a36Sopenharmony_cicreating pull requests without a signed tag then ``https://`` may be a
16562306a36Sopenharmony_cibetter choice. Please see the original thread for the full discussion.
16662306a36Sopenharmony_ci
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ciSubmit Pull Request
16962306a36Sopenharmony_ci-------------------
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ciA pull request is submitted in the same way as an ordinary patch. Send as
17262306a36Sopenharmony_ciinline email to the maintainer and CC LKML and any sub-system specific
17362306a36Sopenharmony_cilists if required. Pull requests to Linus typically have a subject line
17462306a36Sopenharmony_cisomething like::
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci	[GIT PULL] <subsystem> changes for v4.15-rc1
177