>();
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