Skip to content

Commit 7994cc1

Browse files
author
Jonathan Corbet
committed
Docs: Bring SubmittingPatches more into the git era
Much of the information in SubmittingPatches shows its pre-git history. Clean that up a bit and rephrase things with the assumption that developers will be using git. Also rewrite the "pull requests" section and include information on using signed tags. Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 6de16eb commit 7994cc1

File tree

1 file changed

+87
-29
lines changed

1 file changed

+87
-29
lines changed

Documentation/SubmittingPatches

+87-29
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,30 @@ SECTION 1 - CREATING AND SENDING YOUR CHANGE
2424
--------------------------------------------
2525

2626

27+
0) Obtain a current source tree
28+
-------------------------------
29+
30+
If you do not have a repository with the current kernel source handy, use
31+
git to obtain one. You'll want to start with the mainline repository,
32+
which can be grabbed with:
33+
34+
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
35+
36+
Note, however, that you may not want to develop against the mainline tree
37+
directly. Most subsystem maintainers run their own trees and want to see
38+
patches prepared against those trees. See the "T:" entry for the subsystem
39+
in the MAINTAINERS file to find that tree, or simply ask the maintainer if
40+
the tree is not listed there.
41+
42+
It is still possible to download kernel releases via tarballs (as described
43+
in the next section), but that is the hard way to do kernel development.
2744

2845
1) "diff -up"
2946
------------
3047

31-
Use "diff -up" or "diff -uprN" to create patches. git generates patches
32-
in this form by default; if you're using git, you can skip this section
33-
entirely.
48+
If you must generate your patches by hand, use "diff -up" or "diff -uprN"
49+
to create patches. Git generates patches in this form by default; if
50+
you're using git, you can skip this section entirely.
3451

3552
All changes to the Linux kernel occur in the form of patches, as
3653
generated by diff(1). When creating your patch, make sure to create it
@@ -156,10 +173,15 @@ Example:
156173
platform_set_drvdata(), but left the variable "dev" unused,
157174
delete it.
158175

176+
You should also be sure to use at least the first twelve characters of the
177+
SHA-1 ID. The kernel repository holds a *lot* of objects, making
178+
collisions with shorter IDs a real possibility. Bear in mind that, even if
179+
there is no collision with your six-character ID now, that condition may
180+
change five years from now.
181+
159182
If your patch fixes a bug in a specific commit, e.g. you found an issue using
160183
git-bisect, please use the 'Fixes:' tag with the first 12 characters of the
161-
SHA-1 ID, and the one line summary.
162-
Example:
184+
SHA-1 ID, and the one line summary. For example:
163185

164186
Fixes: e21d2170f366 ("video: remove unnecessary platform_set_drvdata()")
165187

@@ -188,6 +210,12 @@ If one patch depends on another patch in order for a change to be
188210
complete, that is OK. Simply note "this patch depends on patch X"
189211
in your patch description.
190212

213+
When dividing your change into a series of patches, take special care to
214+
ensure that the kernel builds and runs properly after each patch in the
215+
series. Developers using "git bisect" to track down a problem can end up
216+
splitting your patch series at any point; they will not thank you if you
217+
introduce bugs in the middle.
218+
191219
If you cannot condense your patch set into a smaller set of patches,
192220
then only post say 15 or so at a time and wait for review and integration.
193221

@@ -445,15 +473,15 @@ which appears in the changelog.
445473
Special note to back-porters: It seems to be a common and useful practice
446474
to insert an indication of the origin of a patch at the top of the commit
447475
message (just after the subject line) to facilitate tracking. For instance,
448-
here's what we see in 2.6-stable :
476+
here's what we see in a 3.x-stable release:
449477

450-
Date: Tue May 13 19:10:30 2008 +0000
478+
Date: Tue Oct 7 07:26:38 2014 -0400
451479

452-
SCSI: libiscsi regression in 2.6.25: fix nop timer handling
480+
libata: Un-break ATA blacklist
453481

454-
commit 4cf1043593db6a337f10e006c23c69e5fc93e722 upstream
482+
commit 1c40279960bcd7d52dbdf1d466b20d24b99176c8 upstream.
455483

456-
And here's what appears in 2.4 :
484+
And here's what might appear in an older kernel once a patch is backported:
457485

458486
Date: Tue May 13 22:12:27 2008 +0200
459487

