Mergiraf: Syntax-Aware Merging for Git
6 months ago
- #merge-conflict
- #syntax-aware
- #git
- Mergiraf is a syntax-aware merge conflict resolver for Git, supporting 33 languages including C, Python, and Rust.
- It uses a generic algorithm with minimal language-specific knowledge to resolve conflicts that Git's default line-based strategy cannot.
- Mergiraf leverages the tree-sitter parsing library to convert code into syntax trees, focusing only on conflicting parts for efficiency.
- The tool can automatically resolve conflicts where changes affect different syntactic elements (e.g., return type vs. argument type) without overlapping.
- In testing with the Linux kernel's merge history, Mergiraf successfully resolved 428 out of 7,415 conflicts that Git's default strategy failed on.
- Mergiraf is written in Rust, licensed under GPLv3, and can be integrated into Git as a merge driver or used manually via the `mergiraf solve` command.
- While not perfect, Mergiraf reduces manual merge effort, especially for obvious conflicts, though users are encouraged to review its resolutions.