diff options
Diffstat (limited to 'org.eclipse.jgit.pgm')
9 files changed, 178 insertions, 76 deletions
diff --git a/org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.core.prefs index 13c32a6d94..ef6f5e732f 100644 --- a/org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.core.prefs @@ -91,7 +91,7 @@ org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore diff --git a/org.eclipse.jgit.pgm/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.pgm/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.pgm/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.pgm/.settings/org.eclipse.mylyn.team.ui.prefs @@ -1,3 +1,3 @@ #Tue Jul 19 20:11:28 CEST 2011 -commit.comment.template=${task.description} \n\nBug\: ${task.key} +commit.comment.template=${task.description}\n\nBug\: ${task.key} eclipse.preferences.version=1 diff --git a/org.eclipse.jgit.pgm/BUILD b/org.eclipse.jgit.pgm/BUILD index 00c48d1e0c..18607ea6ea 100644 --- a/org.eclipse.jgit.pgm/BUILD +++ b/org.eclipse.jgit.pgm/BUILD @@ -9,6 +9,7 @@ java_library( deps = [ ":services", "//lib:args4j", + "//lib:commons-logging", "//lib:httpclient", "//lib:httpcore", "//lib:jetty-http", @@ -23,6 +24,7 @@ java_library( "//org.eclipse.jgit:jgit", "//org.eclipse.jgit.lfs:jgit-lfs", "//org.eclipse.jgit.lfs.server:jgit-lfs-server", + "//org.eclipse.jgit.ssh.apache:ssh-apache", "//org.eclipse.jgit.ui:ui", ], ) diff --git a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF index e715a45678..e10a772a8c 100644 --- a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.pgm Bundle-SymbolicName: org.eclipse.jgit.pgm -Bundle-Version: 5.1.12.qualifier +Bundle-Version: 5.2.3.qualifier Bundle-Vendor: %provider_name Bundle-ActivationPolicy: lazy Bundle-Localization: plugin @@ -28,49 +28,50 @@ Import-Package: javax.servlet;version="[3.1.0,4.0.0)", org.eclipse.jetty.util.log;version="[9.4.5,10.0.0)", org.eclipse.jetty.util.security;version="[9.4.5,10.0.0)", org.eclipse.jetty.util.thread;version="[9.4.5,10.0.0)", - org.eclipse.jgit.api;version="[5.1.12,5.2.0)", - org.eclipse.jgit.api.errors;version="[5.1.12,5.2.0)", - org.eclipse.jgit.archive;version="[5.1.12,5.2.0)", - org.eclipse.jgit.awtui;version="[5.1.12,5.2.0)", - org.eclipse.jgit.blame;version="[5.1.12,5.2.0)", - org.eclipse.jgit.diff;version="[5.1.12,5.2.0)", - org.eclipse.jgit.dircache;version="[5.1.12,5.2.0)", - org.eclipse.jgit.errors;version="[5.1.12,5.2.0)", - org.eclipse.jgit.gitrepo;version="[5.1.12,5.2.0)", - org.eclipse.jgit.internal.ketch;version="[5.1.12,5.2.0)", - org.eclipse.jgit.internal.storage.dfs;version="[5.1.12,5.2.0)", - org.eclipse.jgit.internal.storage.file;version="[5.1.12,5.2.0)", - org.eclipse.jgit.internal.storage.io;version="[5.1.12,5.2.0)", - org.eclipse.jgit.internal.storage.pack;version="[5.1.12,5.2.0)", - org.eclipse.jgit.internal.storage.reftable;version="[5.1.12,5.2.0)", - org.eclipse.jgit.internal.storage.reftree;version="[5.1.12,5.2.0)", - org.eclipse.jgit.lfs;version="[5.1.12,5.2.0)", - org.eclipse.jgit.lfs.lib;version="[5.1.12,5.2.0)", - org.eclipse.jgit.lfs.server;version="[5.1.12,5.2.0)", - org.eclipse.jgit.lfs.server.fs;version="[5.1.12,5.2.0)", - org.eclipse.jgit.lfs.server.s3;version="[5.1.12,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.12,5.2.0)", - org.eclipse.jgit.merge;version="[5.1.12,5.2.0)", - org.eclipse.jgit.nls;version="[5.1.12,5.2.0)", - org.eclipse.jgit.notes;version="[5.1.12,5.2.0)", - org.eclipse.jgit.revplot;version="[5.1.12,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.12,5.2.0)", - org.eclipse.jgit.revwalk.filter;version="[5.1.12,5.2.0)", - org.eclipse.jgit.storage.file;version="[5.1.12,5.2.0)", - org.eclipse.jgit.storage.pack;version="[5.1.12,5.2.0)", - org.eclipse.jgit.transport;version="[5.1.12,5.2.0)", - org.eclipse.jgit.transport.http.apache;version="[5.1.12,5.2.0)", - org.eclipse.jgit.transport.resolver;version="[5.1.12,5.2.0)", - org.eclipse.jgit.treewalk;version="[5.1.12,5.2.0)", - org.eclipse.jgit.treewalk.filter;version="[5.1.12,5.2.0)", - org.eclipse.jgit.util;version="[5.1.12,5.2.0)", - org.eclipse.jgit.util.io;version="[5.1.12,5.2.0)", + org.eclipse.jgit.api;version="[5.2.3,5.3.0)", + org.eclipse.jgit.api.errors;version="[5.2.3,5.3.0)", + org.eclipse.jgit.archive;version="[5.2.3,5.3.0)", + org.eclipse.jgit.awtui;version="[5.2.3,5.3.0)", + org.eclipse.jgit.blame;version="[5.2.3,5.3.0)", + org.eclipse.jgit.diff;version="[5.2.3,5.3.0)", + org.eclipse.jgit.dircache;version="[5.2.3,5.3.0)", + org.eclipse.jgit.errors;version="[5.2.3,5.3.0)", + org.eclipse.jgit.gitrepo;version="[5.2.3,5.3.0)", + org.eclipse.jgit.internal.ketch;version="[5.2.3,5.3.0)", + org.eclipse.jgit.internal.storage.dfs;version="[5.2.3,5.3.0)", + org.eclipse.jgit.internal.storage.file;version="[5.2.3,5.3.0)", + org.eclipse.jgit.internal.storage.io;version="[5.2.3,5.3.0)", + org.eclipse.jgit.internal.storage.pack;version="[5.2.3,5.3.0)", + org.eclipse.jgit.internal.storage.reftable;version="[5.2.3,5.3.0)", + org.eclipse.jgit.internal.storage.reftree;version="[5.2.3,5.3.0)", + org.eclipse.jgit.lfs;version="[5.2.3,5.3.0)", + org.eclipse.jgit.lfs.lib;version="[5.2.3,5.3.0)", + org.eclipse.jgit.lfs.server;version="[5.2.3,5.3.0)", + org.eclipse.jgit.lfs.server.fs;version="[5.2.3,5.3.0)", + org.eclipse.jgit.lfs.server.s3;version="[5.2.3,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.3,5.3.0)", + org.eclipse.jgit.merge;version="[5.2.3,5.3.0)", + org.eclipse.jgit.nls;version="[5.2.3,5.3.0)", + org.eclipse.jgit.notes;version="[5.2.3,5.3.0)", + org.eclipse.jgit.revplot;version="[5.2.3,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.3,5.3.0)", + org.eclipse.jgit.revwalk.filter;version="[5.2.3,5.3.0)", + org.eclipse.jgit.storage.file;version="[5.2.3,5.3.0)", + org.eclipse.jgit.storage.pack;version="[5.2.3,5.3.0)", + org.eclipse.jgit.transport;version="[5.2.3,5.3.0)", + org.eclipse.jgit.transport.http.apache;version="[5.2.3,5.3.0)", + org.eclipse.jgit.transport.resolver;version="[5.2.3,5.3.0)", + org.eclipse.jgit.transport.sshd;version="[5.2.3,5.3.0)", + org.eclipse.jgit.treewalk;version="[5.2.3,5.3.0)", + org.eclipse.jgit.treewalk.filter;version="[5.2.3,5.3.0)", + org.eclipse.jgit.util;version="[5.2.3,5.3.0)", + org.eclipse.jgit.util.io;version="[5.2.3,5.3.0)", org.kohsuke.args4j;version="[2.33.0,3.0.0)", org.kohsuke.args4j.spi;version="[2.33.0,3.0.0)" -Export-Package: org.eclipse.jgit.console;version="5.1.12"; +Export-Package: org.eclipse.jgit.console;version="5.2.3"; uses:="org.eclipse.jgit.transport, org.eclipse.jgit.util", - org.eclipse.jgit.pgm;version="5.1.12"; + org.eclipse.jgit.pgm;version="5.2.3"; uses:="org.eclipse.jgit.revwalk, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.pgm.opt, @@ -81,11 +82,11 @@ Export-Package: org.eclipse.jgit.console;version="5.1.12"; org.eclipse.jgit.treewalk, javax.swing, org.eclipse.jgit.transport", - org.eclipse.jgit.pgm.debug;version="5.1.12"; + org.eclipse.jgit.pgm.debug;version="5.2.3"; uses:="org.eclipse.jgit.util.io, org.eclipse.jgit.pgm", - org.eclipse.jgit.pgm.internal;version="5.1.12";x-friends:="org.eclipse.jgit.pgm.test,org.eclipse.jgit.test", - org.eclipse.jgit.pgm.opt;version="5.1.12"; + org.eclipse.jgit.pgm.internal;version="5.2.3";x-friends:="org.eclipse.jgit.pgm.test,org.eclipse.jgit.test", + org.eclipse.jgit.pgm.opt;version="5.2.3"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.revwalk, org.kohsuke.args4j.spi, diff --git a/org.eclipse.jgit.pgm/META-INF/SOURCE-MANIFEST.MF b/org.eclipse.jgit.pgm/META-INF/SOURCE-MANIFEST.MF index bdb7a18c2e..9831e1347e 100644 --- a/org.eclipse.jgit.pgm/META-INF/SOURCE-MANIFEST.MF +++ b/org.eclipse.jgit.pgm/META-INF/SOURCE-MANIFEST.MF @@ -3,5 +3,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: org.eclipse.jgit.pgm - Sources Bundle-SymbolicName: org.eclipse.jgit.pgm.source Bundle-Vendor: Eclipse.org - JGit -Bundle-Version: 5.1.12.qualifier -Eclipse-SourceBundle: org.eclipse.jgit.pgm;version="5.1.12.qualifier";roots="." +Bundle-Version: 5.2.3.qualifier +Eclipse-SourceBundle: org.eclipse.jgit.pgm;version="5.2.3.qualifier";roots="." diff --git a/org.eclipse.jgit.pgm/pom.xml b/org.eclipse.jgit.pgm/pom.xml index 43eec1186a..81ef1b3f70 100644 --- a/org.eclipse.jgit.pgm/pom.xml +++ b/org.eclipse.jgit.pgm/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.12-SNAPSHOT</version> + <version>5.2.3-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.pgm</artifactId> @@ -101,6 +101,12 @@ </dependency> <dependency> + <groupId>org.eclipse.jgit</groupId> + <artifactId>org.eclipse.jgit.ssh.apache</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> </dependency> 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 08a3d7e7d3..bbf9366ce7 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 @@ -398,6 +398,7 @@ usage_showNotes=Add this ref to the list of note branches from which notes are d usage_showTimeInMilliseconds=Show mtime in milliseconds usage_squash=Squash commits as if a real merge happened, but do not make a commit or move the HEAD. usage_srcPrefix=show the source prefix instead of "a/" +usage_sshDriver=Selects the built-in ssh library to use, JSch or Apache MINA sshd. usage_symbolicVersionForTheProject=Symbolic version for the project usage_tags=fetch all tags usage_notags=do not fetch tags @@ -407,7 +408,7 @@ usage_untrackedFilesMode=show untracked files usage_updateRef=reference to update usage_updateRemoteRefsFromAnotherRepository=Update remote refs from another repository usage_useNameInsteadOfOriginToTrackUpstream=use <name> instead of 'origin' to track upstream -usage_checkoutBranchAfterClone=checkout named branch instead of remotes's HEAD +usage_checkoutBranchAfterClone=checkout named branch instead of remote's HEAD usage_viewCommitHistory=View commit history -usage_orphan=Create a new orphan branch. The first commit made on this new branch will have no parents amd it will be the root of a new history totally disconnected from other branches and commits. +usage_orphan=Create a new orphan branch. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from other branches and commits. usernameFor=Username for {0}: diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java index 7e5b5451b6..c4b4018b8f 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java @@ -44,6 +44,9 @@ package org.eclipse.jgit.pgm; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_SECTION_I18N; +import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_LOG_OUTPUT_ENCODING; import static org.eclipse.jgit.lib.Constants.R_HEADS; import static org.eclipse.jgit.lib.Constants.R_REMOTES; import static org.eclipse.jgit.lib.Constants.R_TAGS; @@ -56,14 +59,20 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; +import java.nio.charset.Charset; import java.text.MessageFormat; import java.util.ResourceBundle; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.pgm.internal.CLIText; +import org.eclipse.jgit.pgm.internal.SshDriver; import org.eclipse.jgit.pgm.opt.CmdLineParser; import org.eclipse.jgit.revwalk.RevWalk; +import org.eclipse.jgit.transport.SshSessionFactory; +import org.eclipse.jgit.transport.sshd.DefaultProxyDataFactory; +import org.eclipse.jgit.transport.sshd.JGitKeyCache; +import org.eclipse.jgit.transport.sshd.SshdSessionFactory; import org.eclipse.jgit.util.io.ThrowingPrintWriter; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.Option; @@ -85,6 +94,9 @@ public abstract class TextBuiltin { @Option(name = "--help", usage = "usage_displayThisHelpText", aliases = { "-h" }) private boolean help; + @Option(name = "--ssh", usage = "usage_sshDriver") + private SshDriver sshDriver = SshDriver.JSCH; + /** * Input stream, typically this is standard input. * @@ -168,6 +180,30 @@ public abstract class TextBuiltin { } /** + * Get the log output encoding specified in the repository's + * {@code i18n.logOutputEncoding} configuration. + * + * @param repository + * the repository. + * @return Charset corresponding to {@code i18n.logOutputEncoding}, or + * {@code UTF_8}. + */ + private Charset getLogOutputEncodingCharset(Repository repository) { + if (repository != null) { + String logOutputEncoding = repository.getConfig().getString( + CONFIG_SECTION_I18N, null, CONFIG_KEY_LOG_OUTPUT_ENCODING); + if (logOutputEncoding != null) { + try { + return Charset.forName(logOutputEncoding); + } catch (IllegalArgumentException e) { + throw die(CLIText.get().cannotCreateOutputStream); + } + } + } + return UTF_8; + } + + /** * Initialize the command to work with a repository. * * @param repository @@ -177,32 +213,18 @@ public abstract class TextBuiltin { * {@code repository} is null. */ protected void init(Repository repository, String gitDir) { - try { - final String outputEncoding = repository != null ? repository - .getConfig().getString("i18n", null, "logOutputEncoding") : null; //$NON-NLS-1$ //$NON-NLS-2$ - if (ins == null) - ins = new FileInputStream(FileDescriptor.in); - if (outs == null) - outs = new FileOutputStream(FileDescriptor.out); - if (errs == null) - errs = new FileOutputStream(FileDescriptor.err); - BufferedWriter outbufw; - if (outputEncoding != null) - outbufw = new BufferedWriter(new OutputStreamWriter(outs, - outputEncoding)); - else - outbufw = new BufferedWriter(new OutputStreamWriter(outs)); - outw = new ThrowingPrintWriter(outbufw); - BufferedWriter errbufw; - if (outputEncoding != null) - errbufw = new BufferedWriter(new OutputStreamWriter(errs, - outputEncoding)); - else - errbufw = new BufferedWriter(new OutputStreamWriter(errs)); - errw = new ThrowingPrintWriter(errbufw); - } catch (IOException e) { - throw die(CLIText.get().cannotCreateOutputStream); - } + Charset charset = getLogOutputEncodingCharset(repository); + + if (ins == null) + ins = new FileInputStream(FileDescriptor.in); + if (outs == null) + outs = new FileOutputStream(FileDescriptor.out); + if (errs == null) + errs = new FileOutputStream(FileDescriptor.err); + outw = new ThrowingPrintWriter(new BufferedWriter( + new OutputStreamWriter(outs, charset))); + errw = new ThrowingPrintWriter(new BufferedWriter( + new OutputStreamWriter(errs, charset))); if (repository != null && repository.getDirectory() != null) { db = repository; @@ -225,6 +247,20 @@ public abstract class TextBuiltin { */ public final void execute(String[] args) throws Exception { parseArguments(args); + switch (sshDriver) { + case APACHE: { + SshdSessionFactory factory = new SshdSessionFactory( + new JGitKeyCache(), new DefaultProxyDataFactory()); + Runtime.getRuntime() + .addShutdownHook(new Thread(() -> factory.close())); + SshSessionFactory.setInstance(factory); + break; + } + case JSCH: + default: + SshSessionFactory.setInstance(null); + break; + } run(); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/SshDriver.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/SshDriver.java new file mode 100644 index 0000000000..7d0423b014 --- /dev/null +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/SshDriver.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2018, Thomas Wolf <thomas.wolf@paranor.ch> + * 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 v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * - Neither the name of the Eclipse Foundation, Inc. nor the + * names of its contributors may be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * 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. + */ +package org.eclipse.jgit.pgm.internal; + +/** + * Simple enumeration for the available built-in ssh clients. + */ +public enum SshDriver { + + /** Default client: use JSch. */ + JSCH, + + /** Use the Apache MINA sshd client from org.eclipse.jgit.ssh.apache. */ + APACHE; + +} |