为什么移动的代码没有在git diff中着色? [英] why moved code is not colored in git diff?

查看:99
本文介绍了为什么移动的代码没有在git diff中着色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了最新的git并将其配置为突出显示已移动的代码:

I install latest git and configure it to highlight moved code:

$ git config diff.colormoved default

这是代码移动时的外观(请参阅1-> 2)

Here is how it looks when code is moved (see 1->2)

但是3-4不会突出显示为已移动代码.

But 3-4 is not highlighted as moved code.

这是独立的更改:

推荐答案

请参阅git-diff(1)中--color-moved/colormoved的文档:

See the documentation for --color-moved/colormoved in git-diff(1):

--color-moved[=<mode>]

已移动的代码行具有不同的颜色.可以通过diff.colorMoved配置设置进行更改.如果未指定选项,则<mode>默认为no;如果未指定模式,则默认为zebra.该模式必须是以下之一:

Moved lines of code are colored differently. It can be changed by the diff.colorMoved configuration setting. The <mode> defaults to no if the option is not given and to zebra if the option with no mode is given. The mode must be one of:


  • 移动的行未突出显示.

  • no
    Moved lines are not highlighted.

默认
是斑马的同义词.将来可能会更改为更明智的模式.

default
Is a synonym for zebra. This may change to a more sensible mode in the future.

普通
在一个位置添加并在另一位置删除的任何行都将使用color.diff.newMoved进行着色.相似地 color.diff.oldMoved将用于添加的已删除行 差异中的其他地方.此模式拾取任何移动的行,但是 在评论中不是很有用 确定是否移动了代码块而没有排列.

plain
Any line that is added in one location and was removed in another location will be colored with color.diff.newMoved. Similarly color.diff.oldMoved will be used for removed lines that are added somewhere else in the diff. This mode picks up any moved line, but it is not very useful in a review to determine if a block of code was moved without permutation.

斑马
贪婪地检测到至少包含20个字母数字字符的移动文本块.使用以下任一种方法绘制检测到的块 color.diff.{old,new}移动的颜色或 color.diff.{old,new}已移动替代.两者之间的变化 颜色表示检测到一个新块.

zebra
Blocks of moved text of at least 20 alphanumeric characters are detected greedily. The detected blocks are painted using either the color.diff.{old,new}Moved color or color.diff.{old,new}MovedAlternative. The change between the two colors indicates that a new block was detected.

变暗的斑马
与斑马相似,但对移动代码中不感兴趣的部分执行了其他调光.两个相邻块的边界线 被认为很有趣,其余的都没意思.

dimmed_zebra
Similar to zebra, but additional dimming of uninteresting parts of moved code is performed. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting.

具体来说,默认值是zebra并且可以检测到

specifically, that the default is zebra and that it detects

至少20个字母数字字符的移动文本块

Blocks of moved text of at least 20 alphanumeric characters

. my $ctx = shift;至少包含20个字母数字字符.如果您使用git diff --color-moved=plain,或将# ten more ANs添加到该行的末尾,则示例将在移动后突出显示.

. my $ctx = shift; doesn’t contain at least 20 alphanumeric characters. If you use git diff --color-moved=plain, or add # ten more ANs to the end of the line, your example will be highlighted as moved.

这篇关于为什么移动的代码没有在git diff中着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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