Understanding Semantic Change Interactions in Merge Conflicts

Understanding Semantic Change Interactions in Merge Conflicts

Abstract

Merge conflicts occur when concurrent changes to a software project cannot be automatically reconciled by a version control system such as Git. A three-way merge provides several concrete artifacts for studying such conflicts: the common ancestor (base), the two conflicting variants (ours and theirs), and the final resolution.

The textual overlap reported by Git does not necessarily imply a semantic conflict. Two branches may modify the same lines while implementing conceptually independent changes, or they may make changes that directly compete, depend on each other, or alter the same behavior in incompatible ways.

This project investigates merge conflicts at this semantic level. It aims to characterize (1) the semantic changes represented by ours and theirs, (2) the relationship between these concurrent changes, and (3) how the final resolution consolidates them. The result should be an empirically grounded taxonomy and an annotated dataset of real-world merge conflicts.

Motivation

A merge conflict is first detected because two branches contain textual edits that Git cannot reconcile automatically. However, the underlying development changes can relate to each other in very different ways.

For example, one branch may migrate a component to a new API while another branch independently extends functionality using the previous API. In this case, the changes are semantically related because one depends on an interface that the other changes.

In another case, one branch may rename a local variable while another adds logging nearby. The edits may overlap textually and therefore trigger a merge conflict, even though the two changes are semantically independent and can both be preserved.

This suggests that a conflict should not be described only by its textual overlap or by a single “conflict cause”. Instead, it can be studied through the following dimensions:

The intended classification should therefore abstract from low-level edit operations such as “line added”, “method renamed”, or “block moved”. The focus is on the semantic meaning of the changes and on the role of the final resolution.

A systematic characterization of these dimensions could improve our understanding of real-world merge conflicts and provide a foundation for future techniques for conflict classification, prediction, and resolution support.

Goal

The goal of this project is to develop an empirically grounded taxonomy for semantic changes, change interactions, and consolidation strategies in merge conflicts.

The following research questions provide an initial focus:

The categories are not intended to be fixed beforehand. They should emerge from the empirical analysis and may be refined as additional conflicts are investigated.

Semantic change types

Possible semantic change types that can serve as initial hypotheses include:

These categories describe the meaning of a change in ours or theirs relative to base. They are not meant to capture simple textual edit patterns.

Change interactions

Possible relationships between the two concurrent changes include:

These are initial working concepts. One important outcome of the study may be to determine how often textual merge conflicts are actually semantically independent changes with only syntactic overlap.

Consolidation strategies

The final resolution can then be characterized by how it consolidates the two concurrent changes. Possible starting categories include:

These consolidation categories should also be treated as hypotheses rather than a prescribed taxonomy.

Example

A conflict can be represented as:

Artifact / DimensionSemantic interpretation
oursmigrates a component to a new API
theirsadds functionality using the previous API
change interactiondependency / adaptation
resolutionadapts the new functionality to the evolved API
consolidation strategyadapt / migrate

A different conflict might look like:

Artifact / DimensionSemantic interpretation
oursrenames a local variable
theirsadds logging around the same statements
change interactionsemantically independent / syntactic overlap
resolutionretains both changes
consolidation strategypreserve both

Possible analysis matrix

One possible result is a matrix of the semantic changes observed in both branches:

ours ↓ / theirsFeatureBug fixRefactoringAPI evolutionConfig / dependencyTests
Feature
Bug fix
Refactoring
API evolution
Config / dependency
Tests

Each populated cell can then be analyzed with respect to the observed interaction types and consolidation strategies. For example, conflicts combining API evolution and feature development might predominantly require adaptation or migration, whereas conflicts involving semantically independent changes might mostly be resolved by preserving both.

The rows, columns, interaction categories, and consolidation categories are all starting points. Their final form is an outcome of the project.

Project Plan

The following plan provides a starting point and can be adapted based on observations made during the project.

1. Sampling and annotation support

An existing dataset of historical merge conflicts and infrastructure for generating HTML reports of individual conflicts are available as starting material. The reports present base, ours, theirs, surrounding source-code context, and the final resolution in a form suitable for manual inspection.

As an engineering component of the project, this infrastructure should be extended with a lightweight tool for sampling, tracking, and documenting the qualitative analysis.

The tool could support:

The goal is not to build a general-purpose annotation platform. The tool should primarily make the empirical study systematic, traceable, reproducible, and easy to revise.

2. Exploratory sample

An initial sample of approximately 20–30 conflicts can be studied in detail using open coding, i.e., by inspecting the cases without a fixed taxonomy and assigning descriptive labels to recurring semantic patterns as they emerge from the data.

For each case, the analysis should examine:

Recurring observations can be grouped into preliminary categories. Each category should be documented with a concise name, a definition, representative examples, and relevant boundary cases.

3. Taxonomy development

The preliminary taxonomies can then be applied to approximately 50–70 additional conflicts.

During this phase, the taxonomy itself is refined iteratively as new conflicts are analyzed. Candidate categories can be adjusted when the observed cases suggest that the current classification does not capture the underlying semantic distinctions well.

Substantial changes to the taxonomy and their rationale should be documented so that its evolution remains traceable and earlier annotations can be revisited consistently.

This phase can also investigate questions such as:

4. Consolidation sample

Once the classification scheme has become reasonably stable, another 30–50 previously unseen conflicts can be analyzed using the consolidated taxonomy.

This phase provides an indication of whether the categories continue to describe cases that were not involved in their development.

A reasonable initial sampling plan is:

PhaseApproximate number of conflicts
Exploratory coding20–30
Taxonomy development50–70
Consolidation30–50
Total100–150

These numbers are planning values rather than strict requirements. Some conflicts may be understood quickly, while others may require substantial investigation of surrounding code or repository history.

To keep the analysis focused, the initial study can concentrate on one programming language. Extending the analysis to additional languages can be considered if time permits.

Analysis and Deliverables

The resulting annotation dataset could contain information such as:

PropertyExample
Semantic change in oursAPI evolution
Semantic change in theirsFeature extension
Change interactionDependency / adaptation
Consolidation strategyAdapt / migrate
Additional modification requiredYes
Required contextConflict and surrounding commit
Classification rationaleFeature adapted to API introduced by the other branch
Confidence / ambiguityMedium

The final analysis can investigate:

The quantitative matrices should be complemented by representative cases and a qualitative discussion of clear, unusual, and ambiguous examples.

The expected project outcomes are:

Requirements

Basic knowledge of Git and software development is expected. Experience with at least one programming language such as Java or Python and basic scripting skills are useful. An interest in empirical software engineering and in systematically understanding source-code changes is important.

Pointers

The following material will be provided as a starting point for the project:

Additional literature on merge conflicts, software evolution, and qualitative taxonomy construction can be identified during the project.

Contact

Manuel Ohrndorf