什么是`git diff --patience`? [英] What is `git diff --patience` for?

查看:97
本文介绍了什么是`git diff --patience`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

耐心算法与默认的 git diff 算法有什么不同,我何时想使用它?

How does the patience algorithm differ from the default git diff algorithm, and when would I want to use it?

推荐答案

您可以阅读来自Bram Cohen的一篇文章,耐心差异算法的作者,但我发现这篇博客文章总结了耐心差异算法:

You can read a post from Bram Cohen, the author of the patience diff algorithm, but I found this blog post to summarize the patience diff algorithm very well:


耐心相反,Diff将精力集中在作为文本中重要内容的标记或签名的低频高内容线上。它的核心仍然是基于LCS的差异,但有一个重要的区别,因为它只考虑签名行中最长的公共子序列:
$ b

Patience Diff, instead, focuses its energy on the low-frequency high-content lines which serve as markers or signatures of important content in the text. It is still an LCS-based diff at its core, but with an important difference, as it only considers the longest common subsequence of the signature lines:



$ b $查找所有在两侧只出现一次的行,然后在这些行上执行最长的常见子序列,并将它们匹配起来。 b

您应该何时使用耐心差异?根据Bram的说法,耐心差异对于这种情况是有好处的:

When should you use patience diff? According to Bram, patience diff is good for this situation:


非常糟糕的情况是两个版本分歧
而且开发人员不会小心地控制补丁大小
。在这些情况下,差异算法偶尔可能会使
变成未对齐,因为它会将大部分大括号
放在一起,但是它会将
一个版本中的大括号函数与
其他版本中下一个函数的花括号。这种情况非常丑陋,并且可能导致完全
不可用的冲突文件,在这种情况下,您最需要的是
这样的内容。

The really bad cases are ones where two versions have diverged dramatically and the developer isn't being careful to keep patch sizes under control. Under those circumstances a diff algorithm can occasionally become 'misaligned' in that it matches long sections of curly brackets together, but it winds up correlating the curly brackets of functions in one version with the curly brackets of the next later function in the other version. This situation is very ugly, and can result in a totally unusable conflict file in the situation where you need such things to be presented coherently the most.

这篇关于什么是`git diff --patience`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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