验证Git提交仅移动行 [英] Verify that Git commit only moves lines

查看:65
本文介绍了验证Git提交仅移动行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Git是否提供任何机制来证明提交移动但不修改文件中的行?我经常使用-w来确定在缩进更改的代码段中是否进行了任何更改.如果一段代码是垂直移动而不是横向移动,那么有什么办法可以突出显示移动部分中的更改吗?

Does Git provide any mechanism for proving that a commit moves but does not modify lines within a file? I frequently use -w to determine whether any changes were made within a section of code whose indentation changed. If a section of code is moved vertically rather than laterally, is there anything one can do to highlight changes within the moved section?

推荐答案

我不认为Git提供了任何直接的方法,但是如果对文件的旧版本和新版本进行排序会产生相同的结果,则相当于更改仅由移动的线条组成.

I don't think Git provides any direct way of doing this, but if sorting the old and new versions of a file yield the same result, that's equivalent to the change consisting only of moving lines.

当然,在交换两行代码和完全加扰文件之间不会区分开来.

Of course that won't distinguish between swapping two blocks of lines and completely scrambling the file.

强调这种变化是另一回事.我几年前问过的这个问题可能是相关的:

Highlighting such changes is another matter. This question, which I asked several years ago, might be relevant:

是否有类似diff的算法来处理移动的线段?

这篇关于验证Git提交仅移动行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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