afnanenayet / diffsitter

A tree-sitter based AST difftool to get meaningful semantic diffs
MIT License
1.56k stars 29 forks source link

Version Control Merge Conflict Resolution #780

Open nordlow opened 6 months ago

nordlow commented 6 months ago

When will diffsitter be extended to assist git (and vcs'es) in resolving merge conflicts? Will that require an entirely different tool?

afnanenayet commented 6 months ago

That's a good question, I honestly hadn't thought about that before, I understand the utility of it, I've definitely had to deal with some pretty nasty merge conflicts that arose when someone reformatted a codebase.

tl;dr I don't know but I'll think about it and see if I can spec out a plan.

One idea I'd already been mulling over is a source-map type thing that would allow diffsitter to show context before and after a diff but allow you to pick whether you wanted to see the context from the old or new document and I think you'd want to use something similar here where you just see the text from one of the documents and have the tool handle the mapping to the new document for you.

Rodrigodd commented 1 week ago

FYI, Git has a configuration for setting a merge driver (see https://github.com/Praqma/git-merge-driver). But from what I see, it does not help with the implementation. The merge driver just receives the three versions of the file and is fully responsible for merging them, adding merge conflict markers as needed.