Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
0e3d985
fixed: missing toString() in VariationLabel
piameier Jul 24, 2025
3e04daf
Merge pull request #168 from piameier/fix-variation-label
pmbittner Jul 24, 2025
afd99b4
feat: prepare `DiffNode` for storing `endif` lines
eugen-shulimov Oct 26, 2024
4bed4b5
feat: prepare `VariationTreeNode` for storing `endif` lines
eugen-shulimov Oct 26, 2024
22d5dea
feat: add a getter for the `endif` line in `VariationNode`
eugen-shulimov Oct 26, 2024
b694ce5
fix: handle `endif` lines in deep copies of variation trees
eugen-shulimov Oct 26, 2024
02f7340
feat: create an unparser for variation trees
eugen-shulimov Oct 28, 2024
e9fb7c5
feat: store `endif` lines when parsing variation diffs
eugen-shulimov Oct 30, 2024
92b9247
feat: create an unparser for variation diffs
eugen-shulimov Nov 1, 2024
e2934fe
feat: create a method that projects text diffs
eugen-shulimov Nov 2, 2024
2c18279
refactor: move some code for readability
eugen-shulimov Nov 4, 2024
a8f5306
test: create tests for VariationUnparser
eugen-shulimov Nov 7, 2024
af4eb0f
feat: create a dataset for my bachelor thesis
eugen-shulimov Nov 27, 2024
5408c72
feat: create an experiment for testing the unparser
eugen-shulimov Nov 27, 2024
b5a2a8c
fix: fix the analysis in the unparser experiment
eugen-shulimov Nov 28, 2024
870b76a
feat: change the dataset of the unparse experiment
eugen-shulimov Dec 3, 2024
5bdb8f1
feat: change some things in the analysis
eugen-shulimov Dec 5, 2024
efb4b2c
feat: add error reporting to UnparseAnalysis
pmbittner Dec 5, 2024
dee62f8
fix: store endifs depending on the time
eugen-shulimov Dec 21, 2024
dd54859
test: add an example of failing to unparse
eugen-shulimov Dec 21, 2024
e312978
fix: add new lines to the unparsed code
eugen-shulimov Dec 21, 2024
f743e2c
feat: rework the unparse experiment evaluation
eugen-shulimov Dec 21, 2024
53b82e1
test: add a test for comparing unparsed diffs semantically
eugen-shulimov Dec 21, 2024
ff46999
fix: fix removeWhitespace for diffs
eugen-shulimov Feb 10, 2025
6ac3440
test: fail tests if an exception is thrown
ibbem Aug 9, 2025
d18386f
test: use asserts instead of manually checking stdout
ibbem Aug 9, 2025
0a35f62
test: remove unnecessary wrappers around unparser
ibbem Aug 9, 2025
b9fa82b
test: reuse directory constants in the unparsing tests
ibbem Aug 9, 2025
bb59058
test: improve the variable names in the unparse tests
ibbem Aug 9, 2025
79b0a27
test: factor out duplicate code in the unparser tests
ibbem Aug 9, 2025
6bcde64
test: make all unparser test helper methods private
ibbem Aug 9, 2025
84e5eab
test: refactor the unparser test case sources
ibbem Aug 9, 2025
69b406f
test: split different parse options into separate unparse tests
ibbem Aug 9, 2025
a8065d9
fix: fix a bug in the variation diff `endif` parsing
ibbem Aug 10, 2025
0db0fdd
refactor: directly pass the time to popIfChain in the diff parser
ibbem Aug 10, 2025
9c91b08
docs: improve some JavaDoc comments related to unparsing
ibbem Aug 10, 2025
fbd6f3c
refactor: refactor VariationUnparser.undiff
ibbem Aug 10, 2025
68d8131
refactor: rename the unparse methods
ibbem Aug 10, 2025
9de8a26
refactor: remove duplicated tree unparsing code
ibbem Aug 10, 2025
cbf504b
fix: fix `Show.baddiff`
ibbem Aug 11, 2025
c860a88
fix: always preserve the child order in `BadVDiff`
ibbem Aug 11, 2025
de10f75
refactor: store `endif`s in the label
ibbem Aug 10, 2025
bf6f5fb
fix: preserve the projection when splitting a `DiffNode`
ibbem Sep 4, 2025
f22b3cd
feat: let `DiffNode` take a `VariationLabel` on construction
ibbem Sep 4, 2025
fd60dfb
refactor: use `char` instead of `String` in `DiffSymbol`
ibbem Sep 4, 2025
5e35c9c
Merge pull request #169 from VariantSync/unparse
pmbittner Sep 4, 2025
41a23ef
chore(deps): bump org.apache.commons:commons-lang3 from 3.17.0 to 3.18.0
dependabot[bot] Aug 26, 2025
467a523
Merge pull request #170 from VariantSync/dependabot/maven/org.apache.…
pmbittner Sep 8, 2025
e855e58
fix: Typos in VariationDiff and TreeView Javadoc
pmbittner Sep 23, 2025
3d8f9cf
fix: remember label type in TreeView::tree(t, r)
pmbittner Sep 23, 2025
f4fdaec
feat: VariationDiff::computeAllFeatureNames()
pmbittner Sep 23, 2025
6a5fb11
test: VariationDiff::computeAllFeatureNames()
pmbittner Oct 2, 2025
a78ad1b
refactor: import FixTrueFalse.Formula in Configure
pmbittner Sep 23, 2025
f3675f0
feat: configurations from formula assignments
pmbittner Sep 23, 2025
2762ab9
Merge pull request #173 from VariantSync/variant-generation
pmbittner Oct 2, 2025
5758264
fix: use the correct child order in line graph exports
ibbem Aug 12, 2025
fc22f32
refactor: refactor the time dependent fields in `DiffNode`
ibbem Aug 11, 2025
d5e8141
refactor: remove state cleanup in the diff parser
ibbem Aug 11, 2025
ef6a1dc
refactor: use a switch for `GraphFormat`
ibbem Aug 11, 2025
9cc672e
test: create tests for `GumTreeDiff.improveMatching`
ibbem Sep 29, 2025
ee71f32
test: fix the DiffTreeParser tests for non-GumTree matchers
ibbem Feb 13, 2025
2809c3a
refactor: remove a duplicated `splitNode` implementation
ibbem Aug 13, 2025
1f24ebc
refactor: simplify `GumTreeDiff.joinNode`
ibbem Aug 13, 2025
2b20e33
refactor: move `joinNode` into `DiffNode`
ibbem Aug 13, 2025
f4e6850
fix: respect trailing lines when matching variation trees
ibbem Sep 29, 2025
99a34f4
fix: don't join syntactically different `DiffNode`s
ibbem Sep 30, 2025
411944b
fix: assign `after` line numbers in GumTreeDiff
ibbem Sep 30, 2025
3af8b1b
fix: let GumTreeDiff update the line numbers in the labels
ibbem Sep 30, 2025
2a95d11
test: activate incidentally solved won't fix tests
ibbem Aug 13, 2025
2fe0989
refactor: eliminate superfluous `try`
ibbem Mar 18, 2023
fca3a9c
docs: note that the diff parser does not require stacks
ibbem Sep 25, 2025
f2e36e2
docs: add a disclaimer to `LineGraphImport`
ibbem Sep 25, 2025
64f242c
Merge pull request #171 from VariantSync/refactorings
ibbem Oct 7, 2025
207aa53
delete deprecated ViewTest
pmbittner Oct 13, 2025
ed7ff62
feat: Label::observablyEqual
pmbittner Oct 13, 2025
dedd98b
feat: DiffNode::isSameAsIgnoringLineNumbers
pmbittner Oct 13, 2025
312ff2e
feat: VariationDiff:isSameAsIgnoringLineNumbers
pmbittner Oct 13, 2025
66e0970
fix: some typos in VariationTreeNode documentation
pmbittner Oct 13, 2025
99f9df5
feat: specification for Configure
pmbittner Oct 13, 2025
a51ad75
docs: refine documentation on Relevance::computeViewNodesCheckAll
pmbittner Oct 13, 2025
9f2c50d
fix: Configure falsely removed ELSE and ELIF nodes
pmbittner Oct 13, 2025
48f93b4
test: new tests for Views
pmbittner Oct 13, 2025
8c63c20
refactor: extract Transformer super interface ...
pmbittner Oct 20, 2025
9dfbfb2
VariationTreeTransformer interface
pmbittner Oct 20, 2025
fa62e30
VariationTreeNode::setFormula
pmbittner Oct 20, 2025
6b2bcb0
feat: traversing variation trees in post-order
pmbittner Oct 20, 2025
a48b4fd
feat: DiffNode::stealChildrenOf at time
pmbittner Oct 20, 2025
fd0d96e
fix: VariationNode::stealChildrenOf
pmbittner Oct 20, 2025
1939f50
feat: EliminateEmptyAlternatives transformer
pmbittner Oct 20, 2025
7f70843
fix: javadoc error in Transformer.java
pmbittner Oct 20, 2025
db2fccf
fix: javadoc error in EliminateEmptyAlternatives
pmbittner Oct 20, 2025
710b946
README: Note on where to find code of L. Güthing
pmbittner Oct 21, 2025
50b7ed3
README: bachelor's thesis of Eugen Shulimov
pmbittner Oct 21, 2025
79f1f43
README: section on supported diff algorithms
pmbittner Oct 21, 2025
5f0b1fb
README: update commuting diagram
pmbittner Oct 21, 2025
7daeff0
fix: VariationNode::stealChildrenOf once again
pmbittner Oct 24, 2025
28b0e4b
Update README.md
pmbittner Oct 26, 2025
d103bdf
Update README.md
pmbittner Oct 26, 2025
047df57
Merge pull request #175 from VariantSync/update-readme
pmbittner Oct 26, 2025
2c6d651
Simplify Assertion in Configure
pmbittner Oct 26, 2025
8197880
remove boilerplate Variation(Tree|Diff)Transformer
pmbittner Oct 26, 2025
7e0365b
DiffNode::makeUnchanged()
pmbittner Oct 27, 2025
ddd4289
feat: HideSomeChanges
pmbittner Oct 27, 2025
551a1b6
fix: bug + alignment in DiffNode::makeUnchanged
pmbittner Oct 28, 2025
02804e5
feat: IndexFormat
pmbittner Oct 28, 2025
6a2c992
support IndexFormat in GUI
pmbittner Oct 28, 2025
df8bc7d
refactor: reuse `VariationNode.assertConsistency` in `DiffNode`
ibbem Oct 30, 2025
da90378
feat: assert that there is at most one ELIF/ELSE
ibbem Oct 30, 2025
282258d
feat: assert that the root `DiffNode` is unchanged
ibbem Oct 30, 2025
9f43cc9
feat: `VariationTree.assertConsistency`
ibbem Oct 30, 2025
0094462
Merge pull request #177 from VariantSync/assert-at-most-one-else
pmbittner Nov 3, 2025
23698b8
refactor: improve the source tracing mechanism
ibbem Oct 23, 2025
952464f
feat: improve the source tracking to reduce `Source.Unknown`
ibbem Oct 24, 2025
d78f3e8
feat: create an interface for and a collection of differs
ibbem Oct 13, 2025
b3aad00
fix: close `ZipFile` in `GitLoader`
ibbem Oct 23, 2025
de79247
doc: fix a typo in `VariationDiffLabelFormat`
ibbem Oct 23, 2025
574bfcb
fix(README): path to visual abstract
pmbittner Nov 3, 2025
d728ec6
remove unused symlink
pmbittner Nov 3, 2025
75be10f
StringUtils::getLeadingWhitespace
pmbittner Nov 3, 2025
1d227f5
fix: EliminateEmptyAlt. making inconsistent labels
pmbittner Nov 3, 2025
1fb58fa
Merge pull request #176 from VariantSync/diff-interface
pmbittner Nov 3, 2025
02ae9a3
Merge branch 'develop' into fix-configure
pmbittner Nov 5, 2025
a991942
fix: ConfigureSpec vs new Source interface
pmbittner Nov 5, 2025
2ee3a19
Merge pull request #174 from VariantSync/fix-configure
pmbittner Nov 5, 2025
6f93366
Source::functionExplanation
pmbittner Nov 6, 2025
7b9be89
make VariationTree a class instead of a record
pmbittner Nov 6, 2025
c325359
VariationTree::setSource
pmbittner Nov 6, 2025
a3511e1
make ViewSource applicable to trees as well
pmbittner Nov 6, 2025
3cd7a2a
fix: relevance not treated as source in ViewSource
pmbittner Nov 6, 2025
41d5e18
ViewSource::toString()
pmbittner Nov 6, 2025
d6134de
use functionExplanation for VDiff/Vtree::toString
pmbittner Nov 6, 2025
97bad80
make BadVDiff be a source
pmbittner Nov 6, 2025
741dc20
document TreeView as a source
pmbittner Nov 6, 2025
7ebde4d
rename: VariationTree::root() -> VariationTree::getRoot()
pmbittner Nov 6, 2025
c141a7a
use functionExplanation in Show titles
pmbittner Nov 6, 2025
5f8961c
increase version number to 2.4.0
pmbittner Nov 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

DiffDetective is an open-source Java library for variability-aware source code differencing and the **analysis of version histories of software product lines**. This means that DiffDetective can **turn a generic differencer into a variability-aware differencer** by means of a pre- or post-processing. DiffDetective is centered around **formally verified** data structures for variability (variation trees) and variability-aware diffs (variation diffs). These data structures are **generic**, and DiffDetective currently implements **C preprocessor support** to parse respective annotations when used to implement variability. The picture below depicts the process of variability-aware differencing.

<img alt="Variability-Aware Differencing Overview" src="docs/teaser.png" height="500" />
<img alt="Variability-Aware Differencing Overview" src="src/main/java/org/variantsync/diffdetective/variation/diff/doc-files/variability-aware-differencing.png" height="500" />

Given two states of a C-preprocessor annotated source code file (left), for example before and after a commit, DiffDetective constructs a variability-aware diff (right) that distinguishes changes to source code from changes to variability annotations. DiffDetective can construct such a variation diff either, by first using a generic differencer, and separating the information (center path), or by first parsing both input versions to an abstract representation, a variation tree (center top and bottom), and constructing a variation diff using a tree differencing algorithm in a second step.

Expand Down Expand Up @@ -80,6 +80,18 @@ Additionally, there is a screencast available on YouTube, guiding you through th
[![DiffDetective Demonstration](docs/yt_thumbnail.png)](https://www.youtube.com/watch?v=q6ight5EDQY)


## Supported Differencing Algorithms

In principle, any generic differencing algorithm (i.e, any algorithm that may operate on text or trees) can be made variability-aware with DiffDetective, as explained in our demo paper (see below). Some algorithms are integrated directly in the DiffDetective library, while others come as additional Maven projects.

### Shipped with DiffDetective
- Git Diff as implemented by [JGit](https://github.com/eclipse-jgit/jgit)
- [GumTree](https://github.com/GumTreeDiff/gumtree), and all algorithms and matching engines supported by the GumTree library

### Extra Modules
- [TrueDiff](https://gitlab.rlp.net/plmz/truediff): Support for TrueDiff comes as [a separate Maven project](https://github.com/VariantSync/TrueDiffDetective).


## Publications

### Variability-Aware Differencing with DiffDetective (FSE 2024, ⭐ [Best Demo Paper](https://2024.esec-fse.org/info/awards) ⭐)
Expand Down Expand Up @@ -167,9 +179,10 @@ Edge-typed variation diffs and the replication package are implemented in a fork

DiffDetective was extended and used within bachelor's and master's theses:

- _Unparsing von Datenstrukturen zur Analyse von C-Präprozessor-Variabilität_, Eugen Shulimov, Bachelor's Thesis, 2025, [DOI 10.17619/UNIPB/1-2385](http://doi.org/10.17619/UNIPB/1-2385), (german): Eugen added an unparser for variation trees, essentially inverting the horizontal arrows in our commuting diagram at the top of this README file. The unparser for variation diffs reuses the unparser for variation trees by projecting a variation diff to its two variation trees (before and after the change), unparsing the trees, and then diffing the obtained text files to eventually compute a text-based diff.
- _Constructing Variation Diffs Using Tree Diffing Algorithms_, Benjamin Moosherr, Bachelor's Thesis, 2023, [DOI 10.18725/OPARU-50108](https://dx.doi.org/10.18725/OPARU-50108): Benjamin added support for tree-differencing and integrated the GumTree differencer ([Github](https://github.com/GumTreeDiff/gumtree), [Paper](https://doi.org/10.1145/2642937.2642982)). In his thesis, Benjamin also reviewed a range of quality metrics for tree-diffs with focus on their applicability for rating variability-aware diffs. The [org.variantsync.diffdetective.experiments.thesis_bm](src/main/java/org/variantsync/diffdetective/experiments/thesis_bm) package implements the corresponding empirical study and may serve as an example on how to use the tree-differencing.
- _Reverse Engineering Feature-Aware Commits From Software Product-Line Repositories_, Lukas Bormann, Bachelor's Thesis, 2023, [10.18725/OPARU-47892](https://dx.doi.org/10.18725/OPARU-47892): Lukas implemented an algorithm for feature-based commit-untangling, which turns variation diff into a series of smaller diffs, each of which contains an edit to a single feature or feature formula. This work was later refined in our publication _Views on Edits to Variational Software_ illustrated above.
- _Inspecting the Evolution of Feature Annotations in Configurable Software_, Lukas Güthing, Master's Thesis, 2023: Lukas implemented different edge-types for associating variability annotations within variation diffs. He published his work later at VaMoS 2024 under the title _Explaining Edits to Variability Annotations in Evolving Software Product Lines_, illustrated above.
- _Inspecting the Evolution of Feature Annotations in Configurable Software_, Lukas Güthing, Master's Thesis, 2023: Lukas implemented different edge-types for associating variability annotations within variation diffs. He published his work later at VaMoS 2024 under the title _Explaining Edits to Variability Annotations in Evolving Software Product Lines_, illustrated above. His work can be found in a [fork][forklg] of DiffDetective.
- _Empirical Evaluation of Feature Trace Recording on the Edit History of Marlin_, Sören Viegener, Bachelor's Thesis, 2021, [DOI 10.18725/OPARU-38603](http://dx.doi.org/10.18725/OPARU-38603): In his thesis, Sören started the DiffDetective project and implemented the first version of an algorithm, which parses text-based diffs to C-preprocessor files to variation diffs. He also came up with an initial classification of edits, which we wanted to reuse to evaluate [Feature Trace Recording](https://variantsync.github.io/FeatureTraceRecording/), a method for deriving variability annotations from annotated patches.

[documentation]: https://variantsync.github.io/DiffDetective/docs/javadoc
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
doCheck ? true,
buildGitHubPages ? true,
dependenciesHash ? "sha256-OdagSk6jYCkkw/kPoOJlma9yEK7hMBcNkuxE6qt0ra8=",
dependenciesHash ? "sha256-xQG7IjBROSXfMIe7kvU8fXfKShdqKwVaJR0y97jsZWU=",
}:
pkgs.stdenvNoCC.mkDerivation rec {
pname = "DiffDetective";
Expand Down
5 changes: 5 additions & 0 deletions docs/datasets/eugen-bachelor-thesis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Project name | Domain | Source code available (\*\*y\*\*es/\*\*n\*\*o)? | Is it a git repository (\*\*y\*\*es/\*\*n\*\*o)? | Repository URL | Clone URL | Estimated number of commits
-------------------|-------------------------|-------------------------------------------------|--------------------------------------------------|--------------------------------------------------------------|----------------------------------------------------|---------------------------------
berkeley-db-libdb | database system | y | y | https://github.com/berkeleydb/libdb | https://github.com/berkeleydb/libdb.git | 7
sylpheed | e-mail client | y | y | https://github.com/jan0sch/sylpheed | https://github.com/jan0sch/sylpheed.git | 2,682
vim | text editor | y | y | https://github.com/vim/vim | https://github.com/vim/vim.git | 17,109
Binary file removed docs/teaser.png
Binary file not shown.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>org.variantsync</groupId>
<artifactId>diffdetective</artifactId>
<!-- The DiffDetective version, needs to be the first version tag in this file. -->
<version>2.3.0</version>
<version>2.4.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -163,7 +163,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.17.0</version>
<version>3.18.0</version>
</dependency>

<dependency>
Expand Down
57 changes: 57 additions & 0 deletions replication/thesis-es/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# syntax=docker/dockerfile:1

FROM alpine:3.15
# PACKAGE STAGE

# Prepare the compile environment. JDK is automatically installed
RUN apk add maven

# Create and navigate to a working directory
WORKDIR /home/user

COPY local-maven-repo ./local-maven-repo

# Copy the source code
COPY src ./src
# Copy the pom.xml if Maven is used
COPY pom.xml .
# Execute the maven package process
RUN mvn package || exit

FROM alpine:3.15

# Create a user
RUN adduser --disabled-password --home /home/sherlock --gecos '' sherlock

RUN apk add --no-cache --upgrade bash
RUN apk add --update openjdk17

# Change into the home directory
WORKDIR /home/sherlock

# Copy the compiled JAR file from the first stage into the second stage
# Syntax: COPY --from=STAGE_ID SOURCE_PATH TARGET_PATH
WORKDIR /home/sherlock/holmes
COPY --from=0 /home/user/target/diffdetective-*-jar-with-dependencies.jar ./DiffDetective.jar
WORKDIR /home/sherlock
RUN mkdir results

# Copy the setup
COPY docs holmes/docs

# Copy the docker resources
COPY docker/* ./
COPY replication/thesis-es/docker/* ./
RUN mkdir DiffDetectiveMining

# Adjust permissions
RUN chown sherlock:sherlock /home/sherlock -R
RUN chmod +x execute.sh
RUN chmod +x entrypoint.sh
RUN chmod +x fix-perms.sh

# Set the entrypoint
ENTRYPOINT ["./entrypoint.sh", "./execute.sh"]

# Set the user
USER sherlock
49 changes: 49 additions & 0 deletions replication/thesis-es/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
![Maven](https://github.com/VariantSync/DiffDetective/actions/workflows/maven.yml/badge.svg)
[![Documentation](https://img.shields.io/badge/Documentation-Read-purple)][documentation]
[![Install](https://img.shields.io/badge/Install-Instructions-blue)](INSTALL.md)
[![GitHubPages](https://img.shields.io/badge/GitHub%20Pages-online-blue.svg?style=flat)][website]
[![License](https://img.shields.io/badge/License-GNU%20LGPLv3-blue)](../../LICENSE.LGPL3)

# Unparsing Experiment
This is an experiment for the bachelor thesis by Eugen Shulimov which tests the unparser for variation trees and diffs.

### Prerequisite
All following commands assume that working directory of your terminal is the `thesis-es` directory. Please switch directories, if this is not the case:
```shell
cd DiffDetective/replication/thesis-es
```

### Build the Docker container
Start the docker deamon.
Clone this repository.
Open a terminal and navigate to the root directory of this repository.
To build the Docker container you can run the `build` script corresponding to your operating system.
#### Windows:
`.\build.bat`
#### Linux/Mac (bash):
`./build.sh`

### Start the experiment
To execute the experiment you can run the `execute`script corresponding to your operating system.

#### Windows:
`.\execute.bat
#### Linux/Mac (bash):
`./execute.sh

> If you want to stop the execution, you can call the provided script for stopping the container in a separate terminal.
> When restarted, the execution will continue processing by restarting at the last unfinished repository.
> #### Windows:
> `.\stop-execution.bat`
> #### Linux/Mac (bash):
> `./stop-execution.sh`

You might see warnings or errors reported from SLF4J like `Failed to load class "org.slf4j.impl.StaticLoggerBinder"` which you can safely ignore.

### View the results in the [results][resultsdir] directory
All raw results are stored in the [results][resultsdir] directory.

[documentation]: https://variantsync.github.io/DiffDetective/docs/javadoc/
[website]: https://variantsync.github.io/DiffDetective/

[resultsdir]: results
19 changes: 19 additions & 0 deletions replication/thesis-es/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo off
setlocal

set "targetSubPath=thesis-es"

rem Get the current directory
for %%A in ("%CD%") do set "currentDir=%%~nxA"

rem Check if the current directory ends with the target sub-path

if "%currentDir:~-9%"=="%targetSubPath%" (
cd ..\..
docker build -t diff-detective-unparse -f replication\thesis-es\Dockerfile .
@pause
) else (
echo error: the script must be run from inside the thesis-es directory, i.e., DiffDetective\replication\%targetSubPath%
)
endlocal

11 changes: 11 additions & 0 deletions replication/thesis-es/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# We have to switch to the root directory of the project and build the Docker image from there,
# because Docker only allows access to the files in the current file system subtree (i.e., no access to ancestors).
# We have to do this to get access to 'src', 'docker', 'local-maven-repo', etc.
# For resiliency against different working directories during execution of this
# script we calculate the correct path using the special bash variable
# BASH_SOURCE.
cd "$(dirname "${BASH_SOURCE[0]}")/../.." || exit

docker build -t diff-detective-unparse -f replication/thesis-es/Dockerfile .
6 changes: 6 additions & 0 deletions replication/thesis-es/docker/DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Docker Files

This directory contains the files that are required to run the Docker container.

## Execution
The [`execute.sh`](execute.sh) script can be adjusted to run the program that should be executed by the Docker container.
11 changes: 11 additions & 0 deletions replication/thesis-es/docker/execute.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

cd /home/sherlock/holmes || exit

echo "Running the experiment."
java -cp DiffDetective.jar org.variantsync.diffdetective.experiments.thesis-es.Main

echo "Collecting results."
cp -r results/* ../results/
echo "The results are located in the 'results' directory."

15 changes: 15 additions & 0 deletions replication/thesis-es/execute.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@echo off
setlocal

set "targetSubPath=thesis-es"

rem Get the current directory
for %%A in ("%CD%") do set "currentDir=%%~nxA"

rem Check if the current directory ends with the target sub-path
if "%currentDir:~-9%"=="%targetSubPath%" (
docker run --rm -v "%cd%\results":"/home/sherlock/results" diff-detective-unparse %*
) else (
echo error: the script must be run from inside the thesis-es directory, i.e., DiffDetective\replication\%targetSubPath%
)
endlocal
8 changes: 8 additions & 0 deletions replication/thesis-es/execute.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Assure that the script is only called from the folder cotaining this script
cd "$(dirname "${BASH_SOURCE[0]}")" || exit

if [[ $# -gt 0 ]]; then
echo "Executing $1"
fi
docker run --rm -v "$(pwd)/results":"/home/sherlock/results" diff-detective-unparse "$@"
4 changes: 4 additions & 0 deletions replication/thesis-es/results/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
3 changes: 3 additions & 0 deletions replication/thesis-es/stop-execution.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo "Stopping all running simulations. This will take a moment..."
@FOR /f "tokens=*" %%i IN ('docker ps -a -q --filter "ancestor=diff-detective-unparse"') DO docker stop %%i
@echo "...done."
4 changes: 4 additions & 0 deletions replication/thesis-es/stop-execution.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
echo "Stopping Docker container. This will take a moment..."
docker stop "$(docker ps -a -q --filter "ancestor=diff-detective-unparse")"
echo "...done."
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@
import java.util.Arrays;
import java.util.List;

import org.variantsync.diffdetective.variation.diff.transform.VariationDiffTransformer;
import org.variantsync.diffdetective.variation.diff.VariationDiff;
import org.variantsync.diffdetective.variation.diff.transform.Transformer;
import org.variantsync.diffdetective.variation.DiffLinesLabel;

public class PreprocessingAnalysis implements Analysis.Hooks {
private final List<VariationDiffTransformer<DiffLinesLabel>> preprocessors;
private final List<Transformer<VariationDiff<DiffLinesLabel>>> preprocessors;

public PreprocessingAnalysis(List<VariationDiffTransformer<DiffLinesLabel>> preprocessors) {
public PreprocessingAnalysis(List<Transformer<VariationDiff<DiffLinesLabel>>> preprocessors) {
this.preprocessors = preprocessors;
}

@SafeVarargs
public PreprocessingAnalysis(VariationDiffTransformer<DiffLinesLabel>... preprocessors) {
public PreprocessingAnalysis(Transformer<VariationDiff<DiffLinesLabel>>... preprocessors) {
this.preprocessors = Arrays.asList(preprocessors);
}

@Override
public boolean analyzeVariationDiff(Analysis analysis) {
VariationDiffTransformer.apply(preprocessors, analysis.getCurrentVariationDiff());
Transformer.apply(preprocessors, analysis.getCurrentVariationDiff());
analysis.getCurrentVariationDiff().assertConsistency();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
import org.variantsync.diffdetective.variation.DiffLinesLabel;
import org.variantsync.diffdetective.variation.diff.VariationDiff;
import org.variantsync.diffdetective.variation.diff.parse.VariationDiffParser;
import org.variantsync.diffdetective.variation.tree.source.GitSource;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -111,14 +113,12 @@ public static CommitDiffResult createCommitDiff(
final CanonicalTreeParser currentTreeParser = new CanonicalTreeParser();
final CanonicalTreeParser prevTreeParser = new CanonicalTreeParser();
try (ObjectReader reader = repository.getGitRepo().getRepository().newObjectReader()) {
try {
currentTreeParser.reset(reader, childCommit.getTree());
if (parentCommit != null) {
prevTreeParser.reset(reader, parentCommit.getTree());
}
} catch (IOException e) {
return CommitDiffResult.Failure(DiffError.JGIT_ERROR, e.toString());
currentTreeParser.reset(reader, childCommit.getTree());
if (parentCommit != null) {
prevTreeParser.reset(reader, parentCommit.getTree());
}
} catch (IOException e) {
return CommitDiffResult.Failure(DiffError.JGIT_ERROR, e.toString());
}

final AbstractTreeIterator parentTreeIterator;
Expand Down Expand Up @@ -254,6 +254,7 @@ private static CommitDiffResult getPatchDiffs(

final VariationDiff<DiffLinesLabel> variationDiff = VariationDiffParser.createVariationDiff(
fullDiff,
new GitSource(repository, childCommit.getId().name(), Path.of(filename)),
repository.getParseOptions().variationDiffParseOptions()
);

Expand Down
16 changes: 14 additions & 2 deletions src/main/java/org/variantsync/diffdetective/diff/git/GitPatch.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package org.variantsync.diffdetective.diff.git;

import java.util.List;

import org.eclipse.jgit.diff.DiffEntry;
import org.variantsync.diffdetective.diff.text.TextBasedDiff;
import org.variantsync.diffdetective.util.Source;
import org.variantsync.diffdetective.variation.diff.Time;
import org.variantsync.diffdetective.variation.diff.VariationDiff; // For Javadoc
import org.variantsync.diffdetective.variation.diff.source.VariationDiffSource;

/**
* Interface for patches from a git repository.
* A git patch is a {@link TextBasedDiff} from which {@link VariationDiff}s can be created.
*
*/
public interface GitPatch extends VariationDiffSource, TextBasedDiff {
public interface GitPatch extends Source, TextBasedDiff {
/**
* Minimal default implementation of {@link GitPatch}
* @param getDiff The diff in text form.
Expand Down Expand Up @@ -41,6 +43,16 @@ public GitPatch shallowClone() {
public String toString() {
return oldFileName + "@ " + getParentCommitHash + " (parent) to " + newFileName + " @ " + getCommitHash + " (child)";
}

@Override
public String getSourceExplanation() {
return "SimpleGitPatch";
}

@Override
public List<Object> getSourceArguments() {
return List.of(getChangeType(), oldFileName(), newFileName(), getCommitHash(), getParentCommitHash());
}
}

/**
Expand Down
Loading