gpt4 book ai didi

git - 如何使用 git-diff 显示空格和制表符

转载 作者:IT王子 更新时间:2023-10-29 00:54:43 32 4
gpt4 key购买 nike

我使用 git-diff 得到以下输出。

- // sort list based on value    
+ // sort list based on value

如何轻松查看行尾删除的制表符/空格的数量?

最佳答案

注意:Git 2.5+(2015 年第 2 季度)将提出一个更具体的空白检测选项。

参见 commits 0e383e1 , 0ad782f , 和 d55ef3e [2015 年 5 月 26 日] Junio C Hamano ( gitster ) .
(由 Junio merge 于 commit 709cd91 ,2015 年 6 月 11 日)

diff.c: --ws-error-highlight=<kind> option

Traditionally, we only cared about whitespace breakages introduced in new lines.
Some people want to paint whitespace breakages on old lines, too. When they see a whitespace breakage on a new line, they can spot the same kind of whitespace breakage on the corresponding old line and want to say "Ah, those breakages are there but they were inherited from the original, so let's not touch them for now."

Introduce --ws-error-highlight=<kind> option, that lets them pass a comma separated list of old, new, and context to specify what lines to highlight whitespace errors on.

documentation now includes :

--ws-error-highlight=<kind>

Highlight whitespace errors on lines specified by <kind> in the color specified by color.diff.whitespace.
<kind> is a comma separated list of old, new, context.
When this option is not given, only whitespace errors in new lines are highlighted.

E.g. --ws-error-highlight=new,old highlights whitespace errors on both deleted and added lines.
all can be used as a short-hand for old,new,context.

例如,旧提交有一个空白错误 ( bbb ),但您可以只关注新错误:

old and new shitespace errors

(在 t/t4015-diff-whitespace.sh 之后完成的测试)


更新 Git 2.11+(2016 年第四季度,一年半后):

git config diff.wsErrorHighlight [old,new,context]

git diff/log --ws-error-highlight=<kind>默认情况下缺少相应的配置变量来设置它。这是在 Git 2.11 中添加的。

参见 commit 0b4b42e , commit 077965f , commit f3f5c7f (2016 年 10 月 4 日)作者:Junio C Hamano ( gitster ) .
(由 Junio C Hamano -- gitster -- merge 于 commit e5272d3 ,2016 年 10 月 26 日)

关于git - 如何使用 git-diff 显示空格和制表符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25550582/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com