ConGra: Benchmarking Automatic Conflict Resolution

Qingyu Zhang, Liangcai Su, Kai Ye, Chenxiong Qian · Submission to ICLR 2025 · Withdrawn

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:

  1. Program-analysis tools (e.g., AST-based merging) only handle narrow, language-specific syntactic patterns and still fail on complex edits.
  2. 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.
  3. 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-8B and DeepSeek-V2 frequently outperformed dedicated code models like CodeLlama-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-turbo with 128K context) trailed an 8K-context Llama3-8B by 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-turbo lagged 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

Abstract

Resolving conflicts from merging different software versions is a challenging task for developers. To reduce the overhead of manual merging, researchers develop various program analysis-based tools which only solve specific types of conflicts and have a limited scope of application. With the development of language models, researchers treat conflict code as text, which theoretically allows for addressing almost all types of conflicts. However, the absence of effective conflict difficulty grading methods hinders a comprehensive evaluation of large language models (LLMs), making it difficult to gain a deeper understanding of their limitations. Furthermore, there is a notable lack of large-scale open benchmarks for evaluating the performance of LLMs in automatic conflict resolution. To address these issues, We introduce ConGra, a CONflict-GRAded benchmarking scheme designed to evaluate the performance of software merging tools under varying complexity conflict scenarios. We propose a novel approach to classify conflicts based on code operations and use it to build a large-scale evaluation dataset based on 44,948 conflicts from 34 real-world projects. We evaluate state-of-the-art LLMs on conflict resolution tasks using this dataset. By employing the proposed dataset, we assess the performance of multiple state-of-the-art LLMs and code LLMs, ultimately uncovering two counterintuitive yet insightful phenomena. ConGra will be released at https://github.com/xxx/ConGra.
BibTeX
@misc{zhang2024congra,
  author = {Qingyu Zhang and Liangcai Su and Kai Ye and Chenxiong Qian},
  title = {{ConGra: Benchmarking Automatic Conflict Resolution}},
  year = {2024},
  eprint = {2409.14121},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.14121},
}

Loading related content...

Figure