diff --git a/WORKSPACE b/WORKSPACE index c9088fc2f..ceb0e4866 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -12,11 +12,11 @@ load( http_archive( name = "rbe_jdk11", - sha256 = "766796de71916118e528b9f4334c29c9c9b4e926227bf3264dee555e6a4306c8", - strip_prefix = "rbe_autoconfig-2.0.0", + sha256 = "dbcfd6f26589ef506b91fe03a12dc559ca9c84699e4cf6381150522287f0e6f6", + strip_prefix = "rbe_autoconfig-3.1.0", urls = [ - "https://gerrit-bazel.storage.googleapis.com/rbe_autoconfig/v2.0.0.tar.gz", - "https://github.com/davido/rbe_autoconfig/archive/v2.0.0.tar.gz", + "https://gerrit-bazel.storage.googleapis.com/rbe_autoconfig/v3.1.0.tar.gz", + "https://github.com/davido/rbe_autoconfig/archive/v3.1.0.tar.gz", ], ) @@ -90,16 +90,18 @@ maven_jar( sha1 = "7f2e0c573eaa7a74bac2e89b359e1f73d92a0a1d", ) +SSHD_VERS = "2.9.2" + maven_jar( name = "sshd-osgi", - artifact = "org.apache.sshd:sshd-osgi:2.8.0", - sha1 = "b2a59b73c045f40d5722b9160d4f909a646d86c9", + artifact = "org.apache.sshd:sshd-osgi:" + SSHD_VERS, + sha1 = "bac0415734519b2fe433fea196017acf7ed32660", ) maven_jar( name = "sshd-sftp", - artifact = "org.apache.sshd:sshd-sftp:2.8.0", - sha1 = "d3cd9bc8d335b3ed1a86d2965deb4d202de27442", + artifact = "org.apache.sshd:sshd-sftp:" + SSHD_VERS, + sha1 = "7f9089c87b3b44f19998252fd3b68637e3322920", ) maven_jar( diff --git a/org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/benchmarks/GetRefsBenchmark.java b/org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/benchmarks/GetRefsBenchmark.java index 7b7b41355..52a881bd1 100644 --- a/org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/benchmarks/GetRefsBenchmark.java +++ b/org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/benchmarks/GetRefsBenchmark.java @@ -9,6 +9,8 @@ */ package org.eclipse.jgit.benchmarks; +import static org.eclipse.jgit.transport.ReceiveCommand.Type.CREATE; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -23,7 +25,14 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.internal.storage.file.FileRepository; -import org.eclipse.jgit.lib.*; +import org.eclipse.jgit.lib.BatchRefUpdate; +import org.eclipse.jgit.lib.ConfigConstants; +import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.lib.RepositoryCache; +import org.eclipse.jgit.lib.StoredConfig; +import org.eclipse.jgit.lib.TextProgressMonitor; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.transport.ReceiveCommand; @@ -46,8 +55,6 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; -import static org.eclipse.jgit.transport.ReceiveCommand.Type.CREATE; - @State(Scope.Thread) public class GetRefsBenchmark { diff --git a/org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/benchmarks/LookupFileStoreBenchmark.java b/org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/benchmarks/LookupFileStoreBenchmark.java index 393edcbc9..e9c9ef36a 100644 --- a/org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/benchmarks/LookupFileStoreBenchmark.java +++ b/org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/benchmarks/LookupFileStoreBenchmark.java @@ -24,7 +24,6 @@ import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; -import org.openjdk.jmh.profile.StackProfiler; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; diff --git a/org.eclipse.jgit.http.server/.settings/.api_filters b/org.eclipse.jgit.http.server/.settings/.api_filters deleted file mode 100644 index 2c32c9864..000000000 --- a/org.eclipse.jgit.http.server/.settings/.api_filters +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java index b0a07f1d5..f16e56d94 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java @@ -168,42 +168,43 @@ public void doPost(HttpServletRequest req, HttpServletResponse rsp) } UploadPackRunnable r = () -> { - UploadPack up = (UploadPack) req.getAttribute(ATTRIBUTE_HANDLER); - // to be explicitly closed by caller - @SuppressWarnings("resource") - SmartOutputStream out = new SmartOutputStream(req, rsp, false) { - @Override - public void flush() throws IOException { - doFlush(); - } - }; - - up.setBiDirectionalPipe(false); - rsp.setContentType(UPLOAD_PACK_RESULT_TYPE); - - try { - up.uploadWithExceptionPropagation(getInputStream(req), out, - null); - out.close(); - } catch (ServiceMayNotContinueException e) { - if (e.isOutput()) { - consumeRequestBody(req); - out.close(); - } - throw e; - } catch (UploadPackInternalServerErrorException e) { - // Special case exception, error message was sent to client. - log(up.getRepository(), e.getCause()); - consumeRequestBody(req); - out.close(); - } finally { - up.close(); - } + upload(req, rsp); }; handler.upload(req, rsp, r); } + private void upload(HttpServletRequest req, HttpServletResponse rsp) + throws IOException, ServiceMayNotContinueException { + // to be explicitly closed by caller + @SuppressWarnings("resource") + SmartOutputStream out = new SmartOutputStream(req, rsp, false) { + @Override + public void flush() throws IOException { + doFlush(); + } + }; + Repository repo = null; + try (UploadPack up = (UploadPack) req.getAttribute(ATTRIBUTE_HANDLER)) { + up.setBiDirectionalPipe(false); + rsp.setContentType(UPLOAD_PACK_RESULT_TYPE); + repo = up.getRepository(); + up.uploadWithExceptionPropagation(getInputStream(req), out, null); + out.close(); + } catch (ServiceMayNotContinueException e) { + if (e.isOutput()) { + consumeRequestBody(req); + out.close(); + } + throw e; + } catch (UploadPackInternalServerErrorException e) { + // Special case exception, error message was sent to client. + log(repo, e.getCause()); + consumeRequestBody(req); + out.close(); + } + } + private void defaultUploadPackHandler(HttpServletRequest req, HttpServletResponse rsp, UploadPackRunnable r) throws IOException { try { diff --git a/org.eclipse.jgit.junit.ssh/META-INF/MANIFEST.MF b/org.eclipse.jgit.junit.ssh/META-INF/MANIFEST.MF index e2fb03754..807339e63 100644 --- a/org.eclipse.jgit.junit.ssh/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.junit.ssh/META-INF/MANIFEST.MF @@ -8,31 +8,31 @@ Bundle-Localization: plugin Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-11 -Import-Package: org.apache.sshd.common;version="[2.8.0,2.9.0)", - org.apache.sshd.common.config.keys;version="[2.8.0,2.9.0)", - org.apache.sshd.common.file.virtualfs;version="[2.8.0,2.9.0)", - org.apache.sshd.common.helpers;version="[2.8.0,2.9.0)", - org.apache.sshd.common.io;version="[2.8.0,2.9.0)", - org.apache.sshd.common.kex;version="[2.8.0,2.9.0)", - org.apache.sshd.common.keyprovider;version="[2.8.0,2.9.0)", - org.apache.sshd.common.session;version="[2.8.0,2.9.0)", - org.apache.sshd.common.signature;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.buffer;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.logging;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.security;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.threads;version="[2.8.0,2.9.0)", - org.apache.sshd.core;version="[2.8.0,2.9.0)", - org.apache.sshd.server;version="[2.8.0,2.9.0)", - org.apache.sshd.server.auth;version="[2.8.0,2.9.0)", - org.apache.sshd.server.auth.gss;version="[2.8.0,2.9.0)", - org.apache.sshd.server.auth.keyboard;version="[2.8.0,2.9.0)", - org.apache.sshd.server.auth.password;version="[2.8.0,2.9.0)", - org.apache.sshd.server.command;version="[2.8.0,2.9.0)", - org.apache.sshd.server.session;version="[2.8.0,2.9.0)", - org.apache.sshd.server.shell;version="[2.8.0,2.9.0)", - org.apache.sshd.server.subsystem;version="[2.8.0,2.9.0)", - org.apache.sshd.sftp;version="[2.8.0,2.9.0)", - org.apache.sshd.sftp.server;version="[2.8.0,2.9.0)", +Import-Package: org.apache.sshd.common;version="[2.9.2,2.10.0)", + org.apache.sshd.common.config.keys;version="[2.9.2,2.10.0)", + org.apache.sshd.common.file.virtualfs;version="[2.9.2,2.10.0)", + org.apache.sshd.common.helpers;version="[2.9.2,2.10.0)", + org.apache.sshd.common.io;version="[2.9.2,2.10.0)", + org.apache.sshd.common.kex;version="[2.9.2,2.10.0)", + org.apache.sshd.common.keyprovider;version="[2.9.2,2.10.0)", + org.apache.sshd.common.session;version="[2.9.2,2.10.0)", + org.apache.sshd.common.signature;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.buffer;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.logging;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.security;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.threads;version="[2.9.2,2.10.0)", + org.apache.sshd.core;version="[2.9.2,2.10.0)", + org.apache.sshd.server;version="[2.9.2,2.10.0)", + org.apache.sshd.server.auth;version="[2.9.2,2.10.0)", + org.apache.sshd.server.auth.gss;version="[2.9.2,2.10.0)", + org.apache.sshd.server.auth.keyboard;version="[2.9.2,2.10.0)", + org.apache.sshd.server.auth.password;version="[2.9.2,2.10.0)", + org.apache.sshd.server.command;version="[2.9.2,2.10.0)", + org.apache.sshd.server.session;version="[2.9.2,2.10.0)", + org.apache.sshd.server.shell;version="[2.9.2,2.10.0)", + org.apache.sshd.server.subsystem;version="[2.9.2,2.10.0)", + org.apache.sshd.sftp;version="[2.9.2,2.10.0)", + org.apache.sshd.sftp.server;version="[2.9.2,2.10.0)", org.eclipse.jgit.annotations;version="[6.4.0,6.5.0)", org.eclipse.jgit.api;version="[6.4.0,6.5.0)", org.eclipse.jgit.api.errors;version="[6.4.0,6.5.0)", diff --git a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java index 4fe98f868..5d043ffc3 100644 --- a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java +++ b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java @@ -480,13 +480,13 @@ protected GitUploadPackCommand(String command, @Override public void run() { - UploadPack uploadPack = new UploadPack(repository); - String gitProtocol = getEnvironment().getEnv().get("GIT_PROTOCOL"); - if (gitProtocol != null) { - uploadPack - .setExtraParameters(Collections.singleton(gitProtocol)); - } - try { + try (UploadPack uploadPack = new UploadPack(repository)) { + String gitProtocol = getEnvironment().getEnv() + .get("GIT_PROTOCOL"); + if (gitProtocol != null) { + uploadPack.setExtraParameters( + Collections.singleton(gitProtocol)); + } uploadPack.upload(getInputStream(), getOutputStream(), getErrorStream()); onExit(0); diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java index a3c5b1202..59662cec9 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java @@ -87,6 +87,8 @@ public abstract class LocalDiskRepositoryTestCase { /** * The current test name. + * + * @since 6.0.1 */ @Rule public TestName currentTest = new TestName(); diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.target index cfdf40cc5..d5ee87b2d 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.target @@ -1,7 +1,7 @@ - + @@ -25,8 +25,8 @@ - - + + @@ -35,28 +35,28 @@ - - - - + + + + - - + + - - + + - - - - + + + + @@ -81,13 +81,13 @@ - - - - + + + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.tpd index 1f6d8b65b..60438d793 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.tpd @@ -1,7 +1,7 @@ target "jgit-4.17" with source configurePhase include "projects/jetty-10.0.x.tpd" -include "orbit/S20221109014815.tpd" +include "orbit/R20221123021534-2022-12.tpd" location "https://download.eclipse.org/releases/2020-09/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18.target index d658228b8..36e37b1f2 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18.target @@ -1,7 +1,7 @@ - + @@ -25,8 +25,8 @@ - - + + @@ -35,28 +35,28 @@ - - - - + + + + - - + + - - + + - - - - + + + + @@ -81,13 +81,13 @@ - - - - + + + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18.tpd index ace8951ad..c894dfea2 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18.tpd @@ -1,7 +1,7 @@ target "jgit-4.18" with source configurePhase include "projects/jetty-10.0.x.tpd" -include "orbit/S20221109014815.tpd" +include "orbit/R20221123021534-2022-12.tpd" location "https://download.eclipse.org/releases/2020-12/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.19.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.19.target index 752f64496..2966e8830 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.19.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.19.target @@ -1,7 +1,7 @@ - + @@ -25,8 +25,8 @@ - - + + @@ -35,28 +35,28 @@ - - - - + + + + - - + + - - + + - - - - + + + + @@ -81,13 +81,13 @@ - - - - + + + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.19.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.19.tpd index 9eaf1a164..615784274 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.19.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.19.tpd @@ -1,7 +1,7 @@ target "jgit-4.19-staging" with source configurePhase include "projects/jetty-10.0.x.tpd" -include "orbit/S20221109014815.tpd" +include "orbit/R20221123021534-2022-12.tpd" location "https://download.eclipse.org/releases/2021-03/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.20.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.20.target index 10d49f82d..6e6e7fb46 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.20.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.20.target @@ -1,7 +1,7 @@ - + @@ -25,8 +25,8 @@ - - + + @@ -35,28 +35,28 @@ - - - - + + + + - - + + - - + + - - - - + + + + @@ -81,13 +81,13 @@ - - - - + + + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.20.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.20.tpd index ac083dfb2..afc5f34ba 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.20.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.20.tpd @@ -1,7 +1,7 @@ target "jgit-4.20" with source configurePhase include "projects/jetty-10.0.x.tpd" -include "orbit/S20221109014815.tpd" +include "orbit/R20221123021534-2022-12.tpd" location "https://download.eclipse.org/releases/2021-06/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.21.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.21.target index e4c2b69c1..edfc027e7 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.21.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.21.target @@ -1,7 +1,7 @@ - + @@ -25,8 +25,8 @@ - - + + @@ -35,28 +35,28 @@ - - - - + + + + - - + + - - + + - - - - + + + + @@ -81,13 +81,13 @@ - - - - + + + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.21.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.21.tpd index 0f1fb8dc4..b701c8114 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.21.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.21.tpd @@ -1,7 +1,7 @@ target "jgit-4.21" with source configurePhase include "projects/jetty-10.0.x.tpd" -include "orbit/S20221109014815.tpd" +include "orbit/R20221123021534-2022-12.tpd" location "https://download.eclipse.org/releases/2021-09/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.22.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.22.target index 57bcd9a12..f5efb8c94 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.22.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.22.target @@ -1,7 +1,7 @@ - + @@ -25,8 +25,8 @@ - - + + @@ -35,28 +35,28 @@ - - - - + + + + - - + + - - + + - - - - + + + + @@ -81,13 +81,13 @@ - - - - + + + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.22.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.22.tpd index 4aae497db..e69ab0a6c 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.22.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.22.tpd @@ -1,7 +1,7 @@ target "jgit-4.22" with source configurePhase include "projects/jetty-10.0.x.tpd" -include "orbit/S20221109014815.tpd" +include "orbit/R20221123021534-2022-12.tpd" location "https://download.eclipse.org/releases/2021-12/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.23.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.23.target index 2a8d7cd43..1100bf2e1 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.23.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.23.target @@ -1,7 +1,7 @@ - + @@ -25,8 +25,8 @@ - - + + @@ -35,28 +35,28 @@ - - - - + + + + - - + + - - + + - - - - + + + + @@ -81,13 +81,13 @@ - - - - + + + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.23.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.23.tpd index 63f7212d8..87a7b7f5d 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.23.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.23.tpd @@ -1,7 +1,7 @@ target "jgit-4.23" with source configurePhase include "projects/jetty-10.0.x.tpd" -include "orbit/S20221109014815.tpd" +include "orbit/R20221123021534-2022-12.tpd" location "https://download.eclipse.org/releases/2022-03/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.24.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.24.target index 93687693c..ccd8d23e2 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.24.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.24.target @@ -1,7 +1,7 @@ - + @@ -25,8 +25,8 @@ - - + + @@ -35,28 +35,28 @@ - - - - + + + + - - + + - - + + - - - - + + + + @@ -81,13 +81,13 @@ - - - - + + + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.24.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.24.tpd index c033d1fc3..91108fc50 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.24.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.24.tpd @@ -1,7 +1,7 @@ target "jgit-4.24" with source configurePhase include "projects/jetty-10.0.x.tpd" -include "orbit/S20221109014815.tpd" +include "orbit/R20221123021534-2022-12.tpd" location "https://download.eclipse.org/releases/2022-06/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.25.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.25.target index a3faa8f24..364f49e72 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.25.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.25.target @@ -1,7 +1,7 @@ - + @@ -25,8 +25,8 @@ - - + + @@ -35,28 +35,28 @@ - - - - + + + + - - + + - - + + - - - - + + + + @@ -81,17 +81,17 @@ - - - - + + + + - + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.25.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.25.tpd index e0fb34ea4..7a67a9792 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.25.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.25.tpd @@ -1,8 +1,8 @@ target "jgit-4.25" with source configurePhase include "projects/jetty-10.0.x.tpd" -include "orbit/S20221109014815.tpd" +include "orbit/R20221123021534-2022-12.tpd" -location "https://download.eclipse.org/staging/2022-09/" { +location "https://download.eclipse.org/releases/2022-09/" { org.eclipse.osgi lazy } diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.26.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.26.target new file mode 100644 index 000000000..257f45eeb --- /dev/null +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.26.target @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.26.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.26.tpd new file mode 100644 index 000000000..5fc49cdab --- /dev/null +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.26.tpd @@ -0,0 +1,8 @@ +target "jgit-4.25" with source configurePhase + +include "projects/jetty-10.0.x.tpd" +include "orbit/R20221123021534-2022-12.tpd" + +location "https://download.eclipse.org/staging/2022-12/" { + org.eclipse.osgi lazy +} diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20221109014815.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20221123021534-2022-12.tpd similarity index 69% rename from org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20221109014815.tpd rename to org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20221123021534-2022-12.tpd index 0c0520bc4..bc4929ba4 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20221109014815.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20221123021534-2022-12.tpd @@ -1,11 +1,11 @@ -target "S20221109014815" with source configurePhase +target "R20221123021534-2022-12" with source configurePhase // see https://download.eclipse.org/tools/orbit/downloads/ -location "https://download.eclipse.org/tools/orbit/downloads/drops/S20221109014815/repository" { +location "https://download.eclipse.org/tools/orbit/downloads/drops/R20221123021534/repository" { com.google.gson [2.9.1.v20220915-1632,2.9.1.v20220915-1632] com.google.gson.source [2.9.1.v20220915-1632,2.9.1.v20220915-1632] - com.jcraft.jsch [0.1.55.v20190404-1902,0.1.55.v20190404-1902] - com.jcraft.jsch.source [0.1.55.v20190404-1902,0.1.55.v20190404-1902] + com.jcraft.jsch [0.1.55.v20221112-0806,0.1.55.v20221112-0806] + com.jcraft.jsch.source [0.1.55.v20221112-0806,0.1.55.v20221112-0806] com.jcraft.jzlib [1.1.3.v20220502-1820,1.1.3.v20220502-1820] com.jcraft.jzlib.source [1.1.3.v20220502-1820,1.1.3.v20220502-1820] com.sun.jna [5.12.1.v20221103-2317,5.12.1.v20221103-2317] @@ -14,28 +14,28 @@ location "https://download.eclipse.org/tools/orbit/downloads/drops/S202211090148 com.sun.jna.platform.source [5.12.1.v20221103-2317,5.12.1.v20221103-2317] javaewah [1.1.13.v20211029-0839,1.1.13.v20211029-0839] javaewah.source [1.1.13.v20211029-0839,1.1.13.v20211029-0839] - net.bytebuddy.byte-buddy [1.9.0.v20181107-1410,1.9.0.v20181107-1410] - net.bytebuddy.byte-buddy-agent [1.9.0.v20181106-1534,1.9.0.v20181106-1534] - net.bytebuddy.byte-buddy-agent.source [1.9.0.v20181106-1534,1.9.0.v20181106-1534] - net.bytebuddy.byte-buddy.source [1.9.0.v20181107-1410,1.9.0.v20181107-1410] + net.bytebuddy.byte-buddy [1.12.18.v20221114-2102,1.12.18.v20221114-2102] + net.bytebuddy.byte-buddy.source [1.12.18.v20221114-2102,1.12.18.v20221114-2102] + net.bytebuddy.byte-buddy-agent [1.12.18.v20221114-2102,1.12.18.v20221114-2102] + net.bytebuddy.byte-buddy-agent.source [1.12.18.v20221114-2102,1.12.18.v20221114-2102] net.i2p.crypto.eddsa [0.3.0.v20220506-1020,0.3.0.v20220506-1020] net.i2p.crypto.eddsa.source [0.3.0.v20220506-1020,0.3.0.v20220506-1020] org.apache.ant [1.10.12.v20211102-1452,1.10.12.v20211102-1452] org.apache.ant.source [1.10.12.v20211102-1452,1.10.12.v20211102-1452] - org.apache.commons.codec [1.14.0.v20200818-1422,1.14.0.v20200818-1422] - org.apache.commons.codec.source [1.14.0.v20200818-1422,1.14.0.v20200818-1422] + org.apache.commons.codec [1.14.0.v20221112-0806,1.14.0.v20221112-0806] + org.apache.commons.codec.source [1.14.0.v20221112-0806,1.14.0.v20221112-0806] org.apache.commons.compress [1.21.0.v20211103-2100,1.21.0.v20211103-2100] org.apache.commons.compress.source [1.21.0.v20211103-2100,1.21.0.v20211103-2100] org.apache.commons.logging [1.2.0.v20180409-1502,1.2.0.v20180409-1502] org.apache.commons.logging.source [1.2.0.v20180409-1502,1.2.0.v20180409-1502] - org.apache.httpcomponents.httpclient [4.5.13.v20210128-2225,4.5.13.v20210128-2225] - org.apache.httpcomponents.httpclient.source [4.5.13.v20210128-2225,4.5.13.v20210128-2225] + org.apache.httpcomponents.httpclient [4.5.13.v20221112-0806,4.5.13.v20221112-0806] + org.apache.httpcomponents.httpclient.source [4.5.13.v20221112-0806,4.5.13.v20221112-0806] org.apache.httpcomponents.httpcore [4.4.15.v20220209-2345,4.4.15.v20220209-2345] org.apache.httpcomponents.httpcore.source [4.4.15.v20220209-2345,4.4.15.v20220209-2345] - org.apache.sshd.osgi [2.8.0.v20211227-1750,2.8.0.v20211227-1750] - org.apache.sshd.osgi.source [2.8.0.v20211227-1750,2.8.0.v20211227-1750] - org.apache.sshd.sftp [2.8.0.v20211227-1750,2.8.0.v20211227-1750] - org.apache.sshd.sftp.source [2.8.0.v20211227-1750,2.8.0.v20211227-1750] + org.apache.sshd.osgi [2.9.2.v20221117-1942,2.9.2.v20221117-1942] + org.apache.sshd.osgi.source [2.9.2.v20221117-1942,2.9.2.v20221117-1942] + org.apache.sshd.sftp [2.9.2.v20221117-1942,2.9.2.v20221117-1942] + org.apache.sshd.sftp.source [2.9.2.v20221117-1942,2.9.2.v20221117-1942] org.assertj [3.20.2.v20210706-1104,3.20.2.v20210706-1104] org.assertj.source [3.20.2.v20210706-1104,3.20.2.v20210706-1104] org.bouncycastle.bcpg [1.72.0.v20221013-1810,1.72.0.v20221013-1810] @@ -60,10 +60,10 @@ location "https://download.eclipse.org/tools/orbit/downloads/drops/S202211090148 org.mockito.mockito-core.source [4.8.1.v20221103-2317,4.8.1.v20221103-2317] org.objenesis [3.3.0.v20221103-2317,3.3.0.v20221103-2317] org.objenesis.source [3.3.0.v20221103-2317,3.3.0.v20221103-2317] - org.slf4j.api [1.7.30.v20200204-2150,1.7.30.v20200204-2150] - org.slf4j.api.source [1.7.30.v20200204-2150,1.7.30.v20200204-2150] - org.slf4j.binding.simple [1.7.30.v20200204-2150,1.7.30.v20200204-2150] - org.slf4j.binding.simple.source [1.7.30.v20200204-2150,1.7.30.v20200204-2150] + org.slf4j.api [1.7.30.v20221112-0806,1.7.30.v20221112-0806] + org.slf4j.api.source [1.7.30.v20221112-0806,1.7.30.v20221112-0806] + org.slf4j.binding.simple [1.7.30.v20221112-0806,1.7.30.v20221112-0806] + org.slf4j.binding.simple.source [1.7.30.v20221112-0806,1.7.30.v20221112-0806] org.tukaani.xz [1.9.0.v20210624-1259,1.9.0.v20210624-1259] org.tukaani.xz.source [1.9.0.v20210624-1259,1.9.0.v20210624-1259] } diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DiffTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DiffTest.java new file mode 100644 index 000000000..859b54de4 --- /dev/null +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DiffTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2022, Matthias Sohn 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.pgm; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.jgit.lib.CLIRepositoryTestCase; +import org.junit.Before; +import org.junit.Test; + +public class DiffTest extends CLIRepositoryTestCase { + + private static final String NO_NEWLINE = "\\ No newline at end of file"; + + @Before + public void setup() throws Exception { + writeTrashFile("a", "a"); + execute("git add a"); + execute("git commit -m added"); + } + + @Test + public void testDiffCommitNewFile() throws Exception { + writeTrashFile("a1", "a"); + String result = toString(execute("git diff")); + assertEquals( + toString("diff --git a/a1 b/a1", "new file mode 100644", + "index 0000000..2e65efe", "--- /dev/null", "+++ b/a1", + "@@ -0,0 +1 @@", "+a", NO_NEWLINE), + result); + } + + @Test + public void testDiffCommitModifiedFile() throws Exception { + writeTrashFile("a", "a1"); + String result = toString(execute("git diff")); + assertEquals( + toString("diff --git a/a b/a", "index 2e65efe..59ef8d1 100644", + "--- a/a", "+++ b/a", "@@ -1 +1 @@", + "-a", NO_NEWLINE, "+a1", NO_NEWLINE), + result); + } + + @Test + public void testDiffCommitModifiedFileNameOnly() throws Exception { + writeTrashFile("a", "a1"); + writeTrashFile("b", "b"); + String result = toString(execute("git diff --name-only")); + assertEquals(toString("a", "b"), result); + } + + @Test + public void testDiffCommitModifiedFileNameStatus() throws Exception { + writeTrashFile("a", "a1"); + writeTrashFile("b", "b"); + String result = toString(execute("git diff --name-status")); + assertEquals(toString("M\ta", "A\tb"), result); + } +} diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/LogTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/LogTest.java new file mode 100644 index 000000000..1cc52a44a --- /dev/null +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/LogTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2022, Matthias Sohn 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.pgm; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.jgit.lib.CLIRepositoryTestCase; +import org.junit.Before; +import org.junit.Test; + +public class LogTest extends CLIRepositoryTestCase { + + @Before + public void setup() throws Exception { + writeTrashFile("a", "a"); + writeTrashFile("b", "a"); + execute("git add a b"); + execute("git commit -m added"); + } + + @Test + public void testLogCommitNewFile() throws Exception { + String result = toString(execute("git log")); + assertEquals( + toString("commit b4680f542095a8b41ea4258a5c03b548543a817c", + "Author: GIT_COMMITTER_NAME ", + "Date: Sat Aug 15 20:12:58 2009 -0330", "added"), + result); + } + + @Test + public void testLogNameOnly() throws Exception { + String result = toString(execute("git log --name-only")); + assertEquals( + toString("commit b4680f542095a8b41ea4258a5c03b548543a817c", + "Author: GIT_COMMITTER_NAME ", + "Date: Sat Aug 15 20:12:58 2009 -0330", "added", "a", + "b"), + result); + } + + @Test + public void testDiffCommitModifiedFileNameStatus() throws Exception { + String result = toString(execute("git log --name-status")); + assertEquals(toString("commit b4680f542095a8b41ea4258a5c03b548543a817c", + "Author: GIT_COMMITTER_NAME ", + "Date: Sat Aug 15 20:12:58 2009 -0330", "added", "A\ta", + "A\tb"), + result); + } +} diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ShowTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ShowTest.java new file mode 100644 index 000000000..47d5d3433 --- /dev/null +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ShowTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2022, Matthias Sohn 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.pgm; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.jgit.lib.CLIRepositoryTestCase; +import org.junit.Before; +import org.junit.Test; + +public class ShowTest extends CLIRepositoryTestCase { + + private static final String NO_NEWLINE = "\\ No newline at end of file"; + + @Before + public void setup() throws Exception { + writeTrashFile("a", "a"); + writeTrashFile("b", "b"); + execute("git add a b"); + execute("git commit -m added"); + writeTrashFile("a", "a1"); + execute("git add a"); + execute("git commit -m modified"); + } + + @Test + public void testShow() throws Exception { + String result = toString(execute("git show")); + assertEquals( + toString("commit ecdf62e777b7413fc463c20e935403d424410ab2", + "Author: GIT_COMMITTER_NAME ", + "Date: Sat Aug 15 20:12:58 2009 -0330", "", + " modified", "", "diff --git a/a b/a", + "index 2e65efe..59ef8d1 100644", "--- a/a", "+++ b/a", + "@@ -1 +1 @@", "-a", NO_NEWLINE, "+a1", NO_NEWLINE), + result); + } + + @Test + public void testShowNameOnly() throws Exception { + String result = toString(execute("git show --name-only")); + assertEquals(toString("commit ecdf62e777b7413fc463c20e935403d424410ab2", + "Author: GIT_COMMITTER_NAME ", + "Date: Sat Aug 15 20:12:58 2009 -0330", "", " modified", + "a"), result); + } + + @Test + public void testShowNameStatus() throws Exception { + String result = toString(execute("git show --name-status")); + assertEquals(toString("commit ecdf62e777b7413fc463c20e935403d424410ab2", + "Author: GIT_COMMITTER_NAME ", + "Date: Sat Aug 15 20:12:58 2009 -0330", "", " modified", + "M\ta"), result); + } +} diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties index b14531a1b..48f4e857a 100644 --- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties +++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties @@ -40,6 +40,7 @@ cannotRenameDetachedHEAD=Cannot rename detached HEAD cannotResolve=Cannot resolve {0} cannotSetupConsole=Cannot setup console cannotUseObjectsWithGlog=Cannot use --objects with glog +cannotUseNameStatusOnlyAndNameOnly=Cannot use --name-only, --name-status are mutually exclusive cantFindGitDirectory=error: can't find git directory cantWrite=Can''t write {0} changesNotStagedForCommit=Changes not staged for commit: @@ -413,6 +414,7 @@ usage_mergeStrategy=Use the given merge strategy. Can be supplied more than once usage_message=Set the commit message to be used for the merge commit (in case one is created). usage_moveRenameABranch=move/rename a branch usage_nameStatus=show only name and status of files +usage_nameOnly=show only name of files usage_noCheckoutAfterClone=no checkout of HEAD is performed after the clone is complete usage_noCommit=Don't commit after a successful merge usage_noPrefix=do not show any source or destination prefix diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java index cdbcbc0d1..3152c4455 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java @@ -48,6 +48,10 @@ class Diff extends TextBuiltin { private DiffFormatter diffFmt; + private boolean showNameOnly = false; + + private boolean showNameAndStatusOnly = false; + @Argument(index = 0, metaVar = "metaVar_treeish") private AbstractTreeIterator oldTree; @@ -81,7 +85,22 @@ void setAlgorithm(SupportedAlgorithm s) { private Integer renameLimit; @Option(name = "--name-status", usage = "usage_nameStatus") - private boolean showNameAndStatusOnly; + void nameAndStatusOnly(boolean on) { + if (showNameOnly) { + throw new IllegalArgumentException( + CLIText.get().cannotUseNameStatusOnlyAndNameOnly); + } + showNameAndStatusOnly = on; + } + + @Option(name = "--name-only", usage = "usage_nameOnly") + void nameOnly(boolean on) { + if (showNameAndStatusOnly) { + throw new IllegalArgumentException( + CLIText.get().cannotUseNameStatusOnlyAndNameOnly); + } + showNameOnly = on; + } @Option(name = "--ignore-space-at-eol") void ignoreSpaceAtEol(@SuppressWarnings("unused") boolean on) { @@ -183,6 +202,9 @@ protected void run() { if (showNameAndStatusOnly) { nameStatus(outw, diffFmt.scan(oldTree, newTree)); outw.flush(); + } else if(showNameOnly) { + nameOnly(outw, diffFmt.scan(oldTree, newTree)); + outw.flush(); } else { diffFmt.format(oldTree, newTree); diffFmt.flush(); @@ -220,4 +242,27 @@ static void nameStatus(ThrowingPrintWriter out, List files) } } } + + static void nameOnly(ThrowingPrintWriter out, List files) + throws IOException { + for (DiffEntry ent : files) { + switch (ent.getChangeType()) { + case ADD: + out.println(ent.getNewPath()); + break; + case DELETE: + out.println(ent.getOldPath()); + break; + case MODIFY: + out.println(ent.getNewPath()); + break; + case COPY: + out.println(ent.getNewPath()); + break; + case RENAME: + out.println(ent.getNewPath()); + break; + } + } + } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java index 353b64b9b..d69305173 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java @@ -60,6 +60,10 @@ class Log extends RevWalkTextBuiltin { private Map noteMaps; + private boolean showNameOnly = false; + + private boolean showNameAndStatusOnly = false; + @Option(name="--decorate", usage="usage_showRefNamesMatchingCommits") private boolean decorate; @@ -99,7 +103,22 @@ void noRenames(@SuppressWarnings("unused") boolean on) { private Integer renameLimit; @Option(name = "--name-status", usage = "usage_nameStatus") - private boolean showNameAndStatusOnly; + void nameAndStatusOnly(boolean on) { + if (showNameOnly) { + throw new IllegalArgumentException( + CLIText.get().cannotUseNameStatusOnlyAndNameOnly); + } + showNameAndStatusOnly = on; + } + + @Option(name = "--name-only", usage = "usage_nameOnly") + void nameOnly(boolean on) { + if (showNameAndStatusOnly) { + throw new IllegalArgumentException( + CLIText.get().cannotUseNameStatusOnlyAndNameOnly); + } + showNameOnly = on; + } @Option(name = "--ignore-space-at-eol") void ignoreSpaceAtEol(@SuppressWarnings("unused") boolean on) { @@ -266,8 +285,10 @@ protected void show(RevCommit c) throws Exception { if (showNotes(c)) outw.println(); - if (c.getParentCount() <= 1 && (showNameAndStatusOnly || showPatch)) + if (c.getParentCount() <= 1 && (showNameAndStatusOnly || showPatch + || showNameOnly)) { showDiff(c); + } outw.flush(); } @@ -364,9 +385,11 @@ private void showDiff(RevCommit c) throws IOException { : null; final RevTree b = c.getTree(); - if (showNameAndStatusOnly) + if (showNameAndStatusOnly) { Diff.nameStatus(outw, diffFmt.scan(a, b)); - else { + } else if (showNameOnly) { + Diff.nameOnly(outw, diffFmt.scan(a, b)); + } else { outw.flush(); diffFmt.format(a, b); diffFmt.flush(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java index 3beab60a8..c18d35a20 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java @@ -58,6 +58,10 @@ class Show extends TextBuiltin { private DiffFormatter diffFmt; + private boolean showNameOnly = false; + + private boolean showNameAndStatusOnly = false; + @Argument(index = 0, metaVar = "metaVar_object") private String objectName; @@ -83,7 +87,22 @@ void noRenames(@SuppressWarnings("unused") boolean on) { private Integer renameLimit; @Option(name = "--name-status", usage = "usage_nameStatus") - private boolean showNameAndStatusOnly; + void nameAndStatusOnly(boolean on) { + if (showNameOnly) { + throw new IllegalArgumentException( + CLIText.get().cannotUseNameStatusOnlyAndNameOnly); + } + showNameAndStatusOnly = on; + } + + @Option(name = "--name-only", usage = "usage_nameOnly") + void nameOnly(boolean on) { + if (showNameAndStatusOnly) { + throw new IllegalArgumentException( + CLIText.get().cannotUseNameStatusOnlyAndNameOnly); + } + showNameOnly = on; + } @Option(name = "--ignore-space-at-eol") void ignoreSpaceAtEol(@SuppressWarnings("unused") boolean on) { @@ -302,9 +321,11 @@ private void showDiff(RevCommit c) throws IOException { final RevTree a = c.getParent(0).getTree(); final RevTree b = c.getTree(); - if (showNameAndStatusOnly) + if (showNameAndStatusOnly) { Diff.nameStatus(outw, diffFmt.scan(a, b)); - else { + } else if (showNameOnly) { + Diff.nameOnly(outw, diffFmt.scan(a, b)); + } else { outw.flush(); diffFmt.format(a, b); diffFmt.flush(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java index 36103f2e6..ac51643b6 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java @@ -42,12 +42,13 @@ protected void run() { try { FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED); db = key.open(true /* must exist */); - org.eclipse.jgit.transport.UploadPack up = new org.eclipse.jgit.transport.UploadPack( - db); - if (0 <= timeout) { - up.setTimeout(timeout); + try (org.eclipse.jgit.transport.UploadPack up = new org.eclipse.jgit.transport.UploadPack( + db)) { + if (0 <= timeout) { + up.setTimeout(timeout); + } + up.upload(ins, outs, errs); } - up.upload(ins, outs, errs); } catch (RepositoryNotFoundException notFound) { throw die(MessageFormat.format(CLIText.get().notAGitRepository, srcGitdir.getPath()), notFound); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java index e06f150e5..490f800c0 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java @@ -119,6 +119,7 @@ public static String fatalError(String message) { /***/ public String cannotResolve; /***/ public String cannotSetupConsole; /***/ public String cannotUseObjectsWithGlog; + /***/ public String cannotUseNameStatusOnlyAndNameOnly; /***/ public String cantFindGitDirectory; /***/ public String cantWrite; /***/ public String changesNotStagedForCommit; diff --git a/org.eclipse.jgit.ssh.apache.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.ssh.apache.test/META-INF/MANIFEST.MF index 913a26291..1f19407e8 100644 --- a/org.eclipse.jgit.ssh.apache.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.ssh.apache.test/META-INF/MANIFEST.MF @@ -7,20 +7,20 @@ Bundle-Version: 6.4.0.qualifier Bundle-Vendor: %Bundle-Vendor Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-11 -Import-Package: org.apache.sshd.client.config.hosts;version="[2.8.0,2.9.0)", - org.apache.sshd.common;version="[2.8.0,2.9.0)", - org.apache.sshd.common.auth;version="[2.8.0,2.9.0)", - org.apache.sshd.common.config.keys;version="[2.8.0,2.9.0)", - org.apache.sshd.common.helpers;version="[2.8.0,2.9.0)", - org.apache.sshd.common.kex;version="[2.8.0,2.9.0)", - org.apache.sshd.common.keyprovider;version="[2.8.0,2.9.0)", - org.apache.sshd.common.session;version="[2.8.0,2.9.0)", - org.apache.sshd.common.signature;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.net;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.security;version="[2.8.0,2.9.0)", - org.apache.sshd.core;version="[2.8.0,2.9.0)", - org.apache.sshd.server;version="[2.8.0,2.9.0)", - org.apache.sshd.server.forward;version="[2.8.0,2.9.0)", +Import-Package: org.apache.sshd.client.config.hosts;version="[2.9.2,2.10.0)", + org.apache.sshd.common;version="[2.9.2,2.10.0)", + org.apache.sshd.common.auth;version="[2.9.2,2.10.0)", + org.apache.sshd.common.config.keys;version="[2.9.2,2.10.0)", + org.apache.sshd.common.helpers;version="[2.9.2,2.10.0)", + org.apache.sshd.common.kex;version="[2.9.2,2.10.0)", + org.apache.sshd.common.keyprovider;version="[2.9.2,2.10.0)", + org.apache.sshd.common.session;version="[2.9.2,2.10.0)", + org.apache.sshd.common.signature;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.net;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.security;version="[2.9.2,2.10.0)", + org.apache.sshd.core;version="[2.9.2,2.10.0)", + org.apache.sshd.server;version="[2.9.2,2.10.0)", + org.apache.sshd.server.forward;version="[2.9.2,2.10.0)", org.eclipse.jgit.api;version="[6.4.0,6.5.0)", org.eclipse.jgit.api.errors;version="[6.4.0,6.5.0)", org.eclipse.jgit.internal.transport.sshd.proxy;version="[6.4.0,6.5.0)", diff --git a/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF b/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF index 1edde8ada..a27d6c72f 100644 --- a/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF @@ -35,57 +35,57 @@ Export-Package: org.eclipse.jgit.internal.transport.sshd;version="6.4.0";x-inter org.apache.sshd.client.keyverifier", org.eclipse.jgit.transport.sshd.agent;version="6.4.0" Import-Package: net.i2p.crypto.eddsa;version="[0.3.0,0.4.0)", - org.apache.sshd.agent;version="[2.8.0,2.9.0)", - org.apache.sshd.client;version="[2.8.0,2.9.0)", - org.apache.sshd.client.auth;version="[2.8.0,2.9.0)", - org.apache.sshd.client.auth.keyboard;version="[2.8.0,2.9.0)", - org.apache.sshd.client.auth.password;version="[2.8.0,2.9.0)", - org.apache.sshd.client.auth.pubkey;version="[2.8.0,2.9.0)", - org.apache.sshd.client.channel;version="[2.8.0,2.9.0)", - org.apache.sshd.client.config.hosts;version="[2.8.0,2.9.0)", - org.apache.sshd.client.config.keys;version="[2.8.0,2.9.0)", - org.apache.sshd.client.future;version="[2.8.0,2.9.0)", - org.apache.sshd.client.keyverifier;version="[2.8.0,2.9.0)", - org.apache.sshd.client.session;version="[2.8.0,2.9.0)", - org.apache.sshd.client.session.forward;version="[2.8.0,2.9.0)", - org.apache.sshd.common;version="[2.8.0,2.9.0)", - org.apache.sshd.common.auth;version="[2.8.0,2.9.0)", - org.apache.sshd.common.channel;version="[2.8.0,2.9.0)", - org.apache.sshd.common.compression;version="[2.8.0,2.9.0)", - org.apache.sshd.common.config.keys;version="[2.8.0,2.9.0)", - org.apache.sshd.common.config.keys.loader;version="[2.8.0,2.9.0)", - org.apache.sshd.common.config.keys.loader.openssh.kdf;version="[2.8.0,2.9.0)", - org.apache.sshd.common.config.keys.u2f;version="[2.8.0,2.9.0)", - org.apache.sshd.common.digest;version="[2.8.0,2.9.0)", - org.apache.sshd.common.forward;version="[2.8.0,2.9.0)", - org.apache.sshd.common.future;version="[2.8.0,2.9.0)", - org.apache.sshd.common.helpers;version="[2.8.0,2.9.0)", - org.apache.sshd.common.io;version="[2.8.0,2.9.0)", - org.apache.sshd.common.kex;version="[2.8.0,2.9.0)", - org.apache.sshd.common.kex.extension;version="[2.8.0,2.9.0)", - org.apache.sshd.common.kex.extension.parser;version="[2.8.0,2.9.0)", - org.apache.sshd.common.keyprovider;version="[2.8.0,2.9.0)", - org.apache.sshd.common.mac;version="[2.8.0,2.9.0)", - org.apache.sshd.common.random;version="[2.8.0,2.9.0)", - org.apache.sshd.common.session;version="[2.8.0,2.9.0)", - org.apache.sshd.common.session.helpers;version="[2.8.0,2.9.0)", - org.apache.sshd.common.signature;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.buffer;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.buffer.keys;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.closeable;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.io;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.io.der;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.io.functors;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.io.resource;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.logging;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.net;version="[2.8.0,2.9.0)", - org.apache.sshd.common.util.security;version="[2.8.0,2.9.0)", - org.apache.sshd.core;version="[2.8.0,2.9.0)", - org.apache.sshd.server.auth;version="[2.8.0,2.9.0)", - org.apache.sshd.sftp;version="[2.8.0,2.9.0)", - org.apache.sshd.sftp.client;version="[2.8.0,2.9.0)", - org.apache.sshd.sftp.common;version="[2.8.0,2.9.0)", + org.apache.sshd.agent;version="[2.9.2,2.10.0)", + org.apache.sshd.client;version="[2.9.2,2.10.0)", + org.apache.sshd.client.auth;version="[2.9.2,2.10.0)", + org.apache.sshd.client.auth.keyboard;version="[2.9.2,2.10.0)", + org.apache.sshd.client.auth.password;version="[2.9.2,2.10.0)", + org.apache.sshd.client.auth.pubkey;version="[2.9.2,2.10.0)", + org.apache.sshd.client.channel;version="[2.9.2,2.10.0)", + org.apache.sshd.client.config.hosts;version="[2.9.2,2.10.0)", + org.apache.sshd.client.config.keys;version="[2.9.2,2.10.0)", + org.apache.sshd.client.future;version="[2.9.2,2.10.0)", + org.apache.sshd.client.keyverifier;version="[2.9.2,2.10.0)", + org.apache.sshd.client.session;version="[2.9.2,2.10.0)", + org.apache.sshd.client.session.forward;version="[2.9.2,2.10.0)", + org.apache.sshd.common;version="[2.9.2,2.10.0)", + org.apache.sshd.common.auth;version="[2.9.2,2.10.0)", + org.apache.sshd.common.channel;version="[2.9.2,2.10.0)", + org.apache.sshd.common.compression;version="[2.9.2,2.10.0)", + org.apache.sshd.common.config.keys;version="[2.9.2,2.10.0)", + org.apache.sshd.common.config.keys.loader;version="[2.9.2,2.10.0)", + org.apache.sshd.common.config.keys.loader.openssh.kdf;version="[2.9.2,2.10.0)", + org.apache.sshd.common.config.keys.u2f;version="[2.9.2,2.10.0)", + org.apache.sshd.common.digest;version="[2.9.2,2.10.0)", + org.apache.sshd.common.forward;version="[2.9.2,2.10.0)", + org.apache.sshd.common.future;version="[2.9.2,2.10.0)", + org.apache.sshd.common.helpers;version="[2.9.2,2.10.0)", + org.apache.sshd.common.io;version="[2.9.2,2.10.0)", + org.apache.sshd.common.kex;version="[2.9.2,2.10.0)", + org.apache.sshd.common.kex.extension;version="[2.9.2,2.10.0)", + org.apache.sshd.common.kex.extension.parser;version="[2.9.2,2.10.0)", + org.apache.sshd.common.keyprovider;version="[2.9.2,2.10.0)", + org.apache.sshd.common.mac;version="[2.9.2,2.10.0)", + org.apache.sshd.common.random;version="[2.9.2,2.10.0)", + org.apache.sshd.common.session;version="[2.9.2,2.10.0)", + org.apache.sshd.common.session.helpers;version="[2.9.2,2.10.0)", + org.apache.sshd.common.signature;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.buffer;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.buffer.keys;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.closeable;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.io;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.io.der;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.io.functors;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.io.resource;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.logging;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.net;version="[2.9.2,2.10.0)", + org.apache.sshd.common.util.security;version="[2.9.2,2.10.0)", + org.apache.sshd.core;version="[2.9.2,2.10.0)", + org.apache.sshd.server.auth;version="[2.9.2,2.10.0)", + org.apache.sshd.sftp;version="[2.9.2,2.10.0)", + org.apache.sshd.sftp.client;version="[2.9.2,2.10.0)", + org.apache.sshd.sftp.common;version="[2.9.2,2.10.0)", org.eclipse.jgit.annotations;version="[6.4.0,6.5.0)", org.eclipse.jgit.errors;version="[6.4.0,6.5.0)", org.eclipse.jgit.fnmatch;version="[6.4.0,6.5.0)", diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitPublicKeyAuthentication.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitPublicKeyAuthentication.java index e1036c628..e2da7991a 100644 --- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitPublicKeyAuthentication.java +++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitPublicKeyAuthentication.java @@ -131,17 +131,6 @@ protected Iterator createPublicKeyIterator( @Override protected PublicKeyIdentity resolveAttemptedPublicKeyIdentity( ClientSession session, String service) throws Exception { - PublicKeyIdentity result = getNextKey(session, service); - // This fixes SSHD-1231. Can be removed once we're using Apache MINA - // sshd > 2.8.0. - // - // See https://issues.apache.org/jira/browse/SSHD-1231 - currentAlgorithms.clear(); - return result; - } - - private PublicKeyIdentity getNextKey(ClientSession session, String service) - throws Exception { PublicKeyIdentity id = super.resolveAttemptedPublicKeyIdentity(session, service); if (addKeysToAgent && id != null && !(id instanceof KeyAgentIdentity)) { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java index ad14b0125..48a062df8 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java @@ -18,8 +18,10 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.Arrays; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.util.RawParseUtils; @@ -244,6 +246,38 @@ public void testLineDelimiter2() throws Exception { assertTrue(rt.isMissingNewlineAtEnd()); } + @Test + public void testCrAtLimit() throws Exception { + int limit = RawText.getBufferSize(); + byte[] data = new byte[RawText.getBufferSize() + 2]; + data[0] = 'A'; + for (int i = 1; i < limit - 1; i++) { + if (i % 7 == 0) { + data[i] = '\n'; + } else { + data[i] = (byte) ('A' + i % 7); + } + } + data[limit - 1] = '\r'; + data[limit] = '\n'; + data[limit + 1] = 'A'; + assertTrue(RawText.isBinary(data, limit, true)); + assertFalse(RawText.isBinary(data, limit, false)); + assertFalse(RawText.isBinary(data, data.length, true)); + byte[] buf = Arrays.copyOf(data, limit); + try (ByteArrayInputStream in = new ByteArrayInputStream(buf)) { + assertTrue(RawText.isBinary(in)); + } + byte[] buf2 = Arrays.copyOf(data, limit + 1); + try (ByteArrayInputStream in = new ByteArrayInputStream(buf2)) { + assertFalse(RawText.isBinary(in)); + } + byte[] buf3 = Arrays.copyOf(data, limit + 2); + try (ByteArrayInputStream in = new ByteArrayInputStream(buf3)) { + assertFalse(RawText.isBinary(in)); + } + } + private static RawText t(String text) { StringBuilder r = new StringBuilder(); for (int i = 0; i < text.length(); i++) { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheTest.java index ab588cb71..3dd4190c8 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsBlockCacheTest.java @@ -289,8 +289,7 @@ public void noConcurrencySerializedReads_oneRepo() throws Exception { assertEquals(1, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]); assertEquals(1, cache.getMissCount()[PackExt.INDEX.ordinal()]); - // Reverse index has no pack extension, it defaults to 0. - assertEquals(1, cache.getMissCount()[0]); + assertEquals(1, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]); } @SuppressWarnings("resource") @@ -319,7 +318,7 @@ public void noConcurrencySerializedReads_twoRepos() throws Exception { waitForExecutorPoolTermination(); assertEquals(2, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]); assertEquals(2, cache.getMissCount()[PackExt.INDEX.ordinal()]); - assertEquals(2, cache.getMissCount()[0]); + assertEquals(2, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]); } @SuppressWarnings("resource") @@ -348,7 +347,7 @@ public void lowConcurrencyParallelReads_twoRepos() throws Exception { waitForExecutorPoolTermination(); assertEquals(2, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]); assertEquals(2, cache.getMissCount()[PackExt.INDEX.ordinal()]); - assertEquals(2, cache.getMissCount()[0]); + assertEquals(2, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]); } @SuppressWarnings("resource") @@ -380,7 +379,7 @@ public void lowConcurrencyParallelReads_twoReposAndIndex() assertEquals(2, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]); // Index is loaded once for each repo. assertEquals(2, cache.getMissCount()[PackExt.INDEX.ordinal()]); - assertEquals(2, cache.getMissCount()[0]); + assertEquals(2, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]); } @Test @@ -402,7 +401,7 @@ public void highConcurrencyParallelReads_oneRepo() throws Exception { assertEquals(1, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]); assertEquals(1, cache.getMissCount()[PackExt.INDEX.ordinal()]); - assertEquals(1, cache.getMissCount()[0]); + assertEquals(1, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]); } @Test @@ -426,7 +425,7 @@ public void highConcurrencyParallelReads_oneRepoParallelReverseIndex() assertEquals(1, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]); assertEquals(1, cache.getMissCount()[PackExt.INDEX.ordinal()]); - assertEquals(1, cache.getMissCount()[0]); + assertEquals(1, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]); } private void resetCache() { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchApplierTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchApplierTest.java index c77a19f1b..aeb3e6127 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchApplierTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchApplierTest.java @@ -71,10 +71,10 @@ public abstract static class Base extends RepositoryTestCase { this.inCore = inCore; } - protected void init(final String name, final boolean preExists, - final boolean postExists) throws Exception { + protected void init(String aName, boolean preExists, boolean postExists) + throws Exception { /* Patch and pre/postimage are read from data org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ */ - this.name = name; + this.name = aName; if (postExists) { postImage = IO .readWholeStream(getTestResource(name + "_PostImage"), 0) @@ -98,8 +98,8 @@ protected void init(final String name, final boolean preExists, } } - void init(final String name) throws Exception { - init(name, true, true); + void init(final String aName) throws Exception { + init(aName, true, true); } protected Result applyPatch() @@ -117,8 +117,8 @@ protected static InputStream getTestResource(String patchFile) { return PatchApplierTest.class.getClassLoader() .getResourceAsStream("org/eclipse/jgit/diff/" + patchFile); } - void verifyChange(Result result, String name) throws Exception { - verifyChange(result, name, true); + void verifyChange(Result result, String aName) throws Exception { + verifyChange(result, aName, true); } protected void verifyContent(Result result, String path, boolean exists) throws Exception { @@ -139,9 +139,9 @@ protected void verifyContent(Result result, String path, boolean exists) throws } } - void verifyChange(Result result, String name, boolean exists) throws Exception { + void verifyChange(Result result, String aName, boolean exists) throws Exception { assertEquals(1, result.getPaths().size()); - verifyContent(result, name, exists); + verifyContent(result, aName, exists); } protected byte[] readBlob(ObjectId treeish, String path) throws Exception { @@ -448,17 +448,17 @@ public void testPatchWithCrLf() throws Exception { @Test public void testPatchWithCrLf2() throws Exception { - String name = "crlf2"; + String aName = "crlf2"; try (Git git = new Git(db)) { db.getConfig().setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOCRLF, false); - init(name, true, true); + init(aName, true, true); db.getConfig().setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOCRLF, true); Result result = applyPatch(); - verifyChange(result, name); + verifyChange(result, aName); } finally { db.getConfig().unset(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOCRLF); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java index 2019c263f..92da34016 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java @@ -248,8 +248,9 @@ public void testOpenPushUseBitmaps() throws Exception { try (Transport transport = Transport.open(uri)) { try (PushConnection pushConnection = transport.openPush()) { assertTrue(pushConnection instanceof BasePackPushConnection); + @SuppressWarnings("resource") BasePackPushConnection basePackPushConnection = (BasePackPushConnection) pushConnection; - assertEquals(true, basePackPushConnection.isUseBitmaps()); + assertTrue(basePackPushConnection.isUseBitmaps()); } } // true @@ -257,8 +258,9 @@ public void testOpenPushUseBitmaps() throws Exception { transport.setPushUseBitmaps(true); try (PushConnection pushConnection = transport.openPush()) { assertTrue(pushConnection instanceof BasePackPushConnection); + @SuppressWarnings("resource") BasePackPushConnection basePackPushConnection = (BasePackPushConnection) pushConnection; - assertEquals(true, basePackPushConnection.isUseBitmaps()); + assertTrue(basePackPushConnection.isUseBitmaps()); } } // false @@ -266,8 +268,9 @@ public void testOpenPushUseBitmaps() throws Exception { transport.setPushUseBitmaps(false); try (PushConnection pushConnection = transport.openPush()) { assertTrue(pushConnection instanceof BasePackPushConnection); + @SuppressWarnings("resource") BasePackPushConnection basePackPushConnection = (BasePackPushConnection) pushConnection; - assertEquals(false, basePackPushConnection.isUseBitmaps()); + assertFalse(basePackPushConnection.isUseBitmaps()); } } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java index df48afef3..91b45e447 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java @@ -2416,16 +2416,18 @@ public void testGetPeerAgentProtocolV0() throws Exception { RevCommit one = remote.commit().message("1").create(); remote.update("one", one); - UploadPack up = new UploadPack(server); - ByteArrayInputStream send = linesAsInputStream( - "want " + one.getName() + " agent=JGit-test/1.2.3\n", - PacketLineIn.end(), - "have 11cedf1b796d44207da702f7d420684022fc0f09\n", "done\n"); + try (UploadPack up = new UploadPack(server)) { + ByteArrayInputStream send = linesAsInputStream( + "want " + one.getName() + " agent=JGit-test/1.2.3\n", + PacketLineIn.end(), + "have 11cedf1b796d44207da702f7d420684022fc0f09\n", + "done\n"); - ByteArrayOutputStream recv = new ByteArrayOutputStream(); - up.upload(send, recv, null); + ByteArrayOutputStream recv = new ByteArrayOutputStream(); + up.upload(send, recv, null); - assertEquals(up.getPeerUserAgent(), "JGit-test/1.2.3"); + assertEquals(up.getPeerUserAgent(), "JGit-test/1.2.3"); + } } @Test @@ -2433,17 +2435,19 @@ public void testGetSessionIDValueProtocolV0() throws Exception { RevCommit one = remote.commit().message("1").create(); remote.update("one", one); - UploadPack up = new UploadPack(server); - ByteArrayInputStream send = linesAsInputStream( - "want " + one.getName() + " agent=JGit-test/1.2.3" - + " session-id=client-session-id\n", - PacketLineIn.end(), - "have 11cedf1b796d44207da702f7d420684022fc0f09\n", "done\n"); + try (UploadPack up = new UploadPack(server)) { + ByteArrayInputStream send = linesAsInputStream( + "want " + one.getName() + " agent=JGit-test/1.2.3" + + " session-id=client-session-id\n", + PacketLineIn.end(), + "have 11cedf1b796d44207da702f7d420684022fc0f09\n", + "done\n"); - ByteArrayOutputStream recv = new ByteArrayOutputStream(); - up.upload(send, recv, null); + ByteArrayOutputStream recv = new ByteArrayOutputStream(); + up.upload(send, recv, null); - assertEquals(up.getClientSID(), "client-session-id"); + assertEquals(up.getClientSID(), "client-session-id"); + } } @Test @@ -2455,19 +2459,20 @@ public void testGetPeerAgentProtocolV2() throws Exception { RevCommit one = remote.commit().message("1").create(); remote.update("one", one); - UploadPack up = new UploadPack(server); - up.setExtraParameters(Sets.of("version=2")); + try (UploadPack up = new UploadPack(server)) { + up.setExtraParameters(Sets.of("version=2")); - ByteArrayInputStream send = linesAsInputStream( - "command=fetch\n", "agent=JGit-test/1.2.4\n", - PacketLineIn.delimiter(), "want " + one.getName() + "\n", - "have 11cedf1b796d44207da702f7d420684022fc0f09\n", "done\n", - PacketLineIn.end()); + ByteArrayInputStream send = linesAsInputStream("command=fetch\n", + "agent=JGit-test/1.2.4\n", PacketLineIn.delimiter(), + "want " + one.getName() + "\n", + "have 11cedf1b796d44207da702f7d420684022fc0f09\n", "done\n", + PacketLineIn.end()); - ByteArrayOutputStream recv = new ByteArrayOutputStream(); - up.upload(send, recv, null); + ByteArrayOutputStream recv = new ByteArrayOutputStream(); + up.upload(send, recv, null); - assertEquals(up.getPeerUserAgent(), "JGit-test/1.2.4"); + assertEquals(up.getPeerUserAgent(), "JGit-test/1.2.4"); + } } @Test @@ -2479,19 +2484,20 @@ public void testGetSessionIDValueProtocolV2() throws Exception { RevCommit one = remote.commit().message("1").create(); remote.update("one", one); - UploadPack up = new UploadPack(server); - up.setExtraParameters(Sets.of("version=2")); + try (UploadPack up = new UploadPack(server)) { + up.setExtraParameters(Sets.of("version=2")); - ByteArrayInputStream send = linesAsInputStream("command=fetch\n", - "agent=JGit-test/1.2.4\n", "session-id=client-session-id\n", - PacketLineIn.delimiter(), "want " + one.getName() + "\n", - "have 11cedf1b796d44207da702f7d420684022fc0f09\n", "done\n", - PacketLineIn.end()); + ByteArrayInputStream send = linesAsInputStream("command=fetch\n", + "agent=JGit-test/1.2.4\n", "session-id=client-session-id\n", + PacketLineIn.delimiter(), "want " + one.getName() + "\n", + "have 11cedf1b796d44207da702f7d420684022fc0f09\n", "done\n", + PacketLineIn.end()); - ByteArrayOutputStream recv = new ByteArrayOutputStream(); - up.upload(send, recv, null); + ByteArrayOutputStream recv = new ByteArrayOutputStream(); + up.upload(send, recv, null); - assertEquals(up.getClientSID(), "client-session-id"); + assertEquals(up.getClientSID(), "client-session-id"); + } } private static class RejectAllRefFilter implements RefFilter { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java index a925a08e3..040b29d8e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java @@ -51,6 +51,8 @@ public class DiffCommand extends GitCommand> { private boolean showNameAndStatusOnly; + private boolean showNameOnly; + private OutputStream out; private int contextLines = -1; @@ -72,7 +74,7 @@ protected DiffCommand(Repository repo) { } private DiffFormatter getDiffFormatter() { - return out != null && !showNameAndStatusOnly + return out != null && !showNameAndStatusOnly && !showNameOnly ? new DiffFormatter(new BufferedOutputStream(out)) : new DiffFormatter(NullOutputStream.INSTANCE); } @@ -114,7 +116,7 @@ public List call() throws GitAPIException { diffFmt.setPathFilter(pathFilter); List result = diffFmt.scan(oldTree, newTree); - if (showNameAndStatusOnly) { + if (showNameAndStatusOnly || showNameOnly) { return result; } if (contextLines >= 0) { @@ -194,6 +196,19 @@ public DiffCommand setShowNameAndStatusOnly(boolean showNameAndStatusOnly) { return this; } + /** + * Set whether to return only names of changed files + * + * @param showNameOnly + * whether to return only names files + * @return this instance + * @since 6.4 + */ + public DiffCommand setShowNameOnly(boolean showNameOnly) { + this.showNameOnly = showNameOnly; + return this; + } + /** * Set output stream * diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java index 19961a13e..b52803513 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java @@ -288,12 +288,13 @@ public static int setBufferSize(int bufferSize) { * if input stream could not be read */ public static boolean isBinary(InputStream raw) throws IOException { - final byte[] buffer = new byte[getBufferSize()]; + final byte[] buffer = new byte[getBufferSize() + 1]; int cnt = 0; while (cnt < buffer.length) { final int n = raw.read(buffer, cnt, buffer.length - cnt); - if (n == -1) + if (n == -1) { break; + } cnt += n; } return isBinary(buffer, cnt, cnt < buffer.length); @@ -347,8 +348,16 @@ public static boolean isBinary(byte[] raw, int length, boolean complete) { // - limited buffer size; may be only the beginning of a large blob // - no counting of printable vs. non-printable bytes < 0x20 and 0x7F int maxLength = getBufferSize(); + boolean isComplete = complete; if (length > maxLength) { + // We restrict the length in all cases to getBufferSize() to get + // predictable behavior. Sometimes we load streams, and sometimes we + // have the full data in memory. With streams, we never look at more + // than the first getBufferSize() bytes. If we looked at more when + // we have the full data, different code paths in JGit might come to + // different conclusions. length = maxLength; + isComplete = false; } byte last = 'x'; // Just something inconspicuous. for (int ptr = 0; ptr < length; ptr++) { @@ -358,7 +367,7 @@ public static boolean isBinary(byte[] raw, int length, boolean complete) { } last = curr; } - if (complete) { + if (isComplete) { // Buffer contains everything... return last == '\r'; // ... so this must be a lone CR } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoRemoteRepositoryException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoRemoteRepositoryException.java index 1dd976cec..1fa411b4d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoRemoteRepositoryException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoRemoteRepositoryException.java @@ -39,7 +39,7 @@ public NoRemoteRepositoryException(URIish uri, String s) { * message * @param cause * root cause exception - * @since 5.13 + * @since 5.13.1 */ public NoRemoteRepositoryException(URIish uri, String s, Throwable cause) { super(uri, s, cause); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java index b30d50921..0a02180d7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java @@ -712,7 +712,7 @@ private static HashEntry clean(HashEntry top) { private void reportIndexRequested(Ref ref, boolean cacheHit, long start) { if (indexEventConsumer == null - || !isIndexOrBitmapExtPos(ref.key.packExtPos)) { + || !isIndexExtPos(ref.key.packExtPos)) { return; } EvictKey evictKey = new EvictKey(ref); @@ -728,7 +728,7 @@ private void reportIndexRequested(Ref ref, boolean cacheHit, private void reportIndexEvicted(Ref dead) { if (indexEventConsumer == null || !indexEventConsumer.shouldReportEvictedEvent() - || !isIndexOrBitmapExtPos(dead.key.packExtPos)) { + || !isIndexExtPos(dead.key.packExtPos)) { return; } EvictKey evictKey = new EvictKey(dead); @@ -742,8 +742,9 @@ private void reportIndexEvicted(Ref dead) { Duration.ofNanos(sinceLastEvictionNanos)); } - private static boolean isIndexOrBitmapExtPos(int packExtPos) { + private static boolean isIndexExtPos(int packExtPos) { return packExtPos == PackExt.INDEX.getPosition() + || packExtPos == PackExt.REVERSE_INDEX.getPosition() || packExtPos == PackExt.BITMAP_INDEX.getPosition(); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java index f7a2c94d4..15511fed3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java @@ -16,6 +16,7 @@ import static org.eclipse.jgit.internal.storage.pack.PackExt.BITMAP_INDEX; import static org.eclipse.jgit.internal.storage.pack.PackExt.INDEX; import static org.eclipse.jgit.internal.storage.pack.PackExt.PACK; +import static org.eclipse.jgit.internal.storage.pack.PackExt.REVERSE_INDEX; import java.io.BufferedInputStream; import java.io.EOFException; @@ -220,8 +221,7 @@ PackReverseIndex getReverseIdx(DfsReader ctx) throws IOException { } PackIndex idx = idx(ctx); - DfsStreamKey revKey = new DfsStreamKey.ForReverseIndex( - desc.getStreamKey(INDEX)); + DfsStreamKey revKey = desc.getStreamKey(REVERSE_INDEX); AtomicBoolean cacheHit = new AtomicBoolean(true); DfsBlockCache.Ref revref = cache.getOrLoadRef(revKey, REF_POSITION, () -> { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java index 4a6723f83..f3f30914f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsStreamKey.java @@ -95,19 +95,4 @@ public boolean equals(Object o) { return false; } } - - static final class ForReverseIndex extends DfsStreamKey { - private final DfsStreamKey idxKey; - - ForReverseIndex(DfsStreamKey idxKey) { - super(idxKey.hash + 1, null); - this.idxKey = idxKey; - } - - @Override - public boolean equals(Object o) { - return o instanceof ForReverseIndex - && idxKey.equals(((ForReverseIndex) o).idxKey); - } - } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java index 6fb775da8..c006995c5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java @@ -27,7 +27,10 @@ public enum PackExt { BITMAP_INDEX("bitmap"), //$NON-NLS-1$ /** A reftable file. */ - REFTABLE("ref"); //$NON-NLS-1$ + REFTABLE("ref"), //$NON-NLS-1$ + + /** A pack reverse index file extension. */ + REVERSE_INDEX("rev"); //$NON-NLS-1$ private final String ext; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java index b9bf09084..ca8ea5d17 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java @@ -947,8 +947,7 @@ private boolean isNoNewlineAtEndOfFile( 0, buf.length); RawText lhrt = new RawText(buf); return lhrt.getString(lhrt.size() - 1) - .equals("\\ No newline at end of file"); // $NON-NLS-1$, - // $NON-NLS-2$ + .equals("\\ No newline at end of file"); //$NON-NLS-1$ } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AwsRequestSignerV4.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AwsRequestSignerV4.java index 6b3d39721..ab3013762 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AwsRequestSignerV4.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AwsRequestSignerV4.java @@ -40,7 +40,7 @@ * "https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html">AWS * Signature Version 4 * - * @since 5.13 + * @since 5.13.1 */ public final class AwsRequestSignerV4 { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java index 663a3449e..e3ba60634 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java @@ -196,7 +196,7 @@ public static void encode(StringBuilder urlstr, String key) { * them to "%2F"). * * @return The translated URL. - * @since 5.13 + * @since 5.13.1 */ public static String urlEncode(String url, boolean keepPathSlash) { String encoded; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/SHA1.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/SHA1.java index 87993d2be..56e90d063 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/SHA1.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/SHA1.java @@ -27,6 +27,8 @@ public abstract class SHA1 { /** * SHA1 implementations available in JGit + * + * @since 5.13.2 */ public enum Sha1Implementation { /** diff --git a/pom.xml b/pom.xml index 8df5b5319..fb9d317ec 100644 --- a/pom.xml +++ b/pom.xml @@ -152,7 +152,7 @@ 6.2.0.202206071550-r 1.10.12 - 2.8.0 + 2.9.2 0.1.55 1.1.3 1.1.13