如何获取git-blame并记录以忽略换行?

时间:2011-10-23 07:07:22

标签: git

我想要一个更改日志和一个非常注释,它会忽略换行中的更改。例如......

-This is the hardest part of testing, where do you start?  People often
-get overwhelmed at the apparent enormity of the task of testing a
-whole module.  Best place to start is at the beginning.  Date::ICal is
-an object-oriented module, and that means you start by making an
-object.  So we test C<new()>.
+This is the hardest part of testing, where do you start?  People often get
+overwhelmed at the apparent enormity of the task of testing a whole module.
+The best place to start is at the beginning.  C<Date::ICal> is an
+object-oriented module, and that means you start by making an object.  Test
+C<new()>.

那里的内容变化很少,但是日志和责备会显示所有内容都发生了变化。这使得补丁难以检查,并妨碍了检查代码年龄的工具。

-w不足。

更新:我得到了一半答案:git log -p --word-diff涵盖了日志记录。

2 个答案:

答案 0 :(得分:0)

你几乎必须编写自己的差异工具。默认情况下在Git中使用的diff工具(以及大多数差异工具,就此而言)都是逐行的差异,这些差异无法实现你想要的效果。

答案 1 :(得分:0)

从git v1.4.3开始,您可以使用diff选项--color-words来显示内联更改,忽略换行符,例如:

git log -p --color-words

由于git 1.7.2有更通用的--word-diff选项,它也可以输出类似的内联差异,但用纯文本而不是用颜色标记差异。

据我所知,git blame无法做到这一点。

相关问题