@@ -462,7 +490,7 @@ And here's what appears in 2.4 :
462490
[backport of 2.6 commit b7acbdfbd1f277c1eb23f344f899cfa4cd0bf36a]
463491

464492
Whatever the format, this information provides a valuable help to people
465-
tracking your trees, and to people trying to trouble-shoot bugs in your
493+
tracking your trees, and to people trying to troubleshoot bugs in your
466494
tree.
467495

468496

@@ -558,6 +586,12 @@ method for indicating a bug fixed by the patch. See #2 above for more details.
558586

559587

560588
15) The canonical patch format
589+
------------------------------
590+
591+
This section describes how the patch itself should be formatted. Note
592+
that, if you have your patches stored in a git repository, proper patch
593+
formatting can be had with "git format-patch". The tools cannot create
594+
the necessary text, though, so read the instructions below anyway.
561595

562596
The canonical patch subject line is:
563597

@@ -672,33 +706,57 @@ See more details on the proper patch format in the following
672706
references.
673707

674708

675-
16) Sending "git pull" requests (from Linus emails)
709+
16) Sending "git pull" requests
710+
-------------------------------
711+
712+
If you have a series of patches, it may be most convenient to have the
713+
maintainer pull them directly into the subsystem repository with a
714+
"git pull" operation. Note, however, that pulling patches from a developer
715+
requires a higher degree of trust than taking patches from a mailing list.
716+
As a result, many subsystem maintainers are reluctant to take pull
717+
requests, especially from new, unknown developers.
718+
719+
A pull request should have [GIT] or [PULL] in the subject line. The
720+
request itself should include the repository name and the branch of
721+
interest on a single line; it should look something like:
722+
723+
Please pull from
676724

677-
Please write the git repo address and branch name alone on the same line
678-
so that I can't even by mistake pull from the wrong branch, and so
679-
that a triple-click just selects the whole thing.
725+
git://jdelvare.pck.nerim.net/jdelvare-2.6 i2c-for-linus
680726

681-
So the proper format is something along the lines of:
727+
to get these changes:"
682728

683-
"Please pull from
729+
A pull request should also include an overall message saying what will be
730+
included in the request, a "git shortlog" listing of the patches
731+
themselves, and a diffstat showing the overall effect of the patch series.
732+
The easiest way to get all this information together is, of course, to let
733+
git do it for you with the "git request-pull" command.
684734

685-
git://jdelvare.pck.nerim.net/jdelvare-2.6 i2c-for-linus
735+
Some maintainers (including Linus) want to see pull requests from signed
736+
commits; that increases their confidence that the request actually came
737+
from you. Linus, in particular, will not pull from public hosting sites
738+
like GitHub in the absence of a signed tag.
686739

687-
to get these changes:"
740+
The first step toward creating such tags is to make a GNUPG key and get it
741+
signed by one or more core kernel developers. This step can be hard for
742+
new developers, but there is no way around it. Attending conferences can
743+
be a good way to find developers who can sign your key.
688744

689-
so that I don't have to hunt-and-peck for the address and inevitably
690-
get it wrong (actually, I've only gotten it wrong a few times, and
691-
checking against the diffstat tells me when I get it wrong, but I'm
692-
just a lot more comfortable when I don't have to "look for" the right
693-
thing to pull, and double-check that I have the right branch-name).
745+
Once you have prepared a patch series in git that you wish to have somebody
746+
pull, create a signed tag with "git tag -s". This will create a new tag
747+
identifying the last commit in the series and containing a signature
748+
created with your private key. You will also have the opportunity to add a
749+
changelog-style message to the tag; this is an ideal place to describe the
750+
effects of the pull request as a whole.
694751

752+
If the tree the maintainer will be pulling from is not the repository you
753+
are working from, don't forget to push the signed tag explicitly to the
754+
public tree.
695755

696-
Please use "git diff -M --stat --summary" to generate the diffstat:
697-
the -M enables rename detection, and the summary enables a summary of
698-
new/deleted or renamed files.
756+
When generating your pull request, use the signed tag as the target. A
757+
command like this will do the trick:
699758

700-
With rename detection, the statistics are rather different [...]
701-
because git will notice that a fair number of the changes are renames.
759+
git request-pull master git://my.public.tree/linux.git my-signed-tag
702760

703761

704762
----------------------

0 commit comments

Comments
 (0)