diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b0371ef --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +insert_final_newline = true diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..75bb8b4 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# unix line endings at unix files +gradlew text eol=lf +*.sh text eol=lf +*.bat text eol=crlf diff --git a/.gitignore b/.gitignore index bd71dd6..023fb68 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ out/ # Local configuration file (sdk path, etc) local.properties +private.properties # Eclipse project files .classpath @@ -33,6 +34,3 @@ local.properties # Keystore and properties *.keystore keystore.properties - -FictionDL.jar -FictionDL-old.jar diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7e4eaf4 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: java + +jdk: +- oraclejdk8 +- oraclejdk9 + +# disable ./gradlew assemble +install: +- true + +script: +- ./gradlew check --info +- ./gradlew javadoc + +before_cache: +- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock +- rm -fr $HOME/.gradle/caches/*/plugin-resolution/ + +cache: + directories: + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0a27341 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,97 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Changed + +- Refined `README.md` + +## [2.2.0] – 2018-06-26 + +### Changed + +- Main repository is now +- The groupid is now `io.github.java-diff-utils` +- Published on maven central + +### Fixed + +- Empty-context add-only patches were applied in the wrong place, typically one line early + +## [2.1.1] – 2016-10-24 + +### Added + +- Added some unit tests. + +### Changed + +- Maven group is `com.github.bkromhout` + +### Fixed + +- Bugfix: Fix issue showing inline diffs. + +## [2.1.0] – 2016-10-24 + +### Changed + +- Removes the dependency on Guava time + +## [2.0.0] – 2016-02-24 + +### Added + +- Add the ability to differentiate the inserted and deleted tags and class-names in inline-diff +- Add tha ability to skip data +- Can now customize diff algorithm in `DiffRowGenerator.Builder` + +### Fixed + +- Fix "equal" lines when lines isn't really equals (when Equalizer return equals on different strings) +- Fix imbrication tag bug in lineDiff (when inline is on a multi-line chunk) + +### Changed + +- Change groupId and artifactId to prevent conflict with origin library: now 'com.github.java-diff-utils:java-diff-utils' instead of 'jp.skypencil.java-diff-utils:diffutils' +- Default class-name is now `null` for deleted and inserted data, and "`change`" for change data +- Default tag for deleted data is `del` +- Default tag for inserted data is `ins` +- Changed build system from Maven to Gradle + +## 1.5.0 – 2014-05-22 + +### Changed + +- make Equalizer configurable. ([pull #1](https://github.com/eller86/java-diff-utils/pull/1)) + +## 1.4.1 – 2014-01-01 + +### Fixed + +- bugfix: parse method should be public + +## 1.4.0 – 2014-01-01 + +### Added + +- add Guava to dependency +- let user uses other string to represent line which does not exist +- implement event based parser like SAX (in difflib.event package) + +### Changed + +- switch from JDK5 to JDK7 + +[Unreleased]: https://github.com/java-diff-utils/java-diff-utils/compare/2.2.0...HEAD +[2.2.0]: https://github.com/java-diff-utils/java-diff-utils/compare/2.1.1...2.2.0 +[2.1.1]: https://github.com/java-diff-utils/java-diff-utils/compare/2.1.0...2.1.1 +[2.1.0]: https://github.com/java-diff-utils/java-diff-utils/compare/2.0.0...2.1.0 +[2.0.0]: https://github.com/java-diff-utils/java-diff-utils/compare/1.5.0...2.0.0 +[1.5.0]: https://github.com/java-diff-utils/java-diff-utils/compare/1.4.1...1.5.0 +[1.4.1]: https://github.com/java-diff-utils/java-diff-utils/compare/1.4.0...1.4.1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5d4849d..df344a9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,7 @@ # Contributing To contribute do the following: + 1. Check existing open issues. 2. If not found, file an issue with any relevant information (versions, steps to reproduce, stacktrace, screenshots, etc). 3. Fork repository. diff --git a/LICENSE b/LICENSE index 44384d2..1716686 100644 --- a/LICENSE +++ b/LICENSE @@ -1,13 +1,52 @@ -Copyright [2009] [Dmitry Naumenko] +The Apache Software License, Version 1.1 -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +Copyright (c) 1999-2003 The Apache Software Foundation. +Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) +All rights reserved. - http://www.apache.org/licenses/LICENSE-2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The end-user documentation included with the redistribution, if + any, must include the following acknowledgement: + "This product includes software developed by the + Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgement may appear in the software itself, + if and wherever such third-party acknowledgements normally appear. + +4. The names "The Jakarta Project", "Commons", and "Apache Software + Foundation" must not be used to endorse or promote products derived + from this software without prior written permission. For written + permission, please contact apache@apache.org. + +5. Products derived from this software may not be called "Apache" + nor may "Apache" appear in their names without prior written + permission of the Apache Software Foundation. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR +ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. +==================================================================== + +This software consists of voluntary contributions made by many +individuals on behalf of the Apache Software Foundation. For more +information on the Apache Software Foundation, please see +. diff --git a/README.md b/README.md index 29888b7..1e1231e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ -# java-diff-utils +# (outdated) java-diff-utils [![Build Status](https://travis-ci.org/java-diff-utils/java-diff-utils.svg?branch=master)](https://travis-ci.org/java-diff-utils/java-diff-utils) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.java-diff-utils/java-diff-utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.java-diff-utils/java-diff-utils) [![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/) -The java-diff-utils library is for computing diffs, applying patches, generation side-by-side view in Java. +> **The maintained successor if this library is https://github.com/java-diff-utils/java-diff-utils** -It is an open source library for performing comparison operations between chunks of text: computing diffs, applying patches, generating unified diffs or parsing them, generating diff output for easy future display (like a side-by-side view) and so on. +> A library for computing diffs, applying patches, generation side-by-side view in Java. -The main reason for creating this library was the lack of easy-to-use libraries with all the usual features necessary for working with diff files. Originally it was inspired by the JRCS library and its nice diff module design. +`java-diff-utils` is an open source library for performing comparison operations between chunks of text: computing diffs, applying patches, generating unified diffs or parsing them, generating diff output for easy future display (like a side-by-side view) and so on. -**Original code and docs were forked from:** [java-diff-utils](https://code.google.com/p/java-diff-utils/) +The main reason for creating this library was the lack of easy-to-use libraries with all the usual features necessary for working with diff files. +Originally it was inspired by the [JRCS library](https://bitbucket.org/apalala/jrcs) and its nice diff module design. ## Main Features @@ -16,48 +17,56 @@ The main reason for creating this library was the lack of easy-to-use libraries * Parsing the unified diff format. * Producing human-readable differences. +## Installation + +Since version 2.2.0, this fork of java-diff-utils is hosted on Maven Central. +This means you can add java-diff-utils as a dependency to your project using Gradle. + +Add java-diff-utils to your dependencies like this: + +```groovy +dependencies { + compile 'io.github.java-diff-utils:java-diff-utils:2.2.0' +} +``` + ## Algorithms This library implements Myers' diff algorithm, but it is modular so it is easy to replace the algorithm with another which might be better suited to your needs. -# Tutorial +## Tutorial * In Spanish: [Comparar Ficheros java-diff-utils](https://www.adictosaltrabajo.com/tutoriales/comparar-ficheros-java-diff-utils/) -## Changelog +## Other variants of this library -### 2.1.1 +The library was originally hosted on Google Code at . +This library is a fork originally created by @KengoTODA ([published on maven central](https://mvnrepository.com/artifact/jp.skypencil.java-diff-utils/diffutils) using the group id `jp.skypencil.java-diff-utils`) and enhanced by @bkromhout. -- Bugfix: Fix issue showing inline diffs. -- Added some unit tests. +Since GitHub does not connect forks based on Google Code, other variants appeared in parallel: -### 2.1.0 +- https://github.com/dnaumenko/java-diff-utils - Created by the original Google Code maintainer +- https://github.com/wumpz/java-diff-utils - Created from the Google Code repository [starting in 2017](https://github.com/wumpz/java-diff-utils/commit/42fde56154afd92d2b9ef8e088185e7af0230cee). Now maintained at http://github.com/java-diff-utils/java-diff-utils. -- Removes the dependency on Guava time +## License -### 2.0.0 +This work is licensed under The Apache Software License, Version 1.1. -- Change groupId and artifactId to prevent conflict with origin library: now 'com.github.java-diff-utils:java-diff-utils' instead of 'jp.skypencil.java-diff-utils:diffutils' -- Adds the ability to differentiate the inserted and deleted tags and class-names in inline-diff -- Default class-name is now `null` for deleted and inserted data, and "`change`" for change data -- Default tag for deleted data is `del` -- Default tag for inserted data is `ins` -- can now customize diff algorithm in `DiffRowGenerator.Builder` -- fix "equal" lines when lines isn't really equals (when Equalizer return equals on different strings) -- fix imbrication tag bug in lineDiff (when inline is on a multi-line chunk) -- Adds tha ability to skip data +Reason: The code contains work of HP, which contributed it under Apache-1.1. +[[Example code](https://github.com/apache/wicket/blob/master/wicket-util/src/main/java/org/apache/wicket/util/diff/Delta.java)]. +It was easier to change the license to Apache-1.1 than to contact HP Legal for a code created in 2003 at HP Bristol. -### 1.5.0 +I had a discussion with [Juancarlo](https://bitbucket.org/apalala/) and Brian McBride. +Brian worked for HPLabs in Bristol (UK) at that time. His authorship appears in three files: -- make Equalizer configurable. ([pull #1](https://github.com/eller86/java-diff-utils/pull/1)) +- https://github.com/apache/wicket/blob/master/wicket-util/src/main/java/org/apache/wicket/util/diff/DiffAlgorithm.java +- https://github.com/apache/wicket/blob/master/wicket-util/src/main/java/org/apache/wicket/util/diff/Revision.java +- https://github.com/apache/wicket/blob/master/wicket-util/src/main/java/org/apache/wicket/util/diff/Delta.java -### 1.4.1 +All other files at JRCS are (according to Juancarlo) 100% authored by Juancarlo in a cleanroom way. -- bugfix: parse method should be public +Since Brian pointed me to HP and I do not want to fight with HP, I agreed with Juancarlo to change the license of the JRCS files to Apache-1.1. -### 1.4.0 +More reading on JRCS and java-diff-utils license issues: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=696165 and https://bugzilla.redhat.com/show_bug.cgi?id=1013039. -- switch from JDK5 to JDK7 -- add Guava to dependency -- let user uses other string to represent line which does not exist -- implement event based parser like SAX (in difflib.event package) +The alternative to Apache-1.1 license is to find out which code was written by Brian and to replace this code by some other clean room developed code. diff --git a/build.gradle b/build.gradle index b671ea0..c43cdbd 100644 --- a/build.gradle +++ b/build.gradle @@ -1,21 +1,52 @@ apply plugin: 'java' apply plugin: 'maven' +apply plugin: 'signing' -group = 'com.github.java-diff-utils' -version = '2.1.1' +group = 'io.github.java-diff-utils' +archivesBaseName = 'java-diff-utils' +version = '2.2.1-SNAPSHOT' -description = """java-diff-utils""" +sourceCompatibility = '1.7' +targetCompatibility = '1.7' -sourceCompatibility = 1.7 -targetCompatibility = 1.7 +dependencies { + compile group: 'com.google.code.findbugs', name: 'jsr305', version:'3.0.0' + testCompile group: 'org.hamcrest', name: 'hamcrest-library', version:'1.3' + testCompile group: 'junit', name: 'junit', version:'4.12' +} -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource +compileJava { + // files are all encoded using UTF-8 + options.encoding = 'UTF-8' +} + +compileTestJava { + // files are all encoded using UTF-8 + options.encoding = 'UTF-8' } javadoc { failOnError = false + options { + // files are all encoded using UTF-8 + encoding = 'UTF-8' + version = true + author = true + } +} + +jar { + manifest { + attributes('Automatic-Module-Name': 'io.github.adr.embedded') + } +} + +repositories { + jcenter() +} + +tasks.withType(Javadoc) { + options.addStringOption('Xdoclint:none', '-quiet') } task javadocJar(type: Jar, dependsOn: javadoc) { @@ -23,18 +54,62 @@ task javadocJar(type: Jar, dependsOn: javadoc) { from javadoc.destinationDir } +task sourcesJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.allSource +} + artifacts { archives sourcesJar archives javadocJar } -repositories { - maven { url "https://oss.sonatype.org/content/repositories/snapshots" } - maven { url "http://repo.maven.apache.org/maven2" } +signing { + sign configurations.archives } -dependencies { - compile group: 'com.google.code.findbugs', name: 'jsr305', version:'3.0.0' - testCompile group: 'org.hamcrest', name: 'hamcrest-library', version:'1.3' - testCompile group: 'junit', name: 'junit', version:'4.12' +// See https://central.sonatype.org/pages/gradle.html for a documentation +uploadArchives { + repositories { + mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + pom.project { + name 'Java Diff Utils' + packaging 'jar' + // optionally artifactId can be defined here + description 'A library for computing diffs, applying patches, generation side-by-side view in Java' + url 'https://github.com/java-diff-utils/java-diff-utils' + + scm { + connection 'scm:git:https://github.com/java-diff-utils/java-diff-utils.git' + developerConnection 'scm:git:github.com:java-diff-utils/java-diff-utils.git' + url 'https://github.com/java-diff-utils/java-diff-utils/tree/master' + } + + licenses { + license { + name 'The Apache Software License, Version 1.1' + url 'http://www.apache.org/licenses/LICENSE-1.1' + } + } + + developers { + developer { + id 'koppor' + name 'Oliver Kopp' + email 'kopp.dev@gmail.com' + } + } + } + } + } } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..905f47a --- /dev/null +++ b/gradle.properties @@ -0,0 +1,6 @@ +signing.keyId= +signing.password= +signing.secretKeyRingFile= + +ossrhUsername= +ossrhPassword= diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5ccda13..d6e2637 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 413fa23..20dbe87 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Feb 23 21:24:53 EST 2016 +#Tue Jun 26 19:45:23 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip diff --git a/gradlew b/gradlew index 9d82f78..4ef3a87 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -6,12 +6,30 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,26 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -85,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -150,11 +154,18 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +# Escape application args +for s in "${@}" ; do + s=\"$s\" + APP_ARGS=$APP_ARGS" "$s +done + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- "$DEFAULT_JVM_OPTS" "$JAVA_OPTS" "$GRADLE_OPTS" "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat old mode 100644 new mode 100755 index 72d362d..e95643d --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -49,7 +49,6 @@ goto fail @rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. @@ -60,11 +59,6 @@ set _SKIP=2 if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ :execute @rem Setup the command line diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index fefed1a..0000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'java-diff-utils' diff --git a/src/main/java/difflib/ChangeDelta.java b/src/main/java/difflib/ChangeDelta.java index 95252d9..0e2128f 100644 --- a/src/main/java/difflib/ChangeDelta.java +++ b/src/main/java/difflib/ChangeDelta.java @@ -1,17 +1,61 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; @@ -19,7 +63,7 @@ /** * Describes the change-delta between original and revised texts. - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. * @author Dmitry Naumenko */ public class ChangeDelta extends Delta { diff --git a/src/main/java/difflib/Chunk.java b/src/main/java/difflib/Chunk.java index 308f31e..650426d 100644 --- a/src/main/java/difflib/Chunk.java +++ b/src/main/java/difflib/Chunk.java @@ -1,30 +1,75 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; -import javax.annotation.Nonnegative; import java.util.Arrays; import java.util.List; +import javax.annotation.Nonnegative; + /** * Holds the information about the part of text involved in the diff process

