Capturing the Context-Aware Code Change via Dynamic Control Flow Graph for Commit Message Generation

Abstract

Commit messages that summarize code changes of each commit in natural language help developers understand code changes without digging into implementation details, thus playing an essential role in comprehending software evolution. In constructing models for automatic commit message generation, prior research has focused on extracting information from the changed code hunks (i.e., code difference), while ignoring the unchanged code hunks (i.e., code context). However, most studies often neglect the fact that the code change is context-aware, that is the semantics of the code difference are heavily dependent on its code context. To take the code context into account, a key challenge arises: the extensive code context may overshadow the minuscule code difference in capturing the changed semantics, which is a disadvantage to commit message generation. In this paper, we propose the dynamic control flow graph (DCFG), which combines both the code contexts and code differences into one dynamic global–local structure. Based on DCFG, we design a novel framework termed capturing the context-aware code change for commit message generation ( ${\text {C}^4\text {MG}}$ C 4 MG ), which attempts to model the changed semantics of the code change based on the relevant code context, while avoiding being misled by the overwhelming amount of unchanged code context. Extensive experiments demonstrate that benefiting from modeling the context-aware code change, ${\text {C}^4\text {MG}}$ C 4 MG outperforms not only the state-of-the-art open-source models but also the large language models (e.g., LLaMA3, GPT-4o, and Gemini) on the commit message generation.

Cite

Text

Du et al. "Capturing the Context-Aware Code Change via Dynamic Control Flow Graph for Commit Message Generation." Machine Learning, 2025. doi:10.1007/S10994-024-06671-3

Markdown

[Du et al. "Capturing the Context-Aware Code Change via Dynamic Control Flow Graph for Commit Message Generation." Machine Learning, 2025.](https://mlanthology.org/mlj/2025/du2025mlj-capturing/) doi:10.1007/S10994-024-06671-3

BibTeX

@article{du2025mlj-capturing,
  title     = {{Capturing the Context-Aware Code Change via Dynamic Control Flow Graph for Commit Message Generation}},
  author    = {Du, Yali and Li, Ying and Ma, Yi-Fan and Li, Ming},
  journal   = {Machine Learning},
  year      = {2025},
  pages     = {94},
  doi       = {10.1007/S10994-024-06671-3},
  volume    = {114},
  url       = {https://mlanthology.org/mlj/2025/du2025mlj-capturing/}
}