git - `git diff --patience` 是做什么用的?

标签 git diff

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

最佳答案

您可以阅读 a post from Bram Cohen ,耐心差异算法的作者,但我发现了this blog post很好地总结了 patience diff 算法:

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:

Find all lines which occur exactly once on both sides, then do longest common subsequence on those lines, matching them up.

什么时候应该使用 patience diff?根据 Bram 的说法,patience diff 对这种情况有好处:

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 - `git diff --patience` 是做什么用的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4045017/

相关文章:

python - 当 git commit-msg Hook 失败时,如何恢复提交消息?

java - 将 "git describe"输出传递给 Java 代码

Python Pandas 条件一阶差分

.net - 是否有用于 .NET 的渲染 HTML 差异引擎

javascript - 有人有渲染 HTML 的差异算法吗?

mysql - 使用 Git Push 的暂存和生产服务器的 Web 开发方案

svn - 将 git-svn 与缺少 .git/svn/的现有仓库一起使用

linux - 比较两个文件并应用差异

algorithm - diff 可以在自己的游戏中被打败吗?

git - 如何让 'git log'默认装饰