Text is represented as * Object[] because the diff engine is capable of handling more than plain ascci. In fact, arrays or lists * of any type that implements {@link java.lang.Object#hashCode hashCode()} and {@link java.lang.Object#equals equals()} * correctly can be subject to differencing using this library.

- * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. * @author . */ package difflib; @@ -21,7 +65,7 @@ * Describes the delete-delta between original and revised texts. * * @author Dmitry Naumenko - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public class DeleteDelta extends Delta { diff --git a/src/main/java/difflib/Delta.java b/src/main/java/difflib/Delta.java index f2c805d..e0ef0dd 100644 --- a/src/main/java/difflib/Delta.java +++ b/src/main/java/difflib/Delta.java @@ -1,17 +1,61 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; @@ -21,7 +65,7 @@ * Describes the delta between original and revised texts. * * @author Dmitry Naumenko - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public abstract class Delta { @@ -35,7 +79,7 @@ public abstract class Delta { * Specifies the type of the delta. * */ - public static enum TYPE { + public enum TYPE { /** A change in the original. */ CHANGE, /** A delete from the original. */ @@ -143,11 +187,10 @@ public boolean equals(Object obj) { } else if (!original.equals(other.original)) return false; if (revised == null) { - if (other.revised != null) - return false; - } else if (!revised.equals(other.revised)) - return false; - return true; + return other.revised == null; + } else { + return revised.equals(other.revised); + } } } diff --git a/src/main/java/difflib/DeltaComparator.java b/src/main/java/difflib/DeltaComparator.java index 98b7ab3..beaff4f 100644 --- a/src/main/java/difflib/DeltaComparator.java +++ b/src/main/java/difflib/DeltaComparator.java @@ -1,27 +1,86 @@ -package difflib; - -import java.io.Serializable; -import java.util.Comparator; - -/** - * @author mksenzov - * @param T The type of the compared elements in the 'lines'. - */ -public class DeltaComparator implements Comparator>, Serializable { - private static final long serialVersionUID = 1L; - public static final Comparator> INSTANCE = new DeltaComparator(); - - private DeltaComparator() { - } - - public int compare(final Delta a, final Delta b) { - final int posA = a.getOriginal().getPosition(); - final int posB = b.getOriginal().getPosition(); - if (posA > posB) { - return 1; - } else if (posA < posB) { - return -1; - } - return 0; - } -} \ No newline at end of file +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + +package difflib; + +import java.io.Serializable; +import java.util.Comparator; + +/** + * @author mksenzov + * @param The type of the compared elements in the 'lines'. + */ +public class DeltaComparator implements Comparator>, Serializable { + private static final long serialVersionUID = 1L; + public static final Comparator> INSTANCE = new DeltaComparator(); + + private DeltaComparator() { + } + + public int compare(final Delta a, final Delta b) { + final int posA = a.getOriginal().getPosition(); + final int posB = b.getOriginal().getPosition(); + if (posA > posB) { + return 1; + } else if (posA < posB) { + return -1; + } + return 0; + } +} diff --git a/src/main/java/difflib/DiffAlgorithm.java b/src/main/java/difflib/DiffAlgorithm.java index 5a2ddea..bc74f01 100644 --- a/src/main/java/difflib/DiffAlgorithm.java +++ b/src/main/java/difflib/DiffAlgorithm.java @@ -1,17 +1,61 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; @@ -23,7 +67,7 @@ * The general interface for computing diffs between two lists of elements of type T. * * @author Dmitry Naumenko - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public interface DiffAlgorithm { @@ -35,7 +79,7 @@ public interface DiffAlgorithm { * @param revised The revised sequence. Must not be {@code null}. * @return The patch representing the diff of the given sequences. Never {@code null}. */ - public Patch diff(T[] original, T[] revised); + Patch diff(T[] original, T[] revised); /** * Computes the difference between the original sequence and the revised @@ -45,11 +89,11 @@ public interface DiffAlgorithm { * @param revised The revised sequence. Must not be {@code null}. * @return The patch representing the diff of the given sequences. Never {@code null}. */ - public Patch diff(List original, List revised); + Patch diff(List original, List revised); /** * Get equalizer use to compare data. * @return */ - public Equalizer getEqualizer(); + Equalizer getEqualizer(); } diff --git a/src/main/java/difflib/DiffException.java b/src/main/java/difflib/DiffException.java index 6ad3dd4..047e7a0 100644 --- a/src/main/java/difflib/DiffException.java +++ b/src/main/java/difflib/DiffException.java @@ -1,17 +1,61 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; diff --git a/src/main/java/difflib/DiffRow.java b/src/main/java/difflib/DiffRow.java index 95f08bc..0dc5cf8 100644 --- a/src/main/java/difflib/DiffRow.java +++ b/src/main/java/difflib/DiffRow.java @@ -1,17 +1,60 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; @@ -36,7 +79,7 @@ public DiffRow(@Nonnull Tag tag, @Nullable String oldLine, @Nullable String newL this.newLine = newLine; } - public static enum Tag { + public enum Tag { INSERT, DELETE, CHANGE, EQUAL, SKIP } @@ -125,11 +168,8 @@ public boolean equals(Object obj) { } else if (!oldLine.equals(other.oldLine)) return false; if (tag == null) { - if (other.tag != null) - return false; - } else if (!tag.equals(other.tag)) - return false; - return true; + return other.tag == null; + } else return tag.equals(other.tag); } public String toString() { diff --git a/src/main/java/difflib/DiffRowGenerator.java b/src/main/java/difflib/DiffRowGenerator.java index 8d37612..4046575 100644 --- a/src/main/java/difflib/DiffRowGenerator.java +++ b/src/main/java/difflib/DiffRowGenerator.java @@ -1,17 +1,60 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; @@ -388,7 +431,7 @@ public List generateDiffRows(List original, List revise return diffRows; } - private static final void addChangeDiffRow(Equalizer equalizer, List diffRows, String orgLine, + private static void addChangeDiffRow(Equalizer equalizer, List diffRows, String orgLine, String revLine, String defaultString) { boolean skipOrg = equalizer.skip(orgLine); boolean skipRev = equalizer.skip(revLine); @@ -472,7 +515,7 @@ private List addMissingLines(final List lines, final int targetS return tempList; } - private static final LinkedList charArrayToStringList(char[] cs) { + private static LinkedList charArrayToStringList(char[] cs) { LinkedList result = new LinkedList(); for (Character character : cs) { result.add(character.toString()); @@ -559,4 +602,4 @@ public static String wrapInTag(String line, String tag, String cssClass) { return startTag + PATTERN_CRLF.matcher(line).replaceAll(joinTag) + endTag; } -} \ No newline at end of file +} diff --git a/src/main/java/difflib/DiffUtils.java b/src/main/java/difflib/DiffUtils.java index 505b0be..9400cd1 100644 --- a/src/main/java/difflib/DiffUtils.java +++ b/src/main/java/difflib/DiffUtils.java @@ -1,17 +1,60 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; @@ -28,13 +71,12 @@ /** * Implements the difference and patching engine - * @param T The type of the compared elements in the 'lines'. * @author Dmitry Naumenko * @version 0.4.1 */ public class DiffUtils { - private static Pattern unifiedDiffChunkRe = Pattern + private static final Pattern unifiedDiffChunkRe = Pattern .compile("^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@$"); private List readLines(@Nonnull File file) { @@ -162,25 +204,8 @@ public static Patch parseUnifiedDiff(List diff) { Matcher m = unifiedDiffChunkRe.matcher(line); if (m.find()) { // Process the lines in the previous chunk - if (rawChunk.size() != 0) { - List oldChunkLines = new ArrayList(); - List newChunkLines = new ArrayList(); - - for (String[] raw_line : rawChunk) { - tag = raw_line[0]; - rest = raw_line[1]; - if (tag.equals(" ") || tag.equals("-")) { - oldChunkLines.add(rest); - } - if (tag.equals(" ") || tag.equals("+")) { - newChunkLines.add(rest); - } - } - patch.addDelta(new ChangeDelta(new Chunk( - old_ln - 1, oldChunkLines), new Chunk( - new_ln - 1, newChunkLines))); - rawChunk.clear(); - } + processRawChunk(rawChunk, patch, old_ln, new_ln); + // Parse the @@ header old_ln = m.group(1) == null ? 1 : Integer.parseInt(m.group(1)); new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3)); @@ -205,6 +230,15 @@ public static Patch parseUnifiedDiff(List diff) { } // Process the lines in the last chunk + processRawChunk(rawChunk, patch, old_ln, new_ln); + + return patch; + } + + public static void processRawChunk(List rawChunk, Patch patch, int old_ln, int new_ln) { + String tag; + String rest; + if (rawChunk.size() != 0) { List oldChunkLines = new ArrayList(); List newChunkLines = new ArrayList(); @@ -220,13 +254,18 @@ public static Patch parseUnifiedDiff(List diff) { } } - patch.addDelta(new ChangeDelta(new Chunk( - old_ln - 1, oldChunkLines), new Chunk(new_ln - 1, - newChunkLines))); + if (oldChunkLines.isEmpty()) { + patch.addDelta(new InsertDelta(new Chunk(old_ln, oldChunkLines), + new Chunk(new_ln - 1, newChunkLines))); + } else if (newChunkLines.isEmpty()) { + patch.addDelta(new DeleteDelta(new Chunk(old_ln - 1, oldChunkLines), + new Chunk(new_ln, newChunkLines))); + } else { + patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, oldChunkLines), + new Chunk(new_ln - 1, newChunkLines))); + } rawChunk.clear(); } - - return patch; } /** @@ -374,6 +413,14 @@ private static List processDeltas(List origLines, revTotal++; } + // In case of empty chunk and context + if (origTotal == 0 && origStart > 1) + --origStart; + + // In case of empty chunk and context + if (revTotal == 0 && revStart > 1) + --revStart; + // Create and insert the block header, conforming to the Unified Diff // standard StringBuffer header = new StringBuffer(); diff --git a/src/main/java/difflib/InsertDelta.java b/src/main/java/difflib/InsertDelta.java index 23914a9..c9b9476 100644 --- a/src/main/java/difflib/InsertDelta.java +++ b/src/main/java/difflib/InsertDelta.java @@ -1,17 +1,60 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; @@ -21,7 +64,7 @@ * Describes the add-delta between original and revised texts. * * @author Dmitry Naumenko - * @param T + * @param * The type of the compared elements in the 'lines'. */ public class InsertDelta extends Delta { diff --git a/src/main/java/difflib/Patch.java b/src/main/java/difflib/Patch.java index b93a5f1..7096ae3 100644 --- a/src/main/java/difflib/Patch.java +++ b/src/main/java/difflib/Patch.java @@ -1,17 +1,60 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; @@ -24,7 +67,7 @@ * Describes the patch holding all deltas between the original and revised texts. * * @author Dmitry Naumenko - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public class Patch { private List> deltas = new LinkedList>(); diff --git a/src/main/java/difflib/PatchFailedException.java b/src/main/java/difflib/PatchFailedException.java index 5fb77d2..75fdb02 100644 --- a/src/main/java/difflib/PatchFailedException.java +++ b/src/main/java/difflib/PatchFailedException.java @@ -1,17 +1,61 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; @@ -30,4 +74,4 @@ public PatchFailedException() { public PatchFailedException(String msg) { super(msg); } -} \ No newline at end of file +} diff --git a/src/main/java/difflib/Utils.java b/src/main/java/difflib/Utils.java index 7607e1a..a1472dd 100644 --- a/src/main/java/difflib/Utils.java +++ b/src/main/java/difflib/Utils.java @@ -1,17 +1,60 @@ /* - Copyright 2010 Dmitry Naumenko (dm.naumenko@gmail.com) - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ package difflib; @@ -21,7 +64,7 @@ import java.util.List; public class Utils { - public static Charset UTF_8 = Charset.forName("UTF-8"); + public static final Charset UTF_8 = Charset.forName("UTF-8"); /** * Replaces all tabs with 4 spaces. diff --git a/src/main/java/difflib/event/PatchHandler.java b/src/main/java/difflib/event/PatchHandler.java index b6ae29b..95a65eb 100644 --- a/src/main/java/difflib/event/PatchHandler.java +++ b/src/main/java/difflib/event/PatchHandler.java @@ -1,3 +1,62 @@ +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + package difflib.event; import difflib.Patch; diff --git a/src/main/java/difflib/event/UnifiedPatchParser.java b/src/main/java/difflib/event/UnifiedPatchParser.java index 3b33bb4..0c378e0 100644 --- a/src/main/java/difflib/event/UnifiedPatchParser.java +++ b/src/main/java/difflib/event/UnifiedPatchParser.java @@ -1,3 +1,62 @@ +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + package difflib.event; import difflib.DiffUtils; diff --git a/src/main/java/difflib/myers/DiffException.java b/src/main/java/difflib/myers/DiffException.java index d3802ff..3155c64 100644 --- a/src/main/java/difflib/myers/DiffException.java +++ b/src/main/java/difflib/myers/DiffException.java @@ -1,9 +1,13 @@ /* - * ==================================================================== + * SPDX-License-Identifier: Apache-1.1 * + * ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,7 +56,6 @@ * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . - * */ package difflib.myers; @@ -60,8 +63,6 @@ /** * Base class for all exceptions emanating from this package. * - * @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $ - * * @author Juanco Anez */ public class DiffException extends Exception { diff --git a/src/main/java/difflib/myers/DiffNode.java b/src/main/java/difflib/myers/DiffNode.java index a2fb071..c5eccd0 100644 --- a/src/main/java/difflib/myers/DiffNode.java +++ b/src/main/java/difflib/myers/DiffNode.java @@ -1,14 +1,65 @@ -package difflib.myers; - -/** - *

Title:

- *

Description:

- *

Copyright: Copyright (c) 2002

- *

Company:

- * @author not attributable - * @version 1.0 +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . */ +package difflib.myers; + /** * A diffnode in a diffpath. *

@@ -21,7 +72,6 @@ * node and each contiguous series of insertions and deletions is represented * by a single {@link DiffNode DiffNodes}. * - * @version $Revision: 60 $ $Date: 2003-05-10 21:56:10 +0300 (Суб, 10 Май 2003) $ * @author Juanco Anez * */ @@ -34,8 +84,8 @@ public final class DiffNode extends PathNode { * will be followed using {@link PathNode#previousSnake} * until a non-diff node is found. * - * @param the position in the original sequence - * @param the position in the revised sequence + * @param i position in the original sequence + * @param j position in the revised sequence * @param prev the previous node in the path. */ public DiffNode(int i, int j, PathNode prev) { @@ -50,4 +100,4 @@ public boolean isSnake() { return false; } -} \ No newline at end of file +} diff --git a/src/main/java/difflib/myers/DifferentiationFailedException.java b/src/main/java/difflib/myers/DifferentiationFailedException.java index c25c081..3c4291d 100644 --- a/src/main/java/difflib/myers/DifferentiationFailedException.java +++ b/src/main/java/difflib/myers/DifferentiationFailedException.java @@ -1,9 +1,13 @@ /* - * ==================================================================== + * SPDX-License-Identifier: Apache-1.1 * + * ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,7 +56,6 @@ * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . - * */ package difflib.myers; @@ -61,8 +64,6 @@ * Thrown whenever the differencing engine cannot produce the differences * between two revisions of ta text. * - * @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $ - * * @author Juanco Anez * @see MyersDiff * @see difflib.DiffAlgorithm diff --git a/src/main/java/difflib/myers/Equalizer.java b/src/main/java/difflib/myers/Equalizer.java index 4202ca3..4f75a29 100644 --- a/src/main/java/difflib/myers/Equalizer.java +++ b/src/main/java/difflib/myers/Equalizer.java @@ -1,3 +1,62 @@ +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + package difflib.myers; import javax.annotation.CheckReturnValue; @@ -6,7 +65,7 @@ /** * Specifies when two compared elements in the Myers algorithm are equal. * - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public interface Equalizer { @@ -17,7 +76,7 @@ public interface Equalizer { * @return Returns true if the elements are equal. */ @CheckReturnValue - public boolean equals(@Nullable T original, @Nullable T revised); + boolean equals(@Nullable T original, @Nullable T revised); /** * Indicates if elements must be skipped. @@ -25,5 +84,5 @@ public interface Equalizer { * @return */ @CheckReturnValue - public boolean skip(@Nullable T original); + boolean skip(@Nullable T original); } diff --git a/src/main/java/difflib/myers/MyersDiff.java b/src/main/java/difflib/myers/MyersDiff.java index 9cccc85..3706e06 100644 --- a/src/main/java/difflib/myers/MyersDiff.java +++ b/src/main/java/difflib/myers/MyersDiff.java @@ -1,10 +1,14 @@ /* - * ==================================================================== + * SPDX-License-Identifier: Apache-1.1 * + * ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2003 The Apache Software Foundation. All rights - * reserved. + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -52,18 +56,23 @@ * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . - * */ package difflib.myers; -import difflib.*; - import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import difflib.ChangeDelta; +import difflib.Chunk; +import difflib.DeleteDelta; +import difflib.Delta; +import difflib.DiffAlgorithm; +import difflib.InsertDelta; +import difflib.Patch; + /** * A clean-room implementation of * Eugene Myers differencing algorithm. @@ -72,7 +81,7 @@ * http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps

* * @author Juanco Anez - * @param T The type of the compared elements in the 'lines'. + * @param The type of the compared elements in the 'lines'. */ public class MyersDiff implements DiffAlgorithm { /** Default equalizer. */ @@ -309,4 +318,4 @@ public static T[] copyOfRange2(U[] original, int from, int to, public Equalizer getEqualizer() { return equalizer; } -} \ No newline at end of file +} diff --git a/src/main/java/difflib/myers/PathNode.java b/src/main/java/difflib/myers/PathNode.java index 4ead5f2..55b9a71 100644 --- a/src/main/java/difflib/myers/PathNode.java +++ b/src/main/java/difflib/myers/PathNode.java @@ -1,9 +1,13 @@ /* - * ==================================================================== + * SPDX-License-Identifier: Apache-1.1 * + * ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,7 +56,6 @@ * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . - * */ package difflib.myers; @@ -60,7 +63,6 @@ /** * A node in a diffpath. * - * @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $ * @author Juanco Anez * * @see DiffNode @@ -137,4 +139,4 @@ public String toString() { buf.append("]"); return buf.toString(); } -} \ No newline at end of file +} diff --git a/src/main/java/difflib/myers/Snake.java b/src/main/java/difflib/myers/Snake.java index 452829b..38d067f 100644 --- a/src/main/java/difflib/myers/Snake.java +++ b/src/main/java/difflib/myers/Snake.java @@ -1,9 +1,13 @@ /* - * ==================================================================== + * SPDX-License-Identifier: Apache-1.1 * + * ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 1996-2006 Juancarlo Añez + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,7 +56,6 @@ * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . - * */ package difflib.myers; @@ -66,7 +69,6 @@ * node and each contiguous series of insertions and deletions is represented * by a single {@link DiffNode DiffNodes}. * - * @version $Revision: 69 $ $Date: 2003-10-13 11:00:44 +0300 (Пнд, 13 Окт 2003) $ * @author Juanco Anez * */ @@ -74,8 +76,8 @@ public final class Snake extends PathNode { /** * Constructs a snake node. * - * @param the position in the original sequence - * @param the position in the revised sequence + * @param i position in the original sequence + * @param j position in the revised sequence * @param prev the previous node in the path. */ public Snake(int i, int j, PathNode prev) { @@ -90,4 +92,4 @@ public boolean isSnake() { return true; } -} \ No newline at end of file +} diff --git a/src/main/java/difflib/myers/package.html b/src/main/java/difflib/myers/package.html index 3ccec66..7cadeea 100644 --- a/src/main/java/difflib/myers/package.html +++ b/src/main/java/difflib/myers/package.html @@ -1,24 +1,63 @@ + ~ SPDX-License-Identifier: Apache-1.1 + ~ + ~ ==================================================================== + ~ The Apache Software License, Version 1.1 + ~ + ~ Copyright (c) 2002 The Apache Software Foundation. + ~ Copyright (c) 1996-2006 Juancarlo Añez + ~ Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + ~ Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + ~ All rights reserved. + ~ + ~ Redistribution and use in source and binary forms, with or without + ~ modification, are permitted provided that the following conditions + ~ are met: + ~ + ~ 1. Redistributions of source code must retain the above copyright + ~ notice, this list of conditions and the following disclaimer. + ~ + ~ 2. Redistributions in binary form must reproduce the above copyright + ~ notice, this list of conditions and the following disclaimer in + ~ the documentation and/or other materials provided with the + ~ distribution. + ~ + ~ 3. The end-user documentation included with the redistribution, if + ~ any, must include the following acknowledgement: + ~ "This product includes software developed by the + ~ Apache Software Foundation (http://www.apache.org/)." + ~ Alternately, this acknowledgement may appear in the software itself, + ~ if and wherever such third-party acknowledgements normally appear. + ~ + ~ 4. The names "The Jakarta Project", "Commons", and "Apache Software + ~ Foundation" must not be used to endorse or promote products derived + ~ from this software without prior written permission. For written + ~ permission, please contact apache@apache.org. + ~ + ~ 5. Products derived from this software may not be called "Apache" + ~ nor may "Apache" appear in their names without prior written + ~ permission of the Apache Software Foundation. + ~ + ~ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + ~ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + ~ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + ~ DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + ~ ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ~ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ~ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + ~ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ~ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + ~ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + ~ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + ~ SUCH DAMAGE. + ~ ==================================================================== + ~ + ~ This software consists of voluntary contributions made by many + ~ individuals on behalf of the Apache Software Foundation. For more + ~ information on the Apache Software Foundation, please see + ~ . + --> + ~ SPDX-License-Identifier: Apache-1.1 + ~ + ~ ==================================================================== + ~ The Apache Software License, Version 1.1 + ~ + ~ Copyright (c) 2002 The Apache Software Foundation. + ~ Copyright (c) 1996-2006 Juancarlo Añez + ~ Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + ~ Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + ~ All rights reserved. + ~ + ~ Redistribution and use in source and binary forms, with or without + ~ modification, are permitted provided that the following conditions + ~ are met: + ~ + ~ 1. Redistributions of source code must retain the above copyright + ~ notice, this list of conditions and the following disclaimer. + ~ + ~ 2. Redistributions in binary form must reproduce the above copyright + ~ notice, this list of conditions and the following disclaimer in + ~ the documentation and/or other materials provided with the + ~ distribution. + ~ + ~ 3. The end-user documentation included with the redistribution, if + ~ any, must include the following acknowledgement: + ~ "This product includes software developed by the + ~ Apache Software Foundation (http://www.apache.org/)." + ~ Alternately, this acknowledgement may appear in the software itself, + ~ if and wherever such third-party acknowledgements normally appear. + ~ + ~ 4. The names "The Jakarta Project", "Commons", and "Apache Software + ~ Foundation" must not be used to endorse or promote products derived + ~ from this software without prior written permission. For written + ~ permission, please contact apache@apache.org. + ~ + ~ 5. Products derived from this software may not be called "Apache" + ~ nor may "Apache" appear in their names without prior written + ~ permission of the Apache Software Foundation. + ~ + ~ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + ~ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + ~ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + ~ DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + ~ ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ~ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ~ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + ~ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ~ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + ~ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + ~ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + ~ SUCH DAMAGE. + ~ ==================================================================== + ~ + ~ This software consists of voluntary contributions made by many + ~ individuals on behalf of the Apache Software Foundation. For more + ~ information on the Apache Software Foundation, please see + ~ . + --> . + */ + package difflib.event; import static org.hamcrest.CoreMatchers.hasItem; diff --git a/src/test/java/diffutils/DiffRowGeneratorTest.java b/src/test/java/diffutils/DiffRowGeneratorTest.java index 8e2ac89..e3a5bb6 100644 --- a/src/test/java/diffutils/DiffRowGeneratorTest.java +++ b/src/test/java/diffutils/DiffRowGeneratorTest.java @@ -1,3 +1,62 @@ +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + package diffutils; import difflib.DiffRow; diff --git a/src/test/java/diffutils/DiffTest.java b/src/test/java/diffutils/DiffTest.java index 6d1ef31..c5f3417 100644 --- a/src/test/java/diffutils/DiffTest.java +++ b/src/test/java/diffutils/DiffTest.java @@ -1,3 +1,62 @@ +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + package diffutils; import difflib.*; diff --git a/src/test/java/diffutils/EmptyContextUnifiedDiffTest.java b/src/test/java/diffutils/EmptyContextUnifiedDiffTest.java new file mode 100644 index 0000000..580b4b8 --- /dev/null +++ b/src/test/java/diffutils/EmptyContextUnifiedDiffTest.java @@ -0,0 +1,90 @@ +package diffutils; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; + +import difflib.DiffUtils; +import difflib.Patch; +import difflib.PatchFailedException; + +import junit.framework.TestCase; + +public class EmptyContextUnifiedDiffTest extends TestCase { + + public List fileToLines(String filename) { + List lines = new LinkedList(); + String line = ""; + BufferedReader in = null; + try { + in = new BufferedReader(new FileReader(filename)); + while ((line = in.readLine()) != null) { + lines.add(line); + } + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + // ignore ... any errors should already have been + // reported via an IOException from the final flush. + } + } + } + return lines; + } + + public void testEmptyUnifiedContextPatch() { + List origLines = fileToLines(TestConstants.MOCK_FOLDER + "unified_empty_context_original.txt"); + List revLines = fileToLines(TestConstants.MOCK_FOLDER + "unified_empty_context_revised.txt"); + List unifiedDiff = fileToLines(TestConstants.MOCK_FOLDER + "unified_empty_context_patch.txt"); + + List patchedLines = null; + Patch patch = DiffUtils.parseUnifiedDiff(unifiedDiff); + + try { + patchedLines = (List) patch.applyTo(origLines); + } catch (PatchFailedException e) { + fail(e.getMessage()); + } + + verifyLinesEqual(patchedLines, revLines); + } + + public void testEmptyUnifiedContextDiff() { + List origLines = fileToLines(TestConstants.MOCK_FOLDER + "unified_empty_context_original.txt"); + List revLines = fileToLines(TestConstants.MOCK_FOLDER + "unified_empty_context_revised.txt"); + + List patchedLines = null; + + // Generate a 0-context diff then reapply + Patch generatedPatch = DiffUtils.diff(origLines, revLines); + List generatedDiff = DiffUtils.generateUnifiedDiff("original", "revised", origLines, generatedPatch, 0); + Patch newPatch = DiffUtils.parseUnifiedDiff(generatedDiff); + + try { + patchedLines = (List) newPatch.applyTo(origLines); + } catch (PatchFailedException e) { + fail(e.getMessage()); + } + + verifyLinesEqual(patchedLines, revLines); + } + + public void verifyLinesEqual(List patchedLines, List revLines) { + assertTrue(revLines.size() == patchedLines.size()); + for (int i = 0; i < revLines.size(); i++) { + String l1 = revLines.get(i); + String l2 = patchedLines.get(i); + if (!l1.equals(l2)) { + fail("Line " + (i + 1) + " of the patched file did not match the revised original"); + } + } + } + +} diff --git a/src/test/java/diffutils/GenerateUnifiedDiffTest.java b/src/test/java/diffutils/GenerateUnifiedDiffTest.java index 64432db..bf1028a 100644 --- a/src/test/java/diffutils/GenerateUnifiedDiffTest.java +++ b/src/test/java/diffutils/GenerateUnifiedDiffTest.java @@ -1,3 +1,62 @@ +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + package diffutils; import java.io.BufferedReader; diff --git a/src/test/java/diffutils/PatchTest.java b/src/test/java/diffutils/PatchTest.java index b6b4d74..e81f365 100644 --- a/src/test/java/diffutils/PatchTest.java +++ b/src/test/java/diffutils/PatchTest.java @@ -1,3 +1,62 @@ +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + package diffutils; import difflib.DiffUtils; diff --git a/src/test/java/diffutils/TestConstants.java b/src/test/java/diffutils/TestConstants.java index 5803394..dc5039d 100644 --- a/src/test/java/diffutils/TestConstants.java +++ b/src/test/java/diffutils/TestConstants.java @@ -1,25 +1,84 @@ -package diffutils; - -import java.io.File; - -/** - * Test constants - * @author simon.mittermueller@gmail.com - * - */ -public final class TestConstants { - - private TestConstants() { - // prevent construction. - } - - /** File separator. */ - public static final String FS = File.separator; - - /** The base resource path. */ - public static String BASE_FOLDER_RESOURCES = "src" + FS + "test" + FS + "resources"; - - /** The base folder containing the test files. Ends with {@link #FS}. */ - public static final String MOCK_FOLDER = BASE_FOLDER_RESOURCES + FS + "mocks" + FS; - -} +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + +package diffutils; + +import java.io.File; + +/** + * Test constants + * @author simon.mittermueller@gmail.com + * + */ +public final class TestConstants { + + private TestConstants() { + // prevent construction. + } + + /** File separator. */ + public static final String FS = File.separator; + + /** The base resource path. */ + public static String BASE_FOLDER_RESOURCES = "src" + FS + "test" + FS + "resources"; + + /** The base folder containing the test files. Ends with {@link #FS}. */ + public static final String MOCK_FOLDER = BASE_FOLDER_RESOURCES + FS + "mocks" + FS; + +} diff --git a/src/test/java/diffutils/examples/ApplyPatch.java b/src/test/java/diffutils/examples/ApplyPatch.java index 7ec1b45..a8f0e78 100644 --- a/src/test/java/diffutils/examples/ApplyPatch.java +++ b/src/test/java/diffutils/examples/ApplyPatch.java @@ -1,3 +1,62 @@ +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + package diffutils.examples; import java.util.List; diff --git a/src/test/java/diffutils/examples/ComputeDifference.java b/src/test/java/diffutils/examples/ComputeDifference.java index a1a3eb1..8ee10cf 100644 --- a/src/test/java/diffutils/examples/ComputeDifference.java +++ b/src/test/java/diffutils/examples/ComputeDifference.java @@ -1,3 +1,62 @@ +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + package diffutils.examples; import java.util.List; diff --git a/src/test/java/diffutils/examples/Example.java b/src/test/java/diffutils/examples/Example.java index 28526cb..fcc34f9 100644 --- a/src/test/java/diffutils/examples/Example.java +++ b/src/test/java/diffutils/examples/Example.java @@ -1,3 +1,62 @@ +/* + * SPDX-License-Identifier: Apache-1.1 + * + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. + * Copyright (c) 2010 Dmitry Naumenko (dm.naumenko@gmail.com) + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgement may appear in the software itself, + * if and wherever such third-party acknowledgements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + package diffutils.examples; import java.io.BufferedReader; diff --git a/src/test/resources/mocks/5A.txt b/src/test/resources/mocks/5A.txt index 96e51b8..69eafd8 100644 --- a/src/test/resources/mocks/5A.txt +++ b/src/test/resources/mocks/5A.txt @@ -1,372 +1,372 @@ -#!/bin/sh -# -# Copyright (c) 2006 Johannes E. Schindelin -# - -test_description='Test special whitespace in diff engine. - -' -. ./test-lib.sh -. ../diff-lib.sh - -# Ray Lehtiniemi's example - -cat << EOF > x -do { - nothing; -} while (0); -EOF - -git update-index --add x - -cat << EOF > x -do -{ - nothing; -} -while (0); -EOF - -cat << EOF > expect -diff --git a/x b/x -index adf3937..6edc172 100644 ---- a/x -+++ b/x -@@ -1,3 +1,5 @@ --do { -+do -+{ - nothing; --} while (0); -+} -+while (0); -EOF - -git diff > out -test_expect_success "Ray's example without options" 'test_cmp expect out' - -git diff -w > out -test_expect_success "Ray's example with -w" 'test_cmp expect out' - -git diff -b > out -test_expect_success "Ray's example with -b" 'test_cmp expect out' - -tr 'Q' '\015' << EOF > x -whitespace at beginning -whitespace change -whitespace in the middle -whitespace at end -unchanged line -CR at endQ -EOF - -git update-index x - -tr '_' ' ' << EOF > x - whitespace at beginning -whitespace change -white space in the middle -whitespace at end__ -unchanged line -CR at end -EOF - -tr 'Q_' '\015 ' << EOF > expect -diff --git a/x b/x -index d99af23..8b32fb5 100644 ---- a/x -+++ b/x -@@ -1,6 +1,6 @@ --whitespace at beginning --whitespace change --whitespace in the middle --whitespace at end -+ whitespace at beginning -+whitespace change -+white space in the middle -+whitespace at end__ -unchanged line --CR at endQ -+CR at end -EOF -git diff > out -test_expect_success 'another test, without options' 'test_cmp expect out' - -cat << EOF > expect -diff --git a/x b/x -index d99af23..8b32fb5 100644 -EOF -git diff -w > out -test_expect_success 'another test, with -w' 'test_cmp expect out' - -tr 'Q' '\015' << EOF > expect -diff --git a/x b/x -index d99af23..8b32fb5 100644 ---- a/x -+++ b/x -@@ -1,6 +1,6 @@ --whitespace at beginning -+ whitespace at beginning -whitespace change --whitespace in the middle -+white space in the middle -whitespace at end -unchanged line -CR at endQ -EOF -git diff -b > out -test_expect_success 'another test, with -b' 'test_cmp expect out' - -test_expect_success 'check mixed spaces and tabs in indent' ' - - # This is indented with SP HT SP. - echo " foo();" > x && - git diff --check | grep "space before tab in indent" - -' - -test_expect_success 'check mixed tabs and spaces in indent' ' - - # This is indented with HT SP HT. - echo " foo();" > x && - git diff --check | grep "space before tab in indent" - -' - -test_expect_success 'check with no whitespace errors' ' - - git commit -m "snapshot" && - echo "foo();" > x && - git diff --check - -' - -test_expect_success 'check with trailing whitespace' ' - - echo "foo(); " > x && - test_must_fail git diff --check - -' - -test_expect_success 'check with space before tab in indent' ' - - # indent has space followed by hard tab - echo " foo();" > x && - test_must_fail git diff --check - -' - -test_expect_success '--check and --exit-code are not exclusive' ' - - git checkout x && - git diff --check --exit-code - -' - -test_expect_success '--check and --quiet are not exclusive' ' - - git diff --check --quiet - -' - -test_expect_success 'check staged with no whitespace errors' ' - - echo "foo();" > x && - git add x && - git diff --cached --check - -' - -test_expect_success 'check staged with trailing whitespace' ' - - echo "foo(); " > x && - git add x && - test_must_fail git diff --cached --check - -' - -test_expect_success 'check staged with space before tab in indent' ' - - # indent has space followed by hard tab - echo " foo();" > x && - git add x && - test_must_fail git diff --cached --check - -' - -test_expect_success 'check with no whitespace errors (diff-index)' ' - - echo "foo();" > x && - git add x && - git diff-index --check HEAD - -' - -test_expect_success 'check with trailing whitespace (diff-index)' ' - - echo "foo(); " > x && - git add x && - test_must_fail git diff-index --check HEAD - -' - -test_expect_success 'check with space before tab in indent (diff-index)' ' - - # indent has space followed by hard tab - echo " foo();" > x && - git add x && - test_must_fail git diff-index --check HEAD - -' - -test_expect_success 'check staged with no whitespace errors (diff-index)' ' - - echo "foo();" > x && - git add x && - git diff-index --cached --check HEAD - -' - -test_expect_success 'check staged with trailing whitespace (diff-index)' ' - - echo "foo(); " > x && - git add x && - test_must_fail git diff-index --cached --check HEAD - -' - -test_expect_success 'check staged with space before tab in indent (diff-index)' ' - - # indent has space followed by hard tab - echo " foo();" > x && - git add x && - test_must_fail git diff-index --cached --check HEAD - -' - -test_expect_success 'check with no whitespace errors (diff-tree)' ' - - echo "foo();" > x && - git commit -m "new commit" x && - git diff-tree --check HEAD^ HEAD - -' - -test_expect_success 'check with trailing whitespace (diff-tree)' ' - - echo "foo(); " > x && - git commit -m "another commit" x && - test_must_fail git diff-tree --check HEAD^ HEAD - -' - -test_expect_success 'check with space before tab in indent (diff-tree)' ' - - # indent has space followed by hard tab - echo " foo();" > x && - git commit -m "yet another" x && - test_must_fail git diff-tree --check HEAD^ HEAD - -' - -test_expect_success 'check trailing whitespace (trailing-space: off)' ' - - git config core.whitespace "-trailing-space" && - echo "foo (); " > x && - git diff --check - -' - -test_expect_success 'check trailing whitespace (trailing-space: on)' ' - - git config core.whitespace "trailing-space" && - echo "foo (); " > x && - test_must_fail git diff --check - -' - -test_expect_success 'check space before tab in indent (space-before-tab: off)' ' - - # indent contains space followed by HT - git config core.whitespace "-space-before-tab" && - echo " foo ();" > x && - git diff --check - -' - -test_expect_success 'check space before tab in indent (space-before-tab: on)' ' - - # indent contains space followed by HT - git config core.whitespace "space-before-tab" && - echo " foo (); " > x && - test_must_fail git diff --check - -' - -test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' ' - - git config core.whitespace "-indent-with-non-tab" - echo " foo ();" > x && - git diff --check - -' - -test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' ' - - git config core.whitespace "indent-with-non-tab" && - echo " foo ();" > x && - test_must_fail git diff --check - -' - -test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' ' - - git config core.whitespace "indent-with-non-tab" && - echo " foo ();" > x && - test_must_fail git diff --check - -' - -test_expect_success 'line numbers in --check output are correct' ' - - echo "" > x && - echo "foo(); " >> x && - git diff --check | grep "x:2:" - -' - -test_expect_success 'checkdiff detects trailing blank lines' ' - echo "foo();" >x && - echo "" >>x && - git diff --check | grep "ends with blank" -' - -test_expect_success 'checkdiff allows new blank lines' ' - git checkout x && - mv x y && - ( - echo "/* This is new */" && - echo "" && - cat y - ) >x && - git diff --check -' - -test_expect_success 'combined diff with autocrlf conversion' ' - - git reset --hard && - echo >x hello && - git commit -m "one side" x && - git checkout HEAD^ && - echo >x goodbye && - git commit -m "the other side" x && - git config core.autocrlf true && - test_must_fail git merge master && - - git diff | sed -e "1,/^@@@/d" >actual && - ! grep "^-" actual - -' - -test_done - +#!/bin/sh +# +# Copyright (c) 2006 Johannes E. Schindelin +# + +test_description='Test special whitespace in diff engine. + +' +. ./test-lib.sh +. ../diff-lib.sh + +# Ray Lehtiniemi's example + +cat << EOF > x +do { + nothing; +} while (0); +EOF + +git update-index --add x + +cat << EOF > x +do +{ + nothing; +} +while (0); +EOF + +cat << EOF > expect +diff --git a/x b/x +index adf3937..6edc172 100644 +--- a/x ++++ b/x +@@ -1,3 +1,5 @@ +-do { ++do ++{ + nothing; +-} while (0); ++} ++while (0); +EOF + +git diff > out +test_expect_success "Ray's example without options" 'test_cmp expect out' + +git diff -w > out +test_expect_success "Ray's example with -w" 'test_cmp expect out' + +git diff -b > out +test_expect_success "Ray's example with -b" 'test_cmp expect out' + +tr 'Q' '\015' << EOF > x +whitespace at beginning +whitespace change +whitespace in the middle +whitespace at end +unchanged line +CR at endQ +EOF + +git update-index x + +tr '_' ' ' << EOF > x + whitespace at beginning +whitespace change +white space in the middle +whitespace at end__ +unchanged line +CR at end +EOF + +tr 'Q_' '\015 ' << EOF > expect +diff --git a/x b/x +index d99af23..8b32fb5 100644 +--- a/x ++++ b/x +@@ -1,6 +1,6 @@ +-whitespace at beginning +-whitespace change +-whitespace in the middle +-whitespace at end ++ whitespace at beginning ++whitespace change ++white space in the middle ++whitespace at end__ +unchanged line +-CR at endQ ++CR at end +EOF +git diff > out +test_expect_success 'another test, without options' 'test_cmp expect out' + +cat << EOF > expect +diff --git a/x b/x +index d99af23..8b32fb5 100644 +EOF +git diff -w > out +test_expect_success 'another test, with -w' 'test_cmp expect out' + +tr 'Q' '\015' << EOF > expect +diff --git a/x b/x +index d99af23..8b32fb5 100644 +--- a/x ++++ b/x +@@ -1,6 +1,6 @@ +-whitespace at beginning ++ whitespace at beginning +whitespace change +-whitespace in the middle ++white space in the middle +whitespace at end +unchanged line +CR at endQ +EOF +git diff -b > out +test_expect_success 'another test, with -b' 'test_cmp expect out' + +test_expect_success 'check mixed spaces and tabs in indent' ' + + # This is indented with SP HT SP. + echo " foo();" > x && + git diff --check | grep "space before tab in indent" + +' + +test_expect_success 'check mixed tabs and spaces in indent' ' + + # This is indented with HT SP HT. + echo " foo();" > x && + git diff --check | grep "space before tab in indent" + +' + +test_expect_success 'check with no whitespace errors' ' + + git commit -m "snapshot" && + echo "foo();" > x && + git diff --check + +' + +test_expect_success 'check with trailing whitespace' ' + + echo "foo(); " > x && + test_must_fail git diff --check + +' + +test_expect_success 'check with space before tab in indent' ' + + # indent has space followed by hard tab + echo " foo();" > x && + test_must_fail git diff --check + +' + +test_expect_success '--check and --exit-code are not exclusive' ' + + git checkout x && + git diff --check --exit-code + +' + +test_expect_success '--check and --quiet are not exclusive' ' + + git diff --check --quiet + +' + +test_expect_success 'check staged with no whitespace errors' ' + + echo "foo();" > x && + git add x && + git diff --cached --check + +' + +test_expect_success 'check staged with trailing whitespace' ' + + echo "foo(); " > x && + git add x && + test_must_fail git diff --cached --check + +' + +test_expect_success 'check staged with space before tab in indent' ' + + # indent has space followed by hard tab + echo " foo();" > x && + git add x && + test_must_fail git diff --cached --check + +' + +test_expect_success 'check with no whitespace errors (diff-index)' ' + + echo "foo();" > x && + git add x && + git diff-index --check HEAD + +' + +test_expect_success 'check with trailing whitespace (diff-index)' ' + + echo "foo(); " > x && + git add x && + test_must_fail git diff-index --check HEAD + +' + +test_expect_success 'check with space before tab in indent (diff-index)' ' + + # indent has space followed by hard tab + echo " foo();" > x && + git add x && + test_must_fail git diff-index --check HEAD + +' + +test_expect_success 'check staged with no whitespace errors (diff-index)' ' + + echo "foo();" > x && + git add x && + git diff-index --cached --check HEAD + +' + +test_expect_success 'check staged with trailing whitespace (diff-index)' ' + + echo "foo(); " > x && + git add x && + test_must_fail git diff-index --cached --check HEAD + +' + +test_expect_success 'check staged with space before tab in indent (diff-index)' ' + + # indent has space followed by hard tab + echo " foo();" > x && + git add x && + test_must_fail git diff-index --cached --check HEAD + +' + +test_expect_success 'check with no whitespace errors (diff-tree)' ' + + echo "foo();" > x && + git commit -m "new commit" x && + git diff-tree --check HEAD^ HEAD + +' + +test_expect_success 'check with trailing whitespace (diff-tree)' ' + + echo "foo(); " > x && + git commit -m "another commit" x && + test_must_fail git diff-tree --check HEAD^ HEAD + +' + +test_expect_success 'check with space before tab in indent (diff-tree)' ' + + # indent has space followed by hard tab + echo " foo();" > x && + git commit -m "yet another" x && + test_must_fail git diff-tree --check HEAD^ HEAD + +' + +test_expect_success 'check trailing whitespace (trailing-space: off)' ' + + git config core.whitespace "-trailing-space" && + echo "foo (); " > x && + git diff --check + +' + +test_expect_success 'check trailing whitespace (trailing-space: on)' ' + + git config core.whitespace "trailing-space" && + echo "foo (); " > x && + test_must_fail git diff --check + +' + +test_expect_success 'check space before tab in indent (space-before-tab: off)' ' + + # indent contains space followed by HT + git config core.whitespace "-space-before-tab" && + echo " foo ();" > x && + git diff --check + +' + +test_expect_success 'check space before tab in indent (space-before-tab: on)' ' + + # indent contains space followed by HT + git config core.whitespace "space-before-tab" && + echo " foo (); " > x && + test_must_fail git diff --check + +' + +test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' ' + + git config core.whitespace "-indent-with-non-tab" + echo " foo ();" > x && + git diff --check + +' + +test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' ' + + git config core.whitespace "indent-with-non-tab" && + echo " foo ();" > x && + test_must_fail git diff --check + +' + +test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' ' + + git config core.whitespace "indent-with-non-tab" && + echo " foo ();" > x && + test_must_fail git diff --check + +' + +test_expect_success 'line numbers in --check output are correct' ' + + echo "" > x && + echo "foo(); " >> x && + git diff --check | grep "x:2:" + +' + +test_expect_success 'checkdiff detects trailing blank lines' ' + echo "foo();" >x && + echo "" >>x && + git diff --check | grep "ends with blank" +' + +test_expect_success 'checkdiff allows new blank lines' ' + git checkout x && + mv x y && + ( + echo "/* This is new */" && + echo "" && + cat y + ) >x && + git diff --check +' + +test_expect_success 'combined diff with autocrlf conversion' ' + + git reset --hard && + echo >x hello && + git commit -m "one side" x && + git checkout HEAD^ && + echo >x goodbye && + git commit -m "the other side" x && + git config core.autocrlf true && + test_must_fail git merge master && + + git diff | sed -e "1,/^@@@/d" >actual && + ! grep "^-" actual + +' + +test_done + diff --git a/src/test/resources/mocks/5B.txt b/src/test/resources/mocks/5B.txt index dd12cf4..112cff5 100644 --- a/src/test/resources/mocks/5B.txt +++ b/src/test/resources/mocks/5B.txt @@ -1,381 +1,381 @@ -#!/bin/sh -# -# Copyright (c) 2006 Johannes E. Schindelin -# - -test_description='Test special whitespace in diff engine. - -' -. ./test-lib.sh -. ../diff-lib.sh - -# Ray Lehtiniemi's example - -cat << EOF > x -do { - nothing; -} while (0); -EOF - -git update-index --add x - -cat << EOF > x -do -{ - nothing; -} -while (0); -EOF - -cat << EOF > expect -diff --git a/x b/x -index adf3937..6edc172 100644 ---- a/x -+++ b/x -@@ -1,3 +1,5 @@ --do { -+do -+{ - nothing; --} while (0); -+} -+while (0); -EOF - -git diff > out -test_expect_success "Ray's example without options" 'test_cmp expect out' - -git diff -w > out -test_expect_success "Ray's example with -w" 'test_cmp expect out' - -git diff -b > out -test_expect_success "Ray's example with -b" 'test_cmp expect out' - -tr 'Q' '\015' << EOF > x -whitespace at beginning -whitespace change -whitespace in the middle -whitespace at end -unchanged line -CR at endQ -EOF - -git update-index x - -tr '_' ' ' << EOF > x - whitespace at beginning -whitespace change -white space in the middle -whitespace at end__ -unchanged line -CR at end -EOF - -tr 'Q_' '\015 ' << EOF > expect -diff --git a/x b/x -index d99af23..8b32fb5 100644 ---- a/x -+++ b/x -@@ -1,6 +1,6 @@ --whitespace at beginning --whitespace change --whitespace in the middle --whitespace at end -+ whitespace at beginning -+whitespace change -+white space in the middle -+whitespace at end__ -unchanged line --CR at endQ -+CR at end -EOF -git diff > out -test_expect_success 'another test, without options' 'test_cmp expect out' - -cat << EOF > expect -diff --git a/x b/x -index d99af23..8b32fb5 100644 -EOF -git diff -w > out -test_expect_success 'another test, with -w' 'test_cmp expect out' - -tr 'Q' '\015' << EOF > expect -diff --git a/x b/x -index d99af23..8b32fb5 100644 ---- a/x -+++ b/x -@@ -1,6 +1,6 @@ --whitespace at beginning -+ whitespace at beginning -whitespace change --whitespace in the middle -+white space in the middle -whitespace at end -unchanged line -CR at endQ -git diff -b --ignore-space-at-eol > out -test_expect_failure 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out' - -tr 'Q' '\015' << EOF > expect -diff --git a/x b/x -index d99af23..8b32fb5 100644 ---- a/x -+++ b/x -EOF -git diff -b > out -test_expect_success 'another test, with -b' 'test_cmp expect out' - -test_expect_success 'check mixed spaces and tabs in indent' ' - - # This is indented with SP HT SP. - echo " foo();" > x && - git diff --check | grep "space before tab in indent" - -' - -test_expect_success 'check mixed tabs and spaces in indent' ' - - # This is indented with HT SP HT. - echo " foo();" > x && - git diff --check | grep "space before tab in indent" - -' - -test_expect_success 'check with no whitespace errors' ' - - git commit -m "snapshot" && - echo "foo();" > x && - git diff --check - -' - -test_expect_success 'check with trailing whitespace' ' - - echo "foo(); " > x && - test_must_fail git diff --check - -' - -test_expect_success 'check with space before tab in indent' ' - - # indent has space followed by hard tab - echo " foo();" > x && - test_must_fail git diff --check - -' - -test_expect_success '--check and --exit-code are not exclusive' ' - - git checkout x && - git diff --check --exit-code - -' - -test_expect_success '--check and --quiet are not exclusive' ' - - git diff --check --quiet - -' - -test_expect_success 'check staged with no whitespace errors' ' - - echo "foo();" > x && - git add x && - git diff --cached --check - -' - -test_expect_success 'check staged with trailing whitespace' ' - - echo "foo(); " > x && - git add x && - test_must_fail git diff --cached --check - -' - -test_expect_success 'check staged with space before tab in indent' ' - - # indent has space followed by hard tab - echo " foo();" > x && - git add x && - test_must_fail git diff --cached --check - -' - -test_expect_success 'check with no whitespace errors (diff-index)' ' - - echo "foo();" > x && - git add x && - git diff-index --check HEAD - -' - -test_expect_success 'check with trailing whitespace (diff-index)' ' - - echo "foo(); " > x && - git add x && - test_must_fail git diff-index --check HEAD - -' - -test_expect_success 'check with space before tab in indent (diff-index)' ' - - # indent has space followed by hard tab - echo " foo();" > x && - git add x && - test_must_fail git diff-index --check HEAD - -' - -test_expect_success 'check staged with no whitespace errors (diff-index)' ' - - echo "foo();" > x && - git add x && - git diff-index --cached --check HEAD - -' - -test_expect_success 'check staged with trailing whitespace (diff-index)' ' - - echo "foo(); " > x && - git add x && - test_must_fail git diff-index --cached --check HEAD - -' - -test_expect_success 'check staged with space before tab in indent (diff-index)' ' - - # indent has space followed by hard tab - echo " foo();" > x && - git add x && - test_must_fail git diff-index --cached --check HEAD - -' - -test_expect_success 'check with no whitespace errors (diff-tree)' ' - - echo "foo();" > x && - git commit -m "new commit" x && - git diff-tree --check HEAD^ HEAD - -' - -test_expect_success 'check with trailing whitespace (diff-tree)' ' - - echo "foo(); " > x && - git commit -m "another commit" x && - test_must_fail git diff-tree --check HEAD^ HEAD - -' - -test_expect_success 'check with space before tab in indent (diff-tree)' ' - - # indent has space followed by hard tab - echo " foo();" > x && - git commit -m "yet another" x && - test_must_fail git diff-tree --check HEAD^ HEAD - -' - -test_expect_success 'check trailing whitespace (trailing-space: off)' ' - - git config core.whitespace "-trailing-space" && - echo "foo (); " > x && - git diff --check - -' - -test_expect_success 'check trailing whitespace (trailing-space: on)' ' - - git config core.whitespace "trailing-space" && - echo "foo (); " > x && - test_must_fail git diff --check - -' - -test_expect_success 'check space before tab in indent (space-before-tab: off)' ' - - # indent contains space followed by HT - git config core.whitespace "-space-before-tab" && - echo " foo ();" > x && - git diff --check - -' - -test_expect_success 'check space before tab in indent (space-before-tab: on)' ' - - # indent contains space followed by HT - git config core.whitespace "space-before-tab" && - echo " foo (); " > x && - test_must_fail git diff --check - -' - -test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' ' - - git config core.whitespace "-indent-with-non-tab" - echo " foo ();" > x && - git diff --check - -' - -test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' ' - - git config core.whitespace "indent-with-non-tab" && - echo " foo ();" > x && - test_must_fail git diff --check - -' - -test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' ' - - git config core.whitespace "indent-with-non-tab" && - echo " foo ();" > x && - test_must_fail git diff --check - -' - -test_expect_success 'line numbers in --check output are correct' ' - - echo "" > x && - echo "foo(); " >> x && - git diff --check | grep "x:2:" - -' - -test_expect_success 'checkdiff detects trailing blank lines' ' - echo "foo();" >x && - echo "" >>x && - git diff --check | grep "ends with blank" -' - -test_expect_success 'checkdiff allows new blank lines' ' - git checkout x && - mv x y && - ( - echo "/* This is new */" && - echo "" && - cat y - ) >x && - git diff --check -' - -test_expect_success 'combined diff with autocrlf conversion' ' - - git reset --hard && - echo >x hello && - git commit -m "one side" x && - git checkout HEAD^ && - echo >x goodbye && - git commit -m "the other side" x && - git config core.autocrlf true && - test_must_fail git merge master && - - git diff | sed -e "1,/^@@@/d" >actual && - ! grep "^-" actual - -' - -test_done - - +#!/bin/sh +# +# Copyright (c) 2006 Johannes E. Schindelin +# + +test_description='Test special whitespace in diff engine. + +' +. ./test-lib.sh +. ../diff-lib.sh + +# Ray Lehtiniemi's example + +cat << EOF > x +do { + nothing; +} while (0); +EOF + +git update-index --add x + +cat << EOF > x +do +{ + nothing; +} +while (0); +EOF + +cat << EOF > expect +diff --git a/x b/x +index adf3937..6edc172 100644 +--- a/x ++++ b/x +@@ -1,3 +1,5 @@ +-do { ++do ++{ + nothing; +-} while (0); ++} ++while (0); +EOF + +git diff > out +test_expect_success "Ray's example without options" 'test_cmp expect out' + +git diff -w > out +test_expect_success "Ray's example with -w" 'test_cmp expect out' + +git diff -b > out +test_expect_success "Ray's example with -b" 'test_cmp expect out' + +tr 'Q' '\015' << EOF > x +whitespace at beginning +whitespace change +whitespace in the middle +whitespace at end +unchanged line +CR at endQ +EOF + +git update-index x + +tr '_' ' ' << EOF > x + whitespace at beginning +whitespace change +white space in the middle +whitespace at end__ +unchanged line +CR at end +EOF + +tr 'Q_' '\015 ' << EOF > expect +diff --git a/x b/x +index d99af23..8b32fb5 100644 +--- a/x ++++ b/x +@@ -1,6 +1,6 @@ +-whitespace at beginning +-whitespace change +-whitespace in the middle +-whitespace at end ++ whitespace at beginning ++whitespace change ++white space in the middle ++whitespace at end__ +unchanged line +-CR at endQ ++CR at end +EOF +git diff > out +test_expect_success 'another test, without options' 'test_cmp expect out' + +cat << EOF > expect +diff --git a/x b/x +index d99af23..8b32fb5 100644 +EOF +git diff -w > out +test_expect_success 'another test, with -w' 'test_cmp expect out' + +tr 'Q' '\015' << EOF > expect +diff --git a/x b/x +index d99af23..8b32fb5 100644 +--- a/x ++++ b/x +@@ -1,6 +1,6 @@ +-whitespace at beginning ++ whitespace at beginning +whitespace change +-whitespace in the middle ++white space in the middle +whitespace at end +unchanged line +CR at endQ +git diff -b --ignore-space-at-eol > out +test_expect_failure 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out' + +tr 'Q' '\015' << EOF > expect +diff --git a/x b/x +index d99af23..8b32fb5 100644 +--- a/x ++++ b/x +EOF +git diff -b > out +test_expect_success 'another test, with -b' 'test_cmp expect out' + +test_expect_success 'check mixed spaces and tabs in indent' ' + + # This is indented with SP HT SP. + echo " foo();" > x && + git diff --check | grep "space before tab in indent" + +' + +test_expect_success 'check mixed tabs and spaces in indent' ' + + # This is indented with HT SP HT. + echo " foo();" > x && + git diff --check | grep "space before tab in indent" + +' + +test_expect_success 'check with no whitespace errors' ' + + git commit -m "snapshot" && + echo "foo();" > x && + git diff --check + +' + +test_expect_success 'check with trailing whitespace' ' + + echo "foo(); " > x && + test_must_fail git diff --check + +' + +test_expect_success 'check with space before tab in indent' ' + + # indent has space followed by hard tab + echo " foo();" > x && + test_must_fail git diff --check + +' + +test_expect_success '--check and --exit-code are not exclusive' ' + + git checkout x && + git diff --check --exit-code + +' + +test_expect_success '--check and --quiet are not exclusive' ' + + git diff --check --quiet + +' + +test_expect_success 'check staged with no whitespace errors' ' + + echo "foo();" > x && + git add x && + git diff --cached --check + +' + +test_expect_success 'check staged with trailing whitespace' ' + + echo "foo(); " > x && + git add x && + test_must_fail git diff --cached --check + +' + +test_expect_success 'check staged with space before tab in indent' ' + + # indent has space followed by hard tab + echo " foo();" > x && + git add x && + test_must_fail git diff --cached --check + +' + +test_expect_success 'check with no whitespace errors (diff-index)' ' + + echo "foo();" > x && + git add x && + git diff-index --check HEAD + +' + +test_expect_success 'check with trailing whitespace (diff-index)' ' + + echo "foo(); " > x && + git add x && + test_must_fail git diff-index --check HEAD + +' + +test_expect_success 'check with space before tab in indent (diff-index)' ' + + # indent has space followed by hard tab + echo " foo();" > x && + git add x && + test_must_fail git diff-index --check HEAD + +' + +test_expect_success 'check staged with no whitespace errors (diff-index)' ' + + echo "foo();" > x && + git add x && + git diff-index --cached --check HEAD + +' + +test_expect_success 'check staged with trailing whitespace (diff-index)' ' + + echo "foo(); " > x && + git add x && + test_must_fail git diff-index --cached --check HEAD + +' + +test_expect_success 'check staged with space before tab in indent (diff-index)' ' + + # indent has space followed by hard tab + echo " foo();" > x && + git add x && + test_must_fail git diff-index --cached --check HEAD + +' + +test_expect_success 'check with no whitespace errors (diff-tree)' ' + + echo "foo();" > x && + git commit -m "new commit" x && + git diff-tree --check HEAD^ HEAD + +' + +test_expect_success 'check with trailing whitespace (diff-tree)' ' + + echo "foo(); " > x && + git commit -m "another commit" x && + test_must_fail git diff-tree --check HEAD^ HEAD + +' + +test_expect_success 'check with space before tab in indent (diff-tree)' ' + + # indent has space followed by hard tab + echo " foo();" > x && + git commit -m "yet another" x && + test_must_fail git diff-tree --check HEAD^ HEAD + +' + +test_expect_success 'check trailing whitespace (trailing-space: off)' ' + + git config core.whitespace "-trailing-space" && + echo "foo (); " > x && + git diff --check + +' + +test_expect_success 'check trailing whitespace (trailing-space: on)' ' + + git config core.whitespace "trailing-space" && + echo "foo (); " > x && + test_must_fail git diff --check + +' + +test_expect_success 'check space before tab in indent (space-before-tab: off)' ' + + # indent contains space followed by HT + git config core.whitespace "-space-before-tab" && + echo " foo ();" > x && + git diff --check + +' + +test_expect_success 'check space before tab in indent (space-before-tab: on)' ' + + # indent contains space followed by HT + git config core.whitespace "space-before-tab" && + echo " foo (); " > x && + test_must_fail git diff --check + +' + +test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' ' + + git config core.whitespace "-indent-with-non-tab" + echo " foo ();" > x && + git diff --check + +' + +test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' ' + + git config core.whitespace "indent-with-non-tab" && + echo " foo ();" > x && + test_must_fail git diff --check + +' + +test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' ' + + git config core.whitespace "indent-with-non-tab" && + echo " foo ();" > x && + test_must_fail git diff --check + +' + +test_expect_success 'line numbers in --check output are correct' ' + + echo "" > x && + echo "foo(); " >> x && + git diff --check | grep "x:2:" + +' + +test_expect_success 'checkdiff detects trailing blank lines' ' + echo "foo();" >x && + echo "" >>x && + git diff --check | grep "ends with blank" +' + +test_expect_success 'checkdiff allows new blank lines' ' + git checkout x && + mv x y && + ( + echo "/* This is new */" && + echo "" && + cat y + ) >x && + git diff --check +' + +test_expect_success 'combined diff with autocrlf conversion' ' + + git reset --hard && + echo >x hello && + git commit -m "one side" x && + git checkout HEAD^ && + echo >x goodbye && + git commit -m "the other side" x && + git config core.autocrlf true && + test_must_fail git merge master && + + git diff | sed -e "1,/^@@@/d" >actual && + ! grep "^-" actual + +' + +test_done + + diff --git a/src/test/resources/mocks/unified_empty_context_original.txt b/src/test/resources/mocks/unified_empty_context_original.txt new file mode 100644 index 0000000..24346cc --- /dev/null +++ b/src/test/resources/mocks/unified_empty_context_original.txt @@ -0,0 +1,5 @@ +This +is +a +test +file diff --git a/src/test/resources/mocks/unified_empty_context_patch.txt b/src/test/resources/mocks/unified_empty_context_patch.txt new file mode 100644 index 0000000..1249035 --- /dev/null +++ b/src/test/resources/mocks/unified_empty_context_patch.txt @@ -0,0 +1,6 @@ +--- uc_original.txt 2011-06-14 16:21:56.578627000 +0300 ++++ uc_insert_revised.txt 2011-06-14 16:20:37.654820000 +0300 +@@ -2,0 +3 @@ ++not +@@ -5 +5,0 @@ +-file diff --git a/src/test/resources/mocks/unified_empty_context_revised.txt b/src/test/resources/mocks/unified_empty_context_revised.txt new file mode 100644 index 0000000..ce3ca7b --- /dev/null +++ b/src/test/resources/mocks/unified_empty_context_revised.txt @@ -0,0 +1,5 @@ +This +is +not +a +test