为什么此补丁的模糊度为1,而模糊度为0失败? [英] Why does this patch applied with a fuzz of 1, and fail with fuzz of 0?

查看:88
本文介绍了为什么此补丁的模糊度为1,而模糊度为0失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ vim patch
Index: toPatch
===================================================================
--- toPatch
+++ toPatch
@@ -2,4 +2,4 @@
  */
-final public class XMLWriter {
+public class XMLWriter {

$ vim toPatch
 */
final public class XMLWriter {

  public static float CURRENT_VERSION=2.2f;
    $ patch -p0 -ui patch
patching file toPatch
Hunk #1 succeeded at 1 with fuzz 2 (offset -1 lines).

为什么绒毛和线偏移了?这是一个演示案例,试图了解差异和补丁,因为有时(有时)工具似乎无法按预期工作。

Why the fuzz and the line offset? This is a demo case trying to understand diff and patch, since tools sometimes/often don't seem to work as expected.

推荐答案

Patch对diff和文件的一致性进行了一些基本检查,如果这些检查失败,则会产生偏移或模糊

Patch does some basic checking of consistency of the diff and your file, and if these checks fail, you get offset or fuzz.

您已偏移-1,因为patch期望文件的diff匹配行2--4的内容。但是,在您的文件中,它们是1--3行。

You have offset -1, since patch expects the contents of the diff match lines 2--4 of your file. In your file, however, they are lines 1--3.

由于上下文的第一行(两个空格和一个 * / )与实际文件中的行不匹配(一个空格和一个 * / )。因此,patch执行了第二遍操作,忽略了上下文的第一行和最后一行。

You have fuzz>0, since the first line of the context (two spaces and a */) does not match the line in the actual file (one space and a */). Because of that, patch did a second pass where it ignored the first and the last line of the context.

这并不能解释为什么您看到fuzz = 2而不是1.也许复制粘贴文件时出错?还有其他想法吗?

This doesn't explain why you see fuzz=2 and not 1. Maybe an error copy-pasting the files? Any other ideas, anybody?

这篇关于为什么此补丁的模糊度为1,而模糊度为0失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