git diff algorithm that does not rip functions apart? (language-aware diff)

后端 未结 2 961
南方客
南方客 2020-12-23 19:22

Is it possible to configure git diff to respect indentation and syntax? I am not talking about ignoring indentation and spaces, but rather to use blank lines, indentation le

相关标签:
2条回答
  • 2020-12-23 20:11

    First of all use a more sophisticated diff algorithm like:

    git config --global diff.algorithm histogram
    

    Then there are also semantic diff tools like https://github.com/GumTreeDiff/gumtree whose algorithm has also been implemented in clang-diff: https://github.com/krobelus/clang-diff-playground

    0 讨论(0)
  • 2020-12-23 20:13

    I do not know how to do that in git alone, but there is at least one commercial tool (i.e. it costs money) which deals with that kind of problems, called SemanticMerge.

    It can handle quite a lot of cool cases, and supports C#, Java, and partially C. You can configure git to use it as merge tool.

    (I'm not affiliated.)

    0 讨论(0)
提交回复
热议问题