An Empirical Investigation into Merge Conflicts and Their Effect on Software Quality

Caius Brindescu, Iftekhar Ahmed, Carlos Jensen, Anita Sarma

Merge conflicts are known to cause extra effort for developers, but little is known about the effect on the software. While some research has been done, many questions remain. To better understand merge conflicts and their impact we conducted an empirical study of the causes, frequency, and impact of merge conflicts, where impact is measured in terms of bug fixing commits associated with conflicts. We analyzed 143 open source projects and found that for 75.23% of conflicts, a developer needs to reflect on the program logic to resolve conflicts, and that almost 1 in 5 merges cause conflicts. We also found code associated with a merge conflict to be twice as likely to have a bug, and code associated with semantic merge conflicts 26x more likely to have a bug.

Merge conflict classification

We manually classified 600 randomly sampled commmits. We then trained a classifier to classify our corpus of 6,979 conflicting commits. The categories are presented in the table below:

CategoryDefinitionComplexityExample
SemanticConflicts involving two conflicting semantic changesNon-trivial
DisjointUnrelated semantic changes overlapping in linesNon-trivial
DeleteA change and a deleteNon-trivial
FormattingConflicting changes in formattingTrivial
CommentsConflicting changes in commentsTrivial
OtherConflicts that do not belong to any of the aboveTrivial

Classification features

This sections details the features that were used to classify commits based on their root cause (Section 3.2.1 in the paper.)

FeatureDetails
AST_A_SIZEThe total number of AST Nodes of the files involved in a conflict, in one branch
LOC_A_SIZEThe sum of LOC of the files involved in a conflict, in one branch
AST_B_SIZEThe total number of AST Nodes of the files involved in a conflict, in the other branch
LOC_B_SIZEThe sum of LOC of the files involved in a conflict, in the other branch
CONFLICTING_AST_A_TO_BThe difference between the two branches, considering only the conflicting region, in AST nodes
CONFLICTING_AST_A_TO_SOLVEDThe difference between one of the branches and the solved version, in AST nodes
CONFLICTING_AST_B_TO_SOLVEDThe difference between the other branch and the solved version, in AST nodes
CONFLICTING_LOC_A_TO_BThe number of lines difference between the two branches, considering only the conflicting region, in LOC
CONFLICTING_LOC_A_TO_SOLVEDThe number of lines difference between one of the branches and the solved version considering only the conflicting region, in LOC
CONFLICTING_LOC_B_TO_SOLVEDThe number of lines difference between the other branch and the solved version, in LOC
LOC_SIZE_SOLVEDThe size of the resolved merge conflict
AST_A_TO_BThe number of lines difference between the two branches, in AST nodes
NO_AUTHORSThe number of authors involved in that particular merge
LOC_DIFFThe difference between the two branches, in LOC, before the merge
AST_DIFFThe difference between the two branches, in AST nodes, before the merge
MERGED_IN_MASTERTrue if the branch was merged into master
TIME_SOLVEDThe time of the resolution
TIME_AThe timestamp of the last commit on one of the branches
TIME_BThe timestamp of the last commit on the other branch
NO_STATEMENTSThe number of statements involved in a conflict
NO_METHODSThe number of methods involved in a conflict
NO_CLASSESThe number of classes involved in a conflict
DIFF_NODES_A_TO_BA set of node types involved in a conflict
IS_AST_CONFLICTTrue, if the conflict happens at the AST level (concurrent modifications to the same AST node)

Classification results

The figure below shows the confusion matrix for our classifier.

Corpus

The table below shows the corpus we used for our paper.

