Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a better diff tool than KDiff3 (moved blocks) ? #4

Closed
robatwilliams opened this issue Sep 13, 2018 · 1 comment
Closed

Is there a better diff tool than KDiff3 (moved blocks) ? #4

robatwilliams opened this issue Sep 13, 2018 · 1 comment

Comments

@robatwilliams
Copy link
Owner

https://stackoverflow.com/questions/572237/whats-the-best-three-way-merge-tool

Especially identifying moved code like git diff --color-moved does.

@robatwilliams
Copy link
Owner Author

robatwilliams commented Jan 20, 2019

There are nicer looking tools, may be even better, but none of them are as capable as git diff for moved block detection.

WinMerge will do it as long as the move is within the same file, and the indentation isn't changed. Neither is often the case with moved blocks while refactoring, so it's not that useful. It's not enabled by default. It'll colour the block in dark orange on both sides.

The following claim or are said to support moved block detection, but didn't do so in my experiments: Code Compare, ExamDiff Pro, Meld. Perhaps they need a block to be longer than one line. I didn't seek out semantic compare tools, although it appears that Code Compare may rely on its semantic features for moved block detection. GitHub doesn't do it either.

The best I've found:

git diff --color-moved --color-moved-ws=allow-indentation-change HEAD^..HEAD

A block needs to be 20 alphanumeric characters long to be detected. The characters don't need to be consecutive, so the line return numerator / denominator; for example is a block of length 26.

Requires Git 2.17.0 for colouring moves, and 2.18.0 for allowing indentation change.

Can be configured to always use these flags:
https://git-scm.com/docs/git-diff#git-diff---color-movedltmodegt
https://git-scm.com/docs/git-diff#git-diff---color-moved-wsltmodesgt

Test cases used for investigation: https://github.com/robatwilliams/diff-hero

@robatwilliams robatwilliams changed the title Is there a better diff tool than KDiff3? Is there a better diff tool than KDiff3 (moved blocks) ? Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant