<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Ward Muylaert</string-name>
          <email>ward.muylaert@vub.be</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Coen De Roover</string-name>
          <email>coen.de.roover@vub.be</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Software Languages Lab, Vrije Universiteit Brussel</institution>
          ,
          <addr-line>Brussels</addr-line>
          ,
          <country country="BE">Belgium</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>-Version control systems (VCS) are widely used to manage the history of code bases. These histories in turn provide opportunities for research. Researchers expect the commits in these version control systems to be atomic. That is, each commit performs one task. This is however not always the case. To remedy this, we propose a commit untangling technique using program slicing. In particular, we posit that all related changes are part of the same program slice. To do so, we perform program slicing on changes. Preliminary results using intra-procedural slicing have proven to be encouraging. We are currently working on expanding our work to be inter-procedural.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>I. INTRODUCTION</title>
      <p>
        Version control systems (VCS) are widely used to manage
the history of code bases. Prominent examples include Git,
SVN, or Mercurial. A developer may “save” their changes
into units called commits. Best practice suggests each commit
should only contain changes related to one task. Such commits
are called atomic commits [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. In this manner, the version
control system can be used to keep track of how the program
under development evolves. The version control system can
also be applied to, for example, revert individual changes
or port changes to other versions of the code base. On the
research side, version control systems provide a trove of
software evolution information open to analysis.
      </p>
      <p>
        However, developers do not necessarily follow the best
practice of creating only atomic commits [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. For example,
a small bug may be quickly fixed while working on another
feature and placed in the same commit. Floss refactoring is
another problem: refactoring in order to implement a new
feature. These situations make for larger commits in which
many unrelated changes are tangled together. Such commits
are called tangled commits.
      </p>
      <p>
        Tangled commits occur on a regular basis. A study by
Herzig et al. found that up to 15% of Java bug fixes contain
tangled changes [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. Tao et al. found that between 17% and
29% of investigated revisions were tangled [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. Nguyen et
al. found that 11% to 39% of all the fixing commits used for
mining archives were tangled [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
      </p>
      <p>
        Tangled commits lead to problems on many fronts. We
provide four examples. A developer will have problems reverting
particular changes if they are a part of a bigger commit.
A developer may also have problems integrating particular
changes from another developer if the desired change is part of
many different changes in a tangled commit. A code reviewer
will have a harder time understanding larger commits of
unrelated changes [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ]. This in turn will lead to lower quality
feedback [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. A researcher interested in historical analysis,
finally, will need to decide on the “one” function of a commit
even though many unrelated changes may be present in the
commit.
      </p>
      <p>
        In light of these difficulties, we propose an automated
commit untangling technique. Our technique employs program
slicing around changes. Program slicing is a technique to
answer questions about the influence of program statements
on other program statements [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ], [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]. We extend this idea.
We posit that all related changes are part of the same program
slice. Thus, a commit may be untangled by means of the
created slices. A preliminary implementation of our technique
performs intra-procedural slicing. Despite this limitation, early
results are encouraging. We are currently in the process of
expanding the implementation to work on an inter-procedural
level.
      </p>
    </sec>
    <sec id="sec-2">
      <title>II. ARCHITECTURE</title>
      <p>Our technique consists of four major parts. First, the commit
is distilled into fine-grained changes to the program’s abstract
syntax tree (AST). Second, a program dependence graph of the
program is created. Third, a slice of the program dependence
graph is produced for every fine-grained change. Finally,
changes are grouped by means of the slices and the commit is
partitioned accordingly. We have implemented our technique
to work on Java programs. The rest of this section provides
further detail into each of the four steps.</p>
      <p>
        For the first step, we make use of ChangeNodes [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
ChangeNodes works on the AST of a Java program. Given
two versions of a program, ChangeNodes provides a list of
Insert, Update, Move, and Delete operations. In our case the
two versions are the version before and the version after the
commit under analysis. Applying the obtained list of changes
to the AST of the earlier version results in the AST of the
later version. ChangeNodes thus provides fine-grained changes
describing the commit.
      </p>
      <p>
        For the second step, we make use of TinyPDG [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ],
[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. TinyPDG creates a program dependence graph (PDG) of
a Java program. TinyPDG does this intra-procedurally. Our
main motivation for choosing TinyPDG is that it makes use of
Eclipse libraries to create the underlying AST. ChangeNodes
also employs the Eclipse libraries for this purpose. This makes
it more straightforward to link these two parts together.
      </p>
      <p>
        In the third step, our technique performs forward and
backward slicing on the program dependence graph. This is
done for every distilled fine-grained change obtained in step
one. Thus for every change ci a slice S(ci) is obtained.
We implemented the intra-procedural slicing algorithm as
described by Horwitz et al. [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] on top of the PDG created by
TinyPDG. The algorithm by Horwitz et al. performs backward
slicing. We adjusted the algorithm so that it also performs
forward slicing. When we refer to slicing, we consider the
combination of forward and backward slicing.
      </p>
      <p>Finally, our technique considers the following relation R
between changes. Changes ci and cj are related (notation:
ciRcj ) if and only if ci 2 S(cj ) _ cj 2 S(ci). By definition
of how slicing works, this relation is reflexive. The relation
is also clearly symmetric due to its symmetric definition. The
relation is however not necessarily transitive. We cannot state
that if ciRcj and cj Rck, then ciRck. Consider for this the
following simplified situation. cj is part of the root node of a
PDG with two children. ci is part of one of the child nodes. ck
is part of the other child node. Slicing in this situation results in
S(ci) = {ci, cj }, S(cj ) = {ci, cj , ck}, and S(ck) = {cj , ck}.
Then ciRcj and cj Rck, but ¬(ciRck). The relation R is thus
not an equivalence relation. Instead, we partition the set of
changes into subsets by means of the following steps.
1) If a change is not in relation with any change in any
of the existing subsets, create a new subset with that
change in it.
2) If a change is in a relation with (an) element(s) of exactly
one existing subset, place the change in that subset.
3) If a change is in a relation with two (or more) elements
of different subsets, join the subsets together and add
the change to it.</p>
      <p>The last step fakes transitivity and effectively “widens” the
relation R: more changes are considered related than they
would be by our original definition of R. In terms of these
subsets, we rephrase our hypothesis as: A commit is atomic
if and only if our technique does not split up the commit into
different subsets of changes.</p>
    </sec>
    <sec id="sec-3">
      <title>III. EVALUATION</title>
      <p>
        To evaluate our hypothesis, we make use of a dataset of
five Java programs as used by Herzig et al. in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. The
programs in question are: ArgoUML, GWT, Jaxen, JRuby,
and Xstream. These projects were chosen for meeting certain
quality criteria. For each of the projects, Herzig et al. manually
identified atomic commits using commit and issue information.
Using the atomic commits, Herzig et al. also created artificial
tangled commits for each of the projects.
      </p>
      <p>We used this dataset to perform a preliminary evaluation of
our hypothesis and technique. This preliminary evaluation has
one obvious limitation. Due to the current implementation of
our technique being intra-procedural, only atomic and tangled
commits affecting just one method could be analysed. This
limits the number of commits that can be analysed, the large
majority of commits cover more than one method. In the case
of the Jaxen project, no commits are left to be analysed. This
limitation will be solved by our (current and) future work in
which we are expanding the implementation to work
interprocedurally. The setup of our evaluation will remain the same
for the inter-procedural evaluation.</p>
      <p>We apply our technique to every atomic and tangled commit
affecting just one method. We consider three separate
outcomes for the analysis of a commit, regardless of it being
atomic or tangled.</p>
      <p>1) The commit is correctly identified as atomic or tangled.</p>
      <p>Our technique and the dataset agree on what kind of
commit it is.
2) The commit is not correctly identified. Our technique
identified the commit as atomic/tangled while the dataset
calls the commit tangled/atomic respectively.
3) No result. This happened when the memory overhead
made the analysis crash. We have not yet played around
with this overhead in order to solve or analyse it.</p>
      <p>In the case of atomic commits, the results are promising.
For each of the projects except JRuby, the ratio of correctly
analysed atomic commits is larger than 90%. For JRuby nearly
20% of commits could not be analysed. Incorrectly identified
commits happened largely through statements like throw or
catch not being supported by TinyPDG.</p>
      <p>Our technique falters on certain types of tangled
commits. Except for the GWT project, more tangled commits
were incorrectly identified as atomic than they were correctly
identified as tangled. However, the large majority of these
incorrect identifications are due to formatting changes or
changes to comments. Our technique does not take formatting
nor comments into account, only code. As such, a commit
handling both one code related task and one formatting task
would be classified as tangled in the dataset, but identified as
atomic by our technique.</p>
    </sec>
    <sec id="sec-4">
      <title>IV. FUTURE WORK</title>
      <p>We are currently in the process of making the
implementation of our technique inter-procedural. To do so, we need to
make two major changes.</p>
      <p>
        First, our program dependence graph needs to consider the
entire program. Rather than a procedure dependence graph, we
require a system dependence graph (SDG) or class dependence
graph (ClDG). To achieve this, we need to extend TinyPDG to
work inter-procedurally. The main hurdle here is creating the
summary edges via the algorithm as described in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. These
are necessary to avoid the calling context problem as described
there.
      </p>
      <p>
        Second, our slicer needs to be adjusted to work on the
interprocedural system dependence graph. These adjustments are
also described by [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
      </p>
      <p>Once our implementation works inter-procedurally, we will
perform the evaluation described in section III again.</p>
      <p>V. CONCLUSION</p>
      <p>We wanted to untangle commits performing more than
one task. For this, we considered the hypothesis that related
changes belong to one and the same program slice. We created
a first implementation to test this hypothesis. This
implementation works intra-procedurally. Despite this limitation, initial
results are promising. Incorrect identifications happen largely
either due to parts of the program our implementation does
not handle (e.g., throw statements) or due to formatting and
comment changes which our technique does not consider. We
are currently working on expanding the implementation of our
technique to work inter-procedurally. Once this is done, we
will redo the evaluation with the complete dataset.</p>
    </sec>
    <sec id="sec-5">
      <title>ACKNOWLEDGMENT</title>
      <p>Ward Muylaert is an SB PhD fellow at FWO, project
number 1S64317N.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>A.</given-names>
            <surname>Bacchelli</surname>
          </string-name>
          and
          <string-name>
            <given-names>C.</given-names>
            <surname>Bird</surname>
          </string-name>
          , “Expectations, outcomes, and challenges of modern code review,
          <source>” in International Conference on Software Engineering (ICSE)</source>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>M.</given-names>
            <surname>Dias</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Bacchelli</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Gousios</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Cassou</surname>
          </string-name>
          , and
          <string-name>
            <given-names>S.</given-names>
            <surname>Ducasse</surname>
          </string-name>
          , “
          <article-title>Untangling fine-grained code changes</article-title>
          ,
          <source>” in International Conference on Software Analysis, Evolution, and Reengineering (SANER)</source>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>K.</given-names>
            <surname>Herzig</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Just</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Zeller</surname>
          </string-name>
          , “
          <article-title>The impact of tangled code changes on defect prediction models,” Empirical Software Engineering</article-title>
          , vol.
          <volume>21</volume>
          , no.
          <issue>2</issue>
          , pp.
          <fpage>303</fpage>
          -
          <lpage>336</lpage>
          , Apr.
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>K.</given-names>
            <surname>Herzig</surname>
          </string-name>
          and
          <string-name>
            <given-names>A.</given-names>
            <surname>Zeller</surname>
          </string-name>
          , “Untangling changes,”
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Higo. Tinypdg</surname>
          </string-name>
          :
          <article-title>A library for building intraprocedural pdgs for java programs</article-title>
          . [Online]. Available: https://github.com/YoshikiHigo/TinyPDG
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Higo</surname>
          </string-name>
          and
          <string-name>
            <given-names>S.</given-names>
            <surname>Kusumoto</surname>
          </string-name>
          , “
          <article-title>Enhancing quality of code clone detection with program dependency graph</article-title>
          ,” in Working Conference on Reverse Engineering,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7] --, “
          <article-title>Code clone detection on specialized pdgs with heuristics</article-title>
          ,
          <source>” in European Conference on Software Maintenance and Reegineering</source>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>S.</given-names>
            <surname>Horwitz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Reps</surname>
          </string-name>
          , and
          <string-name>
            <given-names>D.</given-names>
            <surname>Binkley</surname>
          </string-name>
          , “
          <article-title>Interprocedural slicing using dependence graphs</article-title>
          ,
          <source>” ACM Transactions on Programming Languages and Systems</source>
          , vol.
          <volume>12</volume>
          , no.
          <issue>1</issue>
          , pp.
          <fpage>26</fpage>
          -
          <lpage>60</lpage>
          , Jan.
          <year>1990</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>M.</given-names>
            <surname>Konopka</surname>
          </string-name>
          and
          <string-name>
            <given-names>P.</given-names>
            <surname>Navrat</surname>
          </string-name>
          , “
          <article-title>Untangling development tasks with software developer's activity</article-title>
          ,” in
          <source>2015 IEEE/ACM 2nd International Workshop on Context for Software Development, May</source>
          <year>2015</year>
          , pp.
          <fpage>13</fpage>
          -
          <lpage>14</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>H. A.</given-names>
            <surname>Nguyen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. T.</given-names>
            <surname>Nguyen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T. N.</given-names>
            <surname>Nguyen</surname>
          </string-name>
          , Electrical, Computer, and E. Department, “
          <article-title>Filtering noise in mixed-purpose fixing commits to improve defect prediction and localization</article-title>
          ,” in
          <source>International Symposium on Software Reliability Engineering (ISSRE)</source>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>J.</given-names>
            <surname>Silva</surname>
          </string-name>
          , “
          <article-title>A vocabulary of program slicing-based techniques,” ACM Computing Surveys</article-title>
          , vol.
          <volume>44</volume>
          , no.
          <issue>3</issue>
          ,
          <string-name>
            <surname>Jun</surname>
          </string-name>
          .
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>R.</given-names>
            <surname>Stevens</surname>
          </string-name>
          and
          <string-name>
            <surname>C. De Roover</surname>
          </string-name>
          , “
          <article-title>Extracting executable transformations from distilled code changes</article-title>
          ,
          <source>” in International Conference on Software Analysis, Evolution and Reengineering</source>
          ,
          <year>2017</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Tao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Dang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Xie</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Zhang</surname>
          </string-name>
          , and S. Kim, “
          <article-title>How do software engineers understand code changes? - an exploratory study in industry</article-title>
          ,” in
          <source>International Symposium on the Foundations of Software Engineering (FSE)</source>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Tao</surname>
          </string-name>
          and
          <string-name>
            <given-names>S.</given-names>
            <surname>Kim</surname>
          </string-name>
          , “
          <article-title>Partitioning composite code changes to facilitate code review</article-title>
          ,
          <source>” in International Conference on Mining Software Repositories (MSR)</source>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>M.</given-names>
            <surname>Weiser</surname>
          </string-name>
          , “Program slicing,” in
          <source>International Conference on Software Engineering (ICSE)</source>
          ,
          <year>1981</year>
          , pp.
          <fpage>439</fpage>
          -
          <lpage>449</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>