ProjectLast commitClone URL
ActionBarSherlock2c71339e756bcc0b1424c4525680549ba3a2dc97https://github.com/JakeWharton/ActionBarSherlock.git
Activiti72981d6070b409ab5184a9401fb9f7851a659ef2https://github.com/Activiti/Activiti.git
aipo0a9e9491e2146043601b7462b8dac81471f1db53https://github.com/aipocom/aipo.git
androidannotations7b7a55ebacb58e26988a2f8f8adf0eb6e0b56d2fhttps://github.com/excilys/androidannotations.git
android-bootstrap2905ac2a2f4bae2e9684b798e2ade14c5afd9d34https://github.com/donnfelker/android-bootstrap.git
android-flipab2dea1b045ffc626221c2826ce9dd00823e696dhttps://github.com/openaphid/android-flip.git
android-viewflow3da74fa32a935bcbb37e5ebeb270477cde1985d4https://github.com/pakerfeldt/android-viewflow.git
antlr459676745319b864fe3b8fd61710e730e760f5afdhttps://github.com/antlr/antlr4.git
astrid4fc5c7714fb1b48ae46dcacbda287bcef9c3f6bfhttps://github.com/todoroo/astrid.git
atlas-feeds602a1df271fb2873c11aff26506429ede5613b82https://github.com/atlasapi/atlas-feeds.git
atlas-model7307e326838addaff161b3be836d65c2892b6a74https://github.com/atlasapi/atlas-model.git
atlas-persistence95c437d36ed9555a6afe95442fd04b36cacca664https://github.com/atlasapi/atlas-persistence.git
autopsy5cd50e9aec71479803e5ee149d5dac5bbd7c7ed5https://github.com/sleuthkit/autopsy.git
BallCraft4bf32ffa4f80f669c8300c7d28cc22dae7f34445https://github.com/COMP3111H-Project-Team/BallCraft.git
beamce738053d525f8ce729a9455267f89381a685446https://github.com/bcdev/beam.git
bioformats4d0f6757bed4e9b219ee9bfac575f1e924d9a2b9https://github.com/openmicroscopy/bioformats.git
blueprints70b35dc90a11602b03afe8e0862f8a0836b34c13https://github.com/tinkerpop/blueprints.git
Bukkitf210234e59275330f83b994e199c76f6abd41ee7https://github.com/Bukkit/Bukkit.git
bundlemakerf8d12fbc5927268b7fb817a5bf970a1f2ef2c0e3https://github.com/wuetherich/bundlemaker.git
butterknife6ab6fb5e98a9da8eeaecc4f8917f06adbc8b67a7https://github.com/JakeWharton/butterknife.git
candlepin1f073f1092225b8472323d351e123d4235785d30https://github.com/candlepin/candlepin.git
capedwarf-blue6aca5dd1eb9eb31a9c70c73bdcbed608b2c49022https://github.com/capedwarf/capedwarf-blue.git
cat99ffe1660bb08e04c4c20f0f77a39f9686149622https://github.com/dianping/cat.git
cloudname61fd8d5790d9be894a87b463fad4e69cd94f76e0https://github.com/Cloudname/cloudname.git
cms-cea779b00f26685175aaedb4cd4ea5a561e4f9198ehttps://github.com/enonic/cms-ce.git
commafeed6a699ed5f16fa22852cdb16cb49a908d3473c1dfhttps://github.com/Athou/commafeed.git
commandhelperb8dcdb78b67896f234d698072e829287dbed9c7dhttps://github.com/sk89q/commandhelper.git
CONNECT80cf7475c697414ce3e42e39014c85d52abbdd84https://github.com/CONNECT-Solution/CONNECT.git
coreaef5f83225b5c2a255c4a01f385a4795ce853d17https://github.com/forge/core.git
cse40324e2467c91b75d3384fffae14d91e17e3c001a65https://github.com/coldstar96/cse403.git
cucumber-jvm0aecc4d3e4c15fc34b63f848043deba2c230e35fhttps://github.com/cucumber/cucumber-jvm.git
droidplannerdcf1988852fdf144927ce53453888ce4c350d78chttps://github.com/arthurbenemann/droidplanner.git
DSpace61ac9371b2714f57f4c96470b077eb37ed6b8c9chttps://github.com/DSpace/DSpace.git
dynmap20320c578f89d0d8e41ff992afbf2f60dff3bb65https://github.com/webbukkit/dynmap.git
ecmsc4479a220d78f2f1ec09888cd770d3fd1cd512efhttps://github.com/exoplatform/ecms.git
elasticsearch3bd33f839fd293611810ee8d79be4358213dbc52https://github.com/elasticsearch/elasticsearch.git
elephant-bird61f3a8f1ba939b4fe1d43d76be181af7b5e55c51https://github.com/kevinweil/elephant-bird.git
ENdoSnipe129b66087cd31cb1548b842b897febc3dfb405dchttps://github.com/endosnipe/ENdoSnipe.git
fitnesse893ce6be6606bbe2312a4716008280baec3fd989https://github.com/unclebob/fitnesse.git
flowvisor30fbc0628b4bb3ccba187a8ce4dedeb23f35a670https://github.com/OPENNETWORKINGLAB/flowvisor.git
FML1d627656b890ee9ae530687c16a2c288570b4386https://github.com/MinecraftForge/FML.git
furry-octo-avenger37da50bacb62469be3f4423817c0a03f554509d7https://github.com/iuval/furry-octo-avenger.git
GeoGite92012ff85bc8f6dc99350ad1e774b82f9f95e42https://github.com/opengeo/GeoGit.git
geoserver89d535a96ac16d220e7d2600fd384f04afada7bchttps://github.com/geoserver/geoserver.git
gerrit-trigger-plugin3e31f724712d5a6f43605f18f601ca0d18d63423https://github.com/jenkinsci/gerrit-trigger-plugin.git
ggc-connect1aac49202e35f4fd1565aefa0f7d9a80c3b0e172https://github.com/ggc-itec/ggc-connect.git
gitblit252dc07d7f85cc344b5919bb7c6166ef84b2102ehttps://github.com/gitblit/gitblit.git
glidedf0856b32383237fdbb672849a20dee9c73c2193https://github.com/bumptech/glide.git
graylog2-serverd47836bc8fad6422d9334820137cfb4e8b76b413https://github.com/Graylog2/graylog2-server.git
groovy-core01309f9d4be34ddf93c4a9943b5a97843bff6181https://github.com/groovy/groovy-core.git
gwt-bootstrap3d595bdfabc52c4f682fac5e27bfad7f694c15aehttps://github.com/gwtbootstrap/gwt-bootstrap.git
gxac507f08f46545be97e9b90bc00123600a67f23a1https://github.com/gxa/gxa.git
hankbe0f1b83a038ac167f3c574a1b4c2ddf8a69db98git://github.com/LiveRamp/hank
hazelcast3b4c1c5c2b7c1bc27a37d59cf7597e711f9b8487https://github.com/hazelcast/hazelcast.git
head88e7df964688ca3955b38125213090297d4171a4https://github.com/mifos/head.git
hectora302e68ca8d91b45d332e8c9afd7d98030b54de1https://github.com/hector-client/hector.git
hit9caac9c7288627ae384e8fb2c347ff847ce3017chttps://github.com/CS340Group/hit.git
HoloEverywhereb870abb5ab009a5a6dbab3fb855ec2854e35e125https://github.com/Prototik/HoloEverywhere.git
hornetqfdc19ebf7e456571860ec229a504bf73a2b4cb8dhttps://github.com/hornetq/hornetq.git
Hydra2c9039f25e41ee872c30add7021361d77d6330dehttps://github.com/Findwise/Hydra.git
jackson-dataformat-protobuf1b7fe15db7e13d72235c326bce65468bb75c0e90git://github.com/FasterXML/jackson-dataformat-protobuf
jackson-datatype-joda373b2b76b5ffd10fad6eb78f14e6401badd1814cgit://github.com/FasterXML/jackson-datatype-joda
jade4ja95bac357b4bbedd6ed829ba131133571f1310b9git://github.com/neuland/jade4j
JavaBeanstalkClient971e094639c384caa29937b6b793574c03cefd33git://github.com/RTykulsker/JavaBeanstalkClient
java-driver7d7047fc78507eeb6ebb1b582eaec036461b5658https://github.com/datastax/java-driver.git
javapoet34cfcdf973527ec0f3149d868e55d6600802bf9dhttps://github.com/square/javapoet.git
Java-WebSocket58d17786958ec2b629b75de1eed00915b3e4f7c4https://github.com/TooTallNate/Java-WebSocket.git
jbosstools-openshift40ce9fca876ec7138e0277ff62965275816b2c1ahttps://github.com/jbosstools/jbosstools-openshift.git
jbosstools-vpe85ef65ceba8e900351156afa60178e5abe8617fbhttps://github.com/jbosstools/jbosstools-vpe.git
JGroups565fa123057e966efb19f24d43975cf8ab13ceedhttps://github.com/belaban/JGroups.git
jnae7809ac26d9f1e5034600608d7818b0750eedbfahttps://github.com/twall/jna.git
jobConfigHistory-plugin9fb6df23e3786f45e96ecf38e500c883a6a935d6git://github.com/jenkinsci/jobConfigHistory-plugin
jots4c88c256cadf0da27be1e092044bf3bea5c0623dgit://github.com/sparhami/jots
jsoup1dec69d8df78aee955205d8ae8bed0dfe86056f8https://github.com/jhy/jsoup.git
k-97e43b5848412ad7c0b5a20c578c55eea0aa337d8https://github.com/k9mail/k-9.git
karma-exchange0e5c24e972c0c0b2c71dc2246352e1c60a589536https://github.com/karma-exchange-org/karma-exchange.git
katello-apia3b8078dc093e397bd09cf289d38368eb8e8cd5ehttps://github.com/gkhachik/katello-api.git
LogisticsPipesf2ea777c1dc240fab2a5698e9e0bd593fbb96fc8https://github.com/RS485/LogisticsPipes.git
lombok07b8af4cc5c844c9e085e2c4662df1d08221e710https://github.com/rzwitserloot/lombok.git
maven-android-plugin74044942cc35f4e60f80f8d8c42a1c4ec4698363https://github.com/jayway/maven-android-plugin.git
mercurial-plugin207888ccba25ed53fd0ea151f96e0dfe79e81cdfgit://github.com/jenkinsci/mercurial-plugin
mgwt375a318a53baf7083282c241c4f751a41ae19e0bgit://github.com/dankurka/mgwt
mifosx97587d90198e8a32c7a3d7f11d4ffa9423971392https://github.com/openMF/mifosx.git
MinecraftForge728319cbb5b3f2691d135a109d10f56f4f601abbhttps://github.com/MinecraftForge/MinecraftForge.git
MineFactoryReloaded68c87a84c0bacb1da2e00bbbe339964a3d451971https://github.com/powercrystals/MineFactoryReloaded.git
mobile-android5bb3383768bc1f417f077472b5a17ad03ae516dchttps://github.com/photo/mobile-android.git
modeshapeaa80376d183e944d39648f3ecc2a14ee3edb3a2fhttps://github.com/ModeShape/modeshape.git
molgenis0de67cf2ffe6ac6d032aa9b387b1dc35035f6ae5https://github.com/molgenis/molgenis.git
mondrian671c9df2558677a55d0b3b8ca7efffdcbcc571cfhttps://github.com/pentaho/mondrian.git
mongo-java-serverc121b5b82f2c0effa768961a7dc2ee7523253c92git://github.com/bwaldvogel/mongo-java-server
MonsterIRCe2eaafe47758b86577ce7027aef7b66c2df615f6https://github.com/Monstercraft/MonsterIRC.git
MSLoggerBase8fa875675a7460033c4e9feac23d5ba4ef096d16https://github.com/scudderfish/MSLoggerBase.git
mulee0a0141b1d4dd43be4afa748d312a1af07655699https://github.com/mulesoft/mule.git
narayana5b5b975bdcdba94d1efc5122639ccddee048ab48https://github.com/jbosstm/narayana.git
neo4j4fe03c55acce5f3e1ba8ffefddaafa340a760b2ehttps://github.com/neo4j/neo4j.git
nettyd66cf2cbfa604048543594a7ab96bb78d1607186https://github.com/netty/netty.git
nexuscd395952d84ebb786f39418699c5b921abde3e85https://github.com/sonatype/nexus.git
nexus-oss6b57b79c00de5287d8f7dc71f1f04c818c07865bhttps://github.com/sonatype/nexus-oss.git
nifty-guiae1721052558ba6e30b8624e16443ec803ed085ehttps://github.com/void256/nifty-gui.git
objectos-dojob3f91a4507b625908a362726b5eb77d4c77d7bechttps://github.com/objectos/objectos-dojo.git
OpenCCSensors98759c7d5fb5b62a31f4e3aa85cbc93028a5295fhttps://github.com/Cloudhunter/OpenCCSensors.git
openengsb-frameworkd39058000707f617cd405629f9bc7f17da7b414ahttps://github.com/openengsb/openengsb-framework.git
openmicroscopy3d60c26ddd1574bfb21f702bb20a756585a5d767https://github.com/openmicroscopy/openmicroscopy.git
OpenTripPlanner56111502763f28f391cdca41120c958843d96105https://github.com/openplans/OpenTripPlanner.git
Operation-Valkyried652dbb6eed764898de35bd0b27b5c6d7b15cde9https://github.com/MiloTischler/Operation-Valkyrie.git
Paintroidf18cfde5952b725f9382c7e364dbb2007fd0cddehttps://github.com/Catrobat/Paintroid.git
patientview248520f2a2e4b3fc1c8f36622b92bf2d02ba0b47https://github.com/robworth/patientview.git
pentaho-platform748c021b0e70b8c3f7a3564eac50b3a42ded38f8https://github.com/pentaho/pentaho-platform.git
pentaho-reporting6e34562dd2aba77e4e57efbbca021a028f906e46https://github.com/pentaho/pentaho-reporting.git
PermissionsEx0fe4ee81198499366af2cd9e39333431c1a15de6git://github.com/PEXPlugins/PermissionsEx
phoenix5e49d5f940f9dbd2538fb890f0cc6697068c74achttps://github.com/forcedotcom/phoenix.git
picassoebce0a70c446b32c6fd7a6f0c5bde595925ecca1https://github.com/square/picasso.git
picketlinkc91f1c1e0a62dbe2fe7af5e107e0ac6f177848abhttps://github.com/picketlink/picketlink.git
Priame0bbaabfa61ab258f5d49c77c7417d232bde57bahttps://github.com/Netflix/Priam.git
quickstart1ce1c381b0563f19f1ca16bc2beab1b587fcaab6https://github.com/jbosstm/quickstart.git
realtalk7478dffde69c2cf91afa2d3b8c154e557ec4ef28https://github.com/realtalk403/realtalk.git
reddeer0ca7dabe5d8b568e1f22570b3eb46e89f17f29dehttps://github.com/jboss-reddeer/reddeer.git
retrofitd41d49c5d1e7f09d8062b2521c70b858f6037edfhttps://github.com/square/retrofit.git
riak-java-client3daaccea0127c68d3b8deaf0b9d685e85b801358https://github.com/basho/riak-java-client.git
rultor978ad592342d970ac1ef94347b93603a1e4f8dc9https://github.com/rultor/rultor.git
RxJavaf8e2136b51ec2c90097087de3f6edd09664f3600https://github.com/Netflix/RxJava.git
seqwarec0f048e12d1c872b0914cb48f347f8b3f8d5f5dahttps://github.com/SeqWare/seqware.git
services45a49b49ad7a373fe677b8fc004068c7e3ac33fdhttps://github.com/collectionspace/services.git
Silverpeas-Componentsa878a97df977e854012f99423fa80de45bd99362https://github.com/Silverpeas/Silverpeas-Components.git
snap-desktopb4ff1a3f95ca331028b732859ccb9971ed8e499fhttps://github.com/senbox-org/snap-desktop.git
springside450f76a2e82bbcc97665d320350aa0ead9bbc101bhttps://github.com/springside/springside4.git
s-rampa188b187d8aaa18a6169689a858f95f2c84af7eahttps://github.com/Governance/s-ramp.git
ssGWT-libb7676731b333a45b31f5dbba1209792c899a5425https://github.com/A24Group/ssGWT-lib.git
stripe-java889c7c7496436d9630c58efba5cb32d343321b0bgit://github.com/stripe/stripe-java
SynapseWebClient033ad3d04942e0930978c6d277f6f3d3bd3a6cfahttps://github.com/Sage-Bionetworks/SynapseWebClient.git
systemsgenetics42f79a58b9b0d6ac7c9c23a6ec9be2d14e98b00ehttps://github.com/molgenis/systemsgenetics.git
Tardisd3a48632f8536d4cf784faadb0a4801291fc00f5https://github.com/The-Dream-Team/Tardis.git
testdroid-apied872736b42e12177b7f5e0ee1d6cec8cedcb68chttps://github.com/bitbar/testdroid-api.git
tregmineb158025d55f891d4b1da30dc2ecde20170f4266bhttps://github.com/EmilHernvall/tregmine.git
udig-platformf445aae1f9dfc24e81d5f4e123caee5dd889bd5chttps://github.com/uDig/udig-platform.git
UniversalMediaServer82e4b11034c5272bb26c6f90687c4dbdd9f61ee7https://github.com/UniversalMediaServer/UniversalMediaServer.git
Vanillabc064f0dc283febcaf925103c931532f150e2bc3https://github.com/VanillaDev/Vanilla.git
vInsert696e5fb4652c14576aa0ca33e14208eb4989022chttps://github.com/vInsertOfficial/vInsert.git
vraptor6c36b008e24857075df380e27463b2097b1a146bhttps://github.com/caelum/vraptor.git
vraptor4d1120f10825d888cc8d94625b44074e27b9b745ehttps://github.com/caelum/vraptor4.git
webbitdb3b359cbad0cb75cc05d769a1eb260d3cedf038git://github.com/webbit/webbit
worldguard93d454c6754db402b4eb64c21876fac3de397193https://github.com/sk89q/worldguard.git
xmemcached7eb86628226e5893d8a002ed6cf0f5d9a354c6b9git://github.com/killme2008/xmemcached
xwiki-platform0cf2898507eeddb2906b736427c5c39acdffe773https://github.com/xwiki/xwiki-platform.git
yogad98f6b0b2b60ff195cc6878ed54e515e639bc9dahttps://github.com/skyscreamer/yoga.git
zanata-server82975460dc387eac9cadcc931483ea8c9281dd21https://github.com/zanata/zanata-server.git
ZooTypers6aa777d921ebe1042e625b9b8e1ca7b0be629f8dhttps://github.com/ZooTypers/ZooTypers.git
zt-zip2e80860ea7aace6413ad5601ef83e166ed4b531fgit://github.com/zeroturnaround/zt-zip