TL;DR
When code merges fail in Git, developers face tedious manual conflict resolution. CONGRA introduces the first large-scale, complexity-graded benchmark for evaluating how Large Language Models (LLMs) resolve merge conflicts across four major programming languages. Through 44,948 real-world conflict scenarios, the study reveals surprising phenomena—namely, that LLMs paradoxically struggle more with simpler conflicts and often perform worse when fed naive surrounding context.
What Problem Does This Paper Address?
Traditional version control systems like Git rely on three-way merging ($A - O - B$). When both branches modify the same code region inconsistently, automated merging fails, requiring manual developer intervention.
Existing automated conflict resolution (ACR) approaches have key blind spots:
- Program-analysis tools (e.g., AST-based merging) only handle narrow, language-specific syntactic patterns and still fail on complex edits.
- LLM-based approaches treat code as text and can theoretically resolve any conflict, but there has been no realistic way to evaluate them across different difficulty levels.
- Existing benchmarks are insufficient: The only prior baseline, ConflictBench, contains a mere 180 conflict cases and groups them by simplistic resolution sources rather than actual syntactic/semantic complexity.
Methods
To systematically benchmark LLMs, the authors built the CONGRA evaluation pipeline:
Raw Conflicts (GitHub) ➔ AST Coloring (Tree-sitter) ➔ 7-way Conflict Classifier ➔ Prompting & LLM Eval
- Conflict "Coloring" via Dual Projections: Git conflict markers leave broken, fragmented snippets that standard parsers cannot analyze. CONGRA solves this by constructing two intermediate compilable/parsable files ($M_a$ and $M_b$) that apply edits from branch $A$ and branch $B$ separately.
- Hierarchical Operation Extraction: Using
tree-sitter, CONGRA extracts code operations over the conflicting spans according to a strict priority hierarchy (e.g., Variable Declarations override Function Body Definitions, which override Composite Types). - Complexity Grading (7 Categories): Conflicts are mapped into combinations of three fundamental classes:
- Text (T): Changes involving comments (
CMT). - Functional (F): Modifications to function bodies (
FBD). - Syntax (S): Structural changes affecting variable, type, or prototype declarations (
CTD,FPD,VD,LSO). - Multi-Granular Similarity Evaluation: Instead of brittle exact-string matching, resolutions are deemed correct if any of three normalized metrics exceed 80%: character-level Edit Similarity (ES), token-level Winnowing Similarity (WS), or embedding-based Cosine Semantic Similarity (SS) via
BCEmbedding.
Datasets
The authors created the largest open conflict-resolution benchmark to date:
- 44,948 conflict scenarios extracted from 23,334 files across 34 prominent open-source GitHub repositories (e.g., Linux Kernel, TensorFlow, Pytorch, CPython, Netty, Jenkins).
- Covers four core languages: C, C++, Java, and Python spanning the lifetime of each repository up to June 2024.
Key Insights and Ideas
- Simpler Conflicts Are Harder for LLMs: In an unexpected finding, LLMs performed better on composite, high-complexity conflicts ($T+F+S$) than on isolated, simple conflicts (such as pure comment/text edits $T$). When conflicts involve only text or comments, LLMs receive minimal functional constraints and tend to generate conservative or arbitrary compromises. More complex code changes provide richer contextual clues within the diff block itself.
- Naive Context Often Hurts: Supplying the 100 lines preceding and succeeding a conflict chunk frequently degraded performance compared to providing no surrounding context at all. Real-world code dependencies (types, signatures, variables) often reside far away or in different files; adjacent lines merely introduce distractors.
- General LLMs Match or Beat Specialized Code Models: Models like
Llama3-8BandDeepSeek-V2frequently outperformed dedicated code models likeCodeLlama-7B/34B. Merge conflicts heavily involve natural language intent (variable names, comments, docstrings) where broad language pretraining shines. - Longer Context Windows $\neq$ Better Merge Results: Models boasting ultra-long contexts (e.g.,
GLM-3-turbowith 128K context) trailed an 8K-contextLlama3-8Bby nearly 20% in precision, highlighting that long-context architectures still struggle with needle-in-a-haystack localization for code diffs.
Key Results
Evaluating six primary models (Llama3-8B, DeepSeek-V2, GLM-3-turbo, CodeLlama-7B/34B, DeepSeek-Coder-V1) and modern variants:
- Overall Accuracy & Precision:
- On Java, DeepSeek-V2 reached 84.38% accuracy / 84.40% precision, edging out Llama3-8B (82.93% accuracy / 83.00% precision).
- On Python, Llama3-8B achieved 75.82% accuracy / 77.45% precision, while
GLM-3-turbolagged significantly behind at 57.05% accuracy / 57.31% precision. - State-of-the-Art Comparison (Java, 20 context lines):
- DeepSeek-Coder-V2 ranked highest overall (86.08% accuracy / 86.13% precision), outperforming GPT-4o-mini (83.76% accuracy / 83.82% precision) and Llama3.1-8B (78.07% accuracy / 78.13% precision).
Limitations and Future Work
- Parsing Advanced Language Idioms: Tree-sitter's AST parsing occasionally misses advanced meta-programming patterns (e.g., C++ template instantiation arguments), occasionally misclassifying a syntax conflict as non-syntax.
- Intelligent Context Retrieval: Because fixed window context adds noise, future work should replace adjacent-line dumping with program-slicing or dependency-aware repository retrieval to pull relevant types and references.
Summary updated