162306a36Sopenharmony_ci.. include:: ../disclaimer-zh_CN.rst
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci:Original: Documentation/maintainer/pull-requests.rst
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci:译者:
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci 吴想成 Wu XiangCheng <bobwxc@email.cn>
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci.. _pullrequests_zh:
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci如何创建拉取请求
1262306a36Sopenharmony_ci================
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci本章描述维护人员如何创建并向其他维护人员提交拉取请求。这对将更改从一个维护者
1562306a36Sopenharmony_ci树转移到另一个维护者树非常有用。
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci本文档由Tobin C. Harding(当时他尚不是一名经验丰富的维护人员)编写,内容主要
1862306a36Sopenharmony_ci来自Greg Kroah Hartman和Linus Torvalds在LKML上的评论。Jonathan Corbet和Mauro
1962306a36Sopenharmony_ciCarvalho Chehab提出了一些建议和修改。错误不可避免,如有问题,请找Tobin C.
2062306a36Sopenharmony_ciHarding <me@tobin.cc>。
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci原始邮件线程::
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci	https://lore.kernel.org/r/20171114110500.GA21175@kroah.com
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci创建分支
2862306a36Sopenharmony_ci--------
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci首先,您需要将希望包含拉取请求里的所有更改都放在单独分支中。通常您将基于某开发
3162306a36Sopenharmony_ci人员树的一个分支,一般是打算向其发送拉取请求的开发人员。
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci为了创建拉取请求,您必须首先标记刚刚创建的分支。建议您选择一个有意义的标记名,
3462306a36Sopenharmony_ci以即使过了一段时间您和他人仍能理解的方式。在名称中包含源子系统和目标内核版本
3562306a36Sopenharmony_ci的指示也是一个好的做法。
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ciGreg提供了以下内容。对于一个含有drivers/char中混杂事项、将应用于4.15-rc1内核的
3862306a36Sopenharmony_ci拉取请求,可以命名为 ``char-misc-4.15-rc1`` 。如果要在 ``char-misc-next`` 分支
3962306a36Sopenharmony_ci上打上此标记,您可以使用以下命令::
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci	git tag -s char-misc-4.15-rc1 char-misc-next
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci这将在 ``char-misc-next`` 分支的最后一个提交上创建一个名为 ``char-misc-4.15-rc1``
4462306a36Sopenharmony_ci的标记,并用您的gpg密钥签名(参见 Documentation/maintainer/configure-git.rst )。
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ciLinus只接受基于签名过的标记的拉取请求。其他维护者可能会有所不同。
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci当您运行上述命令时 ``git`` 会打开编辑器要求你描述一下这个标记。在本例中您需要
4962306a36Sopenharmony_ci描述拉取请求,所以请概述一下包含的内容,为什么要合并,是否完成任何测试。所有
5062306a36Sopenharmony_ci这些信息都将留在标记中,然后在维护者合并拉取请求时保留在合并提交中。所以把它
5162306a36Sopenharmony_ci写好,它将永远留在内核中。
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci正如Linus所说::
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci	不管怎么样,至少对我来说,重要的是 *信息* 。我需要知道我在拉取什么、
5662306a36Sopenharmony_ci	为什么我要拉取。我也希望将此消息用于合并消息,因此它不仅应该对我有
5762306a36Sopenharmony_ci	意义,也应该可以成为一个有意义的历史记录。
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci	注意,如果拉取请求有一些不寻常的地方,请详细说明。如果你修改了并非
6062306a36Sopenharmony_ci	由你维护的文件,请解释 **为什么** 。我总会在差异中看到的,如果你不
6162306a36Sopenharmony_ci	提的话,我只会觉得分外可疑。当你在合并窗口后给我发新东西的时候,
6262306a36Sopenharmony_ci	(甚至是比较重大的错误修复),不仅需要解释做了什么、为什么这么做,
6362306a36Sopenharmony_ci	还请解释一下 **时间问题** 。为什么错过了合并窗口……
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci	我会看你写在拉取请求邮件和签名标记里面的内容,所以根据你的工作流,
6662306a36Sopenharmony_ci	你可以在签名标记里面描述工作内容(也会自动放进拉取请求邮件),也
6762306a36Sopenharmony_ci	可以只在标记里面放个占位符,稍后在你实际发给我拉取请求时描述工作内容。
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci	是的,我会编辑这些消息。部分因为我需要做一些琐碎的格式调整(整体缩进、
7062306a36Sopenharmony_ci	括号等),也因为此消息可能对我有意义(描述了冲突或一些个人问题)而对
7162306a36Sopenharmony_ci	合并提交信息上下文没啥意义,因此我需要尽力让它有意义起来。我也会
7262306a36Sopenharmony_ci	修复一些拼写和语法错误,特别是非母语者(母语者也是;^)。但我也会删掉
7362306a36Sopenharmony_ci	或增加一些内容。
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci			Linus
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ciGreg给出了一个拉取请求的例子::
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci	Char/Misc patches for 4.15-rc1
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci	Here is the big char/misc patch set for the 4.15-rc1 merge window.
8262306a36Sopenharmony_ci	Contained in here is the normal set of new functions added to all
8362306a36Sopenharmony_ci	of these crazy drivers, as well as the following brand new
8462306a36Sopenharmony_ci	subsystems:
8562306a36Sopenharmony_ci		- time_travel_controller: Finally a set of drivers for the
8662306a36Sopenharmony_ci		  latest time travel bus architecture that provides i/o to
8762306a36Sopenharmony_ci		  the CPU before it asked for it, allowing uninterrupted
8862306a36Sopenharmony_ci		  processing
8962306a36Sopenharmony_ci		- relativity_shifters: due to the affect that the
9062306a36Sopenharmony_ci		  time_travel_controllers have on the overall system, there
9162306a36Sopenharmony_ci		  was a need for a new set of relativity shifter drivers to
9262306a36Sopenharmony_ci		  accommodate the newly formed black holes that would
9362306a36Sopenharmony_ci		  threaten to suck CPUs into them.  This subsystem handles
9462306a36Sopenharmony_ci		  this in a way to successfully neutralize the problems.
9562306a36Sopenharmony_ci		  There is a Kconfig option to force these to be enabled
9662306a36Sopenharmony_ci		  when needed, so problems should not occur.
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci	All of these patches have been successfully tested in the latest
9962306a36Sopenharmony_ci	linux-next releases, and the original problems that it found have
10062306a36Sopenharmony_ci	all been resolved (apologies to anyone living near Canberra for the
10162306a36Sopenharmony_ci	lack of the Kconfig options in the earlier versions of the
10262306a36Sopenharmony_ci	linux-next tree creations.)
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci	Signed-off-by: Your-name-here <your_email@domain>
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci此标记消息格式就像一个git提交。顶部有一行“总结标题”, 一定要在下面sign-off。
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci现在您已经有了一个本地签名标记,您需要将它推送到可以被拉取的位置::
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci	git push origin char-misc-4.15-rc1
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci创建拉取请求
11562306a36Sopenharmony_ci------------
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci最后要做的是创建拉取请求消息。可以使用 ``git request-pull`` 命令让 ``git``
11862306a36Sopenharmony_ci为你做这件事,但它需要确定你想拉取什么,以及拉取针对的基础(显示正确的拉取
11962306a36Sopenharmony_ci更改和变更状态)。以下命令将生成一个拉取请求::
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci	git request-pull master git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/ char-misc-4.15-rc1
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci引用Greg的话::
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci	此命令要求git比较从“char-misc-4.15-rc1”标记位置到“master”分支头(上述
12662306a36Sopenharmony_ci	例子中指向了我从Linus的树分叉的地方,通常是-rc发布)的差异,并去使用
12762306a36Sopenharmony_ci	git:// 协议拉取。如果你希望使用 https:// 协议,也可以用在这里(但是请
12862306a36Sopenharmony_ci	注意,部分人由于防火墙问题没法用https协议拉取)。
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci	如果char-misc-4.15-rc1标记没有出现在我要求拉取的仓库中,git会提醒
13162306a36Sopenharmony_ci	它不在那里,所以记得推送到公开地方。
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci	“git request-pull”会包含git树的地址和需要拉取的特定标记,以及标记
13462306a36Sopenharmony_ci	描述全文(详尽描述标记)。同时它也会创建此拉取请求的差异状态和单个
13562306a36Sopenharmony_ci	提交的缩短日志。
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ciLinus回复说他倾向于 ``git://`` 协议。其他维护者可能有不同的偏好。另外,请注意
13862306a36Sopenharmony_ci如果你创建的拉取请求没有签名标记, ``https://`` 可能是更好的选择。完整的讨论
13962306a36Sopenharmony_ci请看原邮件。
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci提交拉取请求
14362306a36Sopenharmony_ci------------
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci拉取请求的提交方式与普通补丁相同。向维护人员发送内联电子邮件并抄送LKML以及
14662306a36Sopenharmony_ci任何必要特定子系统的列表。对Linus的拉取请求通常有如下主题行::
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci	[GIT PULL] <subsystem> changes for v4.15-rc1
149