当前位置: 动力学知识库 > 问答 > 编程问答 >

Why git diff --word-diff shows chunks with no differences?

问题描述:

Reviewing changes is a tedious work. reviewing code changes is even more tedious. When code changes are mixed with indentation changes many people just give up.

I'm talking about thing like this:

- public myMethod(String message, boolean log)

- {

+ public myMethod(String message, boolean log) {

Gived a git develop environment, you can launch a simple test to try existing options to filter those irrelevant changes:

echo "hi world!" > file1

echo "hi world!" > file2

git diff file1 file2 #show a difference with spaces

git diff -w file1 file2 #show there is no real diff (no output, cool!)

git diff -b file1 file2 #same, no real diff

echo -e "hi\nworld!" > file3

git diff file1 file3 #there is a diff

git diff -w file1 file3 # again a diff

git diff --patience file1 file3 #no luck to hide this diff

git diff --minimal file1 file3 #neither

git diff --word-diff file1 file3 #almost! a chunk showing... no diff

git diff --word-diff file3 file1 #same with final file contents from file1

That shows that --word-diff almost get the job done, but the chunks with changes are showed anyway, is there any chances to hide them? See -b or -w hide completely its filtered changes.

I know new lines can change semantics in code, but since I'm talking about reviewing, not merging , this must not be a problem to be concerned with.

By now I'm using filter-word-diff to pollute my diffs before take them a look.

分享给朋友:
您可能感兴趣的文章:
随机阅读: