Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
+
+All rights reserved.
+Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS 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 COPYRIGHT OWNER OR 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.
+
+
+Marc Stevens
+Cryptology Group
+Centrum Wiskunde & Informatica
+P.O. Box 94079, 1090 GB Amsterdam, Netherlands
+marc@marc-stevens.nl
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+
+
+
diff --git a/org.eclipse.jgit.ssh.jsch/build.properties b/org.eclipse.jgit.ssh.jsch/build.properties
new file mode 100644
index 000000000..8148271ef
--- /dev/null
+++ b/org.eclipse.jgit.ssh.jsch/build.properties
@@ -0,0 +1,7 @@
+source.. = src/,\
+ resources/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ about.html
diff --git a/org.eclipse.jgit.ssh.jsch/plugin.properties b/org.eclipse.jgit.ssh.jsch/plugin.properties
new file mode 100644
index 000000000..126709b96
--- /dev/null
+++ b/org.eclipse.jgit.ssh.jsch/plugin.properties
@@ -0,0 +1,2 @@
+Bundle-Name=JGit SSH support based on JSch
+Bundle-Vendor=Eclipse JGit
diff --git a/org.eclipse.jgit.ssh.jsch/pom.xml b/org.eclipse.jgit.ssh.jsch/pom.xml
new file mode 100644
index 000000000..2b0f1eec3
--- /dev/null
+++ b/org.eclipse.jgit.ssh.jsch/pom.xml
@@ -0,0 +1,218 @@
+
+
+
+ and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.internal.transport.jsch;
+
+import org.eclipse.jgit.nls.NLS;
+import org.eclipse.jgit.nls.TranslationBundle;
+
+/**
+ * Externalized text messages for localization.
+ */
+public final class JSchText extends TranslationBundle {
+
+ /**
+ * Get an instance of this translation bundle.
+ *
+ * @return an instance of this translation bundle
+ */
+ public static JSchText get() {
+ return NLS.getBundleFor(JSchText.class);
+ }
+
+ // @formatter:off
+ /***/ public String connectionFailed;
+ /***/ public String sshUserNameError;
+ /***/ public String transportSSHRetryInterrupt;
+ /***/ public String unknownHost;
+
+}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java
similarity index 98%
rename from org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java
rename to org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java
index 10646b9e7..01adcf30b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java
+++ b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java
@@ -8,6 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+//TODO(ms): move to org.eclipse.jgit.ssh.jsch in 6.0
package org.eclipse.jgit.transport;
import java.util.ArrayList;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
similarity index 96%
rename from org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
rename to org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
index 718c8f611..88202dd2d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
+++ b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
@@ -15,6 +15,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+//TODO(ms): move to org.eclipse.jgit.ssh.jsch in 6.0
package org.eclipse.jgit.transport;
import static java.util.stream.Collectors.joining;
@@ -37,7 +38,7 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.eclipse.jgit.errors.TransportException;
-import org.eclipse.jgit.internal.JGitText;
+import org.eclipse.jgit.internal.transport.jsch.JSchText;
import org.eclipse.jgit.util.FS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,7 +63,9 @@ import com.jcraft.jsch.Session;
* {@link #configure(org.eclipse.jgit.transport.OpenSshConfig.Host, Session)} to
* supply appropriate {@link com.jcraft.jsch.UserInfo} to the session.
*/
-public abstract class JschConfigSessionFactory extends SshSessionFactory {
+public class JschConfigSessionFactory extends SshSessionFactory {
+
+ private static final String JSCH = "jsch"; //$NON-NLS-1$
private static final Logger LOG = LoggerFactory
.getLogger(JschConfigSessionFactory.class);
@@ -137,7 +140,7 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
user, pass, host, port, hc);
} catch (InterruptedException e1) {
throw new TransportException(
- JGitText.get().transportSSHRetryInterrupt,
+ JSchText.get().transportSSHRetryInterrupt,
e1);
}
}
@@ -149,7 +152,8 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
} catch (JSchException je) {
final Throwable c = je.getCause();
if (c instanceof UnknownHostException) {
- throw new TransportException(uri, JGitText.get().unknownHost,
+ throw new TransportException(uri,
+ JSchText.get().unknownHost,
je);
}
if (c instanceof ConnectException) {
@@ -160,6 +164,11 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
}
+ @Override
+ public String getType() {
+ return JSCH;
+ }
+
private static boolean isAuthenticationFailed(JSchException e) {
return e.getCause() == null && e.getMessage().equals("Auth fail"); //$NON-NLS-1$
}
@@ -279,7 +288,7 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
} catch (NullPointerException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
- LOG.error(MessageFormat.format(JGitText.get().sshUserNameError,
+ LOG.error(MessageFormat.format(JSchText.get().sshUserNameError,
userName, session.getUserName()), e);
}
}
@@ -331,7 +340,9 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
* @param session
* session to configure
*/
- protected abstract void configure(OpenSshConfig.Host hc, Session session);
+ protected void configure(OpenSshConfig.Host hc, Session session) {
+ // No additional configuration required.
+ }
/**
* Obtain the JSch used to create new sessions.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/JschSession.java
similarity index 98%
rename from org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java
rename to org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/JschSession.java
index d7270343c..300e03d79 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java
+++ b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/JschSession.java
@@ -13,6 +13,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+//TODO(ms): move to org.eclipse.jgit.ssh.jsch in 6.0
package org.eclipse.jgit.transport;
import java.io.BufferedOutputStream;
@@ -26,7 +27,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import org.eclipse.jgit.errors.TransportException;
-import org.eclipse.jgit.internal.JGitText;
+import org.eclipse.jgit.internal.transport.jsch.JSchText;
import org.eclipse.jgit.util.io.IsolatedOutputStream;
import com.jcraft.jsch.Channel;
@@ -142,7 +143,7 @@ public class JschSession implements RemoteSession {
if (!channel.isConnected()) {
closeOutputStream();
throw new TransportException(uri,
- JGitText.get().connectionFailed);
+ JSchText.get().connectionFailed);
}
} catch (JSchException e) {
closeOutputStream();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/OpenSshConfig.java
similarity index 98%
rename from org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java
rename to org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/OpenSshConfig.java
index a628897a5..5c6c80c76 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java
+++ b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/OpenSshConfig.java
@@ -8,6 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+//TODO(ms): move to org.eclipse.jgit.ssh.jsch in 6.0
package org.eclipse.jgit.transport;
import static org.eclipse.jgit.internal.transport.ssh.OpenSshConfigFile.positive;
@@ -39,8 +40,8 @@ import com.jcraft.jsch.ConfigRepository;
*
* This parser makes the critical options available to
* {@link org.eclipse.jgit.transport.SshSessionFactory} via
- * {@link org.eclipse.jgit.transport.OpenSshConfig.Host} objects returned by
- * {@link #lookup(String)}, and implements a fully conforming
+ * {@link org.eclipse.jgit.transport.OpenSshConfig.Host} objects returned
+ * by {@link #lookup(String)}, and implements a fully conforming
* {@link com.jcraft.jsch.ConfigRepository} providing
* {@link com.jcraft.jsch.ConfigRepository.Config}s via
* {@link #getConfig(String)}.
diff --git a/org.eclipse.jgit.test/.classpath b/org.eclipse.jgit.test/.classpath
index 7cc18cca3..c99a7b0d3 100644
--- a/org.eclipse.jgit.test/.classpath
+++ b/org.eclipse.jgit.test/.classpath
@@ -1,22 +1,21 @@
-
+
-
+
-
+
-
diff --git a/org.eclipse.jgit.test/BUILD b/org.eclipse.jgit.test/BUILD
index b04ac553d..f12646e85 100644
--- a/org.eclipse.jgit.test/BUILD
+++ b/org.eclipse.jgit.test/BUILD
@@ -58,7 +58,6 @@ java_library(
resources = DATA,
deps = [
"//lib:assertj-core",
- "//lib:jsch",
"//lib:junit",
"//lib:mockito",
"//lib:slf4j-simple",
@@ -67,26 +66,6 @@ java_library(
],
)
-java_library(
- name = "sshd-helpers",
- testonly = 1,
- srcs = glob(["src/org/eclipse/jgit/transport/ssh/*.java"]),
- resource_strip_prefix = "org.eclipse.jgit.test/resources",
- resources = RESOURCES,
- visibility = [
- "//org.eclipse.jgit.ssh.apache.test:__pkg__",
- ],
- deps = [
- "//lib:jsch",
- "//lib:junit",
- "//lib:sshd-osgi",
- "//lib:sshd-sftp",
- "//org.eclipse.jgit:jgit",
- "//org.eclipse.jgit.junit:junit",
- "//org.eclipse.jgit.junit.ssh:junit-ssh",
- ],
-)
-
java_import(
name = "tst_rsrc",
jars = [":tst_rsrc_jar"],
diff --git a/org.eclipse.jgit.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.test/META-INF/MANIFEST.MF
index 97cf7e270..c4c03b744 100644
--- a/org.eclipse.jgit.test/META-INF/MANIFEST.MF
+++ b/org.eclipse.jgit.test/META-INF/MANIFEST.MF
@@ -6,10 +6,8 @@ Bundle-SymbolicName: org.eclipse.jgit.test
Bundle-Version: 6.0.0.qualifier
Bundle-Localization: plugin
Bundle-Vendor: %Bundle-Vendor
-Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.googlecode.javaewah;version="[1.1.6,2.0.0)",
- com.jcraft.jsch;version="[0.1.54,0.2.0)",
net.bytebuddy.dynamic.loading;version="[1.9.0,2.0.0)",
org.apache.commons.compress.archivers;version="[1.15.0,2.0)",
org.apache.commons.compress.archivers.tar;version="[1.15.0,2.0)",
@@ -42,10 +40,10 @@ Import-Package: com.googlecode.javaewah;version="[1.1.6,2.0.0)",
org.eclipse.jgit.internal.storage.pack;version="[6.0.0,6.1.0)",
org.eclipse.jgit.internal.storage.reftable;version="[6.0.0,6.1.0)",
org.eclipse.jgit.internal.storage.reftree;version="[6.0.0,6.1.0)",
+ org.eclipse.jgit.internal.transport.connectivity;version="[6.0.0,6.1.0)",
org.eclipse.jgit.internal.transport.http;version="[6.0.0,6.1.0)",
org.eclipse.jgit.internal.transport.parser;version="[6.0.0,6.1.0)",
org.eclipse.jgit.junit;version="[6.0.0,6.1.0)",
- org.eclipse.jgit.junit.ssh;version="[6.0.0,6.1.0)",
org.eclipse.jgit.junit.time;version="[6.0.0,6.1.0)",
org.eclipse.jgit.lfs;version="[6.0.0,6.1.0)",
org.eclipse.jgit.lib;version="[6.0.0,6.1.0)",
@@ -85,4 +83,3 @@ Import-Package: com.googlecode.javaewah;version="[1.1.6,2.0.0)",
org.tukaani.xz;version="[1.6.0,2.0)"
Require-Bundle: org.hamcrest.core;bundle-version="[1.1.0,2.0.0)",
org.hamcrest.library;bundle-version="[1.1.0,2.0.0)"
-Export-Package: org.eclipse.jgit.transport.ssh;version="6.0.0";x-friends:="org.eclipse.jgit.ssh.apache.test"
diff --git a/org.eclipse.jgit.test/build.properties b/org.eclipse.jgit.test/build.properties
index 78c8f55f3..7dc26c0b0 100644
--- a/org.eclipse.jgit.test/build.properties
+++ b/org.eclipse.jgit.test/build.properties
@@ -1,8 +1,7 @@
source.. = tst/,\
tst-rsrc/,\
exttst/,\
- src/,\
- resources/
+ src/
bin.includes = META-INF/,\
.,\
plugin.properties,\
diff --git a/org.eclipse.jgit.test/pom.xml b/org.eclipse.jgit.test/pom.xml
index a08b94cd5..345e3a4be 100644
--- a/org.eclipse.jgit.test/pom.xml
+++ b/org.eclipse.jgit.test/pom.xml
@@ -149,9 +149,6 @@
plugin.properties
-
- resources/
-
diff --git a/org.eclipse.jgit.test/tests.bzl b/org.eclipse.jgit.test/tests.bzl
index d03031645..34df07d5e 100644
--- a/org.eclipse.jgit.test/tests.bzl
+++ b/org.eclipse.jgit.test/tests.bzl
@@ -34,26 +34,10 @@ def tests(tests):
additional_deps = [
"//org.eclipse.jgit:insecure_cipher_factory",
]
- if src.endswith("OpenSshConfigTest.java"):
- additional_deps = [
- "//lib:jsch",
- ]
- if src.endswith("JschConfigSessionFactoryTest.java"):
- additional_deps = [
- "//lib:jsch",
- ]
if src.endswith("SecurityManagerMissingPermissionsTest.java"):
additional_deps = [
"//lib:log4j",
]
- if src.endswith("JSchSshTest.java"):
- additional_deps = [
- "//lib:jsch",
- "//lib:jzlib",
- "//lib:sshd-osgi",
- "//lib:sshd-sftp",
- ":sshd-helpers",
- ]
if src.endswith("JDKHttpConnectionTest.java"):
additional_deps = [
"//lib:mockito",
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/attributes/add.png b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/attributes/add.png
new file mode 100644
index 000000000..c6aeae4d4
Binary files /dev/null and b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/attributes/add.png differ
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown.patch b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown.patch
new file mode 100644
index 000000000..74c33714b
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown.patch
@@ -0,0 +1,14 @@
+diff --git a/ShiftDown b/ShiftDown
+index 8b9727b..25dc192 100644
+--- a/ShiftDown
++++ b/ShiftDown
+@@ -16,6 +16,9 @@
+ something("A.b", "bar");
+ }
+
++ public void methodC() {
++ something("A.c", "bar");
++ }
+ }
+
+ public class B {
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown2.patch b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown2.patch
new file mode 100644
index 000000000..a2b34b354
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown2.patch
@@ -0,0 +1,24 @@
+diff --git a/ShiftDown2 b/ShiftDown2
+index 8b9727b..63353aa 100644
+--- a/ShiftDown2
++++ b/ShiftDown2
+@@ -16,6 +16,9 @@
+ something("A.b", "bar");
+ }
+
++ public void methodC() {
++ something("A.c", "bar");
++ }
+ }
+
+ public class B {
+@@ -28,5 +31,9 @@
+ something("B.b", "bar");
+ }
+
++ public void methodC() {
++ something("B.c", "bar");
++ }
++
+ }
+ }
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown2_PostImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown2_PostImage
new file mode 100644
index 000000000..738484eef
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown2_PostImage
@@ -0,0 +1,75 @@
+package org.eclipse.jgit.test.apply;
+
+public class TestClass {
+
+ private void something(String prefix, String msg) {
+ System.out.println(prefix + ": " + msg);
+ }
+
+ public class D {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class E {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class F {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class A {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ public void methodC() {
+ something("A.c", "bar");
+ }
+ }
+
+ public class B {
+
+ public void methodA() {
+ something("B.a", "foo");
+ }
+
+ public void methodB() {
+ something("B.b", "bar");
+ }
+
+ public void methodC() {
+ something("B.c", "bar");
+ }
+
+ }
+}
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown2_PreImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown2_PreImage
new file mode 100644
index 000000000..e1ee19c4d
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown2_PreImage
@@ -0,0 +1,68 @@
+package org.eclipse.jgit.test.apply;
+
+public class TestClass {
+
+ private void something(String prefix, String msg) {
+ System.out.println(prefix + ": " + msg);
+ }
+
+ public class D {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class E {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class F {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class A {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class B {
+
+ public void methodA() {
+ something("B.a", "foo");
+ }
+
+ public void methodB() {
+ something("B.b", "bar");
+ }
+
+ }
+}
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown_PostImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown_PostImage
new file mode 100644
index 000000000..5c6e9bccb
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown_PostImage
@@ -0,0 +1,71 @@
+package org.eclipse.jgit.test.apply;
+
+public class TestClass {
+
+ private void something(String prefix, String msg) {
+ System.out.println(prefix + ": " + msg);
+ }
+
+ public class D {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class E {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class F {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class A {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ public void methodC() {
+ something("A.c", "bar");
+ }
+ }
+
+ public class B {
+
+ public void methodA() {
+ something("B.a", "foo");
+ }
+
+ public void methodB() {
+ something("B.b", "bar");
+ }
+
+ }
+}
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown_PreImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown_PreImage
new file mode 100644
index 000000000..e1ee19c4d
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftDown_PreImage
@@ -0,0 +1,68 @@
+package org.eclipse.jgit.test.apply;
+
+public class TestClass {
+
+ private void something(String prefix, String msg) {
+ System.out.println(prefix + ": " + msg);
+ }
+
+ public class D {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class E {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class F {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class A {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class B {
+
+ public void methodA() {
+ something("B.a", "foo");
+ }
+
+ public void methodB() {
+ something("B.b", "bar");
+ }
+
+ }
+}
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp.patch b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp.patch
new file mode 100644
index 000000000..aa994a12e
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp.patch
@@ -0,0 +1,14 @@
+diff --git a/ShiftUp b/ShiftUp
+index e1ee19c..5c6e9bc 100644
+--- a/ShiftUp
++++ b/ShiftUp
+@@ -52,6 +52,9 @@
+ something("A.b", "bar");
+ }
+
++ public void methodC() {
++ something("A.c", "bar");
++ }
+ }
+
+ public class B {
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp2.patch b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp2.patch
new file mode 100644
index 000000000..eca99714c
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp2.patch
@@ -0,0 +1,23 @@
+diff --git a/ShiftUp2 b/ShiftUp2
+index e1ee19c..f010144 100644
+--- a/ShiftUp2
++++ b/ShiftUp2
+@@ -52,6 +52,9 @@
+ something("A.b", "bar");
+ }
+
++ public void methodC() {
++ something("A.c", "bar");
++ }
+ }
+
+ public class B {
+@@ -64,5 +67,8 @@
+ something("B.b", "bar");
+ }
+
++ public void methodC() {
++ something("B.c", "bar");
++ }
+ }
+ }
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp2_PostImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp2_PostImage
new file mode 100644
index 000000000..e279ecedd
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp2_PostImage
@@ -0,0 +1,38 @@
+package org.eclipse.jgit.test.apply;
+
+public class TestClass {
+
+ private void something(String prefix, String msg) {
+ System.out.println(prefix + ": " + msg);
+ }
+
+ public class A {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ public void methodC() {
+ something("A.c", "bar");
+ }
+ }
+
+ public class B {
+
+ public void methodA() {
+ something("B.a", "foo");
+ }
+
+ public void methodB() {
+ something("B.b", "bar");
+ }
+
+ public void methodC() {
+ something("B.c", "bar");
+ }
+ }
+}
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp2_PreImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp2_PreImage
new file mode 100644
index 000000000..8b9727b01
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp2_PreImage
@@ -0,0 +1,32 @@
+package org.eclipse.jgit.test.apply;
+
+public class TestClass {
+
+ private void something(String prefix, String msg) {
+ System.out.println(prefix + ": " + msg);
+ }
+
+ public class A {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class B {
+
+ public void methodA() {
+ something("B.a", "foo");
+ }
+
+ public void methodB() {
+ something("B.b", "bar");
+ }
+
+ }
+}
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp_PostImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp_PostImage
new file mode 100644
index 000000000..25dc192b0
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp_PostImage
@@ -0,0 +1,35 @@
+package org.eclipse.jgit.test.apply;
+
+public class TestClass {
+
+ private void something(String prefix, String msg) {
+ System.out.println(prefix + ": " + msg);
+ }
+
+ public class A {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ public void methodC() {
+ something("A.c", "bar");
+ }
+ }
+
+ public class B {
+
+ public void methodA() {
+ something("B.a", "foo");
+ }
+
+ public void methodB() {
+ something("B.b", "bar");
+ }
+
+ }
+}
diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp_PreImage b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp_PreImage
new file mode 100644
index 000000000..8b9727b01
--- /dev/null
+++ b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ShiftUp_PreImage
@@ -0,0 +1,32 @@
+package org.eclipse.jgit.test.apply;
+
+public class TestClass {
+
+ private void something(String prefix, String msg) {
+ System.out.println(prefix + ": " + msg);
+ }
+
+ public class A {
+
+ public void methodA() {
+ something("A.a", "foo");
+ }
+
+ public void methodB() {
+ something("A.b", "bar");
+ }
+
+ }
+
+ public class B {
+
+ public void methodA() {
+ something("B.a", "foo");
+ }
+
+ public void methodB() {
+ something("B.b", "bar");
+ }
+
+ }
+}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java
index 63cd21f59..055eba718 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ApplyCommandTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012, IBM Corporation and others. and others
+ * Copyright (C) 2011, 2020 IBM Corporation and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
@@ -280,6 +280,46 @@ public class ApplyCommandTest extends RepositoryTestCase {
b.getString(0, b.size(), false));
}
+ @Test
+ public void testShiftUp() throws Exception {
+ ApplyResult result = init("ShiftUp");
+ assertEquals(1, result.getUpdatedFiles().size());
+ assertEquals(new File(db.getWorkTree(), "ShiftUp"),
+ result.getUpdatedFiles().get(0));
+ checkFile(new File(db.getWorkTree(), "ShiftUp"),
+ b.getString(0, b.size(), false));
+ }
+
+ @Test
+ public void testShiftUp2() throws Exception {
+ ApplyResult result = init("ShiftUp2");
+ assertEquals(1, result.getUpdatedFiles().size());
+ assertEquals(new File(db.getWorkTree(), "ShiftUp2"),
+ result.getUpdatedFiles().get(0));
+ checkFile(new File(db.getWorkTree(), "ShiftUp2"),
+ b.getString(0, b.size(), false));
+ }
+
+ @Test
+ public void testShiftDown() throws Exception {
+ ApplyResult result = init("ShiftDown");
+ assertEquals(1, result.getUpdatedFiles().size());
+ assertEquals(new File(db.getWorkTree(), "ShiftDown"),
+ result.getUpdatedFiles().get(0));
+ checkFile(new File(db.getWorkTree(), "ShiftDown"),
+ b.getString(0, b.size(), false));
+ }
+
+ @Test
+ public void testShiftDown2() throws Exception {
+ ApplyResult result = init("ShiftDown2");
+ assertEquals(1, result.getUpdatedFiles().size());
+ assertEquals(new File(db.getWorkTree(), "ShiftDown2"),
+ result.getUpdatedFiles().get(0));
+ checkFile(new File(db.getWorkTree(), "ShiftDown2"),
+ b.getString(0, b.size(), false));
+ }
+
private static byte[] readFile(String patchFile) throws IOException {
final InputStream in = getTestResource(patchFile);
if (in == null) {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
index b0355b2b6..0a0a88c83 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
@@ -124,6 +124,28 @@ public class CheckoutCommandTest extends RepositoryTestCase {
.setForced(true).call().getObjectId());
}
+ @Test
+ public void testCheckoutForced_deleteFileAndRestore() throws Exception {
+ File testFile = new File(db.getWorkTree(), "Test.txt");
+ assertTrue(testFile.exists());
+
+ assertEquals("test", git.getRepository().getBranch());
+ FileUtils.delete(testFile);
+ assertFalse(testFile.exists());
+ // Switch from "test" to "master".
+ assertEquals(initialCommit.getId(), git.checkout().setName("master")
+ .setForced(true).call().getObjectId());
+ assertTrue(testFile.exists());
+
+ assertEquals("master", git.getRepository().getBranch());
+ FileUtils.delete(testFile);
+ assertFalse(testFile.exists());
+ // Stay in current branch.
+ assertEquals(initialCommit.getId(), git.checkout().setName("master")
+ .setForced(true).call().getObjectId());
+ assertTrue(testFile.exists());
+ }
+
@Test
public void testCreateBranchOnCheckout() throws Exception {
git.checkout().setCreateBranch(true).setName("test2").call();
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributeFileTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributeFileTests.java
new file mode 100644
index 000000000..5d05a98d6
--- /dev/null
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributeFileTests.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2020 Thomas Wolf and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.attributes;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Arrays;
+
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.ResetCommand.ResetType;
+import org.eclipse.jgit.dircache.DirCache;
+import org.eclipse.jgit.dircache.DirCacheEntry;
+import org.eclipse.jgit.junit.RepositoryTestCase;
+import org.eclipse.jgit.lib.ConfigConstants;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.storage.file.FileBasedConfig;
+import org.eclipse.jgit.util.IO;
+import org.eclipse.jgit.util.RawParseUtils;
+import org.junit.Test;
+
+/**
+ * End-to-end tests for some attribute combinations. Writes files, commit them,
+ * examines the index, deletes the files, performs a hard reset and checks file
+ * contents again.
+ */
+public class AttributeFileTests extends RepositoryTestCase {
+
+ @Test
+ public void testTextAutoCoreEolCoreAutoCrLfInput() throws Exception {
+ FileBasedConfig cfg = db.getConfig();
+ cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_KEY_AUTOCRLF, false);
+ cfg.save();
+ final String content = "Line1\nLine2\n";
+ try (Git git = Git.wrap(db)) {
+ writeTrashFile(".gitattributes", "* text=auto");
+ File dummy = writeTrashFile("dummy.txt", content);
+ git.add().addFilepattern(".").call();
+ git.commit().setMessage("Commit with LF").call();
+ assertEquals("Unexpected index state",
+ "[.gitattributes, mode:100644, content:* text=auto]"
+ + "[dummy.txt, mode:100644, content:" + content
+ + ']',
+ indexState(CONTENT));
+ assertTrue("Should be able to delete " + dummy, dummy.delete());
+ cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_KEY_EOL, "crlf");
+ cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_KEY_AUTOCRLF, "input");
+ cfg.save();
+ git.reset().setMode(ResetType.HARD).call();
+ assertTrue("File " + dummy + "should exist", dummy.isFile());
+ String textFile = RawParseUtils.decode(IO.readFully(dummy, 512));
+ assertEquals("Unexpected text content", content, textFile);
+ }
+ }
+
+ @Test
+ public void testTextAutoEolLf() throws Exception {
+ writeTrashFile(".gitattributes", "* text=auto eol=lf");
+ performTest("Test\r\nFile", "Test\nFile", "Test\nFile");
+ }
+
+ @Test
+ public void testTextAutoEolCrLf() throws Exception {
+ writeTrashFile(".gitattributes", "* text=auto eol=crlf");
+ performTest("Test\r\nFile", "Test\nFile", "Test\r\nFile");
+ }
+
+ private void performTest(String initial, String index, String finalText)
+ throws Exception {
+ File dummy = writeTrashFile("dummy.foo", initial);
+ byte[] data = readTestResource("add.png");
+ assertTrue("Expected some binary data", data.length > 100);
+ File binary = writeTrashFile("add.png", "");
+ Files.write(binary.toPath(), data);
+ try (Git git = Git.wrap(db)) {
+ git.add().addFilepattern(".").call();
+ git.commit().setMessage("test commit").call();
+ // binary should be unchanged, dummy should match "index"
+ verifyIndexContent("dummy.foo",
+ index.getBytes(StandardCharsets.UTF_8));
+ verifyIndexContent("add.png", data);
+ assertTrue("Should be able to delete " + dummy, dummy.delete());
+ assertTrue("Should be able to delete " + binary, binary.delete());
+ git.reset().setMode(ResetType.HARD).call();
+ assertTrue("File " + dummy + " should exist", dummy.isFile());
+ assertTrue("File " + binary + " should exist", binary.isFile());
+ // binary should be unchanged, dummy should match "finalText"
+ String textFile = RawParseUtils.decode(IO.readFully(dummy, 512));
+ assertEquals("Unexpected text content", finalText, textFile);
+ byte[] binaryFile = IO.readFully(binary, 512);
+ assertArrayEquals("Unexpected binary content", data, binaryFile);
+ }
+ }
+
+ private byte[] readTestResource(String name) throws Exception {
+ try (InputStream in = new BufferedInputStream(
+ getClass().getResourceAsStream(name))) {
+ byte[] data = new byte[512];
+ int read = in.read(data);
+ if (read == data.length) {
+ return data;
+ }
+ return Arrays.copyOf(data, read);
+ }
+ }
+
+ private void verifyIndexContent(String path, byte[] expectedContent)
+ throws Exception {
+ DirCache dc = db.readDirCache();
+ for (int i = 0; i < dc.getEntryCount(); ++i) {
+ DirCacheEntry entry = dc.getEntry(i);
+ if (path.equals(entry.getPathString())) {
+ byte[] data = db.open(entry.getObjectId(), Constants.OBJ_BLOB)
+ .getCachedBytes();
+ assertArrayEquals("Unexpected index content for " + path,
+ expectedContent, data);
+ return;
+ }
+ }
+ fail("Path not found in index: " + path);
+ }
+}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChangeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChangeTest.java
index b271a048a..c2b8641eb 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChangeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChangeTest.java
@@ -13,6 +13,7 @@ package org.eclipse.jgit.diff;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import org.eclipse.jgit.lib.Constants;
@@ -75,4 +76,75 @@ public class RawTextIgnoreWhitespaceChangeTest {
assertTrue(cmp.equals(a, 5, b, 5));
assertTrue(cmp.equals(b, 5, a, 5));
}
+
+ @Test
+ public void testEqualsWithTabs() {
+ RawText a = new RawText(
+ Constants.encodeASCII("a\tb\t \na\tb\t c \n foo\na b\na b"));
+ RawText b = new RawText(
+ Constants.encodeASCII("a b \na b c\n\tfoo\nab\na \tb"));
+
+ // "a\tb\t \n" == "a b \n"
+ assertTrue(cmp.equals(a, 0, b, 0));
+ assertTrue(cmp.equals(b, 0, a, 0));
+
+ // "a\tb\t c \n" == "a b c\n"
+ assertTrue(cmp.equals(a, 1, b, 1));
+ assertTrue(cmp.equals(b, 1, a, 1));
+
+ // " foo" == "\tfoo"
+ assertTrue(cmp.equals(a, 2, b, 2));
+ assertTrue(cmp.equals(b, 2, a, 2));
+
+ // "a b" != "ab"
+ assertFalse(cmp.equals(a, 3, b, 3));
+ assertFalse(cmp.equals(b, 3, a, 3));
+
+ // "a b" == "a \tb "
+ assertTrue(cmp.equals(a, 4, b, 4));
+ assertTrue(cmp.equals(b, 4, a, 4));
+ }
+
+ @Test
+ public void testHashCode() {
+ RawText a = new RawText(Constants
+ .encodeASCII("a b c\n\nab c d \n\ta bc d\nxyz\na b c"));
+ RawText b = new RawText(Constants.encodeASCII(
+ "a b c\na b c\nab c d\na bc d\n \t a bc d\na b c\n"));
+
+ // Same line gives equal hash
+ assertEquals(cmp.hash(a, 0), cmp.hash(a, 0));
+
+ // Empty lines produce the same hash
+ assertEquals(cmp.hash(a, 1), cmp.hash(a, 1));
+
+ // Equal lines from different RawTexts get the same hash (RawText
+ // instance is not part of the hash)
+ assertEquals(cmp.hash(a, 0), cmp.hash(b, 0));
+
+ // A blank produces the same hash as a TAB
+ assertEquals(cmp.hash(new RawText(Constants.encodeASCII(" ")), 0),
+ cmp.hash(new RawText(Constants.encodeASCII("\t")), 0));
+
+ // Lines with only differing whitespace produce same hash
+ assertEquals(cmp.hash(a, 0), cmp.hash(b, 1));
+
+ // Lines with different trailing whitespace produce the same hash
+ assertEquals(cmp.hash(a, 2), cmp.hash(b, 2));
+
+ // A line with leading whitespace produces a hash different from the
+ // same line without leading whitespace
+ assertNotEquals(cmp.hash(a, 3), cmp.hash(b, 3));
+
+ // Lines with different leading whitespace produce equal hashes
+ assertEquals(cmp.hash(a, 3), cmp.hash(b, 4));
+
+ // While different lines _should_ produce different hashes, that may not
+ // always be the case. But for these two lines, it is.
+ assertNotEquals(cmp.hash(a, 4), cmp.hash(b, 4));
+
+ // A line without trailing \n produces the same hash as one without
+ assertEquals(cmp.hash(a, 5), cmp.hash(b, 5));
+
+ }
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java
index f2876b785..cc826c30b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java
@@ -23,7 +23,6 @@ import java.util.Set;
import org.eclipse.jgit.internal.storage.file.GcTestCase;
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexBuilder;
-import org.eclipse.jgit.internal.storage.pack.PackWriterBitmapPreparer.BitmapCommit;
import org.eclipse.jgit.junit.TestRepository.BranchBuilder;
import org.eclipse.jgit.junit.TestRepository.CommitBuilder;
import org.eclipse.jgit.lib.Constants;
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/transport/connectivity/IterativeConnectivityCheckerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/transport/connectivity/IterativeConnectivityCheckerTest.java
new file mode 100644
index 000000000..e75dd2259
--- /dev/null
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/transport/connectivity/IterativeConnectivityCheckerTest.java
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2019, Google LLC and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package org.eclipse.jgit.internal.transport.connectivity;
+
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.verify;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jgit.errors.MissingObjectException;
+import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
+import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
+import org.eclipse.jgit.junit.TestRepository;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.ProgressMonitor;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.transport.PackParser;
+import org.eclipse.jgit.transport.ReceiveCommand;
+import org.eclipse.jgit.transport.ConnectivityChecker;
+import org.eclipse.jgit.transport.ConnectivityChecker.ConnectivityCheckInfo;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+
+public class IterativeConnectivityCheckerTest {
+ @Rule
+ public MockitoRule rule = MockitoJUnit.rule();
+
+ private ObjectId branchHeadObjectId;
+
+ private ObjectId openRewiewObjectId;
+
+ private ObjectId newCommitObjectId;
+ private ObjectId otherHaveObjectId = ObjectId
+ .fromString("DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF");
+
+ private Set advertisedHaves;
+
+ @Mock
+ private ConnectivityChecker connectivityCheckerDelegate;
+
+ @Mock
+ private ProgressMonitor pm;
+
+ @Mock
+ private PackParser parser;
+
+ private RevCommit branchHeadCommitObject;
+ private RevCommit openReviewCommitObject;
+ private RevCommit newCommitObject;
+
+ private ConnectivityCheckInfo connectivityCheckInfo;
+ private IterativeConnectivityChecker connectivityChecker;
+
+ private TestRepository tr;
+
+ @Before
+ public void setUp() throws Exception {
+ tr = new TestRepository<>(
+ new InMemoryRepository(new DfsRepositoryDescription("test")));
+ connectivityChecker = new IterativeConnectivityChecker(
+ connectivityCheckerDelegate);
+ connectivityCheckInfo = new ConnectivityCheckInfo();
+ connectivityCheckInfo.setParser(parser);
+ connectivityCheckInfo.setRepository(tr.getRepository());
+ connectivityCheckInfo.setWalk(tr.getRevWalk());
+
+ branchHeadCommitObject = tr.commit().create();
+ branchHeadObjectId = branchHeadCommitObject.getId();
+
+ openReviewCommitObject = tr.commit().create();
+ openRewiewObjectId = openReviewCommitObject.getId();
+
+ advertisedHaves = wrap(branchHeadObjectId, openRewiewObjectId,
+ otherHaveObjectId);
+ }
+
+ @Test
+ public void testSuccessfulNewBranchBasedOnOld() throws Exception {
+ createNewCommit(branchHeadCommitObject);
+ connectivityCheckInfo.setCommands(
+ Collections.singletonList(createNewBrachCommand()));
+
+ connectivityChecker.checkConnectivity(connectivityCheckInfo,
+ advertisedHaves, pm);
+
+ verify(connectivityCheckerDelegate).checkConnectivity(
+ connectivityCheckInfo,
+ wrap(branchHeadObjectId /* as direct parent */),
+ pm);
+ }
+
+ @Test
+ public void testSuccessfulNewBranchBasedOnOldWithTip() throws Exception {
+ createNewCommit(branchHeadCommitObject);
+ connectivityCheckInfo.setCommands(
+ Collections.singletonList(createNewBrachCommand()));
+
+ connectivityChecker.setForcedHaves(wrap(openRewiewObjectId));
+
+ connectivityChecker.checkConnectivity(connectivityCheckInfo,
+ advertisedHaves, pm);
+
+ verify(connectivityCheckerDelegate).checkConnectivity(
+ connectivityCheckInfo,
+ wrap(branchHeadObjectId /* as direct parent */,
+ openRewiewObjectId),
+ pm);
+ }
+
+ @Test
+ public void testSuccessfulNewBranchMerge() throws Exception {
+ createNewCommit(branchHeadCommitObject, openReviewCommitObject);
+ connectivityCheckInfo.setCommands(
+ Collections.singletonList(createNewBrachCommand()));
+
+ connectivityChecker.checkConnectivity(connectivityCheckInfo,
+ advertisedHaves, pm);
+
+ verify(connectivityCheckerDelegate).checkConnectivity(
+ connectivityCheckInfo,
+ wrap(branchHeadObjectId /* as direct parent */,
+ openRewiewObjectId),
+ pm);
+ }
+
+ @Test
+ public void testSuccessfulNewBranchBasedOnNewWithTip() throws Exception {
+ createNewCommit();
+ connectivityCheckInfo.setCommands(
+ Collections.singletonList(createNewBrachCommand()));
+
+ connectivityChecker.setForcedHaves(wrap(openRewiewObjectId));
+
+ connectivityChecker.checkConnectivity(connectivityCheckInfo,
+ advertisedHaves, pm);
+
+ verify(connectivityCheckerDelegate).checkConnectivity(
+ connectivityCheckInfo, wrap(openRewiewObjectId), pm);
+ }
+
+ @Test
+ public void testSuccessfulPushOldBranch() throws Exception {
+ createNewCommit(branchHeadCommitObject);
+ connectivityCheckInfo.setCommands(
+ Collections.singletonList(pushOldBranchCommand()));
+
+ connectivityChecker.checkConnectivity(connectivityCheckInfo,
+ advertisedHaves, pm);
+
+ verify(connectivityCheckerDelegate).checkConnectivity(
+ connectivityCheckInfo, wrap(branchHeadObjectId /* as direct parent */),
+ pm);
+ }
+
+ @Test
+ public void testSuccessfulPushOldBranchMergeCommit() throws Exception {
+ createNewCommit(branchHeadCommitObject, openReviewCommitObject);
+ connectivityCheckInfo.setCommands(
+ Collections.singletonList(pushOldBranchCommand()));
+
+ connectivityChecker.checkConnectivity(connectivityCheckInfo,
+ advertisedHaves, pm);
+
+ verify(connectivityCheckerDelegate).checkConnectivity(
+ connectivityCheckInfo,
+ wrap(branchHeadObjectId /* as direct parent */,
+ openRewiewObjectId),
+ pm);
+ }
+
+
+ @Test
+ public void testNoChecksIfCantFindSubset() throws Exception {
+ createNewCommit();
+ connectivityCheckInfo.setCommands(
+ Collections.singletonList(createNewBrachCommand()));
+
+ connectivityChecker.checkConnectivity(connectivityCheckInfo,
+ advertisedHaves, pm);
+
+ verify(connectivityCheckerDelegate)
+ .checkConnectivity(connectivityCheckInfo, advertisedHaves, pm);
+ }
+
+ @Test
+ public void testReiterateInCaseNotSuccessful() throws Exception {
+ createNewCommit(branchHeadCommitObject);
+ connectivityCheckInfo.setCommands(
+ Collections.singletonList(createNewBrachCommand()));
+
+ doThrow(new MissingObjectException(branchHeadCommitObject,
+ Constants.OBJ_COMMIT)).when(connectivityCheckerDelegate)
+ .checkConnectivity(connectivityCheckInfo,
+ wrap(branchHeadObjectId /* as direct parent */), pm);
+
+ connectivityChecker.checkConnectivity(connectivityCheckInfo,
+ advertisedHaves, pm);
+
+ verify(connectivityCheckerDelegate)
+ .checkConnectivity(connectivityCheckInfo, advertisedHaves, pm);
+ }
+
+ @Test
+ public void testDependOnGrandparent() throws Exception {
+ RevCommit grandparent = tr.commit(new RevCommit[] {});
+ RevCommit parent = tr.commit(grandparent);
+ createNewCommit(parent);
+
+ branchHeadCommitObject = tr.commit(grandparent);
+ branchHeadObjectId = branchHeadCommitObject.getId();
+ tr.getRevWalk().dispose();
+
+ connectivityCheckInfo.setCommands(
+ Collections.singletonList(createNewBrachCommand()));
+
+ connectivityChecker.checkConnectivity(connectivityCheckInfo,
+ advertisedHaves, pm);
+
+ verify(connectivityCheckerDelegate)
+ .checkConnectivity(connectivityCheckInfo, advertisedHaves, pm);
+ }
+
+ private static Set wrap(ObjectId... objectIds) {
+ return new HashSet<>(Arrays.asList(objectIds));
+ }
+
+ private ReceiveCommand createNewBrachCommand() {
+ return new ReceiveCommand(ObjectId.zeroId(), newCommitObjectId,
+ "totally/a/new/branch");
+ }
+
+ private ReceiveCommand pushOldBranchCommand() {
+ return new ReceiveCommand(branchHeadObjectId, newCommitObjectId,
+ "push/to/an/old/branch");
+ }
+
+ private void createNewCommit(RevCommit... parents) throws Exception {
+ newCommitObject = tr.commit(parents);
+ newCommitObjectId = newCommitObject.getId();
+ }
+
+}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
index 36805d324..798aebe3b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
@@ -109,33 +109,33 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_validSubtreeSort() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
-
- b.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
- b.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
-
- o.add(createEntry("Makefile", FileMode.REGULAR_FILE));
- o.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
- o.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
-
- t.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
- t.add(createEntry("libelf/c", FileMode.REGULAR_FILE, "blah"));
-
- b.finish();
- o.finish();
- t.finish();
- }
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
+
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
+
+ bTreeBuilder.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
+
+ oTreeBuilder.add(createEntry("Makefile", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ tTreeBuilder.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ tTreeBuilder
+ .add(createEntry("libelf/c", FileMode.REGULAR_FILE, "blah"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -163,32 +163,31 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_concurrentSubtreeChange() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
-
- b.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
-
- o.add(createEntry("d/o", FileMode.REGULAR_FILE, "o !"));
- o.add(createEntry("d/t", FileMode.REGULAR_FILE));
-
- t.add(createEntry("d/o", FileMode.REGULAR_FILE));
- t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
-
- b.finish();
- o.finish();
- t.finish();
- }
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
+
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
+
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE, "o !"));
+ oTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
+
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ tTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -212,32 +211,31 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_conflictSubtreeChange() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
-
- b.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
-
- o.add(createEntry("d/o", FileMode.REGULAR_FILE));
- o.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
-
- t.add(createEntry("d/o", FileMode.REGULAR_FILE, "t !"));
- t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
-
- b.finish();
- o.finish();
- t.finish();
- }
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
+
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
+
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
+
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE, "t !"));
+ tTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -246,31 +244,30 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_leftDFconflict1() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
- t.add(createEntry("d/o", FileMode.REGULAR_FILE));
- t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+ oTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ tTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -279,31 +276,30 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_rightDFconflict1() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d/o", FileMode.REGULAR_FILE));
- o.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
- t.add(createEntry("d", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -312,29 +308,28 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_leftDFconflict2() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d", FileMode.REGULAR_FILE, "o !"));
+ bTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
- t.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE, "o !"));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -343,29 +338,28 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
@Test
public void testTrivialTwoWay_rightDFconflict2() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
- t.add(createEntry("d", FileMode.REGULAR_FILE, "t !"));
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@@ -377,10 +371,9 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
.getObjectId(0));
}
- private static ObjectId commit(final ObjectInserter odi,
- final DirCache treeB,
- final ObjectId[] parentIds) throws Exception {
- final CommitBuilder c = new CommitBuilder();
+ private static ObjectId commit(ObjectInserter odi, DirCache treeB,
+ ObjectId[] parentIds) throws Exception {
+ CommitBuilder c = new CommitBuilder();
c.setTreeId(treeB.writeTree(odi));
c.setAuthor(new PersonIdent("A U Thor", "a.u.thor", 1L, 0));
c.setCommitter(c.getAuthor());
diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters
deleted file mode 100644
index c8b7bf799..000000000
--- a/org.eclipse.jgit/.settings/.api_filters
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/org.eclipse.jgit/BUILD b/org.eclipse.jgit/BUILD
index dcfeb1702..f7970976b 100644
--- a/org.eclipse.jgit/BUILD
+++ b/org.eclipse.jgit/BUILD
@@ -20,12 +20,7 @@ java_library(
resources = RESOURCES,
deps = [
":insecure_cipher_factory",
- "//lib:bcpg",
- "//lib:bcpkix",
- "//lib:bcprov",
"//lib:javaewah",
- "//lib:jsch",
- "//lib:jzlib",
"//lib:slf4j-api",
],
)
diff --git a/org.eclipse.jgit/META-INF/MANIFEST.MF b/org.eclipse.jgit/META-INF/MANIFEST.MF
index 0b60c8c46..52aa8a353 100644
--- a/org.eclipse.jgit/META-INF/MANIFEST.MF
+++ b/org.eclipse.jgit/META-INF/MANIFEST.MF
@@ -6,62 +6,76 @@ Bundle-SymbolicName: org.eclipse.jgit
Bundle-Version: 6.0.0.qualifier
Bundle-Localization: plugin
Bundle-Vendor: %Bundle-Vendor
-Bundle-ActivationPolicy: lazy
+Eclipse-ExtensibleAPI: true
Export-Package: org.eclipse.jgit.annotations;version="6.0.0",
org.eclipse.jgit.api;version="6.0.0";
- uses:="org.eclipse.jgit.revwalk,
- org.eclipse.jgit.treewalk.filter,
- org.eclipse.jgit.diff,
- org.eclipse.jgit.util,
+ uses:="org.eclipse.jgit.transport,
org.eclipse.jgit.notes,
org.eclipse.jgit.dircache,
- org.eclipse.jgit.api.errors,
org.eclipse.jgit.lib,
+ org.eclipse.jgit.revwalk,
+ org.eclipse.jgit.treewalk.filter,
+ org.eclipse.jgit.diff,
org.eclipse.jgit.treewalk,
- org.eclipse.jgit.blame,
+ org.eclipse.jgit.util,
org.eclipse.jgit.submodule,
- org.eclipse.jgit.transport,
+ org.eclipse.jgit.api.errors,
+ org.eclipse.jgit.revwalk.filter,
+ org.eclipse.jgit.blame,
org.eclipse.jgit.merge",
- org.eclipse.jgit.api.errors;version="6.0.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.errors",
- org.eclipse.jgit.attributes;version="6.0.0",
+ org.eclipse.jgit.api.errors;version="6.0.0";
+ uses:="org.eclipse.jgit.lib,
+ org.eclipse.jgit.errors",
+ org.eclipse.jgit.attributes;version="6.0.0";
+ uses:="org.eclipse.jgit.lib,
+ org.eclipse.jgit.treewalk",
org.eclipse.jgit.blame;version="6.0.0";
uses:="org.eclipse.jgit.lib,
org.eclipse.jgit.revwalk,
org.eclipse.jgit.treewalk.filter,
org.eclipse.jgit.diff",
org.eclipse.jgit.diff;version="6.0.0";
- uses:="org.eclipse.jgit.patch,
- org.eclipse.jgit.lib,
- org.eclipse.jgit.treewalk,
+ uses:="org.eclipse.jgit.lib,
+ org.eclipse.jgit.attributes,
org.eclipse.jgit.revwalk,
+ org.eclipse.jgit.patch,
org.eclipse.jgit.treewalk.filter,
+ org.eclipse.jgit.treewalk,
org.eclipse.jgit.util",
org.eclipse.jgit.dircache;version="6.0.0";
- uses:="org.eclipse.jgit.lib,
+ uses:="org.eclipse.jgit.events,
+ org.eclipse.jgit.lib,
+ org.eclipse.jgit.attributes,
org.eclipse.jgit.treewalk,
- org.eclipse.jgit.util,
- org.eclipse.jgit.events,
- org.eclipse.jgit.attributes",
+ org.eclipse.jgit.util",
org.eclipse.jgit.errors;version="6.0.0";
- uses:="org.eclipse.jgit.lib,
- org.eclipse.jgit.internal.storage.pack,
- org.eclipse.jgit.transport,
- org.eclipse.jgit.dircache",
- org.eclipse.jgit.events;version="6.0.0";uses:="org.eclipse.jgit.lib",
+ uses:="org.eclipse.jgit.transport,
+ org.eclipse.jgit.dircache,
+ org.eclipse.jgit.lib,
+ org.eclipse.jgit.internal.storage.pack",
+ org.eclipse.jgit.events;version="6.0.0";
+ uses:="org.eclipse.jgit.lib",
org.eclipse.jgit.fnmatch;version="6.0.0",
org.eclipse.jgit.gitrepo;version="6.0.0";
- uses:="org.eclipse.jgit.api,
+ uses:="org.xml.sax.helpers,
+ org.eclipse.jgit.api,
org.eclipse.jgit.lib,
org.eclipse.jgit.revwalk,
- org.xml.sax.helpers,
org.xml.sax",
org.eclipse.jgit.gitrepo.internal;version="6.0.0";x-internal:=true,
org.eclipse.jgit.hooks;version="6.0.0";uses:="org.eclipse.jgit.lib",
org.eclipse.jgit.ignore;version="6.0.0",
- org.eclipse.jgit.ignore.internal;version="6.0.0";x-friends:="org.eclipse.jgit.test",
- org.eclipse.jgit.internal;version="6.0.0";x-friends:="org.eclipse.jgit.test,org.eclipse.jgit.http.test",
- org.eclipse.jgit.internal.fsck;version="6.0.0";x-friends:="org.eclipse.jgit.test",
- org.eclipse.jgit.internal.ketch;version="6.0.0";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm",
+ org.eclipse.jgit.ignore.internal;version="6.0.0";
+ x-friends:="org.eclipse.jgit.test",
+ org.eclipse.jgit.internal;version="6.0.0";
+ x-friends:="org.eclipse.jgit.test,
+ org.eclipse.jgit.http.test",
+ org.eclipse.jgit.internal.fsck;version="6.0.0";
+ x-friends:="org.eclipse.jgit.test",
+ org.eclipse.jgit.internal.ketch;version="6.0.0";
+ x-friends:="org.eclipse.jgit.junit,
+ org.eclipse.jgit.test,
+ org.eclipse.jgit.pgm",
org.eclipse.jgit.internal.revwalk;version="6.0.0";x-internal:=true,
org.eclipse.jgit.internal.storage.dfs;version="6.0.0";
x-friends:="org.eclipse.jgit.test,
@@ -77,101 +91,142 @@ Export-Package: org.eclipse.jgit.annotations;version="6.0.0",
org.eclipse.jgit.pgm,
org.eclipse.jgit.pgm.test,
org.eclipse.jgit.ssh.apache",
- org.eclipse.jgit.internal.storage.io;version="6.0.0";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm",
- org.eclipse.jgit.internal.storage.pack;version="6.0.0";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm",
+ org.eclipse.jgit.internal.storage.io;version="6.0.0";
+ x-friends:="org.eclipse.jgit.junit,
+ org.eclipse.jgit.test,
+ org.eclipse.jgit.pgm",
+ org.eclipse.jgit.internal.storage.pack;version="6.0.0";
+ x-friends:="org.eclipse.jgit.junit,
+ org.eclipse.jgit.test,
+ org.eclipse.jgit.pgm",
org.eclipse.jgit.internal.storage.reftable;version="6.0.0";
x-friends:="org.eclipse.jgit.http.test,
org.eclipse.jgit.junit,
org.eclipse.jgit.test,
org.eclipse.jgit.pgm",
- org.eclipse.jgit.internal.storage.reftree;version="6.0.0";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm",
+ org.eclipse.jgit.internal.storage.reftree;version="6.0.0";
+ x-friends:="org.eclipse.jgit.junit,
+ org.eclipse.jgit.test,
+ org.eclipse.jgit.pgm",
org.eclipse.jgit.internal.submodule;version="6.0.0";x-internal:=true,
- org.eclipse.jgit.internal.transport.http;version="6.0.0";x-friends:="org.eclipse.jgit.test",
- org.eclipse.jgit.internal.transport.parser;version="6.0.0";x-friends:="org.eclipse.jgit.http.server,org.eclipse.jgit.test",
- org.eclipse.jgit.internal.transport.ssh;version="6.0.0";x-friends:="org.eclipse.jgit.ssh.apache",
+ org.eclipse.jgit.internal.transport.connectivity;version="6.0.0";
+ x-friends:="org.eclipse.jgit.test",
+ org.eclipse.jgit.internal.transport.http;version="6.0.0";
+ x-friends:="org.eclipse.jgit.test",
+ org.eclipse.jgit.internal.transport.parser;version="6.0.0";
+ x-friends:="org.eclipse.jgit.http.server,
+ org.eclipse.jgit.test",
+ org.eclipse.jgit.internal.transport.ssh;version="6.0.0";
+ x-friends:="org.eclipse.jgit.ssh.apache,
+ org.eclipse.jgit.ssh.jsch",
org.eclipse.jgit.lib;version="6.0.0";
- uses:="org.eclipse.jgit.revwalk,
- org.eclipse.jgit.treewalk.filter,
- org.eclipse.jgit.util,
- org.eclipse.jgit.events,
+ uses:="org.eclipse.jgit.transport,
+ org.eclipse.jgit.util.sha1,
org.eclipse.jgit.dircache,
+ org.eclipse.jgit.revwalk,
org.eclipse.jgit.internal.storage.file,
+ org.eclipse.jgit.attributes,
+ org.eclipse.jgit.events,
+ com.googlecode.javaewah,
+ org.eclipse.jgit.treewalk.filter,
org.eclipse.jgit.treewalk,
- org.eclipse.jgit.transport,
- org.eclipse.jgit.submodule",
- org.eclipse.jgit.lib.internal;version="6.0.0";x-friends:="org.eclipse.jgit.test",
+ org.eclipse.jgit.util,
+ org.eclipse.jgit.submodule,
+ org.eclipse.jgit.util.time",
+ org.eclipse.jgit.lib.internal;version="6.0.0";
+ x-friends:="org.eclipse.jgit.test",
org.eclipse.jgit.merge;version="6.0.0";
- uses:="org.eclipse.jgit.lib,
- org.eclipse.jgit.treewalk,
+ uses:="org.eclipse.jgit.dircache,
+ org.eclipse.jgit.lib,
org.eclipse.jgit.revwalk,
org.eclipse.jgit.diff,
- org.eclipse.jgit.dircache,
- org.eclipse.jgit.api",
+ org.eclipse.jgit.treewalk,
+ org.eclipse.jgit.util,
+ org.eclipse.jgit.api,
+ org.eclipse.jgit.attributes",
org.eclipse.jgit.nls;version="6.0.0",
org.eclipse.jgit.notes;version="6.0.0";
uses:="org.eclipse.jgit.lib,
- org.eclipse.jgit.treewalk,
org.eclipse.jgit.revwalk,
+ org.eclipse.jgit.treewalk,
org.eclipse.jgit.merge",
- org.eclipse.jgit.patch;version="6.0.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.diff",
- org.eclipse.jgit.revplot;version="6.0.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.revwalk",
+ org.eclipse.jgit.patch;version="6.0.0";
+ uses:="org.eclipse.jgit.lib,
+ org.eclipse.jgit.diff",
+ org.eclipse.jgit.revplot;version="6.0.0";
+ uses:="org.eclipse.jgit.lib,
+ org.eclipse.jgit.revwalk",
org.eclipse.jgit.revwalk;version="6.0.0";
uses:="org.eclipse.jgit.lib,
- org.eclipse.jgit.treewalk,
+ org.eclipse.jgit.diff,
org.eclipse.jgit.treewalk.filter,
+ org.eclipse.jgit.revwalk.filter,
+ org.eclipse.jgit.treewalk",
+ org.eclipse.jgit.revwalk.filter;version="6.0.0";
+ uses:="org.eclipse.jgit.revwalk,
+ org.eclipse.jgit.lib,
+ org.eclipse.jgit.util",
+ org.eclipse.jgit.storage.file;version="6.0.0";
+ uses:="org.eclipse.jgit.lib,
+ org.eclipse.jgit.util",
+ org.eclipse.jgit.storage.pack;version="6.0.0";
+ uses:="org.eclipse.jgit.lib",
+ org.eclipse.jgit.submodule;version="6.0.0";
+ uses:="org.eclipse.jgit.lib,
org.eclipse.jgit.diff,
- org.eclipse.jgit.revwalk.filter",
- org.eclipse.jgit.revwalk.filter;version="6.0.0";uses:="org.eclipse.jgit.revwalk,org.eclipse.jgit.lib,org.eclipse.jgit.util",
- org.eclipse.jgit.storage.file;version="6.0.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.util",
- org.eclipse.jgit.storage.pack;version="6.0.0";uses:="org.eclipse.jgit.lib",
- org.eclipse.jgit.submodule;version="6.0.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.treewalk.filter,org.eclipse.jgit.treewalk",
+ org.eclipse.jgit.treewalk.filter,
+ org.eclipse.jgit.treewalk,
+ org.eclipse.jgit.util",
org.eclipse.jgit.transport;version="6.0.0";
- uses:="org.eclipse.jgit.transport.resolver,
- org.eclipse.jgit.revwalk,
- org.eclipse.jgit.internal.storage.pack,
- com.jcraft.jsch,
- org.eclipse.jgit.util,
+ uses:="javax.crypto,
org.eclipse.jgit.util.io,
- org.eclipse.jgit.internal.storage.file,
- org.eclipse.jgit.internal.transport.parser,
org.eclipse.jgit.lib,
+ org.eclipse.jgit.revwalk,
org.eclipse.jgit.transport.http,
- org.eclipse.jgit.errors,
- org.eclipse.jgit.storage.pack",
- org.eclipse.jgit.transport.http;version="6.0.0";uses:="javax.net.ssl",
- org.eclipse.jgit.transport.resolver;version="6.0.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.transport",
+ org.eclipse.jgit.internal.storage.file,
+ org.eclipse.jgit.treewalk,
+ org.eclipse.jgit.util,
+ org.eclipse.jgit.internal.storage.pack,
+ org.eclipse.jgit.transport.resolver,
+ org.eclipse.jgit.storage.pack,
+ org.eclipse.jgit.errors",
+ org.eclipse.jgit.transport.http;version="6.0.0";
+ uses:="javax.net.ssl",
+ org.eclipse.jgit.transport.resolver;version="6.0.0";
+ uses:="org.eclipse.jgit.transport,
+ org.eclipse.jgit.lib",
org.eclipse.jgit.treewalk;version="6.0.0";
- uses:="org.eclipse.jgit.lib,
- org.eclipse.jgit.revwalk,
+ uses:="org.eclipse.jgit.dircache,
+ org.eclipse.jgit.lib,
org.eclipse.jgit.attributes,
+ org.eclipse.jgit.revwalk,
org.eclipse.jgit.treewalk.filter,
- org.eclipse.jgit.util,
- org.eclipse.jgit.dircache",
- org.eclipse.jgit.treewalk.filter;version="6.0.0";uses:="org.eclipse.jgit.treewalk",
+ org.eclipse.jgit.util",
+ org.eclipse.jgit.treewalk.filter;version="6.0.0";
+ uses:="org.eclipse.jgit.treewalk",
org.eclipse.jgit.util;version="6.0.0";
- uses:="org.eclipse.jgit.lib,
- org.eclipse.jgit.transport.http,
+ uses:="org.eclipse.jgit.transport,
+ org.eclipse.jgit.hooks,
+ org.eclipse.jgit.revwalk,
org.eclipse.jgit.storage.file,
- org.ietf.jgss",
- org.eclipse.jgit.util.io;version="6.0.0",
+ org.ietf.jgss,
+ org.eclipse.jgit.attributes,
+ javax.management,
+ org.eclipse.jgit.lib,
+ org.eclipse.jgit.transport.http,
+ org.eclipse.jgit.treewalk,
+ javax.net.ssl,
+ org.eclipse.jgit.util.time",
+ org.eclipse.jgit.util.io;version="6.0.0";
+ uses:="org.eclipse.jgit.attributes,
+ org.eclipse.jgit.lib,
+ org.eclipse.jgit.treewalk",
org.eclipse.jgit.util.sha1;version="6.0.0",
org.eclipse.jgit.util.time;version="6.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.googlecode.javaewah;version="[1.1.6,2.0.0)",
- com.jcraft.jsch;version="[0.1.37,0.2.0)",
javax.crypto,
javax.net.ssl,
- org.bouncycastle;version="[1.61.0,2.0.0)",
- org.bouncycastle.bcpg;version="[1.61.0,2.0.0)",
- org.bouncycastle.gpg;version="[1.61.0,2.0.0)",
- org.bouncycastle.gpg.keybox;version="[1.61.0,2.0.0)",
- org.bouncycastle.gpg.keybox.jcajce;version="[1.61.0,2.0.0)",
- org.bouncycastle.jce.provider;version="[1.61.0,2.0.0)",
- org.bouncycastle.openpgp;version="[1.61.0,2.0.0)",
- org.bouncycastle.openpgp.jcajce;version="[1.61.0,2.0.0)",
- org.bouncycastle.openpgp.operator;version="[1.61.0,2.0.0)",
- org.bouncycastle.openpgp.operator.jcajce;version="[1.61.0,2.0.0)",
- org.bouncycastle.util.encoders;version="[1.61.0,2.0.0)",
org.slf4j;version="[1.7.0,2.0.0)",
org.xml.sax,
org.xml.sax.helpers
diff --git a/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF b/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF
index 134cbacbe..e1904d5d3 100644
--- a/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF
+++ b/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF
@@ -5,3 +5,4 @@ Bundle-SymbolicName: org.eclipse.jgit.source
Bundle-Vendor: Eclipse.org - JGit
Bundle-Version: 6.0.0.qualifier
Eclipse-SourceBundle: org.eclipse.jgit;version="6.0.0.qualifier";roots="."
+
diff --git a/org.eclipse.jgit/pom.xml b/org.eclipse.jgit/pom.xml
index 0c1d8ea88..1ab15bece 100644
--- a/org.eclipse.jgit/pom.xml
+++ b/org.eclipse.jgit/pom.xml
@@ -36,16 +36,6 @@
-
- com.jcraft
- jsch
-
-
-
- com.jcraft
- jzlib
-
-
com.googlecode.javaewah
JavaEWAH
@@ -56,21 +46,6 @@
slf4j-api
-
- org.bouncycastle
- bcpg-jdk15on
-
-
-
- org.bouncycastle
- bcprov-jdk15on
-
-
-
- org.bouncycastle
- bcpkix-jdk15on
-
-
@@ -169,7 +144,7 @@
false
false
false
- false
+ true
true
false
@@ -235,7 +210,7 @@
false
false
false
- false
+ true
true
false
diff --git a/org.eclipse.jgit/resources/META-INF/services/org.eclipse.jgit.transport.SshSessionFactory b/org.eclipse.jgit/resources/META-INF/services/org.eclipse.jgit.transport.SshSessionFactory
deleted file mode 100644
index 1f8828457..000000000
--- a/org.eclipse.jgit/resources/META-INF/services/org.eclipse.jgit.transport.SshSessionFactory
+++ /dev/null
@@ -1 +0,0 @@
-org.eclipse.jgit.transport.DefaultSshSessionFactory
diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
index c9ca11b54..e6da551bb 100644
--- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
+++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
@@ -269,6 +269,7 @@ exceptionCaughtDuringExecutionOfTagCommand=Exception caught during execution of
exceptionHookExecutionInterrupted=Execution of "{0}" hook interrupted.
exceptionOccurredDuringAddingOfOptionToALogCommand=Exception occurred during adding of {0} as option to a Log command
exceptionOccurredDuringReadingOfGIT_DIR=Exception occurred during reading of $GIT_DIR/{0}. {1}
+exceptionWhileFindingUserHome=Problem determining the user home directory, trying Java user.home
exceptionWhileReadingPack=Exception caught while accessing pack file {0}, the pack file might be corrupt. Caught {1} consecutive errors while trying to read this pack.
expectedACKNAKFoundEOF=Expected ACK/NAK, found EOF
expectedACKNAKGot=Expected ACK/NAK, got: {0}
@@ -304,15 +305,6 @@ flagsAlreadyCreated={0} flags already created.
funnyRefname=funny refname
gcFailed=Garbage collection failed.
gcTooManyUnpruned=Too many loose, unpruneable objects after garbage collection. Consider adjusting gc.auto or gc.pruneExpire.
-gpgFailedToParseSecretKey=Failed to parse secret key file in directory: {0}. Is the entered passphrase correct?
-gpgNoCredentialsProvider=missing credentials provider
-gpgNoKeyring=neither pubring.kbx nor secring.gpg files found
-gpgNoKeyInLegacySecring=no matching secret key found in legacy secring.gpg for key or user id: {0}
-gpgNoPublicKeyFound=Unable to find a public-key with key or user id: {0}
-gpgNoSecretKeyForPublicKey=unable to find associated secret key for public key: {0}
-gpgNotASigningKey=Secret key ({0}) is not suitable for signing
-gpgKeyInfo=GPG Key (fingerprint {0})
-gpgSigningCancelled=Signing was cancelled
headRequiredToStash=HEAD required to stash local changes
hoursAgo={0} hours ago
httpConfigCannotNormalizeURL=Cannot normalize URL path {0}: too many .. segments
@@ -356,6 +348,7 @@ invalidGitdirRef = Invalid .git reference in file ''{0}''
invalidGitModules=Invalid .gitmodules file
invalidGitType=invalid git type: {0}
invalidHexString=Invalid hex string: {0}
+invalidHomeDirectory=Invalid home directory: {0}
invalidHooksPath=Invalid git config core.hooksPath = {0}
invalidId=Invalid id: {0}
invalidId0=Invalid id
@@ -617,6 +610,7 @@ shortReadOfBlock=Short read of block.
shortReadOfOptionalDIRCExtensionExpectedAnotherBytes=Short read of optional DIRC extension {0}; expected another {1} bytes within the section.
shortSkipOfBlock=Short skip of block.
signingNotSupportedOnTag=Signing isn't supported on tag operations yet.
+signingServiceUnavailable=Signing service is not available
similarityScoreMustBeWithinBounds=Similarity score must be between 0 and 100.
skipMustBeNonNegative=skip must be >= 0
skipNotAccessiblePath=The path ''{0}'' isn't accessible. Skip it.
@@ -627,7 +621,6 @@ sourceRefDoesntResolveToAnyObject=Source ref {0} doesn''t resolve to any object.
sourceRefNotSpecifiedForRefspec=Source ref not specified for refspec: {0}
squashCommitNotUpdatingHEAD=Squash commit -- not updating HEAD
sshCommandFailed=Execution of ssh command ''{0}'' failed with error ''{1}''
-sshUserNameError=Jsch error: failed to set SSH user name correctly to ''{0}''; using ''{1}'' picked up from SSH config file.
sslFailureExceptionMessage=Secure connection to {0} could not be established because of SSL problems
sslFailureInfo=A secure connection to {0} could not be established because the server''s certificate could not be validated.
sslFailureCause=SSL reported: {0}
@@ -688,7 +681,6 @@ transportProtoLocal=Local Git Repository
transportProtoSFTP=SFTP
transportProtoSSH=SSH
transportProtoTest=Test
-transportSSHRetryInterrupt=Interrupted while waiting for retry
treeEntryAlreadyExists=Tree entry "{0}" already exists.
treeFilterMarkerTooManyFilters=Too many markTreeFilters passed, maximum number is {0} (passed {1})
treeWalkMustHaveExactlyTwoTrees=TreeWalk should have exactly two trees.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java
index 0d4b3da6a..e228e8276 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012, IBM Corporation and others. and others
+ * Copyright (C) 2011, 2020 IBM Corporation and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
@@ -9,18 +9,15 @@
*/
package org.eclipse.jgit.api;
-import static java.nio.charset.StandardCharsets.UTF_8;
-
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -168,71 +165,156 @@ public class ApplyCommand extends GitCommand {
for (int i = 0; i < rt.size(); i++)
oldLines.add(rt.getString(i));
List newLines = new ArrayList<>(oldLines);
+ int afterLastHunk = 0;
+ int lineNumberShift = 0;
+ int lastHunkNewLine = -1;
for (HunkHeader hh : fh.getHunks()) {
+ // We assume hunks to be ordered
+ if (hh.getNewStartLine() <= lastHunkNewLine) {
+ throw new PatchApplyException(MessageFormat
+ .format(JGitText.get().patchApplyException, hh));
+ }
+ lastHunkNewLine = hh.getNewStartLine();
+
byte[] b = new byte[hh.getEndOffset() - hh.getStartOffset()];
System.arraycopy(hh.getBuffer(), hh.getStartOffset(), b, 0,
b.length);
RawText hrt = new RawText(b);
List hunkLines = new ArrayList<>(hrt.size());
- for (int i = 0; i < hrt.size(); i++)
+ for (int i = 0; i < hrt.size(); i++) {
hunkLines.add(hrt.getString(i));
- int pos = 0;
- for (int j = 1; j < hunkLines.size(); j++) {
+ }
+
+ if (hh.getNewStartLine() == 0) {
+ // Must be the single hunk for clearing all content
+ if (fh.getHunks().size() == 1
+ && canApplyAt(hunkLines, newLines, 0)) {
+ newLines.clear();
+ break;
+ }
+ throw new PatchApplyException(MessageFormat
+ .format(JGitText.get().patchApplyException, hh));
+ }
+ // Hunk lines as reported by the hunk may be off, so don't rely on
+ // them.
+ int applyAt = hh.getNewStartLine() - 1 + lineNumberShift;
+ // But they definitely should not go backwards.
+ if (applyAt < afterLastHunk && lineNumberShift < 0) {
+ applyAt = hh.getNewStartLine() - 1;
+ lineNumberShift = 0;
+ }
+ if (applyAt < afterLastHunk) {
+ throw new PatchApplyException(MessageFormat
+ .format(JGitText.get().patchApplyException, hh));
+ }
+ boolean applies = false;
+ int oldLinesInHunk = hh.getLinesContext()
+ + hh.getOldImage().getLinesDeleted();
+ if (oldLinesInHunk <= 1) {
+ // Don't shift hunks without context lines. Just try the
+ // position corrected by the current lineNumberShift, and if
+ // that fails, the position recorded in the hunk header.
+ applies = canApplyAt(hunkLines, newLines, applyAt);
+ if (!applies && lineNumberShift != 0) {
+ applyAt = hh.getNewStartLine() - 1;
+ applies = applyAt >= afterLastHunk
+ && canApplyAt(hunkLines, newLines, applyAt);
+ }
+ } else {
+ int maxShift = applyAt - afterLastHunk;
+ for (int shift = 0; shift <= maxShift; shift++) {
+ if (canApplyAt(hunkLines, newLines, applyAt - shift)) {
+ applies = true;
+ applyAt -= shift;
+ break;
+ }
+ }
+ if (!applies) {
+ // Try shifting the hunk downwards
+ applyAt = hh.getNewStartLine() - 1 + lineNumberShift;
+ maxShift = newLines.size() - applyAt - oldLinesInHunk;
+ for (int shift = 1; shift <= maxShift; shift++) {
+ if (canApplyAt(hunkLines, newLines, applyAt + shift)) {
+ applies = true;
+ applyAt += shift;
+ break;
+ }
+ }
+ }
+ }
+ if (!applies) {
+ throw new PatchApplyException(MessageFormat
+ .format(JGitText.get().patchApplyException, hh));
+ }
+ // Hunk applies at applyAt. Apply it, and update afterLastHunk and
+ // lineNumberShift
+ lineNumberShift = applyAt - hh.getNewStartLine() + 1;
+ int sz = hunkLines.size();
+ for (int j = 1; j < sz; j++) {
String hunkLine = hunkLines.get(j);
switch (hunkLine.charAt(0)) {
case ' ':
- if (!newLines.get(hh.getNewStartLine() - 1 + pos).equals(
- hunkLine.substring(1))) {
- throw new PatchApplyException(MessageFormat.format(
- JGitText.get().patchApplyException, hh));
- }
- pos++;
+ applyAt++;
break;
case '-':
- if (hh.getNewStartLine() == 0) {
- newLines.clear();
- } else {
- if (!newLines.get(hh.getNewStartLine() - 1 + pos)
- .equals(hunkLine.substring(1))) {
- throw new PatchApplyException(MessageFormat.format(
- JGitText.get().patchApplyException, hh));
- }
- newLines.remove(hh.getNewStartLine() - 1 + pos);
- }
+ newLines.remove(applyAt);
break;
case '+':
- newLines.add(hh.getNewStartLine() - 1 + pos,
- hunkLine.substring(1));
- pos++;
+ newLines.add(applyAt++, hunkLine.substring(1));
+ break;
+ default:
break;
}
}
+ afterLastHunk = applyAt;
}
- if (!isNoNewlineAtEndOfFile(fh))
+ if (!isNoNewlineAtEndOfFile(fh)) {
newLines.add(""); //$NON-NLS-1$
- if (!rt.isMissingNewlineAtEnd())
+ }
+ if (!rt.isMissingNewlineAtEnd()) {
oldLines.add(""); //$NON-NLS-1$
- if (!isChanged(oldLines, newLines))
- return; // don't touch the file
- StringBuilder sb = new StringBuilder();
- for (String l : newLines) {
- // don't bother handling line endings - if it was windows, the \r is
- // still there!
- sb.append(l).append('\n');
}
- if (sb.length() > 0) {
- sb.deleteCharAt(sb.length() - 1);
+ if (!isChanged(oldLines, newLines)) {
+ return; // Don't touch the file
}
- try (Writer fw = new OutputStreamWriter(new FileOutputStream(f),
- UTF_8)) {
- fw.write(sb.toString());
+ try (Writer fw = Files.newBufferedWriter(f.toPath())) {
+ for (Iterator l = newLines.iterator(); l.hasNext();) {
+ fw.write(l.next());
+ if (l.hasNext()) {
+ // Don't bother handling line endings - if it was Windows,
+ // the \r is still there!
+ fw.write('\n');
+ }
+ }
}
-
getRepository().getFS().setExecute(f, fh.getNewMode() == FileMode.EXECUTABLE_FILE);
}
+ private boolean canApplyAt(List hunkLines, List newLines,
+ int line) {
+ int sz = hunkLines.size();
+ int limit = newLines.size();
+ int pos = line;
+ for (int j = 1; j < sz; j++) {
+ String hunkLine = hunkLines.get(j);
+ switch (hunkLine.charAt(0)) {
+ case ' ':
+ case '-':
+ if (pos >= limit
+ || !newLines.get(pos).equals(hunkLine.substring(1))) {
+ return false;
+ }
+ pos++;
+ break;
+ default:
+ break;
+ }
+ }
+ return true;
+ }
+
private static boolean isChanged(List ol, List nl) {
if (ol.size() != nl.size())
return true;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
index 4e18b5994..b4f717503 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
@@ -27,6 +27,7 @@ import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.api.errors.NoFilepatternException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.NoMessageException;
+import org.eclipse.jgit.api.errors.ServiceUnavailableException;
import org.eclipse.jgit.api.errors.UnmergedPathsException;
import org.eclipse.jgit.api.errors.UnsupportedSigningFormatException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
@@ -55,7 +56,6 @@ import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.RefUpdate.Result;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryState;
-import org.eclipse.jgit.lib.internal.BouncyCastleGpgSigner;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevObject;
import org.eclipse.jgit.revwalk.RevTag;
@@ -140,12 +140,16 @@ public class CommitCommand extends GitCommand {
* collected by the setter methods of this class. Each instance of this
* class should only be used for one invocation of the command (means: one
* call to {@link #call()})
+ *
+ * @throws ServiceUnavailableException
+ * if signing service is not available e.g. since it isn't
+ * installed
*/
@Override
- public RevCommit call() throws GitAPIException, NoHeadException,
- NoMessageException, UnmergedPathsException,
- ConcurrentRefUpdateException, WrongRepositoryStateException,
- AbortedByHookException {
+ public RevCommit call() throws GitAPIException, AbortedByHookException,
+ ConcurrentRefUpdateException, NoHeadException, NoMessageException,
+ ServiceUnavailableException, UnmergedPathsException,
+ WrongRepositoryStateException {
checkCallable();
Collections.sort(only);
@@ -239,6 +243,10 @@ public class CommitCommand extends GitCommand {
commit.setTreeId(indexTreeId);
if (signCommit.booleanValue()) {
+ if (gpgSigner == null) {
+ throw new ServiceUnavailableException(
+ JGitText.get().signingServiceUnavailable);
+ }
gpgSigner.sign(commit, signingKey, committer,
credentialsProvider);
}
@@ -510,7 +518,8 @@ public class CommitCommand extends GitCommand {
*
* @throws NoMessageException
* if the commit message has not been specified
- * @throws UnsupportedSigningFormatException if the configured gpg.format is not supported
+ * @throws UnsupportedSigningFormatException
+ * if the configured gpg.format is not supported
*/
private void processOptions(RepositoryState state, RevWalk rw)
throws NoMessageException, UnsupportedSigningFormatException {
@@ -581,9 +590,6 @@ public class CommitCommand extends GitCommand {
JGitText.get().onlyOpenPgpSupportedForSigning);
}
gpgSigner = GpgSigner.getDefault();
- if (gpgSigner == null) {
- gpgSigner = new BouncyCastleGpgSigner();
- }
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java
index 01306f412..64314772b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java
@@ -18,6 +18,8 @@ import java.io.IOException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
import org.eclipse.jgit.lib.RepositoryCache;
+import org.eclipse.jgit.lib.internal.WorkQueue;
+import org.eclipse.jgit.nls.NLS;
import org.eclipse.jgit.util.FS;
/**
@@ -170,6 +172,15 @@ public class Git implements AutoCloseable {
return new InitCommand();
}
+ /**
+ * Shutdown JGit and release resources it holds like NLS and thread pools
+ * @since 5.8
+ */
+ public static void shutdown() {
+ WorkQueue.getExecutor().shutdownNow();
+ NLS.clear();
+ }
+
/**
* Construct a new {@link org.eclipse.jgit.api.Git} object which can
* interact with the specified git repository.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/ServiceUnavailableException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/ServiceUnavailableException.java
new file mode 100644
index 000000000..207ded026
--- /dev/null
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/ServiceUnavailableException.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2020, Matthias Sohn and
+ * other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.api.errors;
+
+/**
+ * Exception thrown when an optional service is not available
+ *
+ * @since 5.8
+ */
+public class ServiceUnavailableException extends GitAPIException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor for ServiceUnavailableException
+ *
+ * @param message
+ * error message
+ * @param cause
+ * a {@link java.lang.Throwable}
+ */
+ public ServiceUnavailableException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructor for ServiceUnavailableException
+ *
+ * @param message
+ * error message
+ */
+ public ServiceUnavailableException(String message) {
+ super(message);
+ }
+}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextComparator.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextComparator.java
index 508d07c20..0c41b8598 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextComparator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextComparator.java
@@ -191,21 +191,15 @@ public abstract class RawTextComparator extends SequenceComparator {
be = trimTrailingWhitespace(b.content, bs, be);
while (as < ae && bs < be) {
- byte ac = a.content[as];
- byte bc = b.content[bs];
+ byte ac = a.content[as++];
+ byte bc = b.content[bs++];
- if (ac != bc)
- return false;
-
- if (isWhitespace(ac))
+ if (isWhitespace(ac) && isWhitespace(bc)) {
as = trimLeadingWhitespace(a.content, as, ae);
- else
- as++;
-
- if (isWhitespace(bc))
bs = trimLeadingWhitespace(b.content, bs, be);
- else
- bs++;
+ } else if (ac != bc) {
+ return false;
+ }
}
return as == ae && bs == be;
}
@@ -215,12 +209,12 @@ public abstract class RawTextComparator extends SequenceComparator {
int hash = 5381;
end = trimTrailingWhitespace(raw, ptr, end);
while (ptr < end) {
- byte c = raw[ptr];
- hash = ((hash << 5) + hash) + (c & 0xff);
- if (isWhitespace(c))
+ byte c = raw[ptr++];
+ if (isWhitespace(c)) {
ptr = trimLeadingWhitespace(raw, ptr, end);
- else
- ptr++;
+ c = ' ';
+ }
+ hash = ((hash << 5) + hash) + (c & 0xff);
}
return hash;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
index e8e198430..8c51a7ac2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
@@ -1217,7 +1217,7 @@ public class DirCacheCheckout {
if (e != null && !FileMode.TREE.equals(e.getFileMode()))
builder.add(e);
if (force) {
- if (f.isModified(e, true, walk.getObjectReader())) {
+ if (f == null || f.isModified(e, true, walk.getObjectReader())) {
kept.add(path);
checkoutEntry(repo, e, walk.getObjectReader(), false,
new CheckoutMetadata(walk.getEolStreamType(CHECKOUT_OP),
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/CharacterHead.java b/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/CharacterHead.java
index ebffa19b1..faf4ee66c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/CharacterHead.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/CharacterHead.java
@@ -19,7 +19,7 @@ final class CharacterHead extends AbstractHead {
* @param expectedCharacter
* expected {@code char}
*/
- protected CharacterHead(char expectedCharacter) {
+ CharacterHead(char expectedCharacter) {
super(false);
this.expectedCharacter = expectedCharacter;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
index ec2414d41..782a3f872 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -297,6 +297,7 @@ public class JGitText extends TranslationBundle {
/***/ public String exceptionHookExecutionInterrupted;
/***/ public String exceptionOccurredDuringAddingOfOptionToALogCommand;
/***/ public String exceptionOccurredDuringReadingOfGIT_DIR;
+ /***/ public String exceptionWhileFindingUserHome;
/***/ public String exceptionWhileReadingPack;
/***/ public String expectedACKNAKFoundEOF;
/***/ public String expectedACKNAKGot;
@@ -332,15 +333,6 @@ public class JGitText extends TranslationBundle {
/***/ public String funnyRefname;
/***/ public String gcFailed;
/***/ public String gcTooManyUnpruned;
- /***/ public String gpgFailedToParseSecretKey;
- /***/ public String gpgNoCredentialsProvider;
- /***/ public String gpgNoKeyring;
- /***/ public String gpgNoKeyInLegacySecring;
- /***/ public String gpgNoPublicKeyFound;
- /***/ public String gpgNoSecretKeyForPublicKey;
- /***/ public String gpgNotASigningKey;
- /***/ public String gpgKeyInfo;
- /***/ public String gpgSigningCancelled;
/***/ public String headRequiredToStash;
/***/ public String hoursAgo;
/***/ public String httpConfigCannotNormalizeURL;
@@ -384,6 +376,7 @@ public class JGitText extends TranslationBundle {
/***/ public String invalidGitModules;
/***/ public String invalidGitType;
/***/ public String invalidHexString;
+ /***/ public String invalidHomeDirectory;
/***/ public String invalidHooksPath;
/***/ public String invalidId;
/***/ public String invalidId0;
@@ -645,6 +638,7 @@ public class JGitText extends TranslationBundle {
/***/ public String shortReadOfOptionalDIRCExtensionExpectedAnotherBytes;
/***/ public String shortSkipOfBlock;
/***/ public String signingNotSupportedOnTag;
+ /***/ public String signingServiceUnavailable;
/***/ public String similarityScoreMustBeWithinBounds;
/***/ public String skipMustBeNonNegative;
/***/ public String skipNotAccessiblePath;
@@ -655,7 +649,6 @@ public class JGitText extends TranslationBundle {
/***/ public String sourceRefNotSpecifiedForRefspec;
/***/ public String squashCommitNotUpdatingHEAD;
/***/ public String sshCommandFailed;
- /***/ public String sshUserNameError;
/***/ public String sslFailureExceptionMessage;
/***/ public String sslFailureInfo;
/***/ public String sslFailureCause;
@@ -716,7 +709,6 @@ public class JGitText extends TranslationBundle {
/***/ public String transportProtoSSH;
/***/ public String transportProtoTest;
/***/ public String transportProvidedRefWithNoObjectId;
- /***/ public String transportSSHRetryInterrupt;
/***/ public String treeEntryAlreadyExists;
/***/ public String treeFilterMarkerTooManyFilters;
/***/ public String treeWalkMustHaveExactlyTwoTrees;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/AddToBitmapWithCacheFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/AddToBitmapWithCacheFilter.java
new file mode 100644
index 000000000..d7ccadfbe
--- /dev/null
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/AddToBitmapWithCacheFilter.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2020, Google LLC and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.internal.revwalk;
+
+import org.eclipse.jgit.lib.BitmapIndex.Bitmap;
+import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.AnyObjectId;
+import org.eclipse.jgit.revwalk.filter.RevFilter;
+import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevFlag;
+
+/**
+ * A RevFilter that adds the visited commits to {@code bitmap} as a side effect.
+ *
+ * When the walk hits a commit that is the same as {@code cachedCommit} or is
+ * part of {@code bitmap}'s BitmapIndex, that entire bitmap is ORed into
+ * {@code bitmap} and the commit and its parents are marked as SEEN so that the
+ * walk does not have to visit its ancestors. This ensures the walk is very
+ * short if there is good bitmap coverage.
+ */
+public class AddToBitmapWithCacheFilter extends RevFilter {
+ private final AnyObjectId cachedCommit;
+
+ private final Bitmap cachedBitmap;
+
+ private final BitmapBuilder bitmap;
+
+ /**
+ * Create a filter with a cached BitmapCommit that adds visited commits to
+ * the given bitmap.
+ *
+ * @param cachedCommit
+ * the cached commit
+ * @param cachedBitmap
+ * the bitmap corresponds to {@code cachedCommit}}
+ * @param bitmap
+ * bitmap to write visited commits to
+ */
+ public AddToBitmapWithCacheFilter(AnyObjectId cachedCommit,
+ Bitmap cachedBitmap,
+ BitmapBuilder bitmap) {
+ this.cachedCommit = cachedCommit;
+ this.cachedBitmap = cachedBitmap;
+ this.bitmap = bitmap;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public final boolean include(RevWalk rw, RevCommit c) {
+ Bitmap visitedBitmap;
+
+ if (bitmap.contains(c)) {
+ // already included
+ } else if ((visitedBitmap = bitmap.getBitmapIndex()
+ .getBitmap(c)) != null) {
+ bitmap.or(visitedBitmap);
+ } else if (cachedCommit.equals(c)) {
+ bitmap.or(cachedBitmap);
+ } else {
+ bitmap.addObject(c, Constants.OBJ_COMMIT);
+ return true;
+ }
+
+ for (RevCommit p : c.getParents()) {
+ p.add(RevFlag.SEEN);
+ }
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public final RevFilter clone() {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public final boolean requiresCommitBody() {
+ return false;
+ }
+}
+
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java
index 6aa1a0e8e..0d3a2b4f1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java
@@ -252,6 +252,11 @@ public class BitmapIndexImpl implements BitmapIndex {
return bitmapIndex;
}
+ @Override
+ public EWAHCompressedBitmap retrieveCompressed() {
+ return build().retrieveCompressed();
+ }
+
private EWAHCompressedBitmap ewahBitmap(Bitmap other) {
if (other instanceof CompressedBitmap) {
CompressedBitmap b = (CompressedBitmap) other;
@@ -372,7 +377,8 @@ public class BitmapIndexImpl implements BitmapIndex {
};
}
- EWAHCompressedBitmap getEwahCompressedBitmap() {
+ @Override
+ public EWAHCompressedBitmap retrieveCompressed() {
return bitmap;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
index 6a822d570..265b71dd2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
@@ -19,8 +19,8 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.nio.file.AtomicMoveNotSupportedException;
import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
import java.nio.file.StandardCopyOption;
import java.text.MessageFormat;
import java.util.ArrayList;
@@ -685,47 +685,46 @@ public class ObjectDirectory extends FileObjectDatabase {
FileUtils.delete(tmp, FileUtils.RETRY);
return InsertLooseObjectResult.EXISTS_LOOSE;
}
+
try {
- Files.move(FileUtils.toPath(tmp), FileUtils.toPath(dst),
- StandardCopyOption.ATOMIC_MOVE);
- dst.setReadOnly();
- unpackedObjectCache.add(id);
- return InsertLooseObjectResult.INSERTED;
- } catch (AtomicMoveNotSupportedException e) {
- LOG.error(e.getMessage(), e);
+ return tryMove(tmp, dst, id);
+ } catch (NoSuchFileException e) {
+ // It's possible the directory doesn't exist yet as the object
+ // directories are always lazily created. Note that we try the
+ // rename/move first as the directory likely does exist.
+ //
+ // Create the directory.
+ //
+ FileUtils.mkdir(dst.getParentFile(), true);
} catch (IOException e) {
- // ignore
+ // Any other IO error is considered a failure.
+ //
+ LOG.error(e.getMessage(), e);
+ FileUtils.delete(tmp, FileUtils.RETRY);
+ return InsertLooseObjectResult.FAILURE;
}
- // Maybe the directory doesn't exist yet as the object
- // directories are always lazily created. Note that we
- // try the rename first as the directory likely does exist.
- //
- FileUtils.mkdir(dst.getParentFile(), true);
try {
- Files.move(FileUtils.toPath(tmp), FileUtils.toPath(dst),
- StandardCopyOption.ATOMIC_MOVE);
- dst.setReadOnly();
- unpackedObjectCache.add(id);
- return InsertLooseObjectResult.INSERTED;
- } catch (AtomicMoveNotSupportedException e) {
- LOG.error(e.getMessage(), e);
+ return tryMove(tmp, dst, id);
} catch (IOException e) {
- LOG.debug(e.getMessage(), e);
- }
-
- if (!createDuplicate && has(id)) {
+ // The object failed to be renamed into its proper location and
+ // it doesn't exist in the repository either. We really don't
+ // know what went wrong, so fail.
+ //
+ LOG.error(e.getMessage(), e);
FileUtils.delete(tmp, FileUtils.RETRY);
- return InsertLooseObjectResult.EXISTS_PACKED;
+ return InsertLooseObjectResult.FAILURE;
}
+ }
- // The object failed to be renamed into its proper
- // location and it doesn't exist in the repository
- // either. We really don't know what went wrong, so
- // fail.
- //
- FileUtils.delete(tmp, FileUtils.RETRY);
- return InsertLooseObjectResult.FAILURE;
+ private InsertLooseObjectResult tryMove(File tmp, File dst,
+ ObjectId id)
+ throws IOException {
+ Files.move(FileUtils.toPath(tmp), FileUtils.toPath(dst),
+ StandardCopyOption.ATOMIC_MOVE);
+ dst.setReadOnly();
+ unpackedObjectCache.add(id);
+ return InsertLooseObjectResult.INSERTED;
}
boolean searchPacksAgain(PackList old) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
index c908e6a24..e6b2cc12f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
@@ -14,7 +14,6 @@ package org.eclipse.jgit.internal.storage.file;
import java.io.EOFException;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
@@ -116,7 +115,7 @@ class ObjectDirectoryInserter extends ObjectInserter {
private ObjectId insertOneObject(
File tmp, ObjectId id, boolean createDuplicate)
- throws IOException, ObjectWritingException {
+ throws IOException {
switch (db.insertUnpackedObject(tmp, id, createDuplicate)) {
case INSERTED:
case EXISTS_PACKED:
@@ -163,18 +162,16 @@ class ObjectDirectoryInserter extends ObjectInserter {
}
}
- @SuppressWarnings("resource" /* java 7 */)
private File toTemp(final SHA1 md, final int type, long len,
- final InputStream is) throws IOException, FileNotFoundException,
- Error {
+ final InputStream is) throws IOException {
boolean delete = true;
File tmp = newTempFile();
- try {
- FileOutputStream fOut = new FileOutputStream(tmp);
+ try (FileOutputStream fOut = new FileOutputStream(tmp)) {
try {
OutputStream out = fOut;
- if (config.getFSyncObjectFiles())
+ if (config.getFSyncObjectFiles()) {
out = Channels.newOutputStream(fOut.getChannel());
+ }
DeflaterOutputStream cOut = compress(out);
SHA1OutputStream dOut = new SHA1OutputStream(cOut, md);
writeHeader(dOut, type, len);
@@ -182,53 +179,54 @@ class ObjectDirectoryInserter extends ObjectInserter {
final byte[] buf = buffer();
while (len > 0) {
int n = is.read(buf, 0, (int) Math.min(len, buf.length));
- if (n <= 0)
+ if (n <= 0) {
throw shortInput(len);
+ }
dOut.write(buf, 0, n);
len -= n;
}
dOut.flush();
cOut.finish();
} finally {
- if (config.getFSyncObjectFiles())
+ if (config.getFSyncObjectFiles()) {
fOut.getChannel().force(true);
- fOut.close();
+ }
}
delete = false;
return tmp;
} finally {
- if (delete)
+ if (delete) {
FileUtils.delete(tmp, FileUtils.RETRY);
+ }
}
}
- @SuppressWarnings("resource" /* java 7 */)
private File toTemp(final int type, final byte[] buf, final int pos,
- final int len) throws IOException, FileNotFoundException {
+ final int len) throws IOException {
boolean delete = true;
File tmp = newTempFile();
- try {
- FileOutputStream fOut = new FileOutputStream(tmp);
+ try (FileOutputStream fOut = new FileOutputStream(tmp)) {
try {
OutputStream out = fOut;
- if (config.getFSyncObjectFiles())
+ if (config.getFSyncObjectFiles()) {
out = Channels.newOutputStream(fOut.getChannel());
+ }
DeflaterOutputStream cOut = compress(out);
writeHeader(cOut, type, len);
cOut.write(buf, pos, len);
cOut.finish();
} finally {
- if (config.getFSyncObjectFiles())
+ if (config.getFSyncObjectFiles()) {
fOut.getChannel().force(true);
- fOut.close();
+ }
}
-
delete = false;
return tmp;
} finally {
- if (delete)
+ if (delete) {
FileUtils.delete(tmp, FileUtils.RETRY);
+ }
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
index 9538cc5e0..5666b5760 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
@@ -11,17 +11,16 @@
package org.eclipse.jgit.internal.storage.file;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
-import java.util.NoSuchElementException;
import org.eclipse.jgit.internal.JGitText;
-import org.eclipse.jgit.internal.storage.file.BitmapIndexImpl.CompressedBitmap;
+import org.eclipse.jgit.internal.storage.pack.BitmapCommit;
import org.eclipse.jgit.internal.storage.pack.ObjectToPack;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.BitmapIndex.Bitmap;
-import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectIdOwnerMap;
@@ -41,8 +40,12 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
private final EWAHCompressedBitmap blobs;
private final EWAHCompressedBitmap tags;
private final BlockList byOffset;
- final BlockList
- byAddOrder = new BlockList<>();
+
+ private final LinkedList
+ bitmapsToWriteXorBuffer = new LinkedList<>();
+
+ private List bitmapsToWrite = new ArrayList<>();
+
final ObjectIdOwnerMap
positionEntries = new ObjectIdOwnerMap<>();
@@ -134,16 +137,64 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
* the flags to be stored with the bitmap
*/
public void addBitmap(AnyObjectId objectId, Bitmap bitmap, int flags) {
- if (bitmap instanceof BitmapBuilder)
- bitmap = ((BitmapBuilder) bitmap).build();
+ addBitmap(objectId, bitmap.retrieveCompressed(), flags);
+ }
- EWAHCompressedBitmap compressed;
- if (bitmap instanceof CompressedBitmap)
- compressed = ((CompressedBitmap) bitmap).getEwahCompressedBitmap();
- else
- throw new IllegalArgumentException(bitmap.getClass().toString());
+ /**
+ * Processes a commit and prepares its bitmap to write to the bitmap index
+ * file.
+ *
+ * @param c
+ * the commit corresponds to the bitmap.
+ * @param bitmap
+ * the bitmap to be written.
+ * @param flags
+ * the flags of the commit.
+ */
+ public void processBitmapForWrite(BitmapCommit c, Bitmap bitmap,
+ int flags) {
+ EWAHCompressedBitmap compressed = bitmap.retrieveCompressed();
+ compressed.trim();
+ StoredBitmap newest = new StoredBitmap(c, compressed, null, flags);
+
+ bitmapsToWriteXorBuffer.add(newest);
+ if (bitmapsToWriteXorBuffer.size() > MAX_XOR_OFFSET_SEARCH) {
+ bitmapsToWrite.add(
+ generateStoredEntry(bitmapsToWriteXorBuffer.pollFirst()));
+ }
- addBitmap(objectId, compressed, flags);
+ if (c.isAddToIndex()) {
+ // The Bitmap map in the base class is used to make revwalks
+ // efficient, so only add bitmaps that keep it efficient without
+ // bloating memory.
+ addBitmap(c, bitmap, flags);
+ }
+ }
+
+ private StoredEntry generateStoredEntry(StoredBitmap bitmapToWrite) {
+ int bestXorOffset = 0;
+ EWAHCompressedBitmap bestBitmap = bitmapToWrite.getBitmap();
+
+ int offset = 1;
+ for (StoredBitmap curr : bitmapsToWriteXorBuffer) {
+ EWAHCompressedBitmap bitmap = curr.getBitmap()
+ .xor(bitmapToWrite.getBitmap());
+ if (bitmap.sizeInBytes() < bestBitmap.sizeInBytes()) {
+ bestBitmap = bitmap;
+ bestXorOffset = offset;
+ }
+ offset++;
+ }
+
+ PositionEntry entry = positionEntries.get(bitmapToWrite);
+ if (entry == null) {
+ throw new IllegalStateException();
+ }
+ bestBitmap.trim();
+ StoredEntry result = new StoredEntry(entry.namePosition, bestBitmap,
+ bestXorOffset, bitmapToWrite.getFlags());
+
+ return result;
}
/**
@@ -161,7 +212,6 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
bitmap.trim();
StoredBitmap result = new StoredBitmap(objectId, bitmap, null, flags);
getBitmaps().add(result);
- byAddOrder.add(result);
}
/** {@inheritDoc} */
@@ -247,15 +297,18 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
/** {@inheritDoc} */
@Override
public int getBitmapCount() {
- return getBitmaps().size();
+ return bitmapsToWriteXorBuffer.size() + bitmapsToWrite.size();
}
/**
* Remove all the bitmaps entries added.
+ *
+ * @param size
+ * the expected number of bitmap entries to be written.
*/
- public void clearBitmaps() {
- byAddOrder.clear();
+ public void resetBitmaps(int size) {
getBitmaps().clear();
+ bitmapsToWrite = new ArrayList<>(size);
}
/** {@inheritDoc} */
@@ -265,64 +318,18 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
}
/**
- * Get an iterator over the xor compressed entries.
+ * Get list of xor compressed entries that need to be written.
*
- * @return an iterator over the xor compressed entries.
+ * @return a list of the xor compressed entries.
*/
- public Iterable getCompressedBitmaps() {
- // Add order is from oldest to newest. The reverse add order is the
- // output order.
- return () -> new Iterator() {
-
- private int index = byAddOrder.size() - 1;
-
- @Override
- public boolean hasNext() {
- return index >= 0;
- }
-
- @Override
- public StoredEntry next() {
- if (!hasNext()) {
- throw new NoSuchElementException();
- }
- StoredBitmap item = byAddOrder.get(index);
- int bestXorOffset = 0;
- EWAHCompressedBitmap bestBitmap = item.getBitmap();
-
- // Attempt to compress the bitmap with an XOR of the
- // previously written entries.
- for (int i = 1; i <= MAX_XOR_OFFSET_SEARCH; i++) {
- int curr = i + index;
- if (curr >= byAddOrder.size()) {
- break;
- }
-
- StoredBitmap other = byAddOrder.get(curr);
- EWAHCompressedBitmap bitmap = other.getBitmap()
- .xor(item.getBitmap());
-
- if (bitmap.sizeInBytes() < bestBitmap.sizeInBytes()) {
- bestBitmap = bitmap;
- bestXorOffset = i;
- }
- }
- index--;
-
- PositionEntry entry = positionEntries.get(item);
- if (entry == null) {
- throw new IllegalStateException();
- }
- bestBitmap.trim();
- return new StoredEntry(entry.namePosition, bestBitmap,
- bestXorOffset, item.getFlags());
- }
+ public List getCompressedBitmaps() {
+ while (!bitmapsToWriteXorBuffer.isEmpty()) {
+ bitmapsToWrite.add(
+ generateStoredEntry(bitmapsToWriteXorBuffer.pollFirst()));
+ }
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
+ Collections.reverse(bitmapsToWrite);
+ return bitmapsToWrite;
}
/** Data object for the on disk representation of a bitmap entry. */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java
index 273eeef7e..4b2528451 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java
@@ -18,7 +18,6 @@ import org.eclipse.jgit.internal.storage.file.BasePackBitmapIndex.StoredBitmap;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.BitmapIndex;
import org.eclipse.jgit.lib.ObjectId;
-import org.eclipse.jgit.lib.ObjectIdOwnerMap;
import com.googlecode.javaewah.EWAHCompressedBitmap;
import com.googlecode.javaewah.IntIterator;
@@ -34,7 +33,6 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
private final BasePackBitmapIndex oldPackIndex;
final PackBitmapIndex newPackIndex;
- private final ObjectIdOwnerMap convertedBitmaps;
private final BitSet inflated;
private final int[] prevToNewMapping;
@@ -65,7 +63,6 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
private PackBitmapIndexRemapper(PackBitmapIndex newPackIndex) {
this.oldPackIndex = null;
this.newPackIndex = newPackIndex;
- this.convertedBitmaps = null;
this.inflated = null;
this.prevToNewMapping = null;
}
@@ -74,7 +71,6 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
BasePackBitmapIndex oldPackIndex, PackBitmapIndex newPackIndex) {
this.oldPackIndex = oldPackIndex;
this.newPackIndex = newPackIndex;
- convertedBitmaps = new ObjectIdOwnerMap<>();
inflated = new BitSet(newPackIndex.getObjectCount());
prevToNewMapping = new int[oldPackIndex.getObjectCount()];
@@ -152,10 +148,6 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
if (bitmap != null || oldPackIndex == null)
return bitmap;
- StoredBitmap stored = convertedBitmaps.get(objectId);
- if (stored != null)
- return stored.getBitmap();
-
StoredBitmap oldBitmap = oldPackIndex.getBitmaps().get(objectId);
if (oldBitmap == null)
return null;
@@ -168,8 +160,6 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
inflated.set(prevToNewMapping[i.next()]);
bitmap = inflated.toEWAHCompressedBitmap();
bitmap.trim();
- convertedBitmaps.add(
- new StoredBitmap(objectId, bitmap, null, oldBitmap.getFlags()));
return bitmap;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
index 852302f00..80c8e10de 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
@@ -470,7 +470,9 @@ public class WindowCache {
mbean = new StatsRecorderImpl();
statsRecorder = mbean;
- Monitoring.registerMBean(mbean, "block_cache"); //$NON-NLS-1$
+ if (cfg.getExposeStatsViaJmx()) {
+ Monitoring.registerMBean(mbean, "block_cache"); //$NON-NLS-1$
+ }
if (maxFiles < 1)
throw new IllegalArgumentException(JGitText.get().openFilesMustBeAtLeast1);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BitmapCommit.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BitmapCommit.java
new file mode 100644
index 000000000..33c478e4a
--- /dev/null
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/BitmapCommit.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2020, Google LLC and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.internal.storage.pack;
+
+import org.eclipse.jgit.lib.AnyObjectId;
+import org.eclipse.jgit.lib.ObjectId;
+
+/**
+ * A commit object for which a bitmap index should be built.
+ */
+public final class BitmapCommit extends ObjectId {
+
+ private final boolean reuseWalker;
+
+ private final int flags;
+
+ private final boolean addToIndex;
+
+ BitmapCommit(AnyObjectId objectId, boolean reuseWalker, int flags) {
+ super(objectId);
+ this.reuseWalker = reuseWalker;
+ this.flags = flags;
+ this.addToIndex = false;
+ }
+
+ BitmapCommit(AnyObjectId objectId, boolean reuseWalker, int flags,
+ boolean addToIndex) {
+ super(objectId);
+ this.reuseWalker = reuseWalker;
+ this.flags = flags;
+ this.addToIndex = addToIndex;
+ }
+
+ boolean isReuseWalker() {
+ return reuseWalker;
+ }
+
+ int getFlags() {
+ return flags;
+ }
+
+ /**
+ * Whether corresponding bitmap should be added to PackBitmapIndexBuilder.
+ *
+ * @return true if the corresponding bitmap should be added to
+ * PackBitmapIndexBuilder.
+ */
+ public boolean isAddToIndex() {
+ return addToIndex;
+ }
+
+ /**
+ * Get a builder of BitmapCommit whose object id is {@code objId}.
+ *
+ * @param objId
+ * the object id of the BitmapCommit
+ * @return a BitmapCommit builder with object id set.
+ */
+ public static Builder newBuilder(AnyObjectId objId) {
+ return new Builder().setId(objId);
+ }
+
+ /**
+ * Get a builder of BitmapCommit whose fields are copied from
+ * {@code commit}.
+ *
+ * @param commit
+ * the bitmap commit the builder is copying from
+ * @return a BitmapCommit build with fields copied from an existing bitmap
+ * commit.
+ */
+ public static Builder copyFrom(BitmapCommit commit) {
+ return new Builder().setId(commit)
+ .setReuseWalker(commit.isReuseWalker())
+ .setFlags(commit.getFlags())
+ .setAddToIndex(commit.isAddToIndex());
+ }
+
+ /**
+ * Builder of BitmapCommit.
+ */
+ public static class Builder {
+ private AnyObjectId objectId;
+
+ private boolean reuseWalker;
+
+ private int flags;
+
+ private boolean addToIndex;
+
+ // Prevent default constructor.
+ private Builder() {
+ }
+
+ /**
+ * Set objectId of the builder.
+ *
+ * @param objectId
+ * the object id of the BitmapCommit
+ * @return the builder itself
+ */
+ public Builder setId(AnyObjectId objectId) {
+ this.objectId = objectId;
+ return this;
+ }
+
+ /**
+ * Set reuseWalker of the builder.
+ *
+ * @param reuseWalker
+ * whether the BitmapCommit should reuse bitmap walker when
+ * walking objects
+ * @return the builder itself
+ */
+ public Builder setReuseWalker(boolean reuseWalker) {
+ this.reuseWalker = reuseWalker;
+ return this;
+ }
+
+ /**
+ * Set flags of the builder.
+ *
+ * @param flags
+ * the flags of the BitmapCommit
+ * @return the builder itself
+ */
+ public Builder setFlags(int flags) {
+ this.flags = flags;
+ return this;
+ }
+
+ /**
+ * Set whether whether the bitmap of the BitmapCommit should be added to
+ * PackBitmapIndexBuilder when building bitmap index file.
+ *
+ * @param addToIndex
+ * whether the bitmap of the BitmapCommit should be added to
+ * PackBitmapIndexBuilder when building bitmap index file
+ * @return the builder itself
+ */
+ public Builder setAddToIndex(boolean addToIndex) {
+ this.addToIndex = addToIndex;
+ return this;
+ }
+
+ /**
+ * Builds BitmapCommit from the builder.
+ *
+ * @return the new BitmapCommit.
+ */
+ public BitmapCommit build() {
+ return new BitmapCommit(objectId, reuseWalker, flags,
+ addToIndex);
+ }
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
index 75dd345f4..824c62ad9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
@@ -2313,14 +2313,14 @@ public class PackWriter implements AutoCloseable {
PackWriterBitmapPreparer bitmapPreparer = new PackWriterBitmapPreparer(
reader, writeBitmaps, pm, stats.interestingObjects, config);
- Collection selectedCommits = bitmapPreparer
+ Collection selectedCommits = bitmapPreparer
.selectCommits(numCommits, excludeFromBitmapSelection);
beginPhase(PackingPhase.BUILDING_BITMAPS, pm, selectedCommits.size());
BitmapWalker walker = bitmapPreparer.newBitmapWalker();
AnyObjectId last = null;
- for (PackWriterBitmapPreparer.BitmapCommit cmit : selectedCommits) {
+ for (BitmapCommit cmit : selectedCommits) {
if (!cmit.isReuseWalker()) {
walker = bitmapPreparer.newBitmapWalker();
}
@@ -2331,8 +2331,14 @@ public class PackWriter implements AutoCloseable {
throw new IllegalStateException(MessageFormat.format(
JGitText.get().bitmapMissingObject, cmit.name(),
last.name()));
- last = cmit;
- writeBitmaps.addBitmap(cmit, bitmap.build(), cmit.getFlags());
+ last = BitmapCommit.copyFrom(cmit).build();
+ writeBitmaps.processBitmapForWrite(cmit, bitmap.build(),
+ cmit.getFlags());
+
+ // The bitmap walker should stop when the walk hits the previous
+ // commit, which saves time.
+ walker.setPrevCommit(last);
+ walker.setPrevBitmap(bitmap);
pm.update(1);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java
index 51b4993e2..f1ede2acf 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java
@@ -58,6 +58,8 @@ class PackWriterBitmapPreparer {
private static final int DAY_IN_SECONDS = 24 * 60 * 60;
+ private static final int DISTANCE_THRESHOLD = 2000;
+
private static final Comparator ORDER_BY_REVERSE_TIMESTAMP = (
RevCommit a, RevCommit b) -> Integer
.signum(b.getCommitTime() - a.getCommitTime());
@@ -244,6 +246,7 @@ class PackWriterBitmapPreparer {
// This commit is selected.
// Calculate where to look for the next one.
int flags = nextFlg;
+ int currDist = distanceFromTip;
nextIn = nextSpan(distanceFromTip);
nextFlg = nextIn == distantCommitSpan
? PackBitmapIndex.FLAG_REUSE
@@ -279,8 +282,17 @@ class PackWriterBitmapPreparer {
longestAncestorChain = new ArrayList<>();
chains.add(longestAncestorChain);
}
- longestAncestorChain.add(new BitmapCommit(c,
- !longestAncestorChain.isEmpty(), flags));
+
+ // The commit bc should reuse bitmap walker from its close
+ // ancestor. And the bitmap of bc should only be added to
+ // PackBitmapIndexBuilder when it's an old enough
+ // commit,i.e. distance from tip should be greater than
+ // DISTANCE_THRESHOLD, to save memory.
+ BitmapCommit bc = BitmapCommit.newBuilder(c).setFlags(flags)
+ .setAddToIndex(currDist >= DISTANCE_THRESHOLD)
+ .setReuseWalker(!longestAncestorChain.isEmpty())
+ .build();
+ longestAncestorChain.add(bc);
writeBitmaps.addBitmap(c, bitmap, 0);
}
@@ -288,12 +300,12 @@ class PackWriterBitmapPreparer {
selections.addAll(chain);
}
}
- writeBitmaps.clearBitmaps(); // Remove the temporary commit bitmaps.
// Add the remaining peeledWant
for (AnyObjectId remainingWant : selectionHelper.newWants) {
selections.add(new BitmapCommit(remainingWant, false, 0));
}
+ writeBitmaps.resetBitmaps(selections.size()); // Remove the temporary commit bitmaps.
pm.endTask();
return selections;
@@ -467,28 +479,6 @@ class PackWriterBitmapPreparer {
new ObjectWalk(reader), bitmapIndex, null);
}
- /**
- * A commit object for which a bitmap index should be built.
- */
- static final class BitmapCommit extends ObjectId {
- private final boolean reuseWalker;
- private final int flags;
-
- BitmapCommit(AnyObjectId objectId, boolean reuseWalker, int flags) {
- super(objectId);
- this.reuseWalker = reuseWalker;
- this.flags = flags;
- }
-
- boolean isReuseWalker() {
- return reuseWalker;
- }
-
- int getFlags() {
- return flags;
- }
- }
-
/**
* Container for state used in the first phase of selecting commits, which
* walks all of the reachable commits via the branch tips that are not
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java
index 4de6c2870..4747be354 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java
@@ -280,7 +280,7 @@ public abstract class ReftableDatabase {
/**
* Returns all refs that resolve directly to the given {@link ObjectId}.
- * Includes peeled {@linkObjectId}s.
+ * Includes peeled {@link ObjectId}s.
*
* @param id
* {@link ObjectId} to resolve
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/internal/FullConnectivityChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/connectivity/FullConnectivityChecker.java
similarity index 99%
rename from org.eclipse.jgit/src/org/eclipse/jgit/transport/internal/FullConnectivityChecker.java
rename to org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/connectivity/FullConnectivityChecker.java
index 60d8f452b..b76e3a3ca 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/internal/FullConnectivityChecker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/connectivity/FullConnectivityChecker.java
@@ -8,7 +8,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-package org.eclipse.jgit.transport.internal;
+package org.eclipse.jgit.internal.transport.connectivity;
import java.io.IOException;
import java.util.Set;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/connectivity/IterativeConnectivityChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/connectivity/IterativeConnectivityChecker.java
new file mode 100644
index 000000000..b44c4ae5c
--- /dev/null
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/connectivity/IterativeConnectivityChecker.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2019, Google LLC and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package org.eclipse.jgit.internal.transport.connectivity;
+
+import static java.util.stream.Collectors.toList;
+
+import java.io.IOException;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Queue;
+import java.util.Set;
+import java.util.stream.Stream;
+
+import org.eclipse.jgit.errors.MissingObjectException;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.ProgressMonitor;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevObject;
+import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.jgit.transport.ConnectivityChecker;
+import org.eclipse.jgit.transport.ReceiveCommand;
+
+/**
+ * Implementation of connectivity checker which tries to do check with smaller
+ * set of references first and if it fails will fall back to check against all
+ * advertised references.
+ *
+ * This is useful for big repos with enormous number of references.
+ */
+public class IterativeConnectivityChecker implements ConnectivityChecker {
+ private static final int MAXIMUM_PARENTS_TO_CHECK = 128;
+
+ private final ConnectivityChecker delegate;
+
+ private Set forcedHaves = Collections.emptySet();
+
+ /**
+ * @param delegate
+ * Delegate checker which will be called for actual checks.
+ */
+ public IterativeConnectivityChecker(ConnectivityChecker delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void checkConnectivity(ConnectivityCheckInfo connectivityCheckInfo,
+ Set advertisedHaves, ProgressMonitor pm)
+ throws MissingObjectException, IOException {
+ try {
+ Set newRefs = new HashSet<>();
+ Set expectedParents = new HashSet<>();
+
+ getAllObjectIds(connectivityCheckInfo.getCommands())
+ .forEach(oid -> {
+ if (advertisedHaves.contains(oid)) {
+ expectedParents.add(oid);
+ } else {
+ newRefs.add(oid);
+ }
+ });
+ if (!newRefs.isEmpty()) {
+ expectedParents.addAll(extractAdvertisedParentCommits(newRefs,
+ advertisedHaves, connectivityCheckInfo.getWalk()));
+ }
+
+ expectedParents.addAll(forcedHaves);
+
+ if (!expectedParents.isEmpty()) {
+ delegate.checkConnectivity(connectivityCheckInfo,
+ expectedParents, pm);
+ return;
+ }
+ } catch (MissingObjectException e) {
+ // This is fine, retry with all haves.
+ }
+ delegate.checkConnectivity(connectivityCheckInfo, advertisedHaves, pm);
+ }
+
+ private static Stream getAllObjectIds(
+ List commands) {
+ return commands.stream().flatMap(cmd -> {
+ if (cmd.getType() == ReceiveCommand.Type.UPDATE || cmd
+ .getType() == ReceiveCommand.Type.UPDATE_NONFASTFORWARD) {
+ return Stream.of(cmd.getOldId(), cmd.getNewId());
+ } else if (cmd.getType() == ReceiveCommand.Type.CREATE) {
+ return Stream.of(cmd.getNewId());
+ }
+ return Stream.of();
+ });
+ }
+
+ /**
+ * Sets additional haves that client can depend on (e.g. gerrit changes).
+ *
+ * @param forcedHaves
+ * Haves server expects client to depend on.
+ */
+ public void setForcedHaves(Set forcedHaves) {
+ this.forcedHaves = Collections.unmodifiableSet(forcedHaves);
+ }
+
+ private static Set extractAdvertisedParentCommits(
+ Set newRefs, Set advertisedHaves, RevWalk rw)
+ throws MissingObjectException, IOException {
+ Set advertisedParents = new HashSet<>();
+ for (ObjectId newRef : newRefs) {
+ RevObject object = rw.parseAny(newRef);
+ if (object instanceof RevCommit) {
+ int numberOfParentsToCheck = 0;
+ Queue parents = new ArrayDeque<>(
+ MAXIMUM_PARENTS_TO_CHECK);
+ parents.addAll(
+ parseParents(((RevCommit) object).getParents(), rw));
+ // Looking through a chain of ancestors handles the case where a
+ // series of commits is sent in a single push for a new branch.
+ while (!parents.isEmpty()) {
+ RevCommit parentCommit = parents.poll();
+ if (advertisedHaves.contains(parentCommit.getId())) {
+ advertisedParents.add(parentCommit.getId());
+ } else if (numberOfParentsToCheck < MAXIMUM_PARENTS_TO_CHECK) {
+ RevCommit[] grandParents = parentCommit.getParents();
+ numberOfParentsToCheck += grandParents.length;
+ parents.addAll(parseParents(grandParents, rw));
+ }
+ }
+ }
+ }
+ return advertisedParents;
+ }
+
+ private static List parseParents(RevCommit[] parents,
+ RevWalk rw) {
+ return Arrays.stream(parents).map((commit) -> {
+ try {
+ return rw.parseCommit(commit);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }).collect(toList());
+ }
+}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/internal/DelegatingSSLSocketFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/http/DelegatingSSLSocketFactory.java
similarity index 98%
rename from org.eclipse.jgit/src/org/eclipse/jgit/transport/internal/DelegatingSSLSocketFactory.java
rename to org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/http/DelegatingSSLSocketFactory.java
index d25ecd459..5aab61ad0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/internal/DelegatingSSLSocketFactory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/http/DelegatingSSLSocketFactory.java
@@ -7,7 +7,7 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-package org.eclipse.jgit.transport.internal;
+package org.eclipse.jgit.internal.transport.http;
import java.io.IOException;
import java.net.InetAddress;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java
index 2fbc9122f..98c63cdcd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java
@@ -32,6 +32,7 @@ import java.util.TreeSet;
import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.errors.InvalidPatternException;
import org.eclipse.jgit.fnmatch.FileNameMatcher;
+import org.eclipse.jgit.transport.SshConfigStore;
import org.eclipse.jgit.transport.SshConstants;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.StringUtils;
@@ -80,7 +81,7 @@ import org.eclipse.jgit.util.SystemReader;
* @see man
* ssh-config
*/
-public class OpenSshConfigFile {
+public class OpenSshConfigFile implements SshConfigStore {
/**
* "Host" name of the HostEntry for the default options before the first
@@ -152,8 +153,9 @@ public class OpenSshConfigFile {
* the user supplied; <= 0 if none
* @param userName
* the user supplied, may be {@code null} or empty if none given
- * @return r configuration for the requested name.
+ * @return the configuration for the requested name.
*/
+ @Override
@NonNull
public HostEntry lookup(@NonNull String hostName, int port,
String userName) {
@@ -446,7 +448,7 @@ public class OpenSshConfigFile {
* of several matching host entries, %-substitutions, and ~ replacement have
* all been done.
*/
- public static class HostEntry {
+ public static class HostEntry implements SshConfigStore.HostConfig {
/**
* Keys that can be specified multiple times, building up a list. (I.e.,
@@ -489,7 +491,7 @@ public class OpenSshConfigFile {
private Map> listOptions;
/**
- * Retrieves the value of a single-valued key, or the first is the key
+ * Retrieves the value of a single-valued key, or the first if the key
* has multiple values. Keys are case-insensitive, so
* {@code getValue("HostName") == getValue("HOSTNAME")}.
*
@@ -497,6 +499,7 @@ public class OpenSshConfigFile {
* to get the value of
* @return the value, or {@code null} if none
*/
+ @Override
public String getValue(String key) {
String result = options != null ? options.get(key) : null;
if (result == null) {
@@ -524,6 +527,7 @@ public class OpenSshConfigFile {
* to get the values of
* @return a possibly empty list of values
*/
+ @Override
public List getValues(String key) {
List values = listOptions != null ? listOptions.get(key)
: null;
@@ -778,6 +782,7 @@ public class OpenSshConfigFile {
*
* @return all single-valued options
*/
+ @Override
@NonNull
public Map getOptions() {
if (options == null) {
@@ -792,6 +797,7 @@ public class OpenSshConfigFile {
*
* @return all multi-valued options
*/
+ @Override
@NonNull
public Map> getMultiValuedOptions() {
if (listOptions == null && multiOptions == null) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BitmapIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BitmapIndex.java
index f61286d6d..f6695bdf7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BitmapIndex.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BitmapIndex.java
@@ -14,6 +14,8 @@ import java.util.Iterator;
import org.eclipse.jgit.internal.storage.file.PackBitmapIndex;
+import com.googlecode.javaewah.EWAHCompressedBitmap;
+
/**
* A compressed bitmap representation of the entire object graph.
*
@@ -81,6 +83,14 @@ public interface BitmapIndex {
*/
@Override
Iterator iterator();
+
+ /**
+ * Returns the corresponding raw compressed EWAH bitmap of the bitmap.
+ *
+ * @return the corresponding {@code EWAHCompressedBitmap}
+ * @since 5.8
+ */
+ EWAHCompressedBitmap retrieveCompressed();
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgSigner.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgSigner.java
index d953a0194..5b32cf0b5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgSigner.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgSigner.java
@@ -9,11 +9,16 @@
*/
package org.eclipse.jgit.lib;
+import java.util.Iterator;
+import java.util.ServiceConfigurationError;
+import java.util.ServiceLoader;
+
import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.api.errors.CanceledException;
-import org.eclipse.jgit.lib.internal.BouncyCastleGpgSigner;
import org.eclipse.jgit.transport.CredentialsProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Creates GPG signatures for Git objects.
@@ -21,8 +26,23 @@ import org.eclipse.jgit.transport.CredentialsProvider;
* @since 5.3
*/
public abstract class GpgSigner {
+ private static final Logger LOG = LoggerFactory.getLogger(GpgSigner.class);
+
+ private static GpgSigner defaultSigner = loadGpgSigner();
- private static GpgSigner defaultSigner = new BouncyCastleGpgSigner();
+ private static GpgSigner loadGpgSigner() {
+ try {
+ ServiceLoader loader = ServiceLoader
+ .load(GpgSigner.class);
+ Iterator iter = loader.iterator();
+ if (iter.hasNext()) {
+ return iter.next();
+ }
+ } catch (ServiceConfigurationError e) {
+ LOG.error(e.getMessage(), e);
+ }
+ return null;
+ }
/**
* Get the default signer, or null
.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
index ff5a84ca6..6832c9cd8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
@@ -441,7 +441,7 @@ public abstract class RefDatabase {
/**
* Returns all refs that resolve directly to the given {@link ObjectId}.
- * Includes peeled {@linkObjectId}s. This is the inverse lookup of
+ * Includes peeled {@link ObjectId}s. This is the inverse lookup of
* {@link #exactRef(String...)}.
*
*
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java
index 6d4437f4c..9b556393e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/nls/GlobalBundleCache.java
@@ -70,4 +70,8 @@ class GlobalBundleCache {
throw new Error(e);
}
}
+
+ static void clear() {
+ cachedBundles.clear();
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java b/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java
index daa039d34..d7dd3bee5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java
@@ -100,6 +100,15 @@ public class NLS {
return b.get(type);
}
+ /**
+ * Release resources held by NLS
+ * @since 5.8
+ */
+ public static void clear() {
+ local.remove();
+ GlobalBundleCache.clear();
+ }
+
private final Locale locale;
private final ConcurrentHashMap map = new ConcurrentHashMap<>();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java
index 023962e25..8cd5eb223 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java
@@ -16,6 +16,7 @@ import java.util.Arrays;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.internal.revwalk.AddToBitmapFilter;
+import org.eclipse.jgit.internal.revwalk.AddToBitmapWithCacheFilter;
import org.eclipse.jgit.internal.revwalk.AddUnseenToBitmapFilter;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.BitmapIndex;
@@ -41,6 +42,11 @@ public final class BitmapWalker {
private long countOfBitmapIndexMisses;
+ // Cached bitmap and commit to save walk time.
+ private AnyObjectId prevCommit;
+
+ private Bitmap prevBitmap;
+
/**
* Create a BitmapWalker.
*
@@ -55,6 +61,28 @@ public final class BitmapWalker {
this.pm = (pm == null) ? NullProgressMonitor.INSTANCE : pm;
}
+ /**
+ * Set the cached commit for the walker.
+ *
+ * @param prevCommit
+ * the cached commit.
+ * @since 5.8
+ */
+ public void setPrevCommit(AnyObjectId prevCommit) {
+ this.prevCommit = prevCommit;
+ }
+
+ /**
+ * Set the bitmap associated with the cached commit for the walker.
+ *
+ * @param prevBitmap
+ * the bitmap associated with the cached commit.
+ * @since 5.8
+ */
+ public void setPrevBitmap(Bitmap prevBitmap) {
+ this.prevBitmap = prevBitmap;
+ }
+
/**
* Return the number of objects that had to be walked because they were not covered by a
* bitmap.
@@ -169,7 +197,10 @@ public final class BitmapWalker {
}
if (marked) {
- if (seen == null) {
+ if (prevCommit != null) {
+ walker.setRevFilter(new AddToBitmapWithCacheFilter(prevCommit,
+ prevBitmap, bitmapResult));
+ } else if (seen == null) {
walker.setRevFilter(new AddToBitmapFilter(bitmapResult));
} else {
walker.setRevFilter(
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCacheConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCacheConfig.java
index 221353a91..a12f65259 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCacheConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/WindowCacheConfig.java
@@ -47,6 +47,8 @@ public class WindowCacheConfig {
private int streamFileThreshold;
+ private boolean exposeStats;
+
/**
* Create a default configuration.
*/
@@ -58,6 +60,7 @@ public class WindowCacheConfig {
packedGitMMAP = false;
deltaBaseCacheLimit = 10 * MB;
streamFileThreshold = PackConfig.DEFAULT_BIG_FILE_THRESHOLD;
+ exposeStats = true;
}
/**
@@ -219,6 +222,39 @@ public class WindowCacheConfig {
streamFileThreshold = newLimit;
}
+ /**
+ * Tell whether the statistics JMX bean should be automatically registered.
+ *
+ * Registration of that bean via JMX is additionally subject to a boolean
+ * JGit-specific user config "jmx.WindowCacheStats". The bean will be
+ * registered only if this user config is {@code true} and
+ * {@code getExposeStatsViaJmx() == true}.
+ *
+ *
+ * By default, this returns {@code true} unless changed via
+ * {@link #setExposeStatsViaJmx(boolean)}.
+ *
+ * @return whether to expose WindowCacheStats statistics via JMX upon
+ * {@link #install()}
+ * @since 5.8
+ */
+ public boolean getExposeStatsViaJmx() {
+ return exposeStats;
+ }
+
+ /**
+ * Defines whether the statistics JMX MBean should be automatically set up.
+ * (By default {@code true}.) If set to {@code false}, the JMX monitoring
+ * bean is not registered.
+ *
+ * @param expose
+ * whether to register the JMX Bean
+ * @since 5.8
+ */
+ public void setExposeStatsViaJmx(boolean expose) {
+ exposeStats = expose;
+ }
+
/**
* Update properties by setting fields from the configuration.
*
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/DefaultSshSessionFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/DefaultSshSessionFactory.java
deleted file mode 100644
index afa0a11c2..000000000
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/DefaultSshSessionFactory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2009, Constantine Plotnikov
- * Copyright (C) 2009, Google Inc.
- * Copyright (C) 2008, Robin Rosenberg
- * Copyright (C) 2008, Shawn O. Pearce and others
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0 which is available at
- * https://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-package org.eclipse.jgit.transport;
-
-import com.jcraft.jsch.Session;
-
-/**
- * Loads known hosts and private keys from $HOME/.ssh
.
- *
- * This is the default implementation used by JGit and provides most of the
- * compatibility necessary to match OpenSSH, a popular implementation of SSH
- * used by C Git.
- *
- * If user interactivity is required by SSH (e.g. to obtain a password), the
- * connection will immediately fail.
- *
- * @since 5.7
- */
-public class DefaultSshSessionFactory extends JschConfigSessionFactory {
- /** {@inheritDoc} */
- @Override
- protected void configure(OpenSshConfig.Host hc, Session session) {
- // No additional configuration required.
- }
-}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
index 8a8c1ae0b..79f60c320 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
@@ -48,6 +48,7 @@ import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.storage.file.PackLock;
import org.eclipse.jgit.internal.submodule.SubmoduleValidator;
import org.eclipse.jgit.internal.submodule.SubmoduleValidator.SubmoduleValidationException;
+import org.eclipse.jgit.internal.transport.connectivity.FullConnectivityChecker;
import org.eclipse.jgit.internal.transport.parser.FirstCommand;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.BatchRefUpdate;
@@ -72,7 +73,6 @@ import org.eclipse.jgit.transport.ConnectivityChecker.ConnectivityCheckInfo;
import org.eclipse.jgit.transport.PacketLineIn.InputOverLimitIOException;
import org.eclipse.jgit.transport.ReceiveCommand.Result;
import org.eclipse.jgit.transport.RefAdvertiser.PacketLineOutRefAdvertiser;
-import org.eclipse.jgit.transport.internal.FullConnectivityChecker;
import org.eclipse.jgit.util.io.InterruptTimer;
import org.eclipse.jgit.util.io.LimitedInputStream;
import org.eclipse.jgit.util.io.TimeoutInputStream;
@@ -2060,6 +2060,16 @@ public class ReceivePack {
postReceive = h != null ? h : PostReceiveHook.NULL;
}
+ /**
+ * Get the current unpack error handler.
+ *
+ * @return the current unpack error handler.
+ * @since 5.8
+ */
+ public UnpackErrorHandler getUnpackErrorHandler() {
+ return unpackErrorHandler;
+ }
+
/**
* @param unpackErrorHandler
* the unpackErrorHandler to set
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshConfigStore.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshConfigStore.java
new file mode 100644
index 000000000..04a4922bb
--- /dev/null
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshConfigStore.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2020, Thomas Wolf and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.transport;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jgit.annotations.NonNull;
+
+/**
+ * An abstraction for a SSH config storage, like the OpenSSH ~/.ssh/config file.
+ *
+ * @since 5.8
+ */
+public interface SshConfigStore {
+
+ /**
+ * Locate the configuration for a specific host request.
+ *
+ * @param hostName
+ * to look up
+ * @param port
+ * the user supplied; <= 0 if none
+ * @param userName
+ * the user supplied, may be {@code null} or empty if none given
+ * @return the configuration for the requested name.
+ */
+ @NonNull
+ HostConfig lookup(@NonNull String hostName, int port, String userName);
+
+ /**
+ * A host entry from the ssh config. Any merging of global values and of
+ * several matching host entries, %-substitutions, and ~ replacement have
+ * all been done.
+ */
+ interface HostConfig {
+
+ /**
+ * Retrieves the value of a single-valued key, or the first if the key
+ * has multiple values. Keys are case-insensitive, so
+ * {@code getValue("HostName") == getValue("HOSTNAME")}.
+ *
+ * @param key
+ * to get the value of
+ * @return the value, or {@code null} if none
+ */
+ String getValue(String key);
+
+ /**
+ * Retrieves the values of a multi- or list-valued key. Keys are
+ * case-insensitive, so
+ * {@code getValue("HostName") == getValue("HOSTNAME")}.
+ *
+ * @param key
+ * to get the values of
+ * @return a possibly empty list of values
+ */
+ List getValues(String key);
+
+ /**
+ * Retrieves an unmodifiable map of all single-valued options, with
+ * case-insensitive lookup by keys.
+ *
+ * @return all single-valued options
+ */
+ @NonNull
+ Map getOptions();
+
+ /**
+ * Retrieves an unmodifiable map of all multi- or list-valued options,
+ * with case-insensitive lookup by keys.
+ *
+ * @return all multi-valued options
+ */
+ @NonNull
+ Map> getMultiValuedOptions();
+
+ }
+
+ /**
+ * An empty {@link HostConfig}.
+ */
+ static final HostConfig EMPTY_CONFIG = new HostConfig() {
+
+ @Override
+ public String getValue(String key) {
+ return null;
+ }
+
+ @Override
+ public List getValues(String key) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public Map getOptions() {
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public Map> getMultiValuedOptions() {
+ return Collections.emptyMap();
+ }
+
+ };
+}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshSessionFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshSessionFactory.java
index e6d204242..ef845f4dc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshSessionFactory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshSessionFactory.java
@@ -43,11 +43,12 @@ public abstract class SshSessionFactory {
}
return null;
}
+
/**
* Get the currently configured JVM-wide factory.
*
- * A factory is always available. By default the factory will read from the
- * user's $HOME/.ssh
and assume OpenSSH compatibility.
+ * By default the factory will read from the user's $HOME/.ssh
+ * and assume OpenSSH compatibility.
*
* @return factory the current factory for this JVM.
*/
@@ -60,7 +61,7 @@ public abstract class SshSessionFactory {
*
* @param newFactory
* factory for future sessions to be created through. If null the
- * default factory will be restored.s
+ * default factory will be restored.
*/
public static void setInstance(SshSessionFactory newFactory) {
if (newFactory != null) {
@@ -109,6 +110,15 @@ public abstract class SshSessionFactory {
CredentialsProvider credentialsProvider, FS fs, int tms)
throws TransportException;
+ /**
+ * The name of the type of session factory.
+ *
+ * @return the name of the type of session factory.
+ *
+ * @since 5.8
+ */
+ public abstract String getType();
+
/**
* Close (or recycle) a session to a host.
*
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
index 947c4c322..b9cb2484d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
@@ -50,6 +50,8 @@ import org.eclipse.jgit.util.io.StreamCopyThread;
* enumeration, save file modification and hook execution.
*/
public class TransportGitSsh extends SshTransport implements PackTransport {
+ private static final String EXT = "ext"; //$NON-NLS-1$
+
static final TransportProtocol PROTO_SSH = new TransportProtocol() {
private final String[] schemeNames = { "ssh", "ssh+git", "git+ssh" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -127,6 +129,11 @@ public class TransportGitSsh extends SshTransport implements PackTransport {
throws TransportException {
return new ExtSession();
}
+
+ @Override
+ public String getType() {
+ return EXT;
+ }
});
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
index c3c1f2a40..16169f028 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
@@ -39,11 +39,13 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.net.HttpCookie;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.ProxySelector;
+import java.net.SocketException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -573,6 +575,14 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
}
} catch (NotSupportedException | TransportException e) {
throw e;
+ } catch (InterruptedIOException e) {
+ // Timeout!? Don't try other authentication methods.
+ throw new TransportException(uri, MessageFormat.format(
+ JGitText.get().connectionTimeOut, u.getHost()), e);
+ } catch (SocketException e) {
+ // Nothing on other end, timeout, connection reset, ...
+ throw new TransportException(uri,
+ JGitText.get().connectionFailed, e);
} catch (SSLHandshakeException e) {
handleSslFailure(e);
continue; // Re-try
@@ -1501,6 +1511,10 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
} catch (SSLHandshakeException e) {
handleSslFailure(e);
continue; // Re-try
+ } catch (SocketException | InterruptedIOException e) {
+ // Timeout!? Must propagate; don't try other authentication
+ // methods.
+ throw e;
} catch (IOException e) {
if (authenticator == null || authMethod
.getType() != HttpAuthMethod.Type.NONE) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/HttpConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/HttpConnection.java
index c4d086d4b..98c231a46 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/HttpConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/HttpConnection.java
@@ -40,6 +40,12 @@ public interface HttpConnection {
*/
int HTTP_OK = java.net.HttpURLConnection.HTTP_OK;
+ /**
+ * @see HttpURLConnection#HTTP_NOT_AUTHORITATIVE
+ * @since 5.8
+ */
+ int HTTP_NOT_AUTHORITATIVE = java.net.HttpURLConnection.HTTP_NOT_AUTHORITATIVE;
+
/**
* @see HttpURLConnection#HTTP_MOVED_PERM
* @since 4.7
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/JDKHttpConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/JDKHttpConnection.java
index 925c4e2f8..3b0bae21e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/JDKHttpConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/http/JDKHttpConnection.java
@@ -32,7 +32,7 @@ import javax.net.ssl.SSLSocket;
import javax.net.ssl.TrustManager;
import org.eclipse.jgit.annotations.NonNull;
-import org.eclipse.jgit.transport.internal.DelegatingSSLSocketFactory;
+import org.eclipse.jgit.internal.transport.http.DelegatingSSLSocketFactory;
import org.eclipse.jgit.util.HttpSupport;
/**
* A {@link org.eclipse.jgit.transport.http.HttpConnection} which simply
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
index 988953b00..91574efec 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -1036,12 +1036,36 @@ public abstract class FS {
public File userHome() {
Holder p = userHome;
if (p == null) {
- p = new Holder<>(userHomeImpl());
+ p = new Holder<>(safeUserHomeImpl());
userHome = p;
}
return p.value;
}
+ private File safeUserHomeImpl() {
+ File home;
+ try {
+ home = userHomeImpl();
+ if (home != null) {
+ home.toPath();
+ return home;
+ }
+ } catch (RuntimeException e) {
+ LOG.error(JGitText.get().exceptionWhileFindingUserHome, e);
+ }
+ home = defaultUserHomeImpl();
+ if (home != null) {
+ try {
+ home.toPath();
+ return home;
+ } catch (InvalidPathException e) {
+ LOG.error(MessageFormat
+ .format(JGitText.get().invalidHomeDirectory, home), e);
+ }
+ }
+ return null;
+ }
+
/**
* Set the user's home directory location.
*
@@ -1081,6 +1105,10 @@ public abstract class FS {
* @return the user's home directory; null if the user does not have one.
*/
protected File userHomeImpl() {
+ return defaultUserHomeImpl();
+ }
+
+ private File defaultUserHomeImpl() {
final String home = AccessController.doPrivileged(
(PrivilegedAction) () -> System.getProperty("user.home") //$NON-NLS-1$
);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java
index deab4e67a..c33c869b6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java
@@ -140,19 +140,19 @@ public final class EolStreamTypeUtil {
}
// new git system
+ if ("auto".equals(attrs.getValue("text"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ return EolStreamType.AUTO_LF;
+ }
+
String eol = attrs.getValue("eol"); //$NON-NLS-1$
- if (eol != null)
+ if (eol != null) {
// check-in is always normalized to LF
return EolStreamType.TEXT_LF;
-
+ }
if (attrs.isSet("text")) { //$NON-NLS-1$
return EolStreamType.TEXT_LF;
}
- if ("auto".equals(attrs.getValue("text"))) { //$NON-NLS-1$ //$NON-NLS-2$
- return EolStreamType.AUTO_LF;
- }
-
switch (options.getAutoCRLF()) {
case TRUE:
case INPUT:
@@ -168,6 +168,8 @@ public final class EolStreamTypeUtil {
switch (options.getAutoCRLF()) {
case TRUE:
return EolStreamType.TEXT_CRLF;
+ case INPUT:
+ return EolStreamType.DIRECT;
default:
// no decision
}
@@ -205,7 +207,10 @@ public final class EolStreamTypeUtil {
// new git system
String eol = attrs.getValue("eol"); //$NON-NLS-1$
if (eol != null) {
- if ("crlf".equals(eol)) {//$NON-NLS-1$
+ if ("crlf".equals(eol)) { //$NON-NLS-1$
+ if ("auto".equals(attrs.getValue("text"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ return EolStreamType.AUTO_CRLF;
+ }
return EolStreamType.TEXT_CRLF;
} else if ("lf".equals(eol)) { //$NON-NLS-1$
return EolStreamType.DIRECT;
diff --git a/pom.xml b/pom.xml
index debe8e2d4..a714f2391 100644
--- a/pom.xml
+++ b/pom.xml
@@ -162,7 +162,7 @@
1.19
4.3.1
3.1.0
- 9.4.25.v20191220
+ 9.4.28.v20200408
0.14.3
4.5.10
4.4.12
@@ -173,7 +173,7 @@
2.8.2
1.65
4.0.0
- 3.0.0
+ 3.1.0
3.0.0
3.0.0-M4
${maven-surefire-plugin-version}
@@ -234,7 +234,7 @@
org.apache.maven.plugins
maven-shade-plugin
- 3.2.3
+ 3.2.4
@@ -766,7 +766,7 @@
org.bouncycastle
bcprov-jdk15on
- ${bouncycastle-version}
+ 1.65.01
@@ -988,9 +988,11 @@
org.eclipse.jgit.ant
org.eclipse.jgit.archive
org.eclipse.jgit.ui
+ org.eclipse.jgit.gpg.bc
org.eclipse.jgit.http.apache
org.eclipse.jgit.http.server
org.eclipse.jgit.ssh.apache
+ org.eclipse.jgit.ssh.jsch
org.eclipse.jgit.pgm
org.eclipse.jgit.lfs
org.eclipse.jgit.lfs.server
@@ -1000,11 +1002,13 @@
org.eclipse.jgit.test
org.eclipse.jgit.ant.test
+ org.eclipse.jgit.gpg.bc.test
org.eclipse.jgit.http.test
org.eclipse.jgit.pgm.test
org.eclipse.jgit.lfs.test
org.eclipse.jgit.lfs.server.test
org.eclipse.jgit.ssh.apache.test
+ org.eclipse.jgit.ssh.jsch.test
org.eclipse.jgit.coverage
org.eclipse.jgit.benchmarks
diff --git a/tools/version.sh b/tools/version.sh
index 80693cdbd..75f1a6a0d 100755
--- a/tools/version.sh
+++ b/tools/version.sh
@@ -113,6 +113,7 @@ perl -pi~ -e '
s/^(Bundle-Version:\s*).*$/${1}'"$OSGI_V"'/;
s/(org.eclipse.jgit.*;version=")[^"[(]*(")/${1}'"$API_V"'${2}/;
s/(org.eclipse.jgit.*;version="\[)[^"]*(\)")/${1}'"$API_V,$API_N"'${2}/;
+ s/(Fragment-Host: org.eclipse.jgit.*;bundle-version="\[)[^"]*(\)")/${1}'"$API_V,$API_N"'${2}/;
' $(git ls-files | grep META-INF/MANIFEST.MF)
perl -pi~ -e '