当提到“提交补丁”时,“补丁”一词到底意味着什么?

发布于 2024-07-06 12:57:50 字数 85 浏览 10 评论 0原文

当提到“提交补丁”时,补丁一词到底是什么意思?

我已经看到它被广泛使用,尤其是在开源世界中。 它是什么意思以及提交补丁到底涉及什么?

What exactly does the word patch mean when referring to 'submitting a patch'?

I've seen this used a lot, especially in the open source world. What what does it mean and what exactly is involved in submitting a patch?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

暖阳 2024-07-13 12:57:50

该文件包含已更改的代码文件之间的差异列表。 它通常采用通过对两个文件执行 diff -u 生成的格式。 大多数版本控制系统都允许轻松创建补丁,但通常采用相同的格式。

这样就可以使用 patch 命令轻松地将代码更改应用于其他人的源代码副本。

例如:

假设我有以下代码:

<?php
  $foo = 0;
?>

我将其更改为:

<?php
  $bar = 0;
?>

补丁文件可能如下所示:

Index: test.php
===================================================================
--- test.php    (revision 40)
+++ test.php    (working copy)
@@ -3,7 +3,7 @@
         <?php
-            $foo = 0;
+            $bar= 0;
         ?>

It's a file with a list of differences between the code files that have changed. It's usually in the format generated by doing a diff -u on the two files. Most version control systems allow the easy creation of patches but it's generally in that same format.

This allows the code change to be easily applied to someone else's copy of the source code using the patch command.

For example:

Let's say I have the following code:

<?php
  $foo = 0;
?>

and I change it to this:

<?php
  $bar = 0;
?>

The patch file might look like this:

Index: test.php
===================================================================
--- test.php    (revision 40)
+++ test.php    (working copy)
@@ -3,7 +3,7 @@
         <?php
-            $foo = 0;
+            $bar= 0;
         ?>
半透明的墙 2024-07-13 12:57:50

Richard Jones 是 Red Hat 的一名开发人员,他有 关于向开源项目提交代码的不错的小入门书,其中包括制作和提交补丁。

Richard Jones, a developer at Red Hat, has a nice little primer on submitting code to open source projects which covers making and submitting patches.

泪冰清 2024-07-13 12:57:50

补丁通常是一个文件,其中包含如何更改某些内容的信息(通常是修复错误,但也可能是增强功能)。 有不同类型的补丁。

源代码补丁包含需要如何修改一个或多个源代码文件的信息。 您可以使用 diff 命令轻松生成它们,并且可以使用 patch 命令应用它们(在 Linux/UNIX 系统上,这些命令是标准的)。

然而,也有二进制补丁。 二进制补丁包含需要如何更改二进制文件中的某些字节的信息。 当然,二进制补丁在开源世界中很少见,但在计算机的早期,我看到它们经常修改已发布的二进制文件(通常是为了解决错误)。

提交补丁意味着您已经在本地修复了某些内容,现在您将文件发送给某人,这样他就可以将此补丁应用到他的本地副本或网络上的公共副本,从而其他用户可以从修复中受益。

如果您有一些几乎可以在某个平台上编译的源代码,但需要进行一些微小的更改才能真正在该平台上进行编译,则也经常使用补丁。 当然,您可以获取源代码,对其进行修改并提供修改后的代码以供下载。 但是,如果原始来源再次发生变化(例如错误得到修复或添加了小的增强功能)怎么办? 然后您必须重新下载源代码,再次应用更改并提供新的修改版本。 要使修改后的源代码保持最新需要做很多工作。 您无需进行修改,而是在原始副本和修改后的副本之间创建一个差异,并将其存储在您的服务器上。 如果现在用户想要从源代码下载并编译应用程序,他可以首先下载最新的和最新的版本。 原始源代码的最大版本,然后应用您的补丁(这样它就会编译)并且始终拥有最新版本,而无需更改补丁。 仅当原始源在您的补丁修改的地方之一被完全更改时才会出现问题。 在这种情况下,系统将拒绝应用补丁,需要制作新的补丁。

A patch is usually a file that contains information how to change something (very often to fix a bug, but could also be an enhancement). There are different kind of patches.

A source code patch contains information how one or multiple source code files need to be modified. You can easily generate them using the diff command and you can apply them using the patch command (on Linux/UNIX systems these commands are standard).

However, there are also binary patches. A binary patch contains information how certain bytes within a binary need to be changed. Binary patches are, of course, rare in the OpenSource world, but in the early days of computers I saw them a lot to modify shipped binaries (usually to work around a bug).

Submitting a patch means you have locally fixed something and now you send the file to someone, so he can apply this patch to his local copy or to a public copy on the web, thus other users can benefit of the fix.

