- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我需要一种自动方式来向配置文件添加一行。我使用 diff
创建了一个 .diff 文件,我想用 patch
应用它。但是,我需要修补的文件可能会在其他地方稍作修改。例如。在配置文件的其他地方添加了一些其他行。
我假设 patch
实际上会对此很聪明,并弄清楚补丁是否仍然可以在没有冲突的情况下应用,但是每当我尝试将补丁应用到配置文件时我都会收到错误消息与原始文件略有不同。
我是否需要将任何其他标志传递给 patch
或 diff
以使其不那么严格?我正在使用
diff -ruN oldfile.conf newfile.conf > mypatch.diff
然后使用打上补丁
patch myconfig.conf mypatch.diff
我想要的是补丁将尝试相当自由地应用补丁,如果它不知道如何应用,则只返回警告,而不是错误。目前我看到这些错误:
jeroen@jeroen-ubuntu:~/Desktop$ diff -ruN default.conf default_new.conf > mypatch.diff
jeroen@jeroen-ubuntu:~/Desktop$ patch default2.conf mypatch.diff
patching file default2.conf
Hunk #1 FAILED at 28.
1 out of 1 hunk FAILED -- saving rejects to file default2.conf.rej
jeroen@jeroen-ubuntu:~/Desktop$
最佳答案
I assumed that patch would actually be smart about this and figure out if the patch could still be applied without conflicts, but I am getting an error whenever I try to apply the patch to a config file that is slightly different from the original file.
其实是这样的。但是,这在很大程度上取决于您对“略有不同”的定义。基本上,更改需要远离补丁修改的地方。
您可以尝试使用 -F
参数调用 patch
-F num or --fuzz=num
Set the maximum fuzz factor. This option only applies to diffs that have context, and causes patch to ignore up to that many lines of con- text in looking for places to install a hunk. Note that a larger fuzz factor increases the odds of a faulty patch. The default fuzz fac- tor is 2. A fuzz factor greater than or equal to the number of lines of context in the context diff, ordinarily 3, ignores all context.
但我不建议这样做。
只要你想
an automated way to add a line to a configuration file
您是否考虑过使用 perl
、awk
或 ed
来完成这项工作?我认为 patch
不是适合它的工具。
关于linux - 补丁对差异文件过于严格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10657102/
最近我遇到了 AngularJS Strict DI 模式。使用它的目的和好处是什么?通过在移动设备上使用它,我们会获得显着的性能提升吗? 我尝试将它应用到我的代码中,并且在编写代码时我没有做任何注释
要在复制文本的底部添加额外信息 - 我想使用以下 JS: document.addEventListener('copy', (event) => { const pagelin
Java 是否有一个好的、严格 的日期解析器?我可以访问 Joda-Time,但我还没有看到这个选项。我发现了“Is there a good date parser for Java”这个问题,虽然
在下面的网页中,图像和 div 之间有几个像素的间隙。 (我已经在 Firefox 3 和 Safari 4 中测试过。) 我怎样才能缩小差距? body { background-color:
前段时间我遇到了一个“问题”,但我一直没有弄清楚。希望有人能照亮它。当我将 DOCTYPE 从严格更改为过渡时,是什么导致某些浏览器(Chrome、Opera 和 Safari)以不同方式呈现页面。我
PHP 以其类型杂耍而闻名。我必须承认这让我很困惑,而且我很难在比较中找出基本的逻辑/基本内容。 例如:如果 $a > $b 为真且 $b > $c 为真,是否意味着 $a > $c总是也是真的吗?
有在ECMAScript Language Specification11.9.1 等于运算符 (==): NOTE 3 The equality operator is not always tra
考虑这些不同的尝试,比如 last : Prelude> import Data.Foldable Prelude Data.Foldable> foldr const undefined (reve
我正在考虑使用 jQuery 元数据插件。看起来很有趣,但是... ... alert($('li.someclass').metadata().some); 这段代码有效吗? 更新 当然这是一个老例
我有一个 CSS 文件,我的本地开发服务器(webpack)正在提供一个显然错误的 mime 类型。 Refused to apply style from 'http://localhost:100
因此对于 Google Chrome 和 Opera,cookie 具有 SameSite 属性,该属性可以具有以下两个值之一:strict 或 lax。 它们之间的一些区别之一是 SameSite=
我试图到处寻找这个问题的答案,但似乎我运气不好。 我有一个非常简单的 Mongoose 模型 var userObject = { profile: { username: {
我正在为必须使用 XHTML 1.0 Strict 进行验证的类编写程序。根据 w3 的验证程序,我的页面通过了验证。我还有一个 HTML5 版本(这是原始版本),它可以按应有的方式进行验证和工作。
我得到了很多 validation errors因为 在 里面。如果我删除 br 标签,那么它工作正常。 为什么会产生问题? 最佳答案 不是br在p里面,而是你没有结束 br与 /特点。你有 在代码中
好吧,这让我抓狂。 我想在我的文档周围加上边框。它应该很好地绕过整个窗口/视口(viewport)。所以我定义: body { border: 1px solid red; } 当我的文档处于 q
我在 MySql 服务器上运行的查询遇到问题。这是查询: SELECT itms.Gender,itms.Age, (CASE WHEN (plv.Discount = 0 OR t1.EverGre
我有以下 javascript 函数,如果所有必填字段都不完整并且是我使用 Google Apps 脚本创建的表单的一部分,它会阻止表单提交。请注意,#submitbutton 实际上是一个常规按钮,
我是一名优秀的程序员,十分优秀!