本文介绍了新的git diff压缩启发式不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 现在已经解决了,感谢@ torek的回答This is solved now, thanks to @torek's answer我需要更多的行高于新增加的内容,以便Git可以向上移动diff'ed块,我的意思是: $ $ p $ code $ + + b + c + + [foo,bar,baz]。 + i + end + [foo,bar,baz]。 i.upcase end I needed to have more lines above the new addition so that Git could move up the diff'ed block, and by that I mean: +a+b+c++["foo", "bar", "baz"].map do |i|+ i+end+ ["foo", "bar", "baz"].map do |i| i.upcase end我使用Git 2.9 Mac OSX 这是一个简化的测试用例: Original Question...I'm using Git 2.9 on Mac OSXHere is a reduced test case:我添加并提交以下内容: $ mkdir git-highlight && cd git-highlight$ touch foo.rbI add and commit the following content:现在我修改文件以获取以下内容内容:["foo", "bar", "baz"].map do |i| i.upcaseendNow I modify the file to have the following content:如果我要运行 git diff 或 git diff --compaction-heuristic 然后我得到以下意外的输出:["foo", "bar", "baz"].map do |i| iend["foo", "bar", "baz"].map do |i| i.upcaseendIf I was to run either git diff or git diff --compaction-heuristic then I get the following unexpected output:如果您从GitHub https://github.com/blog/2188-git-2- 9-has-been-released-我引导我相信我的输出应该看起来更像: diff --git a/foo.rb b/foo.rbindex 9056b22..f0d289a 100644--- a/foo.rb+++ b/foo.rb@@ -1,3 +1,7 @@ ["foo", "bar", "baz"].map do |i|+ i+end++["foo", "bar", "baz"].map do |i| i.upcase endIf you read this blog post from GitHub https://github.com/blog/2188-git-2-9-has-been-released I'm led to believe that my output should look something more like: git的差异化算法更聪明并能够识别块更改。+["foo", "bar", "baz"].map do |i|+ i+end+ ["foo", "bar", "baz"].map do |i| i.upcase end我也尝试将以下内容添加到我的〜/ .gitconfig 但它对结果没有任何影响,我仍然得到了意想不到的结果: The idea being git's diffing algorithm is more intelligent and able to identify the block change.I've also tried adding the following to my ~/.gitconfig but it doesn't make any difference to the outcome, I still get the unexpected output:关于我在这里失踪的任何想法?[diff] compactionHeuristic = true 推荐答案我还没有玩过新的功能,所以这可能需要从一粒盐到一个完整的盐舔,但: b $ b I have not played with the new features yet, so this may need anywhere from a grain of salt to a full salt lick, but:该描述特别指出,git diff hunk被向上移动直至到达空白行。第一行没有空行;如果有的话,这可能就足够了。 (它可能需要更多的高于上下文 - 这不需要是空白的 - 因为规范要在上面和下面包括三行上下文,并且从简要描述中不清楚向上移动是否会受到缺少额外的行。)The description specifically says that git diff hunks are moved up until reaching a blank line. There is no blank line above line 1; if there were, that might suffice. (It might require even more "above" context—which need not be blank—since the norm is to include three lines of context above and below, and it's not clear from the brief description whether the "moving up" will be stymied by the lack of additional lines.) 这篇关于新的git diff压缩启发式不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-02 06:47