Patches are also often used if you have some source code that almost compiles on a certain platform, but some tiny changes are necessary to really have it compile there. Of course you could take the source, modify it and offer the modified code for download. But what if the original source changes again (e.g. bugs get fixed or small enhancements were added)? Then you had to re-download the source, apply the changes again and offer the new modified version. It's a lot of work to keep your modified source up-to-date. Instead of modifying, you create a diff between the original and your modified copy and store it on your server. If now a user wants to download and compile the app from source, he can first download the latest & greatest version of the original source, then apply your patch (so it will compile) and always has the latest version, without you having to change the patch. A problem will only arise if the original source has been changed exactly in one of the places your patch modifies. In this case the system will refuse to apply the patch and a new patch needs to be made.

初见终念 2024-07-13 12:57:50

补丁是一个文件,包含将维护者的源代码树转换为您自己的源代码树所需的所有信息。 它通常由 diffsvn diffgit format-patch 等工具创建。

传统上,开源项目接受普通 schlub 以补丁形式提交的内容,因此他们不必向其他人授予对其存储库的提交访问权限。

A patch is a file containing all of the necessary information to turn the maintainer's source tree in to your own. It's usually created by tools like diff or svn diff or git format-patch.

Traditionally, open-source projects accept submissions from normal schlubs in the form of patches so they don't have to give others commit access to their repositories.

亣腦蒛氧 2024-07-13 12:57:50

补丁通常采用 .patch 文件的形式,是一种常见的平面文件格式,用于传输两组代码文件之间的差异。 因此,如果您正在开发一个开源项目,并对文件进行代码更改,并希望将其提交给项目所有者进行签入(通常是因为您没有签入权限),您可以通过补丁来完成此操作。

WinMerge 内置了此功能,TortoiseSVN 等许多其他工具也是如此。

A patch, ususally in the form of a .patch file, is a common flat file format for transmitting the differences between two sets of code files. So if you are working on an open source project, and make code changes to files, and want to submit that to the project owner to be checked in (usually because you don't have checkin rights), you would do so via a patch.

WinMerge has this functionality built in, as do many other tools like TortoiseSVN.

无语# 2024-07-13 12:57:50

补丁文件代表现有源和您修改过的源之间的差异。 它是许多项目中添加功能或修复错误的主要方法。

您可以使用 diff 命令创建补丁(例如)。

然后,您可以将此补丁提交到开发邮件列表,如果收到良好,那么提交者将应用该补丁(从而自动应用您的更改)并提交代码。

使用 patch 命令应用补丁。

A patch file represents the difference between existing source and source you've modified. It is the primary means of adding features or fixing bugs in many projects.

You create a patch using the diff command (for example).

You can then submit this patch to the development mailing list and if it received well, then a committer will apply the patch (thus automatically applying your changes) and commit the code.

Patches are applied using the patch command.

酒儿 2024-07-13 12:57:50

一般来说,它意味着提交一个统一的 diff 文件,其中包含某个功能的聚合变更集。 您可以在维基百科上阅读有关补丁的更多信息。 一些版本控制系统(svn、git 等)将根据变更集为您创建补丁文件。

Generally it implies submitting a unified diff file with the aggregate changeset for a feature. You can read more about patches on Wikipedia. Several version control systems (svn, git, etc.) will create a patch file for you based on a changeset.

待天淡蓝洁白时 2024-07-13 12:57:50
 1. n. A temporary addition to a piece of code, usually as a quick-and-dirty

纠正现有的错误或错误功能。 补丁可能有效,也可能无效,并且可能有效,也可能无效
最终永久纳入该计划。 与 diff 的区别
或 mod,因为补丁是通过比其他补丁更原始的方式生成的
计划的内容; 经典的例子是使用前面修改的指令
面板开关,以及直接对程序的二进制可执行文件进行的更改
最初是用 HLL 编写的。 比较单行修复。

请在此处查看行话文件中的完整定义

 1. n. A temporary addition to a piece of code, usually as a quick-and-dirty

remedy to an existing bug or misfeature. A patch may or may not work, and may or may not
eventually be incorporated permanently into the program. Distinguished from a diff
or mod by the fact that a patch is generated by more primitive means than the rest
of the program; the classical examples are instructions modified by using the front
panel switches, and changes made directly to the binary executable of a program
originally written in an HLL. Compare one-line fix.

See the entire definition in the jargon file here

网名女生简单气质 2024-07-13 12:57:50

补丁还用于更新系统二进制文件的行为。 微软一直在发布补丁,但它们不是源代码。 它们是安装改进的二进制文件的 .msp 文件。 与所有计算机科学术语一样,“补丁”一词含义广泛。

Patch is also used in the act of updating system binaries. Microsoft sends out patches all the time but they aren't source code. They are .msp files that install improved binaries. As with all computer science terms, patch is overloaded.

夜司空 2024-07-13 12:57:50

我一直认为这个词意味着错误修复,就像妈妈过去在你的破洞牛仔裤上贴上膝盖补丁一样。

I've always believed the term meant a bug fix, like a knee patch Mom used to put on your holey jeans.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文