diff options
185 files changed, 2099 insertions, 970 deletions
@@ -1,10 +1,18 @@ -Han-Wen Nienhuys <hanwen@google.com> Han-Wen NIenhuys <hanwen@google.com> -Mark Ingram <markdingram@gmail.com> markdingram <markdingram@gmail.com> -Roberto Tyley <roberto.tyley@guardian.co.uk> roberto <roberto.tyley@guardian.co.uk> -Saša Živkov <sasa.zivkov@sap.com> Sasa Zivkov <sasa.zivkov@sap.com> -Saša Živkov <sasa.zivkov@sap.com> Saša Živkov <zivkov@gmail.com> -Saša Živkov <sasa.zivkov@sap.com> Sasa Zivkov <zivkov@gmail.com> -Shawn Pearce <spearce@spearce.org> Shawn O. Pearce <sop@google.com> -Shawn Pearce <spearce@spearce.org> Shawn Pearce <sop@google.com> -Shawn Pearce <spearce@spearce.org> Shawn O. Pearce <spearce@spearce.org> -Terry Parker <tparker@google.com> tparker <tparker@google.com> +Chris Aniszczyk <caniszczyk@gmail.com> Chris Aniszczyk <zx@eclipsesource.com> +Christian Halstrick <christian.halstrick@sap.com> Christian Halstrick <christian.halstrick@gmail.com> +Dani Megert <Daniel_Megert@ch.ibm.com> Daniel Megert <daniel_megert@ch.ibm.com> +David Pursehouse <david.pursehouse@gmail.com> David Pursehouse <david.pursehouse@sonymobile.com> +Han-Wen Nienhuys <hanwen@google.com> Han-Wen NIenhuys <hanwen@google.com> +Hector Oswaldo Caballero <hector.caballero@ericsson.com> Hector Caballero <hector.caballero@ericsson.com> +Lars Vogel <Lars.Vogel@vogella.com> Lars Vogel <Lars.Vogel@gmail.com> +Mark Ingram <markdingram@gmail.com> markdingram <markdingram@gmail.com> +Markus Duft <markus.duft@ssi-schaefer.com> Markus Duft <markus.duft@salomon.at> +Michael Keppler <michael.keppler@gmx.de> Michael Keppler <Michael.Keppler@gmx.de> +Roberto Tyley <roberto.tyley@guardian.co.uk> roberto <roberto.tyley@guardian.co.uk> +Saša Živkov <sasa.zivkov@sap.com> Sasa Zivkov <sasa.zivkov@sap.com> +Saša Živkov <sasa.zivkov@sap.com> Saša Živkov <zivkov@gmail.com> +Saša Živkov <sasa.zivkov@sap.com> Sasa Zivkov <zivkov@gmail.com> +Shawn Pearce <spearce@spearce.org> Shawn O. Pearce <sop@google.com> +Shawn Pearce <spearce@spearce.org> Shawn Pearce <sop@google.com> +Shawn Pearce <spearce@spearce.org> Shawn O. Pearce <spearce@spearce.org> +Terry Parker <tparker@google.com> tparker <tparker@google.com> @@ -23,7 +23,6 @@ java_library( java_library( name = "commons-logging", - testonly = 1, visibility = ["//visibility:public"], exports = ["@commons-logging//jar"], ) diff --git a/org.eclipse.jgit.ant.test/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.ant.test/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.ant.test/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.ant.test/.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.ant.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.ant.test/META-INF/MANIFEST.MF index 4d1a830c2a..e6bef69afd 100644 --- a/org.eclipse.jgit.ant.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.ant.test/META-INF/MANIFEST.MF @@ -4,13 +4,13 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.ant.test Bundle-SymbolicName: org.eclipse.jgit.ant.test -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: org.apache.tools.ant, - org.eclipse.jgit.ant.tasks;version="[5.1.3,5.2.0)", - org.eclipse.jgit.junit;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)", + org.eclipse.jgit.ant.tasks;version="[5.2.0,5.3.0)", + org.eclipse.jgit.junit;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)", org.hamcrest.core;version="[1.1.0,2.0.0)", org.junit;version="[4.12,5.0.0)" diff --git a/org.eclipse.jgit.ant.test/pom.xml b/org.eclipse.jgit.ant.test/pom.xml index 69433bed9a..9526dafe05 100644 --- a/org.eclipse.jgit.ant.test/pom.xml +++ b/org.eclipse.jgit.ant.test/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.ant.test</artifactId> diff --git a/org.eclipse.jgit.ant/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.ant/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.ant/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.ant/.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.ant/META-INF/MANIFEST.MF b/org.eclipse.jgit.ant/META-INF/MANIFEST.MF index c507f01c86..d151b32de3 100644 --- a/org.eclipse.jgit.ant/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.ant/META-INF/MANIFEST.MF @@ -3,11 +3,11 @@ Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Automatic-Module-Name: org.eclipse.jgit.ant Bundle-SymbolicName: org.eclipse.jgit.ant -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: org.apache.tools.ant, - org.eclipse.jgit.storage.file;version="[5.1.3,5.2.0)" + org.eclipse.jgit.storage.file;version="[5.2.0,5.3.0)" Bundle-Localization: plugin Bundle-Vendor: %Provider-Name -Export-Package: org.eclipse.jgit.ant.tasks;version="5.1.3"; +Export-Package: org.eclipse.jgit.ant.tasks;version="5.2.0"; uses:="org.apache.tools.ant.types,org.apache.tools.ant" diff --git a/org.eclipse.jgit.ant/pom.xml b/org.eclipse.jgit.ant/pom.xml index 88c1759ae2..445a2f512a 100644 --- a/org.eclipse.jgit.ant/pom.xml +++ b/org.eclipse.jgit.ant/pom.xml @@ -48,7 +48,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.ant</artifactId> diff --git a/org.eclipse.jgit.archive/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.archive/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.archive/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.archive/.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.archive/META-INF/MANIFEST.MF b/org.eclipse.jgit.archive/META-INF/MANIFEST.MF index 427effd745..31875bb362 100644 --- a/org.eclipse.jgit.archive/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.archive/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.archive Bundle-SymbolicName: org.eclipse.jgit.archive -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Vendor: %provider_name Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.8 @@ -13,15 +13,15 @@ Import-Package: org.apache.commons.compress.archivers;version="[1.4,2.0)", org.apache.commons.compress.compressors.bzip2;version="[1.4,2.0)", org.apache.commons.compress.compressors.gzip;version="[1.4,2.0)", org.apache.commons.compress.compressors.xz;version="[1.4,2.0)", - org.eclipse.jgit.api;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.nls;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)", + org.eclipse.jgit.api;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.nls;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)", org.osgi.framework;version="[1.3.0,2.0.0)" Bundle-ActivationPolicy: lazy Bundle-Activator: org.eclipse.jgit.archive.FormatActivator -Export-Package: org.eclipse.jgit.archive;version="5.1.3"; +Export-Package: org.eclipse.jgit.archive;version="5.2.0"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.api, org.apache.commons.compress.archivers, diff --git a/org.eclipse.jgit.archive/META-INF/SOURCE-MANIFEST.MF b/org.eclipse.jgit.archive/META-INF/SOURCE-MANIFEST.MF index 3bdd424a3d..7556798f28 100644 --- a/org.eclipse.jgit.archive/META-INF/SOURCE-MANIFEST.MF +++ b/org.eclipse.jgit.archive/META-INF/SOURCE-MANIFEST.MF @@ -3,5 +3,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: org.eclipse.jgit.archive - Sources Bundle-SymbolicName: org.eclipse.jgit.archive.source Bundle-Vendor: Eclipse.org - JGit -Bundle-Version: 5.1.3.qualifier -Eclipse-SourceBundle: org.eclipse.jgit.archive;version="5.1.3.qualifier";roots="." +Bundle-Version: 5.2.0.qualifier +Eclipse-SourceBundle: org.eclipse.jgit.archive;version="5.2.0.qualifier";roots="." diff --git a/org.eclipse.jgit.archive/pom.xml b/org.eclipse.jgit.archive/pom.xml index 9eb383d68d..b374dbda1e 100644 --- a/org.eclipse.jgit.archive/pom.xml +++ b/org.eclipse.jgit.archive/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.archive</artifactId> diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java index 9ed60d941a..aee80d8307 100644 --- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java +++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java @@ -42,7 +42,7 @@ */ package org.eclipse.jgit.archive; -import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING; +import static java.nio.charset.StandardCharsets.UTF_8; import java.io.IOException; import java.io.OutputStream; @@ -85,7 +85,7 @@ public final class TarFormat extends BaseFormat implements public ArchiveOutputStream createArchiveOutputStream(OutputStream s, Map<String, Object> o) throws IOException { TarArchiveOutputStream out = new TarArchiveOutputStream(s, - CHARACTER_ENCODING); + UTF_8.name()); out.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX); out.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX); return applyFormatOptions(out, o); @@ -99,8 +99,7 @@ public final class TarFormat extends BaseFormat implements if (mode == FileMode.SYMLINK) { final TarArchiveEntry entry = new TarArchiveEntry( path, TarConstants.LF_SYMLINK); - entry.setLinkName(new String( - loader.getCachedBytes(100), CHARACTER_ENCODING)); + entry.setLinkName(new String(loader.getCachedBytes(100), UTF_8)); out.putArchiveEntry(entry); out.closeArchiveEntry(); return; diff --git a/org.eclipse.jgit.http.apache/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.http.apache/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.http.apache/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.http.apache/.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.http.apache/META-INF/MANIFEST.MF b/org.eclipse.jgit.http.apache/META-INF/MANIFEST.MF index dbf7fefa8e..1e8842bb7d 100644 --- a/org.eclipse.jgit.http.apache/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.http.apache/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Automatic-Module-Name: org.eclipse.jgit.http.apache Bundle-SymbolicName: org.eclipse.jgit.http.apache -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Localization: plugin Bundle-Vendor: %Provider-Name @@ -23,10 +23,10 @@ Import-Package: org.apache.http;version="[4.3.0,5.0.0)", org.apache.http.impl.client;version="[4.3.0,5.0.0)", org.apache.http.impl.conn;version="[4.3.0,5.0.0)", org.apache.http.params;version="[4.3.0,5.0.0)", - org.eclipse.jgit.nls;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.http;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)" -Export-Package: org.eclipse.jgit.transport.http.apache;version="5.1.3"; + org.eclipse.jgit.nls;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.http;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)" +Export-Package: org.eclipse.jgit.transport.http.apache;version="5.2.0"; uses:="org.apache.http.client, org.eclipse.jgit.transport.http, org.apache.http.entity, diff --git a/org.eclipse.jgit.http.apache/pom.xml b/org.eclipse.jgit.http.apache/pom.xml index 15345b2f02..8aea8870e4 100644 --- a/org.eclipse.jgit.http.apache/pom.xml +++ b/org.eclipse.jgit.http.apache/pom.xml @@ -48,7 +48,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.http.apache</artifactId> diff --git a/org.eclipse.jgit.http.server/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.http.server/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.http.server/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.http.server/.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.http.server/META-INF/MANIFEST.MF b/org.eclipse.jgit.http.server/META-INF/MANIFEST.MF index 37f5b1df8c..f9a66b90a3 100644 --- a/org.eclipse.jgit.http.server/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.http.server/META-INF/MANIFEST.MF @@ -3,13 +3,13 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.http.server Bundle-SymbolicName: org.eclipse.jgit.http.server -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Localization: plugin Bundle-Vendor: %provider_name -Export-Package: org.eclipse.jgit.http.server;version="5.1.3", - org.eclipse.jgit.http.server.glue;version="5.1.3"; +Export-Package: org.eclipse.jgit.http.server;version="5.2.0", + org.eclipse.jgit.http.server.glue;version="5.2.0"; uses:="javax.servlet,javax.servlet.http", - org.eclipse.jgit.http.server.resolver;version="5.1.3"; + org.eclipse.jgit.http.server.resolver;version="5.2.0"; uses:="org.eclipse.jgit.transport.resolver, org.eclipse.jgit.lib, org.eclipse.jgit.transport, @@ -18,12 +18,12 @@ Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: javax.servlet;version="[2.5.0,3.2.0)", javax.servlet.http;version="[2.5.0,3.2.0)", - org.eclipse.jgit.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.dfs;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.nls;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.resolver;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)" + org.eclipse.jgit.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.dfs;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.nls;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.resolver;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)" diff --git a/org.eclipse.jgit.http.server/pom.xml b/org.eclipse.jgit.http.server/pom.xml index d27fecf64e..a5c1a1ca6f 100644 --- a/org.eclipse.jgit.http.server/pom.xml +++ b/org.eclipse.jgit.http.server/pom.xml @@ -52,7 +52,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.http.server</artifactId> diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java index 1a9d192450..b084b0db54 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java @@ -69,7 +69,7 @@ class InfoRefsServlet extends HttpServlet { // Assume a dumb client and send back the dumb client // version of the info/refs file. rsp.setContentType(HttpSupport.TEXT_PLAIN); - rsp.setCharacterEncoding(Constants.CHARACTER_ENCODING); + rsp.setCharacterEncoding(UTF_8.name()); final Repository db = getRepository(req); try (OutputStreamWriter out = new OutputStreamWriter( diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java index 9601c8cafa..b6d73b5591 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.http.server; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.util.HttpSupport.ENCODING_GZIP; import static org.eclipse.jgit.util.HttpSupport.ENCODING_X_GZIP; import static org.eclipse.jgit.util.HttpSupport.HDR_ACCEPT_ENCODING; @@ -191,9 +192,9 @@ public final class ServletUtils { public static void sendPlainText(final String content, final HttpServletRequest req, final HttpServletResponse rsp) throws IOException { - final byte[] raw = content.getBytes(Constants.CHARACTER_ENCODING); + final byte[] raw = content.getBytes(UTF_8); rsp.setContentType(TEXT_PLAIN); - rsp.setCharacterEncoding(Constants.CHARACTER_ENCODING); + rsp.setCharacterEncoding(UTF_8.name()); send(raw, req, rsp); } diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java index ad5e8d479e..06bdce679d 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java @@ -105,6 +105,7 @@ class SmartOutputStream extends TemporaryBuffer { // If output hasn't started yet, the entire thing fit into our // buffer. Try to use a proper Content-Length header, and also // deflate the response with gzip if it will be smaller. + @SuppressWarnings("resource") TemporaryBuffer out = this; if (256 < out.length() && acceptsGzipEncoding(req)) { diff --git a/org.eclipse.jgit.http.test/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.http.test/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.http.test/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.http.test/.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.http.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.http.test/META-INF/MANIFEST.MF index 7bfa910295..37a95494de 100644 --- a/org.eclipse.jgit.http.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.http.test/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.http.test Bundle-SymbolicName: org.eclipse.jgit.http.test -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Vendor: %provider_name Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.8 @@ -28,25 +28,25 @@ Import-Package: javax.servlet;version="[2.5.0,3.2.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.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.http.server;version="[5.1.3,5.2.0)", - org.eclipse.jgit.http.server.glue;version="[5.1.3,5.2.0)", - org.eclipse.jgit.http.server.resolver;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.dfs;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.reftable;version="[5.1.3,5.2.0)", - org.eclipse.jgit.junit;version="[5.1.3,5.2.0)", - org.eclipse.jgit.junit.http;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.nls;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.http;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.http.apache;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.resolver;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)", + org.eclipse.jgit.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.http.server;version="[5.2.0,5.3.0)", + org.eclipse.jgit.http.server.glue;version="[5.2.0,5.3.0)", + org.eclipse.jgit.http.server.resolver;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.dfs;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.reftable;version="[5.2.0,5.3.0)", + org.eclipse.jgit.junit;version="[5.2.0,5.3.0)", + org.eclipse.jgit.junit.http;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.nls;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.http;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.http.apache;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.resolver;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)", org.hamcrest;version="[1.1.0,2.0.0)", org.hamcrest.core;version="[1.1.0,2.0.0)", org.junit;version="[4.12,5.0.0)", diff --git a/org.eclipse.jgit.http.test/pom.xml b/org.eclipse.jgit.http.test/pom.xml index 94e5f3b47f..5bc342cbe8 100644 --- a/org.eclipse.jgit.http.test/pom.xml +++ b/org.eclipse.jgit.http.test/pom.xml @@ -51,7 +51,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.http.test</artifactId> diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java index 82e79b8e50..553c340a73 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/FileResolverTest.java @@ -147,6 +147,7 @@ public class FileResolverTest extends LocalDiskRepositoryTestCase { try { resolver.open(null, name); + fail("opened non-git repository"); } catch (RepositoryNotFoundException e) { assertEquals("repository not found: " + name, e.getMessage()); diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/RegexPipelineTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/RegexPipelineTest.java index 725a5902df..59c2b4e677 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/RegexPipelineTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/RegexPipelineTest.java @@ -43,11 +43,14 @@ package org.eclipse.jgit.http.test; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; +import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.HttpURLConnection; import java.net.URI; @@ -82,7 +85,8 @@ public class RegexPipelineTest extends HttpTestCase { protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { res.setStatus(200); - PrintWriter out = new PrintWriter(res.getOutputStream()); + PrintWriter out = new PrintWriter(new BufferedWriter( + new OutputStreamWriter(res.getOutputStream(), UTF_8))); out.write(name); out.write("\n"); out.write(String.valueOf(req.getServletPath())); @@ -120,7 +124,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/a").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test", r.readLine()); assertEquals("", r.readLine()); assertEquals("/a", r.readLine()); @@ -129,7 +134,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/b").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test", r.readLine()); assertEquals("", r.readLine()); assertEquals("/b", r.readLine()); @@ -155,7 +161,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/a").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test1", r.readLine()); assertEquals("", r.readLine()); assertEquals("/a", r.readLine()); @@ -183,7 +190,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/a/b").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test1", r.readLine()); assertEquals("", r.readLine()); // No RegexGroupFilter defaults to first group. @@ -193,7 +201,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/c/d").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test2", r.readLine()); assertEquals("", r.readLine()); assertEquals("/c", r.readLine()); @@ -202,7 +211,8 @@ public class RegexPipelineTest extends HttpTestCase { c = ((HttpURLConnection) uri.resolve("/e/f/g").toURL() .openConnection()); assertEquals(200, c.getResponseCode()); - r = new BufferedReader(new InputStreamReader(c.getInputStream())); + r = new BufferedReader( + new InputStreamReader(c.getInputStream(), UTF_8)); assertEquals("test3", r.readLine()); assertEquals("/e/f", r.readLine()); assertEquals("/g", r.readLine()); diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java index 51aa5f2ba7..d1c7737d4f 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java @@ -266,7 +266,7 @@ public class SmartClientSmartServerTest extends HttpTestCase { throws IOException, ServletException { final HttpServletResponse r = (HttpServletResponse) response; r.setContentType("text/plain"); - r.setCharacterEncoding(Constants.CHARACTER_ENCODING); + r.setCharacterEncoding(UTF_8.name()); try (PrintWriter w = r.getWriter()) { w.print("OK"); } diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/transport/http/apache/HttpClientConnectionTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/transport/http/apache/HttpClientConnectionTest.java index 72c4921de6..8a0d59c748 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/transport/http/apache/HttpClientConnectionTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/transport/http/apache/HttpClientConnectionTest.java @@ -76,7 +76,7 @@ public class HttpClientConnectionTest { assertTrue(headerValues.contains("NTLM")); } - private class HttpResponseMock extends AbstractHttpMessage + private static class HttpResponseMock extends AbstractHttpMessage implements HttpResponse { @Override public StatusLine getStatusLine() { diff --git a/org.eclipse.jgit.junit.http/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.junit.http/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.junit.http/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.junit.http/.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.junit.http/META-INF/MANIFEST.MF b/org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF index 2a8f61f3ed..a95385a686 100644 --- a/org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.junit.http Bundle-SymbolicName: org.eclipse.jgit.junit.http -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Localization: plugin Bundle-Vendor: %provider_name Bundle-ActivationPolicy: lazy @@ -22,16 +22,16 @@ Import-Package: javax.servlet;version="[2.5.0,3.2.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.ssl;version="[9.4.5,10.0.0)", - org.eclipse.jgit.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.http.server;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.junit;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.resolver;version="[5.1.3,5.2.0)", + org.eclipse.jgit.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.http.server;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.junit;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.resolver;version="[5.2.0,5.3.0)", org.junit;version="[4.12,5.0.0)" -Export-Package: org.eclipse.jgit.junit.http;version="5.1.3"; +Export-Package: org.eclipse.jgit.junit.http;version="5.2.0"; uses:="org.eclipse.jgit.transport, org.eclipse.jgit.junit, javax.servlet.http, diff --git a/org.eclipse.jgit.junit.http/pom.xml b/org.eclipse.jgit.junit.http/pom.xml index e16f4e9e57..72ab8d3d12 100644 --- a/org.eclipse.jgit.junit.http/pom.xml +++ b/org.eclipse.jgit.junit.http/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.junit.http</artifactId> diff --git a/org.eclipse.jgit.junit/.settings/.api_filters b/org.eclipse.jgit.junit/.settings/.api_filters deleted file mode 100644 index e5de787fa6..0000000000 --- a/org.eclipse.jgit.junit/.settings/.api_filters +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<component id="org.eclipse.jgit.junit" version="2"> - <resource path="src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java" type="org.eclipse.jgit.junit.LocalDiskRepositoryTestCase"> - <filter comment="Don't care about non-API in tests." id="643842064"> - <message_arguments> - <message_argument value="FileRepository"/> - <message_argument value="LocalDiskRepositoryTestCase"/> - <message_argument value="createBareRepository()"/> - </message_arguments> - </filter> - <filter comment="Don't care about non-API in tests." id="643842064"> - <message_arguments> - <message_argument value="FileRepository"/> - <message_argument value="LocalDiskRepositoryTestCase"/> - <message_argument value="createRepository(boolean, boolean)"/> - </message_arguments> - </filter> - <filter comment="Don't care about non-API in tests." id="643842064"> - <message_arguments> - <message_argument value="FileRepository"/> - <message_argument value="LocalDiskRepositoryTestCase"/> - <message_argument value="createWorkRepository()"/> - </message_arguments> - </filter> - </resource> - <resource path="src/org/eclipse/jgit/junit/RepositoryTestCase.java" type="org.eclipse.jgit.junit.RepositoryTestCase"> - <filter comment="Don't care about non-API in tests." id="627060751"> - <message_arguments> - <message_argument value="FileRepository"/> - <message_argument value="RepositoryTestCase"/> - <message_argument value="db"/> - </message_arguments> - </filter> - </resource> -</component> diff --git a/org.eclipse.jgit.junit/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.junit/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.junit/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.junit/.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.junit/META-INF/MANIFEST.MF b/org.eclipse.jgit.junit/META-INF/MANIFEST.MF index f8e77af300..9721c42e50 100644 --- a/org.eclipse.jgit.junit/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.junit/META-INF/MANIFEST.MF @@ -3,31 +3,31 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.junit Bundle-SymbolicName: org.eclipse.jgit.junit -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Localization: plugin Bundle-Vendor: %provider_name Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Import-Package: org.eclipse.jgit.api;version="[5.1.3,5.2.0)", - org.eclipse.jgit.api.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.dircache;version="[5.1.3,5.2.0)", - org.eclipse.jgit.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.pack;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.merge;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk.filter;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util.io;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util.time;version="[5.1.3,5.2.0)", +Import-Package: org.eclipse.jgit.api;version="[5.2.0,5.3.0)", + org.eclipse.jgit.api.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.dircache;version="[5.2.0,5.3.0)", + org.eclipse.jgit.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.pack;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.merge;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk.filter;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util.io;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util.time;version="[5.2.0,5.3.0)", org.junit;version="[4.12,5.0.0)", org.junit.rules;version="[4.12,5.0.0)", org.junit.runner;version="[4.12,5.0.0)", org.junit.runners.model;version="[4.12,5.0.0)" -Export-Package: org.eclipse.jgit.junit;version="5.1.3"; +Export-Package: org.eclipse.jgit.junit;version="5.2.0"; uses:="org.eclipse.jgit.dircache, org.eclipse.jgit.lib, org.eclipse.jgit.revwalk, @@ -36,4 +36,4 @@ Export-Package: org.eclipse.jgit.junit;version="5.1.3"; org.eclipse.jgit.util, org.eclipse.jgit.storage.file, org.eclipse.jgit.api", - org.eclipse.jgit.junit.time;version="5.1.3" + org.eclipse.jgit.junit.time;version="5.2.0" diff --git a/org.eclipse.jgit.junit/pom.xml b/org.eclipse.jgit.junit/pom.xml index 60dceb203c..24e2c71f9b 100644 --- a/org.eclipse.jgit.junit/pom.xml +++ b/org.eclipse.jgit.junit/pom.xml @@ -52,7 +52,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.junit</artifactId> diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java index d3d7d682e8..8de386e344 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java @@ -70,7 +70,7 @@ import org.eclipse.jgit.util.time.ProposedTimestamp; * Mock {@link org.eclipse.jgit.util.SystemReader} for tests. */ public class MockSystemReader extends SystemReader { - private final class MockConfig extends FileBasedConfig { + private static final class MockConfig extends FileBasedConfig { private MockConfig(File cfgLocation, FS fs) { super(cfgLocation, fs); } diff --git a/org.eclipse.jgit.lfs.server.test/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.lfs.server.test/.settings/org.eclipse.mylyn.team.ui.prefs index ce7a0f0478..984263dd94 100644 --- a/org.eclipse.jgit.lfs.server.test/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.lfs.server.test/.settings/org.eclipse.mylyn.team.ui.prefs @@ -1,2 +1,2 @@ -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.lfs.server.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.lfs.server.test/META-INF/MANIFEST.MF index f4fb262a3e..80354033cf 100644 --- a/org.eclipse.jgit.lfs.server.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.lfs.server.test/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.lfs.server.test Bundle-SymbolicName: org.eclipse.jgit.lfs.server.test -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Vendor: %provider_name Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.8 @@ -28,24 +28,24 @@ 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.3,5.2.0)", - org.eclipse.jgit.api.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.junit;version="[5.1.3,5.2.0)", - org.eclipse.jgit.junit.http;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.server;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.server.fs;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.test;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk.filter;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)", + org.eclipse.jgit.api;version="[5.2.0,5.3.0)", + org.eclipse.jgit.api.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.junit;version="[5.2.0,5.3.0)", + org.eclipse.jgit.junit.http;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.server;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.server.fs;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.test;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk.filter;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)", org.hamcrest.core;version="[1.1.0,2.0.0)", org.junit;version="[4.12,5.0.0)", org.junit.rules;version="[4.12,5.0.0)", diff --git a/org.eclipse.jgit.lfs.server.test/pom.xml b/org.eclipse.jgit.lfs.server.test/pom.xml index 4fa8d7680e..5210d4f904 100644 --- a/org.eclipse.jgit.lfs.server.test/pom.xml +++ b/org.eclipse.jgit.lfs.server.test/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.lfs.server.test</artifactId> diff --git a/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/PushTest.java b/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/PushTest.java index b081a8ef73..4eb4a0da54 100644 --- a/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/PushTest.java +++ b/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/PushTest.java @@ -42,6 +42,7 @@ */ package org.eclipse.jgit.lfs.server.fs; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.InputStream; @@ -149,7 +150,7 @@ public class PushTest extends LfsServerTest { new String(IO .readWholeStream(is, (int) ldr.getSize()) - .array())); + .array(), UTF_8)); } } diff --git a/org.eclipse.jgit.lfs.server/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.lfs.server/.settings/org.eclipse.mylyn.team.ui.prefs index ce7a0f0478..984263dd94 100644 --- a/org.eclipse.jgit.lfs.server/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.lfs.server/.settings/org.eclipse.mylyn.team.ui.prefs @@ -1,2 +1,2 @@ -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.lfs.server/META-INF/MANIFEST.MF b/org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF index 31b01a93b2..2b6771c808 100644 --- a/org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.lfs.server/META-INF/MANIFEST.MF @@ -3,19 +3,19 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.lfs.server Bundle-SymbolicName: org.eclipse.jgit.lfs.server -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Localization: plugin Bundle-Vendor: %provider_name -Export-Package: org.eclipse.jgit.lfs.server;version="5.1.3"; +Export-Package: org.eclipse.jgit.lfs.server;version="5.2.0"; uses:="javax.servlet.http, org.eclipse.jgit.lfs.lib", - org.eclipse.jgit.lfs.server.fs;version="5.1.3"; + org.eclipse.jgit.lfs.server.fs;version="5.2.0"; uses:="javax.servlet, javax.servlet.http, org.eclipse.jgit.lfs.server, org.eclipse.jgit.lfs.lib", - org.eclipse.jgit.lfs.server.internal;version="5.1.3";x-internal:=true, - org.eclipse.jgit.lfs.server.s3;version="5.1.3"; + org.eclipse.jgit.lfs.server.internal;version="5.2.0";x-internal:=true, + org.eclipse.jgit.lfs.server.s3;version="5.2.0"; uses:="org.eclipse.jgit.lfs.server, org.eclipse.jgit.lfs.lib" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 @@ -25,15 +25,15 @@ Import-Package: com.google.gson;version="[2.8.0,3.0.0)", javax.servlet.http;version="[3.1.0,4.0.0)", org.apache.http;version="[4.3.0,5.0.0)", org.apache.http.client;version="[4.3.0,5.0.0)", - org.eclipse.jgit.annotations;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.internal;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.nls;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.http;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.http.apache;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)", + org.eclipse.jgit.annotations;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.internal;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.nls;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.http;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.http.apache;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)", org.slf4j;version="[1.7.0,2.0.0)" diff --git a/org.eclipse.jgit.lfs.server/pom.xml b/org.eclipse.jgit.lfs.server/pom.xml index 910c13aa2f..6a708d5f54 100644 --- a/org.eclipse.jgit.lfs.server/pom.xml +++ b/org.eclipse.jgit.lfs.server/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.lfs.server</artifactId> diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java index b21c94e4e6..7b76cecf0c 100644 --- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java +++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java @@ -411,7 +411,8 @@ class SignerV4 { String stringToSign = stringToSign(SCHEME, ALGORITHM, dateTimeStamp, scope, canonicalRequest); - byte[] signature = (SCHEME + bucketConfig.getSecretKey()).getBytes(); + byte[] signature = (SCHEME + bucketConfig.getSecretKey()) + .getBytes(UTF_8); signature = sign(dateStamp, signature); signature = sign(bucketConfig.getRegion(), signature); signature = sign(S3, signature); diff --git a/org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.team.ui.prefs index ce7a0f0478..984263dd94 100644 --- a/org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.lfs.test/.settings/org.eclipse.mylyn.team.ui.prefs @@ -1,2 +1,2 @@ -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.lfs.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.lfs.test/META-INF/MANIFEST.MF index 2a5b5a546a..19c9953c90 100644 --- a/org.eclipse.jgit.lfs.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.lfs.test/META-INF/MANIFEST.MF @@ -3,23 +3,23 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.lfs.test Bundle-SymbolicName: org.eclipse.jgit.lfs.test -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Vendor: %provider_name Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Import-Package: org.eclipse.jgit.internal.storage.dfs;version="[5.1.3,5.2.0)", - org.eclipse.jgit.junit;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk.filter;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)", +Import-Package: org.eclipse.jgit.internal.storage.dfs;version="[5.2.0,5.3.0)", + org.eclipse.jgit.junit;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk.filter;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)", org.hamcrest.core;version="[1.1.0,2.0.0)", org.junit;version="[4.12,5.0.0)", org.junit.runner;version="[4.12,5.0.0)", org.junit.runners;version="[4.12,5.0.0)" -Export-Package: org.eclipse.jgit.lfs.test;version="5.1.3";x-friends:="org.eclipse.jgit.lfs.server.test" +Export-Package: org.eclipse.jgit.lfs.test;version="5.2.0";x-friends:="org.eclipse.jgit.lfs.server.test" diff --git a/org.eclipse.jgit.lfs.test/pom.xml b/org.eclipse.jgit.lfs.test/pom.xml index 5f00b1fa74..c04f9162b3 100644 --- a/org.eclipse.jgit.lfs.test/pom.xml +++ b/org.eclipse.jgit.lfs.test/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.lfs.test</artifactId> diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java index a1283ddf41..146a25ed3d 100644 --- a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java +++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java @@ -43,7 +43,7 @@ package org.eclipse.jgit.lfs.lib; -import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.ByteArrayOutputStream; @@ -66,7 +66,7 @@ public class LFSPointerTest { assertEquals( "version https://git-lfs.github.com/spec/v1\noid sha256:" + s + "\nsize 4\n", - baos.toString(CHARACTER_ENCODING)); + baos.toString(UTF_8.name())); } } } diff --git a/org.eclipse.jgit.lfs/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.lfs/.settings/org.eclipse.mylyn.team.ui.prefs index ce7a0f0478..984263dd94 100644 --- a/org.eclipse.jgit.lfs/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.lfs/.settings/org.eclipse.mylyn.team.ui.prefs @@ -1,2 +1,2 @@ -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.lfs/META-INF/MANIFEST.MF b/org.eclipse.jgit.lfs/META-INF/MANIFEST.MF index 8785903456..f3ab7fc038 100644 --- a/org.eclipse.jgit.lfs/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.lfs/META-INF/MANIFEST.MF @@ -3,33 +3,33 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.lfs Bundle-SymbolicName: org.eclipse.jgit.lfs -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Localization: plugin Bundle-Vendor: %provider_name -Export-Package: org.eclipse.jgit.lfs;version="5.1.3", - org.eclipse.jgit.lfs.errors;version="5.1.3", - org.eclipse.jgit.lfs.internal;version="5.1.3";x-friends:="org.eclipse.jgit.lfs.test,org.eclipse.jgit.lfs.server.fs,org.eclipse.jgit.lfs.server", - org.eclipse.jgit.lfs.lib;version="5.1.3" +Export-Package: org.eclipse.jgit.lfs;version="5.2.0", + org.eclipse.jgit.lfs.errors;version="5.2.0", + org.eclipse.jgit.lfs.internal;version="5.2.0";x-friends:="org.eclipse.jgit.lfs.test,org.eclipse.jgit.lfs.server.fs,org.eclipse.jgit.lfs.server", + org.eclipse.jgit.lfs.lib;version="5.2.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: com.google.gson;version="[2.8.2,3.0.0)", com.google.gson.stream;version="[2.8.2,3.0.0)", org.apache.http.impl.client;version="[4.2.6,5.0.0)", org.apache.http.impl.conn;version="[4.2.6,5.0.0)", - org.eclipse.jgit.annotations;version="[5.1.3,5.2.0)";resolution:=optional, - org.eclipse.jgit.api.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.attributes;version="[5.1.3,5.2.0)", - org.eclipse.jgit.diff;version="[5.1.3,5.2.0)", - org.eclipse.jgit.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.hooks;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.nls;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.storage.pack;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.http;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk.filter;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util.io;version="[5.1.3,5.2.0)" + org.eclipse.jgit.annotations;version="[5.2.0,5.3.0)";resolution:=optional, + org.eclipse.jgit.api.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.attributes;version="[5.2.0,5.3.0)", + org.eclipse.jgit.diff;version="[5.2.0,5.3.0)", + org.eclipse.jgit.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.hooks;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.nls;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.storage.pack;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.http;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk.filter;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util.io;version="[5.2.0,5.3.0)" diff --git a/org.eclipse.jgit.lfs/pom.xml b/org.eclipse.jgit.lfs/pom.xml index d2ec285c9e..f49b8b6c75 100644 --- a/org.eclipse.jgit.lfs/pom.xml +++ b/org.eclipse.jgit.lfs/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.lfs</artifactId> diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java index fac87c177e..7bacf49269 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/SmudgeFilter.java @@ -222,7 +222,10 @@ public class SmudgeFilter extends FilterCommand { Integer.valueOf(responseCode))); } Path path = lfs.getMediaFile(ptr.getOid()); - path.getParent().toFile().mkdirs(); + Path parent = path.getParent(); + if (parent != null) { + parent.toFile().mkdirs(); + } try (InputStream contentIn = contentServerConn .getInputStream()) { long bytesCopied = Files.copy(contentIn, path); diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.feature/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.packaging/org.eclipse.jgit.feature/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.feature/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.feature/.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.packaging/org.eclipse.jgit.feature/feature.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.feature/feature.xml index f95bad6c61..9343e36ce2 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.feature/feature.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.eclipse.jgit" label="%featureName" - version="5.1.3.qualifier" + version="5.2.0.qualifier" provider-name="%providerName"> <description url="http://www.eclipse.org/jgit/"> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.feature/pom.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.feature/pom.xml index 8571e8ce54..48e1a45952 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.feature/pom.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.feature/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>jgit.tycho.parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <groupId>org.eclipse.jgit.feature</groupId> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.http.apache.feature/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.packaging/org.eclipse.jgit.http.apache.feature/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.http.apache.feature/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.http.apache.feature/.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.packaging/org.eclipse.jgit.http.apache.feature/feature.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.http.apache.feature/feature.xml index 4829918193..10dc8a3081 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.http.apache.feature/feature.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.http.apache.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.eclipse.jgit.http.apache" label="%featureName" - version="5.1.3.qualifier" + version="5.2.0.qualifier" provider-name="%providerName"> <description url="http://www.eclipse.org/jgit/"> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.http.apache.feature/pom.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.http.apache.feature/pom.xml index 3872c46361..b833f98f73 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.http.apache.feature/pom.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.http.apache.feature/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>jgit.tycho.parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <groupId>org.eclipse.jgit.feature</groupId> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/.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.packaging/org.eclipse.jgit.junit.feature/feature.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/feature.xml index 99ebd30a4e..cae4dd9c2e 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/feature.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.eclipse.jgit.junit" label="%featureName" - version="5.1.3.qualifier" + version="5.2.0.qualifier" provider-name="%providerName"> <description url="http://www.eclipse.org/jgit/"> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/pom.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/pom.xml index c19f0799e4..ad32702dfc 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/pom.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>jgit.tycho.parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <groupId>org.eclipse.jgit.feature</groupId> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.lfs.feature/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.packaging/org.eclipse.jgit.lfs.feature/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.lfs.feature/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.lfs.feature/.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.packaging/org.eclipse.jgit.lfs.feature/feature.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.lfs.feature/feature.xml index 92bacfe97e..692d48c0d1 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.lfs.feature/feature.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.lfs.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.eclipse.jgit.lfs" label="%featureName" - version="5.1.3.qualifier" + version="5.2.0.qualifier" provider-name="%providerName"> <description url="http://www.eclipse.org/jgit/"> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.lfs.feature/pom.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.lfs.feature/pom.xml index d6e96b3330..b88eba080f 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.lfs.feature/pom.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.lfs.feature/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>jgit.tycho.parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <groupId>org.eclipse.jgit.feature</groupId> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/.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.packaging/org.eclipse.jgit.pgm.feature/feature.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/feature.xml index e43008cf08..bbf0c6fd84 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/feature.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.eclipse.jgit.pgm" label="%featureName" - version="5.1.3.qualifier" + version="5.2.0.qualifier" provider-name="%providerName"> <description url="http://www.eclipse.org/jgit/"> @@ -31,8 +31,8 @@ version="0.0.0"/> <requires> - <import feature="org.eclipse.jgit" version="5.1.3" match="equivalent"/> - <import feature="org.eclipse.jgit.lfs" version="5.1.3" match="equivalent"/> + <import feature="org.eclipse.jgit" version="5.2.0" match="equivalent"/> + <import feature="org.eclipse.jgit.lfs" version="5.2.0" match="equivalent"/> </requires> <plugin diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/pom.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/pom.xml index cf4ff9d58d..0854a57e5e 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/pom.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>jgit.tycho.parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <groupId>org.eclipse.jgit.feature</groupId> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.source.feature/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.source.feature/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.source.feature/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.source.feature/.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.packaging/org.eclipse.jgit.pgm.source.feature/feature.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.source.feature/feature.xml index b3e587657f..a70e79126f 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.source.feature/feature.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.source.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.eclipse.jgit.pgm.source" label="%featureName" - version="5.1.3.qualifier" + version="5.2.0.qualifier" provider-name="%providerName"> <description url="http://www.eclipse.org/jgit/"> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.source.feature/pom.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.source.feature/pom.xml index f83679021b..1287d059d4 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.source.feature/pom.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.source.feature/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>jgit.tycho.parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <groupId>org.eclipse.jgit.feature</groupId> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/.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.packaging/org.eclipse.jgit.repository/pom.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/pom.xml index 4e91331ad9..c5681bd38b 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/pom.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>jgit.tycho.parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.repository</artifactId> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/.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.packaging/org.eclipse.jgit.source.feature/feature.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/feature.xml index 0789a8fa83..1581663980 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/feature.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.eclipse.jgit.source" label="%featureName" - version="5.1.3.qualifier" + version="5.2.0.qualifier" provider-name="%providerName"> <description url="http://www.eclipse.org/jgit/"> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/pom.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/pom.xml index 643297ea9d..82e055f137 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/pom.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>jgit.tycho.parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <groupId>org.eclipse.jgit.feature</groupId> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/META-INF/MANIFEST.MF b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/META-INF/MANIFEST.MF index d0c1cdcf2b..ebe9a531b9 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/META-INF/MANIFEST.MF @@ -2,4 +2,4 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: JGit Target Platform Bundle Bundle-SymbolicName: org.eclipse.jgit.target -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/pom.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/pom.xml index f5b0078c77..7e5755f54e 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/pom.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/pom.xml @@ -49,7 +49,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>jgit.tycho.parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.target</artifactId> diff --git a/org.eclipse.jgit.packaging/pom.xml b/org.eclipse.jgit.packaging/pom.xml index 142a70639d..4d04a35bd3 100644 --- a/org.eclipse.jgit.packaging/pom.xml +++ b/org.eclipse.jgit.packaging/pom.xml @@ -53,7 +53,7 @@ <groupId>org.eclipse.jgit</groupId> <artifactId>jgit.tycho.parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> <packaging>pom</packaging> <name>JGit Tycho Parent</name> diff --git a/org.eclipse.jgit.pgm.test/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.pgm.test/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.pgm.test/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.pgm.test/.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.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF index 49c0e58093..f9e9984ff9 100644 --- a/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF @@ -3,28 +3,28 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.pgm.test Bundle-SymbolicName: org.eclipse.jgit.pgm.test -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Vendor: %provider_name Bundle-Localization: plugin Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Import-Package: org.eclipse.jgit.api;version="[5.1.3,5.2.0)", - org.eclipse.jgit.api.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.diff;version="[5.1.3,5.2.0)", - org.eclipse.jgit.dircache;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.file;version="5.1.3", - org.eclipse.jgit.junit;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.merge;version="[5.1.3,5.2.0)", - org.eclipse.jgit.pgm;version="[5.1.3,5.2.0)", - org.eclipse.jgit.pgm.internal;version="[5.1.3,5.2.0)", - org.eclipse.jgit.pgm.opt;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util.io;version="[5.1.3,5.2.0)", +Import-Package: org.eclipse.jgit.api;version="[5.2.0,5.3.0)", + org.eclipse.jgit.api.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.diff;version="[5.2.0,5.3.0)", + org.eclipse.jgit.dircache;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.file;version="5.2.0", + org.eclipse.jgit.junit;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.merge;version="[5.2.0,5.3.0)", + org.eclipse.jgit.pgm;version="[5.2.0,5.3.0)", + org.eclipse.jgit.pgm.internal;version="[5.2.0,5.3.0)", + org.eclipse.jgit.pgm.opt;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util.io;version="[5.2.0,5.3.0)", org.hamcrest.core;bundle-version="[1.1.0,2.0.0)", org.junit;version="[4.12,5.0.0)", org.junit.rules;version="[4.12,5.0.0)", diff --git a/org.eclipse.jgit.pgm.test/pom.xml b/org.eclipse.jgit.pgm.test/pom.xml index 25c7962326..6c8ce35fa9 100644 --- a/org.eclipse.jgit.pgm.test/pom.xml +++ b/org.eclipse.jgit.pgm.test/pom.xml @@ -50,7 +50,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.pgm.test</artifactId> diff --git a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java index 81875f11bc..9ad22ddf2e 100644 --- a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java +++ b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java @@ -42,11 +42,13 @@ */ package org.eclipse.jgit.pgm; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertNull; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; @@ -153,7 +155,8 @@ public class CLIGitCommand extends Main { @Override PrintWriter createErrorWriter() { - return new PrintWriter(result.err); + return new PrintWriter(new OutputStreamWriter( + result.err, UTF_8)); } @Override @@ -249,19 +252,19 @@ public class CLIGitCommand extends Main { } public String outString() { - return out.toString(); + return new String(out.toByteArray(), UTF_8); } public List<String> outLines() { - return IO.readLines(out.toString()); + return IO.readLines(outString()); } public String errString() { - return err.toString(); + return new String(err.toByteArray(), UTF_8); } public List<String> errLines() { - return IO.readLines(err.toString()); + return IO.readLines(errString()); } } diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java index 40a223d92f..42530f3a34 100644 --- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java @@ -37,6 +37,7 @@ */ package org.eclipse.jgit.pgm; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.ByteArrayOutputStream; @@ -47,7 +48,6 @@ import java.net.MalformedURLException; import java.util.List; import java.util.Map; -import org.eclipse.jgit.lib.Constants; import org.junit.Before; import org.junit.Test; @@ -204,7 +204,7 @@ public class ProxyConfigTest { while ((length = inputStream.read(buffer)) != -1) { result.write(buffer, 0, length); } - return result.toString(Constants.CHARACTER_ENCODING); + return result.toString(UTF_8.name()); } } } 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 ddc84bea06..abd85566ad 100644 --- a/org.eclipse.jgit.pgm/BUILD +++ b/org.eclipse.jgit.pgm/BUILD @@ -7,6 +7,7 @@ java_library( deps = [ ":services", "//lib:args4j", + "//lib:commons-logging", "//lib:httpclient", "//lib:httpcore", "//lib:jetty-http", diff --git a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF index abe59f46aa..ecce3baeab 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.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Vendor: %provider_name Bundle-ActivationPolicy: lazy Bundle-Localization: plugin @@ -28,49 +28,49 @@ 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.3,5.2.0)", - org.eclipse.jgit.api.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.archive;version="[5.1.3,5.2.0)", - org.eclipse.jgit.awtui;version="[5.1.3,5.2.0)", - org.eclipse.jgit.blame;version="[5.1.3,5.2.0)", - org.eclipse.jgit.diff;version="[5.1.3,5.2.0)", - org.eclipse.jgit.dircache;version="[5.1.3,5.2.0)", - org.eclipse.jgit.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.gitrepo;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.ketch;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.dfs;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.io;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.pack;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.reftable;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.reftree;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.server;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.server.fs;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs.server.s3;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.merge;version="[5.1.3,5.2.0)", - org.eclipse.jgit.nls;version="[5.1.3,5.2.0)", - org.eclipse.jgit.notes;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revplot;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk.filter;version="[5.1.3,5.2.0)", - org.eclipse.jgit.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.storage.pack;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.http.apache;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.resolver;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk.filter;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util.io;version="[5.1.3,5.2.0)", + org.eclipse.jgit.api;version="[5.2.0,5.3.0)", + org.eclipse.jgit.api.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.archive;version="[5.2.0,5.3.0)", + org.eclipse.jgit.awtui;version="[5.2.0,5.3.0)", + org.eclipse.jgit.blame;version="[5.2.0,5.3.0)", + org.eclipse.jgit.diff;version="[5.2.0,5.3.0)", + org.eclipse.jgit.dircache;version="[5.2.0,5.3.0)", + org.eclipse.jgit.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.gitrepo;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.ketch;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.dfs;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.io;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.pack;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.reftable;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.reftree;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.server;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.server.fs;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs.server.s3;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.merge;version="[5.2.0,5.3.0)", + org.eclipse.jgit.nls;version="[5.2.0,5.3.0)", + org.eclipse.jgit.notes;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revplot;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk.filter;version="[5.2.0,5.3.0)", + org.eclipse.jgit.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.storage.pack;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.http.apache;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.resolver;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk.filter;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util.io;version="[5.2.0,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.3"; +Export-Package: org.eclipse.jgit.console;version="5.2.0"; uses:="org.eclipse.jgit.transport, org.eclipse.jgit.util", - org.eclipse.jgit.pgm;version="5.1.3"; + org.eclipse.jgit.pgm;version="5.2.0"; uses:="org.eclipse.jgit.revwalk, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.pgm.opt, @@ -81,11 +81,11 @@ Export-Package: org.eclipse.jgit.console;version="5.1.3"; org.eclipse.jgit.treewalk, javax.swing, org.eclipse.jgit.transport", - org.eclipse.jgit.pgm.debug;version="5.1.3"; + org.eclipse.jgit.pgm.debug;version="5.2.0"; uses:="org.eclipse.jgit.util.io, org.eclipse.jgit.pgm", - org.eclipse.jgit.pgm.internal;version="5.1.3";x-friends:="org.eclipse.jgit.pgm.test,org.eclipse.jgit.test", - org.eclipse.jgit.pgm.opt;version="5.1.3"; + org.eclipse.jgit.pgm.internal;version="5.2.0";x-friends:="org.eclipse.jgit.pgm.test,org.eclipse.jgit.test", + org.eclipse.jgit.pgm.opt;version="5.2.0"; 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 e550903184..c10ea7787a 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.3.qualifier -Eclipse-SourceBundle: org.eclipse.jgit.pgm;version="5.1.3.qualifier";roots="." +Bundle-Version: 5.2.0.qualifier +Eclipse-SourceBundle: org.eclipse.jgit.pgm;version="5.2.0.qualifier";roots="." diff --git a/org.eclipse.jgit.pgm/pom.xml b/org.eclipse.jgit.pgm/pom.xml index 4d5792913e..b229a8f985 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.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.pgm</artifactId> 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..66c84aff94 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,6 +59,7 @@ 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; @@ -168,6 +172,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 +205,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; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java index bb51b50487..300a01d246 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java @@ -474,7 +474,7 @@ class TextHashFunctions extends TextBuiltin { } /** Utility to help us identify unique lines in a file. */ - private class Line { + private static class Line { private final RawText txt; private final int pos; diff --git a/org.eclipse.jgit.test/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.test/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.test/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.test/.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.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.test/META-INF/MANIFEST.MF index 689db22b3a..2f828a4f39 100644 --- a/org.eclipse.jgit.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.test/META-INF/MANIFEST.MF @@ -3,58 +3,58 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.test Bundle-SymbolicName: org.eclipse.jgit.test -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Localization: plugin Bundle-Vendor: %provider_name Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: com.googlecode.javaewah;version="[1.1.6,2.0.0)", com.jcraft.jsch;version="[0.1.54,0.2.0)", - org.eclipse.jgit.api;version="[5.1.3,5.2.0)", - org.eclipse.jgit.api.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.attributes;version="[5.1.3,5.2.0)", - org.eclipse.jgit.awtui;version="[5.1.3,5.2.0)", - org.eclipse.jgit.blame;version="[5.1.3,5.2.0)", - org.eclipse.jgit.diff;version="[5.1.3,5.2.0)", - org.eclipse.jgit.dircache;version="[5.1.3,5.2.0)", - org.eclipse.jgit.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.events;version="[5.1.3,5.2.0)", - org.eclipse.jgit.fnmatch;version="[5.1.3,5.2.0)", - org.eclipse.jgit.gitrepo;version="[5.1.3,5.2.0)", - org.eclipse.jgit.hooks;version="[5.1.3,5.2.0)", - org.eclipse.jgit.ignore;version="[5.1.3,5.2.0)", - org.eclipse.jgit.ignore.internal;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.fsck;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.dfs;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.io;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.pack;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.reftable;version="[5.1.3,5.2.0)", - org.eclipse.jgit.internal.storage.reftree;version="[5.1.3,5.2.0)", - org.eclipse.jgit.junit;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lfs;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.merge;version="[5.1.3,5.2.0)", - org.eclipse.jgit.nls;version="[5.1.3,5.2.0)", - org.eclipse.jgit.notes;version="[5.1.3,5.2.0)", - org.eclipse.jgit.patch;version="[5.1.3,5.2.0)", - org.eclipse.jgit.pgm;version="[5.1.3,5.2.0)", - org.eclipse.jgit.pgm.internal;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revplot;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk.filter;version="[5.1.3,5.2.0)", - org.eclipse.jgit.storage.file;version="[5.1.3,5.2.0)", - org.eclipse.jgit.storage.pack;version="[5.1.3,5.2.0)", - org.eclipse.jgit.submodule;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.http;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport.resolver;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.treewalk.filter;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util.io;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util.sha1;version="[5.1.3,5.2.0)", + org.eclipse.jgit.api;version="[5.2.0,5.3.0)", + org.eclipse.jgit.api.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.attributes;version="[5.2.0,5.3.0)", + org.eclipse.jgit.awtui;version="[5.2.0,5.3.0)", + org.eclipse.jgit.blame;version="[5.2.0,5.3.0)", + org.eclipse.jgit.diff;version="[5.2.0,5.3.0)", + org.eclipse.jgit.dircache;version="[5.2.0,5.3.0)", + org.eclipse.jgit.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.events;version="[5.2.0,5.3.0)", + org.eclipse.jgit.fnmatch;version="[5.2.0,5.3.0)", + org.eclipse.jgit.gitrepo;version="[5.2.0,5.3.0)", + org.eclipse.jgit.hooks;version="[5.2.0,5.3.0)", + org.eclipse.jgit.ignore;version="[5.2.0,5.3.0)", + org.eclipse.jgit.ignore.internal;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.fsck;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.dfs;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.io;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.pack;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.reftable;version="[5.2.0,5.3.0)", + org.eclipse.jgit.internal.storage.reftree;version="[5.2.0,5.3.0)", + org.eclipse.jgit.junit;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lfs;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.merge;version="[5.2.0,5.3.0)", + org.eclipse.jgit.nls;version="[5.2.0,5.3.0)", + org.eclipse.jgit.notes;version="[5.2.0,5.3.0)", + org.eclipse.jgit.patch;version="[5.2.0,5.3.0)", + org.eclipse.jgit.pgm;version="[5.2.0,5.3.0)", + org.eclipse.jgit.pgm.internal;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revplot;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk.filter;version="[5.2.0,5.3.0)", + org.eclipse.jgit.storage.file;version="[5.2.0,5.3.0)", + org.eclipse.jgit.storage.pack;version="[5.2.0,5.3.0)", + org.eclipse.jgit.submodule;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.http;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport.resolver;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.treewalk.filter;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util.io;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util.sha1;version="[5.2.0,5.3.0)", org.junit;version="[4.12,5.0.0)", org.junit.experimental.theories;version="[4.12,5.0.0)", org.junit.rules;version="[4.12,5.0.0)", diff --git a/org.eclipse.jgit.test/pom.xml b/org.eclipse.jgit.test/pom.xml index b51cebce7a..6aa34f5b76 100644 --- a/org.eclipse.jgit.test/pom.xml +++ b/org.eclipse.jgit.test/pom.xml @@ -52,7 +52,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.test</artifactId> diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java index 911f659149..16cec6485c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java @@ -43,6 +43,7 @@ */ package org.eclipse.jgit.api; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.util.FileUtils.RECURSIVE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -118,7 +119,7 @@ public class AddCommandTest extends RepositoryTestCase { public void testAddExistingSingleFile() throws IOException, GitAPIException { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } @@ -489,7 +490,7 @@ public class AddCommandTest extends RepositoryTestCase { GitAPIException { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("row1\r\nrow2"); } @@ -519,7 +520,7 @@ public class AddCommandTest extends RepositoryTestCase { data.append("row1\r\nrow2"); } String crData = data.toString(); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print(crData); } String lfData = data.toString().replaceAll("\r", ""); @@ -544,7 +545,7 @@ public class AddCommandTest extends RepositoryTestCase { GitAPIException { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("row1\r\nrow2\u0000"); } @@ -570,7 +571,7 @@ public class AddCommandTest extends RepositoryTestCase { FileUtils.mkdir(new File(db.getWorkTree(), "sub")); File file = new File(db.getWorkTree(), "sub/a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } @@ -588,7 +589,7 @@ public class AddCommandTest extends RepositoryTestCase { GitAPIException { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } @@ -597,7 +598,7 @@ public class AddCommandTest extends RepositoryTestCase { dc.getEntry(0).getObjectId(); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("other content"); } @@ -613,7 +614,7 @@ public class AddCommandTest extends RepositoryTestCase { public void testAddExistingSingleFileTwiceWithCommit() throws Exception { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } @@ -624,7 +625,7 @@ public class AddCommandTest extends RepositoryTestCase { git.commit().setMessage("commit a.txt").call(); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("other content"); } @@ -640,7 +641,7 @@ public class AddCommandTest extends RepositoryTestCase { public void testAddRemovedFile() throws Exception { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } @@ -663,7 +664,7 @@ public class AddCommandTest extends RepositoryTestCase { public void testAddRemovedCommittedFile() throws Exception { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } @@ -690,13 +691,13 @@ public class AddCommandTest extends RepositoryTestCase { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } File file2 = new File(db.getWorkTree(), "b.txt"); FileUtils.createNewFile(file2); - try (PrintWriter writer = new PrintWriter(file2)) { + try (PrintWriter writer = new PrintWriter(file2, UTF_8.name())) { writer.print("content b"); } @@ -707,12 +708,12 @@ public class AddCommandTest extends RepositoryTestCase { addEntryToBuilder("b.txt", file2, newObjectInserter, builder, 0); addEntryToBuilder("a.txt", file, newObjectInserter, builder, 1); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("other content"); } addEntryToBuilder("a.txt", file, newObjectInserter, builder, 3); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("our content"); } addEntryToBuilder("a.txt", file, newObjectInserter, builder, 2) @@ -743,13 +744,13 @@ public class AddCommandTest extends RepositoryTestCase { public void testAddTwoFiles() throws Exception { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } File file2 = new File(db.getWorkTree(), "b.txt"); FileUtils.createNewFile(file2); - try (PrintWriter writer = new PrintWriter(file2)) { + try (PrintWriter writer = new PrintWriter(file2, UTF_8.name())) { writer.print("content b"); } @@ -767,13 +768,13 @@ public class AddCommandTest extends RepositoryTestCase { FileUtils.mkdir(new File(db.getWorkTree(), "sub")); File file = new File(db.getWorkTree(), "sub/a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } File file2 = new File(db.getWorkTree(), "sub/b.txt"); FileUtils.createNewFile(file2); - try (PrintWriter writer = new PrintWriter(file2)) { + try (PrintWriter writer = new PrintWriter(file2, UTF_8.name())) { writer.print("content b"); } @@ -791,19 +792,19 @@ public class AddCommandTest extends RepositoryTestCase { FileUtils.mkdir(new File(db.getWorkTree(), "sub")); File file = new File(db.getWorkTree(), "sub/a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } File ignoreFile = new File(db.getWorkTree(), ".gitignore"); FileUtils.createNewFile(ignoreFile); - try (PrintWriter writer = new PrintWriter(ignoreFile)) { + try (PrintWriter writer = new PrintWriter(ignoreFile, UTF_8.name())) { writer.print("sub/b.txt"); } File file2 = new File(db.getWorkTree(), "sub/b.txt"); FileUtils.createNewFile(file2); - try (PrintWriter writer = new PrintWriter(file2)) { + try (PrintWriter writer = new PrintWriter(file2, UTF_8.name())) { writer.print("content b"); } @@ -821,13 +822,13 @@ public class AddCommandTest extends RepositoryTestCase { FileUtils.mkdir(new File(db.getWorkTree(), "sub")); File file = new File(db.getWorkTree(), "sub/a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } File file2 = new File(db.getWorkTree(), "sub/b.txt"); FileUtils.createNewFile(file2); - try (PrintWriter writer = new PrintWriter(file2)) { + try (PrintWriter writer = new PrintWriter(file2, UTF_8.name())) { writer.print("content b"); } @@ -849,13 +850,13 @@ public class AddCommandTest extends RepositoryTestCase { FileUtils.mkdir(new File(db.getWorkTree(), "sub")); File file = new File(db.getWorkTree(), "sub/a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } File file2 = new File(db.getWorkTree(), "sub/b.txt"); FileUtils.createNewFile(file2); - try (PrintWriter writer = new PrintWriter(file2)) { + try (PrintWriter writer = new PrintWriter(file2, UTF_8.name())) { writer.print("content b"); } @@ -872,12 +873,12 @@ public class AddCommandTest extends RepositoryTestCase { // new unstaged file sub/c.txt File file3 = new File(db.getWorkTree(), "sub/c.txt"); FileUtils.createNewFile(file3); - try (PrintWriter writer = new PrintWriter(file3)) { + try (PrintWriter writer = new PrintWriter(file3, UTF_8.name())) { writer.print("content c"); } // file sub/a.txt is modified - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("modified content"); } @@ -904,13 +905,13 @@ public class AddCommandTest extends RepositoryTestCase { FileUtils.mkdir(new File(db.getWorkTree(), "sub")); File file = new File(db.getWorkTree(), "sub/a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } File file2 = new File(db.getWorkTree(), "sub/b.txt"); FileUtils.createNewFile(file2); - try (PrintWriter writer = new PrintWriter(file2)) { + try (PrintWriter writer = new PrintWriter(file2, UTF_8.name())) { writer.print("content b"); } @@ -927,12 +928,12 @@ public class AddCommandTest extends RepositoryTestCase { // new unstaged file sub/c.txt File file3 = new File(db.getWorkTree(), "sub/c.txt"); FileUtils.createNewFile(file3); - try (PrintWriter writer = new PrintWriter(file3)) { + try (PrintWriter writer = new PrintWriter(file3, UTF_8.name())) { writer.print("content c"); } // file sub/a.txt is modified - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("modified content"); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java index 1300f98d8a..1c41018161 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ArchiveCommandTest.java @@ -42,6 +42,7 @@ */ package org.eclipse.jgit.api; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -190,7 +191,8 @@ public class ArchiveCommandTest extends RepositoryTestCase { } } - private class MockFormat implements ArchiveCommand.Format<MockOutputStream> { + private static class MockFormat + implements ArchiveCommand.Format<MockOutputStream> { private Map<String, String> entries = new HashMap<>(); @@ -230,7 +232,9 @@ public class ArchiveCommandTest extends RepositoryTestCase { @Override public void putEntry(MockOutputStream out, ObjectId tree, String path, FileMode mode, ObjectLoader loader) { - String content = mode != FileMode.TREE ? new String(loader.getBytes()) : null; + String content = mode != FileMode.TREE + ? new String(loader.getBytes(), UTF_8) + : null; entries.put(path, content); } @@ -240,7 +244,7 @@ public class ArchiveCommandTest extends RepositoryTestCase { } } - public class MockOutputStream extends OutputStream { + public static class MockOutputStream extends OutputStream { private int foo; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java index 0d7009dca4..6b5fe502b7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java @@ -370,8 +370,7 @@ public class CloneCommandTest extends RepositoryTestCase { } @Test - public void testCloneRepositoryOnlyOneBranch() throws IOException, - JGitInternalException, GitAPIException { + public void testCloneRepositoryOnlyOneBranch() throws Exception { File directory = createTempDirectory("testCloneRepositoryWithBranch"); CloneCommand command = Git.cloneRepository(); command.setBranch("refs/heads/master"); @@ -382,25 +381,47 @@ public class CloneCommandTest extends RepositoryTestCase { Git git2 = command.call(); addRepoToClose(git2.getRepository()); assertNotNull(git2); + assertNull(git2.getRepository().resolve("tag-for-blob")); + assertNotNull(git2.getRepository().resolve("tag-initial")); assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master"); assertEquals("refs/remotes/origin/master", allRefNames(git2 .branchList().setListMode(ListMode.REMOTE).call())); + RemoteConfig cfg = new RemoteConfig(git2.getRepository().getConfig(), + Constants.DEFAULT_REMOTE_NAME); + List<RefSpec> specs = cfg.getFetchRefSpecs(); + assertEquals(1, specs.size()); + assertEquals( + new RefSpec("+refs/heads/master:refs/remotes/origin/master"), + specs.get(0)); + } + @Test + public void testBareCloneRepositoryOnlyOneBranch() throws Exception { // Same thing, but now test with bare repo - directory = createTempDirectory("testCloneRepositoryWithBranch_bare"); - command = Git.cloneRepository(); + File directory = createTempDirectory( + "testCloneRepositoryWithBranch_bare"); + CloneCommand command = Git.cloneRepository(); command.setBranch("refs/heads/master"); command.setBranchesToClone(Collections .singletonList("refs/heads/master")); command.setDirectory(directory); command.setURI(fileUri()); command.setBare(true); - git2 = command.call(); + Git git2 = command.call(); addRepoToClose(git2.getRepository()); assertNotNull(git2); + assertNull(git2.getRepository().resolve("tag-for-blob")); + assertNotNull(git2.getRepository().resolve("tag-initial")); assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master"); assertEquals("refs/heads/master", allRefNames(git2.branchList() .setListMode(ListMode.ALL).call())); + RemoteConfig cfg = new RemoteConfig(git2.getRepository().getConfig(), + Constants.DEFAULT_REMOTE_NAME); + List<RefSpec> specs = cfg.getFetchRefSpecs(); + assertEquals(1, specs.size()); + assertEquals( + new RefSpec("+refs/heads/master:refs/heads/master"), + specs.get(0)); } public static String allRefNames(List<Ref> refs) { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java index ca0630ea35..c028ca300c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java @@ -42,6 +42,7 @@ */ package org.eclipse.jgit.api; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -120,7 +121,7 @@ public class CommitAndLogCommandTest extends RepositoryTestCase { // create first file File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content1"); } @@ -131,7 +132,7 @@ public class CommitAndLogCommandTest extends RepositoryTestCase { // create second file file = new File(db.getWorkTree(), "b.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content2"); } @@ -231,7 +232,7 @@ public class CommitAndLogCommandTest extends RepositoryTestCase { JGitInternalException, GitAPIException { File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content"); } @@ -242,7 +243,7 @@ public class CommitAndLogCommandTest extends RepositoryTestCase { assertEquals("6b584e8ece562ebffc15d38808cd6b98fc3d97ea", tw.getObjectId(0).getName()); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content2"); } commit = git.commit().setMessage("second commit").call(); @@ -265,7 +266,7 @@ public class CommitAndLogCommandTest extends RepositoryTestCase { // create file File file = new File(db.getWorkTree(), "a.txt"); FileUtils.createNewFile(file); - try (PrintWriter writer = new PrintWriter(file)) { + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { writer.print("content1"); } @@ -358,7 +359,7 @@ public class CommitAndLogCommandTest extends RepositoryTestCase { messageHeader + messageFooter) .setInsertChangeId(true).call(); // we should find a real change id (at the end of the file) - byte[] chars = commit.getFullMessage().getBytes(); + byte[] chars = commit.getFullMessage().getBytes(UTF_8); int lastLineBegin = RawParseUtils.prevLF(chars, chars.length - 2); String lastLine = RawParseUtils.decode(chars, lastLineBegin + 1, chars.length); @@ -371,7 +372,7 @@ public class CommitAndLogCommandTest extends RepositoryTestCase { .setInsertChangeId(true).call(); // we should find a real change id (in the line as dictated by the // template) - chars = commit.getFullMessage().getBytes(); + chars = commit.getFullMessage().getBytes(UTF_8); int lineStart = 0; int lineEnd = 0; for (int i = 0; i < 4; i++) { @@ -389,7 +390,7 @@ public class CommitAndLogCommandTest extends RepositoryTestCase { messageHeader + changeIdTemplate + messageFooter) .setInsertChangeId(false).call(); // we should find the untouched template - chars = commit.getFullMessage().getBytes(); + chars = commit.getFullMessage().getBytes(UTF_8); lineStart = 0; lineEnd = 0; for (int i = 0; i < 4; i++) { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java index bbd6ec0bde..83181eea23 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java @@ -43,6 +43,7 @@ */ package org.eclipse.jgit.api; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -1298,7 +1299,7 @@ public class CommitOnlyTest extends RepositoryTestCase { final TreeWalk tw = TreeWalk.forPath(repo, path, rw.parseTree(headId)); return new String(tw.getObjectReader().open(tw.getObjectId(0)) - .getBytes()); + .getBytes(), UTF_8); } } catch (Exception e) { return ""; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CrLfNativeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CrLfNativeTest.java new file mode 100644 index 0000000000..c72612850a --- /dev/null +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CrLfNativeTest.java @@ -0,0 +1,181 @@ +/* + * 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.api; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.jgit.api.ResetCommand.ResetType; +import org.eclipse.jgit.junit.MockSystemReader; +import org.eclipse.jgit.junit.RepositoryTestCase; +import org.eclipse.jgit.lib.CoreConfig.EolStreamType; +import org.eclipse.jgit.storage.file.FileBasedConfig; +import org.eclipse.jgit.treewalk.FileTreeIterator; +import org.eclipse.jgit.treewalk.TreeWalk; +import org.eclipse.jgit.treewalk.TreeWalk.OperationType; +import org.eclipse.jgit.util.SystemReader; +import org.junit.Test; + +public class CrLfNativeTest extends RepositoryTestCase { + + @Test + public void checkoutWithCrLfNativeUnix() throws Exception { + verifyNativeCheckout(new MockSystemReader() { + { + setUnix(); + } + }); + } + + @Test + public void checkoutWithCrLfNativeWindows() throws Exception { + verifyNativeCheckout(new MockSystemReader() { + { + setWindows(); + } + }); + } + + private void verifyNativeCheckout(SystemReader systemReader) + throws Exception { + SystemReader.setInstance(systemReader); + Git git = Git.wrap(db); + FileBasedConfig config = db.getConfig(); + config.setString("core", null, "autocrlf", "false"); + config.setString("core", null, "eol", "native"); + config.save(); + // core.eol is active only if text is set, or if text=auto + writeTrashFile(".gitattributes", "*.txt text\n"); + File file = writeTrashFile("file.txt", "line 1\nline 2\n"); + git.add().addFilepattern("file.txt").addFilepattern(".gitattributes") + .call(); + git.commit().setMessage("Initial").call(); + // Check-in with core.eol=native normalization + assertEquals( + "[.gitattributes, mode:100644, content:*.txt text\n]" + + "[file.txt, mode:100644, content:line 1\nline 2\n]", + indexState(CONTENT)); + writeTrashFile("file.txt", "something else"); + git.add().addFilepattern("file.txt").call(); + git.commit().setMessage("New commit").call(); + git.reset().setMode(ResetType.HARD).setRef("HEAD~").call(); + // Check-out should convert to the native line separator + checkFile(file, systemReader.isWindows() ? "line 1\r\nline 2\r\n" + : "line 1\nline 2\n"); + Status status = git.status().call(); + assertTrue("git status should be clean", status.isClean()); + } + + /** + * Verifies the handling of the crlf attribute: crlf == text, -crlf == + * -text, crlf=input == eol=lf + * + * @throws Exception + */ + @Test + public void testCrLfAttribute() throws Exception { + FileBasedConfig config = db.getConfig(); + config.setString("core", null, "autocrlf", "false"); + config.setString("core", null, "eol", "crlf"); + config.save(); + writeTrashFile(".gitattributes", + "*.txt text\n*.crlf crlf\n*.bin -text\n*.nocrlf -crlf\n*.input crlf=input\n*.eol eol=lf"); + writeTrashFile("foo.txt", ""); + writeTrashFile("foo.crlf", ""); + writeTrashFile("foo.bin", ""); + writeTrashFile("foo.nocrlf", ""); + writeTrashFile("foo.input", ""); + writeTrashFile("foo.eol", ""); + Map<String, EolStreamType> inTypes = new HashMap<>(); + Map<String, EolStreamType> outTypes = new HashMap<>(); + try (TreeWalk walk = new TreeWalk(db)) { + walk.addTree(new FileTreeIterator(db)); + while (walk.next()) { + String path = walk.getPathString(); + if (".gitattributes".equals(path)) { + continue; + } + EolStreamType in = walk + .getEolStreamType(OperationType.CHECKIN_OP); + EolStreamType out = walk + .getEolStreamType(OperationType.CHECKOUT_OP); + inTypes.put(path, in); + outTypes.put(path, out); + } + } + assertEquals("", checkTypes("check-in", inTypes)); + assertEquals("", checkTypes("check-out", outTypes)); + } + + private String checkTypes(String prefix, Map<String, EolStreamType> types) { + StringBuilder result = new StringBuilder(); + EolStreamType a = types.get("foo.crlf"); + EolStreamType b = types.get("foo.txt"); + report(result, prefix, "crlf != text", a, b); + a = types.get("foo.nocrlf"); + b = types.get("foo.bin"); + report(result, prefix, "-crlf != -text", a, b); + a = types.get("foo.input"); + b = types.get("foo.eol"); + report(result, prefix, "crlf=input != eol=lf", a, b); + return result.toString(); + } + + private void report(StringBuilder result, String prefix, String label, + EolStreamType a, + EolStreamType b) { + if (a == null || b == null || !a.equals(b)) { + result.append(prefix).append(' ').append(label).append(": ") + .append(toString(a)).append(" != ").append(toString(b)) + .append('\n'); + } + } + + private String toString(EolStreamType type) { + return type == null ? "null" : type.name(); + } +} diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java index a422ef91cb..bb0714d233 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java @@ -42,13 +42,15 @@ */ package org.eclipse.jgit.api; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; import java.io.IOException; +import java.nio.file.Files; import java.util.Arrays; import java.util.Collection; @@ -404,7 +406,7 @@ public class DescribeCommandTest extends RepositoryTestCase { } private static void touch(File f, String contents) throws Exception { - try (FileWriter w = new FileWriter(f)) { + try (BufferedWriter w = Files.newBufferedWriter(f.toPath(), UTF_8)) { w.write(contents); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolRepositoryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolRepositoryTest.java index 48d373344e..47806cb99d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolRepositoryTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolRepositoryTest.java @@ -38,6 +38,7 @@ */ package org.eclipse.jgit.api; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -722,10 +723,10 @@ public class EolRepositoryTest extends RepositoryTestCase { } e.attrs = e.attrs.trim(); e.file = new String( - IO.readFully(new File(db.getWorkTree(), pathName))); + IO.readFully(new File(db.getWorkTree(), pathName)), UTF_8); DirCacheEntry dce = dirCache.getEntry(pathName); ObjectLoader open = walk.getObjectReader().open(dce.getObjectId()); - e.index = new String(open.getBytes()); + e.index = new String(open.getBytes(), UTF_8); e.indexContentLength = dce.getLength(); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java index 2b97b307bf..9b12011aab 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java @@ -82,6 +82,8 @@ public class ResetCommandTest extends RepositoryTestCase { private File indexFile; + private File indexNestedFile; + private File untrackedFile; private DirCacheEntry prestage; @@ -97,7 +99,7 @@ public class ResetCommandTest extends RepositoryTestCase { indexFile = writeTrashFile("a.txt", "content"); // create nested file - writeTrashFile("dir/b.txt", "content"); + indexNestedFile = writeTrashFile("dir/b.txt", "content"); // add files and commit them git.add().addFilepattern("a.txt").addFilepattern("dir/b.txt").call(); @@ -119,13 +121,16 @@ public class ResetCommandTest extends RepositoryTestCase { AmbiguousObjectException, IOException, GitAPIException { setupRepository(); ObjectId prevHead = db.resolve(Constants.HEAD); - assertSameAsHead(git.reset().setMode(ResetType.HARD) + ResetCommand reset = git.reset(); + assertSameAsHead(reset.setMode(ResetType.HARD) .setRef(initialCommit.getName()).call()); + assertFalse("reflog should be enabled", reset.isReflogDisabled()); // check if HEAD points to initial commit now ObjectId head = db.resolve(Constants.HEAD); assertEquals(initialCommit, head); // check if files were removed assertFalse(indexFile.exists()); + assertFalse(indexNestedFile.exists()); assertTrue(untrackedFile.exists()); // fileInIndex must no longer be in HEAD and in the index String fileInIndexPath = indexFile.getAbsolutePath(); @@ -148,6 +153,7 @@ public class ResetCommandTest extends RepositoryTestCase { assertEquals(initialCommit, head); // check if files were removed assertFalse(indexFile.exists()); + assertFalse(indexNestedFile.exists()); assertTrue(untrackedFile.exists()); // fileInIndex must no longer be in HEAD and in the index String fileInIndexPath = indexFile.getAbsolutePath(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeTest.java index f0d3c3690f..f4ccf0506b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeTest.java @@ -42,6 +42,7 @@ */ package org.eclipse.jgit.attributes; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.attributes.Attribute.State.SET; import static org.eclipse.jgit.attributes.Attribute.State.UNSET; import static org.junit.Assert.assertEquals; @@ -88,7 +89,7 @@ public class AttributesNodeTest { String attributeFileContent = "*.type1 A -B C=value\n" + "*.type2 -A B C=value2"; - is = new ByteArrayInputStream(attributeFileContent.getBytes()); + is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8)); AttributesNode node = new AttributesNode(); node.parse(is); assertAttribute("file.type1", node, @@ -102,7 +103,7 @@ public class AttributesNodeTest { String attributeFileContent = "!*.type1 A -B C=value\n" + "!*.type2 -A B C=value2"; - is = new ByteArrayInputStream(attributeFileContent.getBytes()); + is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8)); AttributesNode node = new AttributesNode(); node.parse(is); assertAttribute("file.type1", node, new Attributes()); @@ -113,7 +114,7 @@ public class AttributesNodeTest { public void testEmptyNegativeAttributeKey() throws IOException { String attributeFileContent = "*.type1 - \n" // + "*.type2 - -A"; - is = new ByteArrayInputStream(attributeFileContent.getBytes()); + is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8)); AttributesNode node = new AttributesNode(); node.parse(is); assertAttribute("file.type1", node, new Attributes()); @@ -125,7 +126,7 @@ public class AttributesNodeTest { String attributeFileContent = "*.type1 = \n" // + "*.type2 =value\n"// + "*.type3 attr=\n"; - is = new ByteArrayInputStream(attributeFileContent.getBytes()); + is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8)); AttributesNode node = new AttributesNode(); node.parse(is); assertAttribute("file.type1", node, new Attributes()); @@ -140,7 +141,7 @@ public class AttributesNodeTest { + " \n" // + "*.type2 -A B C=value2"; - is = new ByteArrayInputStream(attributeFileContent.getBytes()); + is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8)); AttributesNode node = new AttributesNode(); node.parse(is); assertAttribute("file.type1", node, @@ -156,7 +157,7 @@ public class AttributesNodeTest { + "*.type3 \t\t B\n" // + "*.type3\t-A";// - is = new ByteArrayInputStream(attributeFileContent.getBytes()); + is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8)); AttributesNode node = new AttributesNode(); node.parse(is); assertAttribute("file.type1", node, @@ -170,7 +171,7 @@ public class AttributesNodeTest { public void testDoubleAsteriskAtEnd() throws IOException { String attributeFileContent = "dir/** \tA -B\tC=value"; - is = new ByteArrayInputStream(attributeFileContent.getBytes()); + is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8)); AttributesNode node = new AttributesNode(); node.parse(is); assertAttribute("dir", node, diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java index d12f302dae..b6291bfca4 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderTest.java @@ -89,6 +89,7 @@ public class DirCacheBuilderTest extends RepositoryTestCase { assertEquals(0, e.getRawMode()); try { b.add(e); + fail("did not reject unset file mode"); } catch (IllegalArgumentException err) { assertEquals("FileMode not set for path a", err.getMessage()); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java index 92f0cf6196..3b330ab3b8 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java @@ -52,9 +52,9 @@ import static org.junit.Assert.fail; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileReader; import java.io.IOException; import java.net.URI; +import java.nio.file.Files; import java.util.HashMap; import java.util.Map; @@ -139,7 +139,7 @@ public class RepoCommandTest extends RepositoryTestCase { resolveRelativeUris(); } - class IndexedRepos implements RepoCommand.RemoteReader { + static class IndexedRepos implements RepoCommand.RemoteReader { Map<String, Repository> uriRepoMap; IndexedRepos() { uriRepoMap = new HashMap<>(); @@ -474,8 +474,8 @@ public class RepoCommandTest extends RepositoryTestCase { .call(); File hello = new File(db.getWorkTree(), "foo/hello.txt"); assertTrue("submodule should be checked out", hello.exists()); - try (BufferedReader reader = new BufferedReader( - new FileReader(hello))) { + try (BufferedReader reader = Files.newBufferedReader(hello.toPath(), + UTF_8)) { String content = reader.readLine(); assertEquals("submodule content should be as expected", "master world", content); @@ -565,8 +565,8 @@ public class RepoCommandTest extends RepositoryTestCase { // The original file should exist File hello = new File(localDb.getWorkTree(), "foo/hello.txt"); assertTrue("The original file should exist", hello.exists()); - try (BufferedReader reader = new BufferedReader( - new FileReader(hello))) { + try (BufferedReader reader = Files.newBufferedReader(hello.toPath(), + UTF_8)) { String content = reader.readLine(); assertEquals("The original file should have expected content", "master world", content); @@ -574,8 +574,8 @@ public class RepoCommandTest extends RepositoryTestCase { // The dest file should also exist hello = new File(localDb.getWorkTree(), "Hello"); assertTrue("The destination file should exist", hello.exists()); - try (BufferedReader reader = new BufferedReader( - new FileReader(hello))) { + try (BufferedReader reader = Files.newBufferedReader(hello.toPath(), + UTF_8)) { String content = reader.readLine(); assertEquals("The destination file should have expected content", "master world", content); @@ -610,8 +610,8 @@ public class RepoCommandTest extends RepositoryTestCase { assertTrue("The .gitmodules file should exist", gitmodules.exists()); // The first line of .gitmodules file should be expected - try (BufferedReader reader = new BufferedReader( - new FileReader(gitmodules))) { + try (BufferedReader reader = Files + .newBufferedReader(gitmodules.toPath(), UTF_8)) { String content = reader.readLine(); assertEquals( "The first line of .gitmodules file should be as expected", @@ -644,8 +644,8 @@ public class RepoCommandTest extends RepositoryTestCase { .setURI(rootUri) .call(); File hello = new File(db.getWorkTree(), "foo/hello.txt"); - try (BufferedReader reader = new BufferedReader( - new FileReader(hello))) { + try (BufferedReader reader = Files.newBufferedReader(hello.toPath(), + UTF_8)) { String content = reader.readLine(); assertEquals("submodule content should be as expected", "branch world", content); @@ -671,8 +671,8 @@ public class RepoCommandTest extends RepositoryTestCase { .setURI(rootUri) .call(); File hello = new File(db.getWorkTree(), "foo/hello.txt"); - try (BufferedReader reader = new BufferedReader( - new FileReader(hello))) { + try (BufferedReader reader = Files.newBufferedReader(hello.toPath(), + UTF_8)) { String content = reader.readLine(); assertEquals("submodule content should be as expected", "branch world", content); @@ -698,8 +698,8 @@ public class RepoCommandTest extends RepositoryTestCase { .setURI(rootUri) .call(); File hello = new File(db.getWorkTree(), "foo/hello.txt"); - try (BufferedReader reader = new BufferedReader( - new FileReader(hello))) { + try (BufferedReader reader = Files.newBufferedReader(hello.toPath(), + UTF_8)) { String content = reader.readLine(); assertEquals("submodule content should be as expected", "branch world", content); @@ -771,8 +771,8 @@ public class RepoCommandTest extends RepositoryTestCase { assertFalse("The foo/Hello file should be skipped", foohello.exists()); // The content of Hello file should be expected - try (BufferedReader reader = new BufferedReader( - new FileReader(hello))) { + try (BufferedReader reader = Files.newBufferedReader(hello.toPath(), + UTF_8)) { String content = reader.readLine(); assertEquals("The Hello file should have expected content", "branch world", content); @@ -829,8 +829,8 @@ public class RepoCommandTest extends RepositoryTestCase { // The .gitmodules file should have 'submodule "bar"' and shouldn't // have // 'submodule "foo"' lines. - try (BufferedReader reader = new BufferedReader( - new FileReader(dotmodules))) { + try (BufferedReader reader = Files + .newBufferedReader(dotmodules.toPath(), UTF_8)) { boolean foo = false; boolean bar = false; while (true) { @@ -879,8 +879,8 @@ public class RepoCommandTest extends RepositoryTestCase { } // Check .gitmodules file - try (BufferedReader reader = new BufferedReader( - new FileReader(dotmodules))) { + try (BufferedReader reader = Files + .newBufferedReader(dotmodules.toPath(), UTF_8)) { boolean foo = false; boolean foobar = false; boolean a = false; @@ -935,8 +935,8 @@ public class RepoCommandTest extends RepositoryTestCase { .call(); File hello = new File(localDb.getWorkTree(), "foo/hello.txt"); assertTrue("submodule should be checked out", hello.exists()); - try (BufferedReader reader = new BufferedReader( - new FileReader(hello))) { + try (BufferedReader reader = Files.newBufferedReader(hello.toPath(), + UTF_8)) { String content = reader.readLine(); assertEquals("submodule content should be as expected", "master world", content); @@ -1074,8 +1074,9 @@ public class RepoCommandTest extends RepositoryTestCase { ".gitattributes"); assertTrue("The .gitattributes file should exist", gitattributes.exists()); - try (BufferedReader reader = new BufferedReader( - new FileReader(gitattributes));) { + try (BufferedReader reader = Files + .newBufferedReader(gitattributes.toPath(), + UTF_8)) { String content = reader.readLine(); assertEquals(".gitattributes content should be as expected", "/test a1 a2", content); @@ -1142,8 +1143,8 @@ public class RepoCommandTest extends RepositoryTestCase { .setURI(rootUri) .call(); File hello = new File(db.getWorkTree(), "foo/hello.txt"); - try (BufferedReader reader = new BufferedReader( - new FileReader(hello))) { + try (BufferedReader reader = Files.newBufferedReader(hello.toPath(), + UTF_8)) { String content = reader.readLine(); assertEquals("submodule content should be as expected", "branch world", content); @@ -1169,8 +1170,8 @@ public class RepoCommandTest extends RepositoryTestCase { .setURI(rootUri) .call(); File hello = new File(db.getWorkTree(), "foo/hello.txt"); - try (BufferedReader reader = new BufferedReader( - new FileReader(hello))) { + try (BufferedReader reader = Files.newBufferedReader(hello.toPath(), + UTF_8)) { String content = reader.readLine(); assertEquals("submodule content should be as expected", "branch world", content); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java index deffa04b54..f6cb55870b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java @@ -43,14 +43,16 @@ package org.eclipse.jgit.internal.storage.file; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; import java.io.IOException; +import java.nio.file.Files; import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase; import org.eclipse.jgit.lib.ConfigConstants; @@ -120,18 +122,19 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase { Repository repo1 = createWorkRepository(); File dir = createTempDirectory("dir"); File dotGit = new File(dir, Constants.DOT_GIT); - try (FileWriter writer = new FileWriter(dotGit)) { - writer.append("gitdir: " + repo1.getDirectory().getAbsolutePath()).close(); - FileRepositoryBuilder builder = new FileRepositoryBuilder(); + try (BufferedWriter writer = Files.newBufferedWriter(dotGit.toPath(), + UTF_8)) { + writer.append("gitdir: " + repo1.getDirectory().getAbsolutePath()); + } + FileRepositoryBuilder builder = new FileRepositoryBuilder(); - builder.setWorkTree(dir); - builder.setMustExist(true); - Repository repo2 = builder.build(); + builder.setWorkTree(dir); + builder.setMustExist(true); + Repository repo2 = builder.build(); - assertEquals(repo1.getDirectory().getAbsolutePath(), repo2 - .getDirectory().getAbsolutePath()); - assertEquals(dir, repo2.getWorkTree()); - } + assertEquals(repo1.getDirectory().getAbsolutePath(), + repo2.getDirectory().getAbsolutePath()); + assertEquals(dir, repo2.getWorkTree()); } @Test @@ -140,20 +143,20 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase { File dir = new File(repo1.getWorkTree(), "dir"); assertTrue(dir.mkdir()); File dotGit = new File(dir, Constants.DOT_GIT); - try (FileWriter writer = new FileWriter(dotGit)) { - writer.append("gitdir: ../" + Constants.DOT_GIT).close(); - - FileRepositoryBuilder builder = new FileRepositoryBuilder(); - builder.setWorkTree(dir); - builder.setMustExist(true); - Repository repo2 = builder.build(); - - // The tmp directory may be a symlink so the actual path - // may not - assertEquals(repo1.getDirectory().getCanonicalPath(), repo2 - .getDirectory().getCanonicalPath()); - assertEquals(dir, repo2.getWorkTree()); + try (BufferedWriter writer = Files.newBufferedWriter(dotGit.toPath(), + UTF_8)) { + writer.append("gitdir: ../" + Constants.DOT_GIT); } + FileRepositoryBuilder builder = new FileRepositoryBuilder(); + builder.setWorkTree(dir); + builder.setMustExist(true); + Repository repo2 = builder.build(); + + // The tmp directory may be a symlink so the actual path + // may not + assertEquals(repo1.getDirectory().getCanonicalPath(), + repo2.getDirectory().getCanonicalPath()); + assertEquals(dir, repo2.getWorkTree()); } @Test @@ -161,22 +164,23 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase { Repository repo1 = createWorkRepository(); File dir = createTempDirectory("dir"); File dotGit = new File(dir, Constants.DOT_GIT); - try (FileWriter writer = new FileWriter(dotGit)) { + try (BufferedWriter writer = Files.newBufferedWriter(dotGit.toPath(), + UTF_8)) { writer.append( - "gitdir: " + repo1.getDirectory().getAbsolutePath()).close(); - FileRepositoryBuilder builder = new FileRepositoryBuilder(); - - builder.setWorkTree(dir); - builder.findGitDir(dir); - assertEquals(repo1.getDirectory().getAbsolutePath(), builder - .getGitDir().getAbsolutePath()); - builder.setMustExist(true); - Repository repo2 = builder.build(); - - // The tmp directory may be a symlink - assertEquals(repo1.getDirectory().getCanonicalPath(), repo2 - .getDirectory().getCanonicalPath()); - assertEquals(dir, repo2.getWorkTree()); + "gitdir: " + repo1.getDirectory().getAbsolutePath()); } + FileRepositoryBuilder builder = new FileRepositoryBuilder(); + + builder.setWorkTree(dir); + builder.findGitDir(dir); + assertEquals(repo1.getDirectory().getAbsolutePath(), + builder.getGitDir().getAbsolutePath()); + builder.setMustExist(true); + Repository repo2 = builder.build(); + + // The tmp directory may be a symlink + assertEquals(repo1.getDirectory().getCanonicalPath(), + repo2.getDirectory().getCanonicalPath()); + assertEquals(dir, repo2.getWorkTree()); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java index cbb73bb08e..3ca689ac01 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java @@ -42,6 +42,7 @@ package org.eclipse.jgit.internal.storage.file; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -189,7 +190,8 @@ public class ObjectDirectoryTest extends RepositoryTestCase { String commit = "d3148f9410b071edd4a4c85d2a43d1fa2574b0d2"; try (PrintWriter writer = new PrintWriter( - new File(repository.getDirectory(), Constants.SHALLOW))) { + new File(repository.getDirectory(), Constants.SHALLOW), + UTF_8.name())) { writer.println(commit); } Set<ObjectId> shallowCommits = dir.getShallowCommits(); @@ -205,7 +207,8 @@ public class ObjectDirectoryTest extends RepositoryTestCase { String commit = "X3148f9410b071edd4a4c85d2a43d1fa2574b0d2"; try (PrintWriter writer = new PrintWriter( - new File(repository.getDirectory(), Constants.SHALLOW))) { + new File(repository.getDirectory(), Constants.SHALLOW), + UTF_8.name())) { writer.println(commit); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogReaderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogReaderTest.java index dc05eeabe1..acdaf3aa3c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogReaderTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogReaderTest.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.internal.storage.file; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -67,31 +68,31 @@ import org.junit.Test; public class ReflogReaderTest extends SampleDataRepositoryTestCase { static byte[] oneLine = "da85355dfc525c9f6f3927b876f379f46ccf826e 3e7549db262d1e836d9bf0af7e22355468f1717c A O Thor Too <authortoo@wri.tr> 1243028200 +0200\tcommit: Add a toString for debugging to RemoteRefUpdate\n" - .getBytes(); + .getBytes(UTF_8); static byte[] twoLine = ("0000000000000000000000000000000000000000 c6734895958052a9dbc396cff4459dc1a25029ab A U Thor <thor@committer.au> 1243028201 -0100\tbranch: Created from rr/renamebranchv4\n" + "c6734895958052a9dbc396cff4459dc1a25029ab 54794942a18a237c57a80719afed44bb78172b10 Same A U Thor <same.author@example.com> 1243028202 +0100\trebase finished: refs/heads/rr/renamebranch5 onto c6e3b9fe2da0293f11eae202ec35fb343191a82d\n") - .getBytes(); + .getBytes(UTF_8); static byte[] twoLineWithAppendInProgress = ("0000000000000000000000000000000000000000 c6734895958052a9dbc396cff4459dc1a25029ab A U Thor <thor@committer.au> 1243028201 -0100\tbranch: Created from rr/renamebranchv4\n" + "c6734895958052a9dbc396cff4459dc1a25029ab 54794942a18a237c57a80719afed44bb78172b10 Same A U Thor <same.author@example.com> 1243028202 +0100\trebase finished: refs/heads/rr/renamebranch5 onto c6e3b9fe2da0293f11eae202ec35fb343191a82d\n" + "54794942a18a237c57a80719afed44bb78172b10 ") - .getBytes(); + .getBytes(UTF_8); static byte[] aLine = "1111111111111111111111111111111111111111 3e7549db262d1e836d9bf0af7e22355468f1717c A U Thor <thor@committer.au> 1243028201 -0100\tbranch: change to a\n" - .getBytes(); + .getBytes(UTF_8); static byte[] masterLine = "2222222222222222222222222222222222222222 3e7549db262d1e836d9bf0af7e22355468f1717c A U Thor <thor@committer.au> 1243028201 -0100\tbranch: change to master\n" - .getBytes(); + .getBytes(UTF_8); static byte[] headLine = "3333333333333333333333333333333333333333 3e7549db262d1e836d9bf0af7e22355468f1717c A U Thor <thor@committer.au> 1243028201 -0100\tbranch: change to HEAD\n" - .getBytes(); + .getBytes(UTF_8); static byte[] oneLineWithoutComment = "da85355dfc525c9f6f3927b876f379f46ccf826e 3e7549db262d1e836d9bf0af7e22355468f1717c A O Thor Too <authortoo@wri.tr> 1243028200 +0200\n" - .getBytes(); + .getBytes(UTF_8); static byte[] switchBranch = "0d43a6890a19fd657faad1c4cfbe3cb1b47851c3 4809df9c0d8bce5b00955563f77c5a9f25aa0d12 A O Thor Too <authortoo@wri.tr> 1315088009 +0200\tcheckout: moving from new/work to master\n" - .getBytes(); + .getBytes(UTF_8); @Test public void testReadOneLine() throws Exception { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogWriterTest.java index 1d188c3148..a84be7e9f0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogWriterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogWriterTest.java @@ -42,6 +42,7 @@ *******************************************************************************/ package org.eclipse.jgit.internal.storage.file; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.File; @@ -73,9 +74,9 @@ public class ReflogWriterTest extends SampleDataRepositoryTestCase { writer.log("refs/heads/master", oldId, newId, ident, "stash: Add\nmessage\r\nwith line feeds"); - byte[] buffer = new byte[oneLine.getBytes().length]; + byte[] buffer = new byte[oneLine.getBytes(UTF_8).length]; readReflog(buffer); - assertEquals(oneLine, new String(buffer)); + assertEquals(oneLine, new String(buffer, UTF_8)); } private void readReflog(byte[] buffer) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java index 02073226d0..96caa01a9e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java @@ -333,9 +333,9 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { public void test002_CreateBadTree() throws Exception { // We won't create a tree entry with an empty filename // + final TreeFormatter formatter = new TreeFormatter(); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage(JGitText.get().invalidTreeZeroLengthName); - final TreeFormatter formatter = new TreeFormatter(); formatter.append("", FileMode.TREE, ObjectId.fromString("4b825dc642cb6eb9a060e54bf8d69288fbee4904")); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java index 01426eeb8c..9063b65189 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java @@ -141,7 +141,7 @@ public class WindowCacheGetTest extends SampleDataRepositoryTestCase { } } - private class TestObject { + private static class TestObject { ObjectId id; int type; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java index c4c4da8165..21d8d66adf 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java @@ -48,6 +48,7 @@ package org.eclipse.jgit.lib; +import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.concurrent.TimeUnit.DAYS; import static java.util.concurrent.TimeUnit.HOURS; import static java.util.concurrent.TimeUnit.MILLISECONDS; @@ -66,11 +67,15 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; import org.eclipse.jgit.api.MergeCommand.FastForwardMode; import org.eclipse.jgit.errors.ConfigInvalidException; @@ -78,6 +83,7 @@ import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.junit.MockSystemReader; import org.eclipse.jgit.merge.MergeConfig; import org.eclipse.jgit.storage.file.FileBasedConfig; +import org.eclipse.jgit.transport.RefSpec; import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.SystemReader; import org.junit.After; @@ -94,6 +100,12 @@ public class ConfigTest { // A non-ASCII whitespace character: U+2002 EN QUAD. private static final char WS = '\u2002'; + private static final String REFS_ORIGIN = "+refs/heads/*:refs/remotes/origin/*"; + + private static final String REFS_UPSTREAM = "+refs/heads/*:refs/remotes/upstream/*"; + + private static final String REFS_BACKUP = "+refs/heads/*:refs/remotes/backup/*"; + @Rule public ExpectedException expectedEx = ExpectedException.none(); @@ -690,11 +702,7 @@ public class ConfigTest { assertEquals("", c.getString("a", null, "y")); assertArrayEquals(new String[]{""}, c.getStringList("a", null, "y")); - try { - c.getInt("a", null, "y", 1); - } catch (IllegalArgumentException e) { - assertEquals("Invalid integer value: a.y=", e.getMessage()); - } + assertEquals(1, c.getInt("a", null, "y", 1)); assertNull(c.getString("a", null, "z")); assertArrayEquals(new String[]{}, c.getStringList("a", null, "z")); @@ -711,11 +719,7 @@ public class ConfigTest { assertNull(c.getString("a", null, "y")); assertArrayEquals(new String[]{null}, c.getStringList("a", null, "y")); - try { - c.getInt("a", null, "y", 1); - } catch (IllegalArgumentException e) { - assertEquals("Invalid integer value: a.y=", e.getMessage()); - } + assertEquals(1, c.getInt("a", null, "y", 1)); assertNull(c.getString("a", null, "z")); assertArrayEquals(new String[]{}, c.getStringList("a", null, "z")); @@ -801,11 +805,9 @@ public class ConfigTest { public void testIncludeTooManyRecursions() throws IOException { File config = tmp.newFile("config"); String include = "[include]\npath=" + pathToString(config) + "\n"; - Files.write(config.toPath(), include.getBytes()); - FileBasedConfig fbConfig = new FileBasedConfig(null, config, - FS.DETECTED); + Files.write(config.toPath(), include.getBytes(UTF_8)); try { - fbConfig.load(); + loadConfig(config); fail(); } catch (ConfigInvalidException cie) { for (Throwable t = cie; t != null; t = t.getCause()) { @@ -824,7 +826,7 @@ public class ConfigTest { File config = tmp.newFile("config"); String fooBar = "[foo]\nbar=true\n"; - Files.write(config.toPath(), fooBar.getBytes()); + Files.write(config.toPath(), fooBar.getBytes(UTF_8)); Config parsed = parse("[include]\npath=" + pathToString(config) + "\n"); assertFalse(parsed.getBoolean("foo", "bar", false)); @@ -835,15 +837,13 @@ public class ConfigTest { throws IOException, ConfigInvalidException { File included = tmp.newFile("included"); String content = "[foo]\nbar=true\n"; - Files.write(included.toPath(), content.getBytes()); + Files.write(included.toPath(), content.getBytes(UTF_8)); File config = tmp.newFile("config"); content = "[Include]\npath=" + pathToString(included) + "\n"; - Files.write(config.toPath(), content.getBytes()); + Files.write(config.toPath(), content.getBytes(UTF_8)); - FileBasedConfig fbConfig = new FileBasedConfig(null, config, - FS.DETECTED); - fbConfig.load(); + FileBasedConfig fbConfig = loadConfig(config); assertTrue(fbConfig.getBoolean("foo", "bar", false)); } @@ -852,15 +852,13 @@ public class ConfigTest { throws IOException, ConfigInvalidException { File included = tmp.newFile("included"); String content = "[foo]\nbar=true\n"; - Files.write(included.toPath(), content.getBytes()); + Files.write(included.toPath(), content.getBytes(UTF_8)); File config = tmp.newFile("config"); content = "[include]\nPath=" + pathToString(included) + "\n"; - Files.write(config.toPath(), content.getBytes()); + Files.write(config.toPath(), content.getBytes(UTF_8)); - FileBasedConfig fbConfig = new FileBasedConfig(null, config, - FS.DETECTED); - fbConfig.load(); + FileBasedConfig fbConfig = loadConfig(config); assertTrue(fbConfig.getBoolean("foo", "bar", false)); } @@ -881,15 +879,13 @@ public class ConfigTest { File included = tmp.newFile("included"); String includedPath = pathToString(included); String content = "[include]\npath=\n"; - Files.write(included.toPath(), content.getBytes()); + Files.write(included.toPath(), content.getBytes(UTF_8)); File config = tmp.newFile("config"); String include = "[include]\npath=" + includedPath + "\n"; - Files.write(config.toPath(), include.getBytes()); - FileBasedConfig fbConfig = new FileBasedConfig(null, config, - FS.DETECTED); + Files.write(config.toPath(), include.getBytes(UTF_8)); try { - fbConfig.load(); + loadConfig(config); fail("Expected ConfigInvalidException"); } catch (ConfigInvalidException e) { // Check that there is some exception in the chain that contains @@ -904,6 +900,306 @@ public class ConfigTest { } } + @Test + public void testIncludeSetValueMustNotTouchIncludedLines1() + throws IOException, ConfigInvalidException { + File includedFile = createAllTypesIncludedContent(); + + File configFile = tmp.newFile("config"); + String content = createAllTypesSampleContent("Alice Parker", false, 11, + 21, 31, CoreConfig.AutoCRLF.FALSE, + "+refs/heads/*:refs/remotes/origin/*") + "\n[include]\npath=" + + pathToString(includedFile); + Files.write(configFile.toPath(), content.getBytes(UTF_8)); + + FileBasedConfig fbConfig = loadConfig(configFile); + assertValuesAsIncluded(fbConfig, REFS_ORIGIN, REFS_UPSTREAM); + assertSections(fbConfig, "user", "core", "remote", "include"); + + setAllValuesNew(fbConfig); + assertValuesAsIsSaveLoad(fbConfig, config -> { + assertValuesAsIncluded(config, REFS_BACKUP, REFS_UPSTREAM); + assertSections(fbConfig, "user", "core", "remote", "include"); + }); + } + + @Test + public void testIncludeSetValueMustNotTouchIncludedLines2() + throws IOException, ConfigInvalidException { + File includedFile = createAllTypesIncludedContent(); + + File configFile = tmp.newFile("config"); + String content = "[include]\npath=" + pathToString(includedFile) + "\n" + + createAllTypesSampleContent("Alice Parker", false, 11, 21, 31, + CoreConfig.AutoCRLF.FALSE, + "+refs/heads/*:refs/remotes/origin/*"); + Files.write(configFile.toPath(), content.getBytes(UTF_8)); + + FileBasedConfig fbConfig = loadConfig(configFile); + assertValuesAsConfig(fbConfig, REFS_UPSTREAM, REFS_ORIGIN); + assertSections(fbConfig, "include", "user", "core", "remote"); + + setAllValuesNew(fbConfig); + assertValuesAsIsSaveLoad(fbConfig, config -> { + assertValuesAsNew(config, REFS_UPSTREAM, REFS_BACKUP); + assertSections(fbConfig, "include", "user", "core", "remote"); + }); + } + + @Test + public void testIncludeSetValueOnFileWithJustContainsInclude() + throws IOException, ConfigInvalidException { + File includedFile = createAllTypesIncludedContent(); + + File configFile = tmp.newFile("config"); + String content = "[include]\npath=" + pathToString(includedFile); + Files.write(configFile.toPath(), content.getBytes(UTF_8)); + + FileBasedConfig fbConfig = loadConfig(configFile); + assertValuesAsIncluded(fbConfig, REFS_UPSTREAM); + assertSections(fbConfig, "include", "user", "core", "remote"); + + setAllValuesNew(fbConfig); + assertValuesAsIsSaveLoad(fbConfig, config -> { + assertValuesAsNew(config, REFS_UPSTREAM, REFS_BACKUP); + assertSections(fbConfig, "include", "user", "core", "remote"); + }); + } + + @Test + public void testIncludeSetValueOnFileWithJustEmptySection1() + throws IOException, ConfigInvalidException { + File includedFile = createAllTypesIncludedContent(); + + File configFile = tmp.newFile("config"); + String content = "[user]\n[include]\npath=" + + pathToString(includedFile); + Files.write(configFile.toPath(), content.getBytes(UTF_8)); + + FileBasedConfig fbConfig = loadConfig(configFile); + assertValuesAsIncluded(fbConfig, REFS_UPSTREAM); + assertSections(fbConfig, "user", "include", "core", "remote"); + + setAllValuesNew(fbConfig); + assertValuesAsIsSaveLoad(fbConfig, config -> { + assertValuesAsNewWithName(config, "Alice Muller", REFS_UPSTREAM, + REFS_BACKUP); + assertSections(fbConfig, "user", "include", "core", "remote"); + }); + } + + @Test + public void testIncludeSetValueOnFileWithJustEmptySection2() + throws IOException, ConfigInvalidException { + File includedFile = createAllTypesIncludedContent(); + + File configFile = tmp.newFile("config"); + String content = "[include]\npath=" + pathToString(includedFile) + + "\n[user]"; + Files.write(configFile.toPath(), content.getBytes(UTF_8)); + + FileBasedConfig fbConfig = loadConfig(configFile); + assertValuesAsIncluded(fbConfig, REFS_UPSTREAM); + assertSections(fbConfig, "include", "user", "core", "remote"); + + setAllValuesNew(fbConfig); + assertValuesAsIsSaveLoad(fbConfig, config -> { + assertValuesAsNew(config, REFS_UPSTREAM, REFS_BACKUP); + assertSections(fbConfig, "include", "user", "core", "remote"); + }); + } + + @Test + public void testIncludeSetValueOnFileWithJustExistingSection1() + throws IOException, ConfigInvalidException { + File includedFile = createAllTypesIncludedContent(); + + File configFile = tmp.newFile("config"); + String content = "[user]\nemail=alice@home\n[include]\npath=" + + pathToString(includedFile); + Files.write(configFile.toPath(), content.getBytes(UTF_8)); + + FileBasedConfig fbConfig = loadConfig(configFile); + assertValuesAsIncluded(fbConfig, REFS_UPSTREAM); + assertSections(fbConfig, "user", "include", "core", "remote"); + + setAllValuesNew(fbConfig); + assertValuesAsIsSaveLoad(fbConfig, config -> { + assertValuesAsNewWithName(config, "Alice Muller", REFS_UPSTREAM, + REFS_BACKUP); + assertSections(fbConfig, "user", "include", "core", "remote"); + }); + } + + @Test + public void testIncludeSetValueOnFileWithJustExistingSection2() + throws IOException, ConfigInvalidException { + File includedFile = createAllTypesIncludedContent(); + + File configFile = tmp.newFile("config"); + String content = "[include]\npath=" + pathToString(includedFile) + + "\n[user]\nemail=alice@home\n"; + Files.write(configFile.toPath(), content.getBytes(UTF_8)); + + FileBasedConfig fbConfig = loadConfig(configFile); + assertValuesAsIncluded(fbConfig, REFS_UPSTREAM); + assertSections(fbConfig, "include", "user", "core", "remote"); + + setAllValuesNew(fbConfig); + assertValuesAsIsSaveLoad(fbConfig, config -> { + assertValuesAsNew(config, REFS_UPSTREAM, REFS_BACKUP); + assertSections(fbConfig, "include", "user", "core", "remote"); + }); + } + + @Test + public void testIncludeUnsetSectionMustNotTouchIncludedLines() + throws IOException, ConfigInvalidException { + File includedFile = tmp.newFile("included"); + RefSpec includedRefSpec = new RefSpec(REFS_UPSTREAM); + String includedContent = "[remote \"origin\"]\n" + "fetch=" + + includedRefSpec; + Files.write(includedFile.toPath(), includedContent.getBytes(UTF_8)); + + File configFile = tmp.newFile("config"); + RefSpec refSpec = new RefSpec(REFS_ORIGIN); + String content = "[include]\npath=" + pathToString(includedFile) + "\n" + + "[remote \"origin\"]\n" + "fetch=" + refSpec; + Files.write(configFile.toPath(), content.getBytes(UTF_8)); + + FileBasedConfig fbConfig = loadConfig(configFile); + + Consumer<FileBasedConfig> assertion = config -> { + assertEquals(Arrays.asList(includedRefSpec, refSpec), + config.getRefSpecs("remote", "origin", "fetch")); + }; + assertion.accept(fbConfig); + + fbConfig.unsetSection("remote", "origin"); + assertValuesAsIsSaveLoad(fbConfig, config -> { + assertEquals(Collections.singletonList(includedRefSpec), + config.getRefSpecs("remote", "origin", "fetch")); + }); + } + + private File createAllTypesIncludedContent() throws IOException { + File includedFile = tmp.newFile("included"); + String includedContent = createAllTypesSampleContent("Alice Muller", + true, 10, 20, 30, CoreConfig.AutoCRLF.TRUE, + "+refs/heads/*:refs/remotes/upstream/*"); + Files.write(includedFile.toPath(), includedContent.getBytes(UTF_8)); + return includedFile; + } + + private static void assertValuesAsIsSaveLoad(FileBasedConfig fbConfig, + Consumer<FileBasedConfig> assertion) + throws IOException, ConfigInvalidException { + assertion.accept(fbConfig); + + fbConfig.save(); + assertion.accept(fbConfig); + + fbConfig = loadConfig(fbConfig.getFile()); + assertion.accept(fbConfig); + } + + private static void setAllValuesNew(Config config) { + config.setString("user", null, "name", "Alice Bauer"); + config.setBoolean("core", null, "fileMode", false); + config.setInt("core", null, "deltaBaseCacheLimit", 12); + config.setLong("core", null, "packedGitLimit", 22); + config.setLong("core", null, "repositoryCacheExpireAfter", 32); + config.setEnum("core", null, "autocrlf", CoreConfig.AutoCRLF.FALSE); + config.setString("remote", "origin", "fetch", + "+refs/heads/*:refs/remotes/backup/*"); + } + + private static void assertValuesAsIncluded(Config config, String... refs) { + assertAllTypesSampleContent("Alice Muller", true, 10, 20, 30, + CoreConfig.AutoCRLF.TRUE, config, refs); + } + + private static void assertValuesAsConfig(Config config, String... refs) { + assertAllTypesSampleContent("Alice Parker", false, 11, 21, 31, + CoreConfig.AutoCRLF.FALSE, config, refs); + } + + private static void assertValuesAsNew(Config config, String... refs) { + assertValuesAsNewWithName(config, "Alice Bauer", refs); + } + + private static void assertValuesAsNewWithName(Config config, String name, + String... refs) { + assertAllTypesSampleContent(name, false, 12, 22, 32, + CoreConfig.AutoCRLF.FALSE, config, refs); + } + + private static void assertSections(Config config, String... sections) { + assertEquals(Arrays.asList(sections), + new ArrayList<>(config.getSections())); + } + + private static String createAllTypesSampleContent(String name, + boolean fileMode, int deltaBaseCacheLimit, long packedGitLimit, + long repositoryCacheExpireAfter, CoreConfig.AutoCRLF autoCRLF, + String fetchRefSpec) { + final StringBuilder builder = new StringBuilder(); + builder.append("[user]\n"); + builder.append("name="); + builder.append(name); + builder.append("\n"); + + builder.append("[core]\n"); + builder.append("fileMode="); + builder.append(fileMode); + builder.append("\n"); + + builder.append("deltaBaseCacheLimit="); + builder.append(deltaBaseCacheLimit); + builder.append("\n"); + + builder.append("packedGitLimit="); + builder.append(packedGitLimit); + builder.append("\n"); + + builder.append("repositoryCacheExpireAfter="); + builder.append(repositoryCacheExpireAfter); + builder.append("\n"); + + builder.append("autocrlf="); + builder.append(autoCRLF.name()); + builder.append("\n"); + + builder.append("[remote \"origin\"]\n"); + builder.append("fetch="); + builder.append(fetchRefSpec); + builder.append("\n"); + return builder.toString(); + } + + private static void assertAllTypesSampleContent(String name, + boolean fileMode, int deltaBaseCacheLimit, long packedGitLimit, + long repositoryCacheExpireAfter, CoreConfig.AutoCRLF autoCRLF, + Config config, String... fetchRefSpecs) { + assertEquals(name, config.getString("user", null, "name")); + assertEquals(fileMode, + config.getBoolean("core", "fileMode", !fileMode)); + assertEquals(deltaBaseCacheLimit, + config.getInt("core", "deltaBaseCacheLimit", -1)); + assertEquals(packedGitLimit, + config.getLong("core", "packedGitLimit", -1)); + assertEquals(repositoryCacheExpireAfter, config.getTimeUnit("core", + null, "repositoryCacheExpireAfter", -1, MILLISECONDS)); + assertEquals(autoCRLF, config.getEnum("core", null, "autocrlf", + CoreConfig.AutoCRLF.INPUT)); + final List<RefSpec> refspecs = new ArrayList<>(); + for (String fetchRefSpec : fetchRefSpecs) { + refspecs.add(new RefSpec(fetchRefSpec)); + } + + assertEquals(refspecs, config.getRefSpecs("remote", "origin", "fetch")); + } + private static void assertReadLong(long exp) throws ConfigInvalidException { assertReadLong(exp, String.valueOf(exp)); } @@ -1217,4 +1513,12 @@ public class ConfigTest { assertEquals(expectedMessage, e.getMessage()); } } + + private static FileBasedConfig loadConfig(File file) + throws IOException, ConfigInvalidException { + final FileBasedConfig config = new FileBasedConfig(null, file, + FS.DETECTED); + config.load(); + return config; + } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java index 32a1ec96a5..057e0c881b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java @@ -37,6 +37,7 @@ */ package org.eclipse.jgit.lib; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -343,7 +344,7 @@ public class DirCacheCheckoutMaliciousPathTest extends RepositoryTestCase { ObjectInserter newObjectInserter; newObjectInserter = git.getRepository().newObjectInserter(); ObjectId blobId = newObjectInserter.insert(Constants.OBJ_BLOB, - "data".getBytes()); + "data".getBytes(UTF_8)); newObjectInserter = git.getRepository().newObjectInserter(); FileMode mode = FileMode.REGULAR_FILE; ObjectId insertId = blobId; @@ -366,8 +367,8 @@ public class DirCacheCheckoutMaliciousPathTest extends RepositoryTestCase { insertId = blobId; for (int i = path.length - 1; i >= 0; --i) { TreeFormatter treeFormatter = new TreeFormatter(); - treeFormatter.append(path[i].getBytes(), 0, - path[i].getBytes().length, + treeFormatter.append(path[i].getBytes(UTF_8), 0, + path[i].getBytes(UTF_8).length, mode, insertId, true); insertId = newObjectInserter.insert(treeFormatter); mode = FileMode.TREE; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java index eb87827805..534b323fe6 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java @@ -40,6 +40,7 @@ */ package org.eclipse.jgit.lib; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -310,7 +311,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { assertTrue("unexpected content for path " + path + " in index. Expected: <" + expectedValue + ">", Arrays.equals(db.open(read.getEntry(j).getObjectId()) - .getCachedBytes(), i.get(path).getBytes())); + .getCachedBytes(), i.get(path).getBytes(UTF_8))); } } @@ -405,7 +406,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { ObjectId genSha1(String data) { try (ObjectInserter w = db.newObjectInserter()) { - ObjectId id = w.insert(Constants.OBJ_BLOB, data.getBytes()); + ObjectId id = w.insert(Constants.OBJ_BLOB, data.getBytes(UTF_8)); w.flush(); return id; } catch (IOException e) { @@ -928,6 +929,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { "e/g3")); try { checkout(); + fail("did not throw CheckoutConflictException"); } catch (CheckoutConflictException e) { assertWorkDir(mkmap("a", "a", "b/c", "b/c", "d", "d", "e/f", "e/f", "e/g", "e/g3")); @@ -2048,7 +2050,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { assertArrayEquals( "unexpected content for path " + path + " in workDir. ", - buffer, i.get(path).getBytes()); + buffer, i.get(path).getBytes(UTF_8)); } nrFiles++; } else if (file.isDirectory()) { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/MergeHeadMsgTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/MergeHeadMsgTest.java index 347883f842..abf7d56819 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/MergeHeadMsgTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/MergeHeadMsgTest.java @@ -42,6 +42,7 @@ */ package org.eclipse.jgit.lib; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -72,7 +73,9 @@ public class MergeHeadMsgTest extends RepositoryTestCase { // same test again, this time with lower-level io try (FileOutputStream fos = new FileOutputStream( new File(db.getDirectory(), "MERGE_HEAD"));) { - fos.write("0000000000000000000000000000000000000000\n1c6db447abdbb291b25f07be38ea0b1bf94947c5\n".getBytes(Constants.CHARACTER_ENCODING)); + fos.write( + "0000000000000000000000000000000000000000\n1c6db447abdbb291b25f07be38ea0b1bf94947c5\n" + .getBytes(UTF_8)); } assertEquals(db.readMergeHeads().size(), 2); assertEquals(db.readMergeHeads().get(0), ObjectId.zeroId()); @@ -82,7 +85,7 @@ public class MergeHeadMsgTest extends RepositoryTestCase { assertEquals(db.readMergeHeads(), null); try (FileOutputStream fos = new FileOutputStream( new File(db.getDirectory(), "MERGE_HEAD"))) { - fos.write(sampleId.getBytes(Constants.CHARACTER_ENCODING)); + fos.write(sampleId.getBytes(UTF_8)); } assertEquals(db.readMergeHeads().size(), 1); assertEquals(db.readMergeHeads().get(0), ObjectId.fromString(sampleId)); @@ -100,7 +103,7 @@ public class MergeHeadMsgTest extends RepositoryTestCase { assertFalse(new File(db.getDirectory(), "MERGE_MSG").exists()); try (FileOutputStream fos = new FileOutputStream( new File(db.getDirectory(), Constants.MERGE_MSG))) { - fos.write(mergeMsg.getBytes(Constants.CHARACTER_ENCODING)); + fos.write(mergeMsg.getBytes(UTF_8)); } assertEquals(db.readMergeCommitMsg(), mergeMsg); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectLoaderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectLoaderTest.java index 83e61d9ab4..055e66ed81 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectLoaderTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectLoaderTest.java @@ -260,6 +260,12 @@ public class ObjectLoaderTest { fail("never should have reached read"); return -1; } + + @Override + public int read(byte b[], int off, int len) { + fail("never should have reached read"); + return -1; + } }; } }; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java index 3542dfad2d..bb24994ee8 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.lib; import static java.lang.Long.valueOf; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; @@ -181,7 +182,7 @@ public class RacyGitTests extends RepositoryTestCase { private File addToWorkDir(String path, String content) throws IOException { File f = new File(db.getWorkTree(), path); try (FileOutputStream fos = new FileOutputStream(f)) { - fos.write(content.getBytes(Constants.CHARACTER_ENCODING)); + fos.write(content.getBytes(UTF_8)); return f; } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java index a42027b584..7d2c4a2784 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.lib; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -261,7 +262,7 @@ public class RefTest extends SampleDataRepositoryTestCase { assertEquals(Storage.PACKED, ref.getStorage()); try (FileOutputStream os = new FileOutputStream( new File(db.getDirectory(), "refs/heads/master"))) { - os.write(ref.getObjectId().name().getBytes()); + os.write(ref.getObjectId().name().getBytes(UTF_8)); os.write('\n'); } @@ -333,4 +334,17 @@ public class RefTest extends SampleDataRepositoryTestCase { assertEquals(1, refs.size()); checkContainsRef(refs, db.exactRef("refs/heads/prefix/a")); } + + @Test + public void testGetRefsByPrefixes() throws IOException { + List<Ref> refs = db.getRefDatabase().getRefsByPrefix(); + assertEquals(0, refs.size()); + + refs = db.getRefDatabase().getRefsByPrefix("refs/heads/p", + "refs/tags/A"); + assertEquals(3, refs.size()); + checkContainsRef(refs, db.exactRef("refs/heads/pa")); + checkContainsRef(refs, db.exactRef("refs/heads/prefix/a")); + checkContainsRef(refs, db.exactRef("refs/tags/A")); + } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/SquashCommitMsgTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/SquashCommitMsgTest.java index 203c00e28a..f58ab06074 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/SquashCommitMsgTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/SquashCommitMsgTest.java @@ -42,6 +42,7 @@ */ package org.eclipse.jgit.lib; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -68,7 +69,7 @@ public class SquashCommitMsgTest extends RepositoryTestCase { assertFalse(new File(db.getDirectory(), Constants.SQUASH_MSG).exists()); try (FileOutputStream fos = new FileOutputStream( new File(db.getDirectory(), Constants.SQUASH_MSG))) { - fos.write(squashMsg.getBytes(Constants.CHARACTER_ENCODING)); + fos.write(squashMsg.getBytes(UTF_8)); } assertEquals(db.readSquashCommitMsg(), squashMsg); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java index 5af62b6704..3da779b4ec 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.merge; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.ByteArrayOutputStream; @@ -301,8 +302,8 @@ public class MergeAlgorithmTest { MergeResult r = new MergeAlgorithm().merge(RawTextComparator.DEFAULT, T(commonBase), T(ours), T(theirs)); ByteArrayOutputStream bo=new ByteArrayOutputStream(50); - fmt.formatMerge(bo, r, "B", "O", "T", Constants.CHARACTER_ENCODING); - return new String(bo.toByteArray(), Constants.CHARACTER_ENCODING); + fmt.formatMerge(bo, r, "B", "O", "T", UTF_8); + return new String(bo.toByteArray(), UTF_8); } public String t(String text) { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java index 8f12dd7b27..8ca5d453fb 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java @@ -839,7 +839,7 @@ public class MergerTest extends RepositoryTestCase { /** * Throws an exception if reading beyond limit. */ - class BigReadForbiddenStream extends ObjectStream.Filter { + static class BigReadForbiddenStream extends ObjectStream.Filter { int limit; BigReadForbiddenStream(ObjectStream orig, int limit) { @@ -878,7 +878,7 @@ public class MergerTest extends RepositoryTestCase { } } - class BigReadForbiddenReader extends ObjectReader.Filter { + static class BigReadForbiddenReader extends ObjectReader.Filter { ObjectReader delegate; int limit; @@ -972,7 +972,7 @@ public class MergerTest extends RepositoryTestCase { merger.getMergeResults().get("file"); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { fmt.formatMerge(out, merger.getMergeResults().get("file"), - "BASE", "OURS", "THEIRS", UTF_8.name()); + "BASE", "OURS", "THEIRS", UTF_8); String expected = "<<<<<<< OURS\n" + "1master\n" + "=======\n" diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/PlotCommitListTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/PlotCommitListTest.java index 9a6043f321..7297de3646 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/PlotCommitListTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revplot/PlotCommitListTest.java @@ -56,7 +56,7 @@ import org.junit.Test; public class PlotCommitListTest extends RevWalkTestCase { - class CommitListAssert { + static class CommitListAssert { private PlotCommitList<PlotLane> pcl; private PlotCommit<PlotLane> current; private int nextIndex = 0; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java index 7f0d60295c..b401d2bea2 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java @@ -52,6 +52,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.util.StringTokenizer; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.util.FS; @@ -67,16 +68,23 @@ public class FileBasedConfigTest { private static final String NAME = "name"; + private static final String EMAIL = "email"; + private static final String ALICE = "Alice"; private static final String BOB = "Bob"; + private static final String ALICE_EMAIL = "alice@home"; + private static final String CONTENT1 = "[" + USER + "]\n\t" + NAME + " = " + ALICE + "\n"; private static final String CONTENT2 = "[" + USER + "]\n\t" + NAME + " = " + BOB + "\n"; + private static final String CONTENT3 = "[" + USER + "]\n\t" + NAME + " = " + + ALICE + "\n" + "[" + USER + "]\n\t" + EMAIL + " = " + ALICE_EMAIL; + private File trash; @Before @@ -93,14 +101,14 @@ public class FileBasedConfigTest { @Test public void testSystemEncoding() throws IOException, ConfigInvalidException { - final File file = createFile(CONTENT1.getBytes()); + final File file = createFile(CONTENT1.getBytes(UTF_8)); final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED); config.load(); assertEquals(ALICE, config.getString(USER, null, NAME)); config.setString(USER, null, NAME, BOB); config.save(); - assertArrayEquals(CONTENT2.getBytes(), IO.readFully(file)); + assertArrayEquals(CONTENT2.getBytes(UTF_8), IO.readFully(file)); } @Test @@ -112,7 +120,7 @@ public class FileBasedConfigTest { config.setString(USER, null, NAME, BOB); config.save(); - assertArrayEquals(CONTENT2.getBytes(), IO.readFully(file)); + assertArrayEquals(CONTENT2.getBytes(UTF_8), IO.readFully(file)); } @Test @@ -142,8 +150,8 @@ public class FileBasedConfigTest { @Test public void testLeadingWhitespaces() throws IOException, ConfigInvalidException { final ByteArrayOutputStream bos1 = new ByteArrayOutputStream(); - bos1.write(" \n\t".getBytes()); - bos1.write(CONTENT1.getBytes()); + bos1.write(" \n\t".getBytes(UTF_8)); + bos1.write(CONTENT1.getBytes(UTF_8)); final File file = createFile(bos1.toByteArray()); final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED); @@ -154,18 +162,18 @@ public class FileBasedConfigTest { config.save(); final ByteArrayOutputStream bos2 = new ByteArrayOutputStream(); - bos2.write(" \n\t".getBytes()); - bos2.write(CONTENT2.getBytes()); + bos2.write(" \n\t".getBytes(UTF_8)); + bos2.write(CONTENT2.getBytes(UTF_8)); assertArrayEquals(bos2.toByteArray(), IO.readFully(file)); } @Test public void testIncludeAbsolute() throws IOException, ConfigInvalidException { - final File includedFile = createFile(CONTENT1.getBytes()); + final File includedFile = createFile(CONTENT1.getBytes(UTF_8)); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - bos.write("[include]\npath=".getBytes()); - bos.write(pathToString(includedFile).getBytes()); + bos.write("[include]\npath=".getBytes(UTF_8)); + bos.write(pathToString(includedFile).getBytes(UTF_8)); final File file = createFile(bos.toByteArray()); final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED); @@ -176,10 +184,10 @@ public class FileBasedConfigTest { @Test public void testIncludeRelativeDot() throws IOException, ConfigInvalidException { - final File includedFile = createFile(CONTENT1.getBytes(), "dir1"); + final File includedFile = createFile(CONTENT1.getBytes(UTF_8), "dir1"); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - bos.write("[include]\npath=".getBytes()); - bos.write(("./" + includedFile.getName()).getBytes()); + bos.write("[include]\npath=".getBytes(UTF_8)); + bos.write(("./" + includedFile.getName()).getBytes(UTF_8)); final File file = createFile(bos.toByteArray(), "dir1"); final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED); @@ -190,11 +198,11 @@ public class FileBasedConfigTest { @Test public void testIncludeRelativeDotDot() throws IOException, ConfigInvalidException { - final File includedFile = createFile(CONTENT1.getBytes(), "dir1"); + final File includedFile = createFile(CONTENT1.getBytes(UTF_8), "dir1"); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - bos.write("[include]\npath=".getBytes()); + bos.write("[include]\npath=".getBytes(UTF_8)); bos.write(("../" + includedFile.getParentFile().getName() + "/" - + includedFile.getName()).getBytes()); + + includedFile.getName()).getBytes(UTF_8)); final File file = createFile(bos.toByteArray(), "dir2"); final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED); @@ -205,10 +213,10 @@ public class FileBasedConfigTest { @Test public void testIncludeRelativeDotDotNotFound() throws IOException, ConfigInvalidException { - final File includedFile = createFile(CONTENT1.getBytes()); + final File includedFile = createFile(CONTENT1.getBytes(UTF_8)); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - bos.write("[include]\npath=".getBytes()); - bos.write(("../" + includedFile.getName()).getBytes()); + bos.write("[include]\npath=".getBytes(UTF_8)); + bos.write(("../" + includedFile.getName()).getBytes(UTF_8)); final File file = createFile(bos.toByteArray()); final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED); @@ -219,10 +227,10 @@ public class FileBasedConfigTest { @Test public void testIncludeWithTilde() throws IOException, ConfigInvalidException { - final File includedFile = createFile(CONTENT1.getBytes(), "home"); + final File includedFile = createFile(CONTENT1.getBytes(UTF_8), "home"); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - bos.write("[include]\npath=".getBytes()); - bos.write(("~/" + includedFile.getName()).getBytes()); + bos.write("[include]\npath=".getBytes(UTF_8)); + bos.write(("~/" + includedFile.getName()).getBytes(UTF_8)); final File file = createFile(bos.toByteArray(), "repo"); final FS fs = FS.DETECTED.newInstance(); @@ -233,6 +241,50 @@ public class FileBasedConfigTest { assertEquals(ALICE, config.getString(USER, null, NAME)); } + @Test + public void testIncludeDontInlineIncludedLinesOnSave() + throws IOException, ConfigInvalidException { + // use a content with multiple sections and multiple key/value pairs + // because code for first line works different than for subsequent lines + final File includedFile = createFile(CONTENT3.getBytes(UTF_8), "dir1"); + + final File file = createFile(new byte[0], "dir2"); + FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED); + config.setString("include", null, "path", + ("../" + includedFile.getParentFile().getName() + "/" + + includedFile.getName())); + + // just by setting the include.path, it won't be included + assertEquals(null, config.getString(USER, null, NAME)); + assertEquals(null, config.getString(USER, null, EMAIL)); + config.save(); + + // and it won't be included after saving + assertEquals(null, config.getString(USER, null, NAME)); + assertEquals(null, config.getString(USER, null, EMAIL)); + + final String expectedText = config.toText(); + assertEquals(2, + new StringTokenizer(expectedText, "\n", false).countTokens()); + + config = new FileBasedConfig(file, FS.DETECTED); + config.load(); + + String actualText = config.toText(); + assertEquals(expectedText, actualText); + // but it will be included after (re)loading + assertEquals(ALICE, config.getString(USER, null, NAME)); + assertEquals(ALICE_EMAIL, config.getString(USER, null, EMAIL)); + + config.save(); + + actualText = config.toText(); + assertEquals(expectedText, actualText); + // and of course preserved after saving + assertEquals(ALICE, config.getString(USER, null, NAME)); + assertEquals(ALICE_EMAIL, config.getString(USER, null, EMAIL)); + } + private File createFile(byte[] content) throws IOException { return createFile(content, null); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java index fed22c0262..a0cd37ee5f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java @@ -42,6 +42,7 @@ */ package org.eclipse.jgit.submodule; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PATH; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_URL; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_SUBMODULE_SECTION; @@ -52,9 +53,10 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.io.BufferedWriter; import java.io.File; -import java.io.FileWriter; import java.io.IOException; +import java.nio.file.Files; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Status; @@ -155,10 +157,12 @@ public class SubmoduleWalkTest extends RepositoryTestCase { if (!dotGit.getParentFile().exists()) dotGit.getParentFile().mkdirs(); - File modulesGitDir = new File(db.getDirectory(), "modules" - + File.separatorChar + path); - new FileWriter(dotGit).append( - "gitdir: " + modulesGitDir.getAbsolutePath()).close(); + File modulesGitDir = new File(db.getDirectory(), + "modules" + File.separatorChar + path); + try (BufferedWriter fw = Files.newBufferedWriter(dotGit.toPath(), + UTF_8)) { + fw.append("gitdir: " + modulesGitDir.getAbsolutePath()); + } FileRepositoryBuilder builder = new FileRepositoryBuilder(); builder.setWorkTree(new File(db.getWorkTree(), path)); builder.build().create(); @@ -209,9 +213,11 @@ public class SubmoduleWalkTest extends RepositoryTestCase { File modulesGitDir = new File(db.getDirectory(), "modules" + File.separatorChar + path); - new FileWriter(dotGit).append( - "gitdir: " + "../" + Constants.DOT_GIT + "/modules/" + path) - .close(); + try (BufferedWriter fw = Files.newBufferedWriter(dotGit.toPath(), + UTF_8)) { + fw.append("gitdir: " + "../" + Constants.DOT_GIT + "/modules/" + + path); + } FileRepositoryBuilder builder = new FileRepositoryBuilder(); builder.setWorkTree(new File(db.getWorkTree(), path)); builder.build().create(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PacketLineOutTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PacketLineOutTest.java index 391a701b8e..ad8ae42536 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PacketLineOutTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PacketLineOutTest.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.transport; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -50,7 +51,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import org.eclipse.jgit.lib.Constants; import org.junit.Before; import org.junit.Test; @@ -173,8 +173,8 @@ public class PacketLineOutTest { assertEquals(1, flushCnt[0]); } - private void assertBuffer(String exp) throws IOException { + private void assertBuffer(String exp) { assertEquals(exp, new String(rawOut.toByteArray(), - Constants.CHARACTER_ENCODING)); + UTF_8)); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java index 4d1150844c..39309a1d55 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.transport; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.hasItems; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -263,25 +264,26 @@ public class ProtocolV2ParserTest { @Test public void testFetchMustNotHaveMultipleFilters() throws IOException { - thrown.expect(PackProtocolException.class); PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM, "filter blob:none", "filter blob:limit=12", PacketLineIn.END); ProtocolV2Parser parser = new ProtocolV2Parser( ConfigBuilder.start().allowFilter().done()); - FetchV2Request request = parser.parseFetchRequest(pckIn, + + thrown.expect(PackProtocolException.class); + parser.parseFetchRequest(pckIn, testRepo.getRepository().getRefDatabase()); - assertEquals(0, request.getFilterBlobLimit()); } @Test public void testFetchFilterWithoutAllowFilter() throws IOException { - thrown.expect(PackProtocolException.class); PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM, "filter blob:limit=12", PacketLineIn.END); ProtocolV2Parser parser = new ProtocolV2Parser( ConfigBuilder.getDefault()); + + thrown.expect(PackProtocolException.class); parser.parseFetchRequest(pckIn, testRepo.getRepository().getRefDatabase()); } @@ -314,9 +316,6 @@ public class ProtocolV2ParserTest { @Test public void testFetchWithRefInWantUnknownRef() throws Exception { - thrown.expect(PackProtocolException.class); - thrown.expectMessage(containsString("refs/heads/branchC")); - PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM, "want e4980cdc48cfa1301493ca94eb70523f6788b819", "want-ref refs/heads/branchC", @@ -329,8 +328,66 @@ public class ProtocolV2ParserTest { testRepo.update("branchA", one); testRepo.update("branchB", two); + thrown.expect(PackProtocolException.class); + thrown.expectMessage(containsString("refs/heads/branchC")); parser.parseFetchRequest(pckIn, testRepo.getRepository().getRefDatabase()); } + @Test + public void testLsRefsMinimalReq() throws IOException { + PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM, + PacketLineIn.END); + + ProtocolV2Parser parser = new ProtocolV2Parser( + ConfigBuilder.getDefault()); + LsRefsV2Request req = parser.parseLsRefsRequest(pckIn); + assertFalse(req.getPeel()); + assertFalse(req.getSymrefs()); + assertEquals(0, req.getRefPrefixes().size()); + } + + @Test + public void testLsRefsSymrefs() throws IOException { + PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM, "symrefs", + PacketLineIn.END); + + ProtocolV2Parser parser = new ProtocolV2Parser( + ConfigBuilder.getDefault()); + LsRefsV2Request req = parser.parseLsRefsRequest(pckIn); + assertFalse(req.getPeel()); + assertTrue(req.getSymrefs()); + assertEquals(0, req.getRefPrefixes().size()); + + } + + @Test + public void testLsRefsPeel() throws IOException { + PacketLineIn pckIn = formatAsPacketLine( + PacketLineIn.DELIM, + "peel", + PacketLineIn.END); + + ProtocolV2Parser parser = new ProtocolV2Parser( + ConfigBuilder.getDefault()); + LsRefsV2Request req = parser.parseLsRefsRequest(pckIn); + assertTrue(req.getPeel()); + assertFalse(req.getSymrefs()); + assertEquals(0, req.getRefPrefixes().size()); + } + + @Test + public void testLsRefsRefPrefixes() throws IOException { + PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.DELIM, + "ref-prefix refs/for", "ref-prefix refs/heads", + PacketLineIn.END); + + ProtocolV2Parser parser = new ProtocolV2Parser( + ConfigBuilder.getDefault()); + LsRefsV2Request req = parser.parseLsRefsRequest(pckIn); + assertFalse(req.getPeel()); + assertFalse(req.getSymrefs()); + assertEquals(2, req.getRefPrefixes().size()); + assertThat(req.getRefPrefixes(), hasItems("refs/for", "refs/heads")); + } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java index 0647167eab..4bf26b6288 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java @@ -42,6 +42,7 @@ package org.eclipse.jgit.transport; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -334,7 +335,7 @@ public class PushCertificateParserTest { assertFalse(input.contains(PushCertificateParser.END_CERT)); input += input; Reader reader = new InputStreamReader( - new ByteArrayInputStream(Constants.encode(input))); + new ByteArrayInputStream(Constants.encode(input)), UTF_8); assertNotNull(PushCertificateParser.fromReader(reader)); assertNotNull(PushCertificateParser.fromReader(reader)); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java index 68e0129525..fa4fd65069 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateStoreTest.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.transport; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.lib.ObjectId.zeroId; import static org.eclipse.jgit.lib.RefUpdate.Result.FAST_FORWARD; import static org.eclipse.jgit.lib.RefUpdate.Result.LOCK_FAILURE; @@ -96,7 +97,9 @@ public class PushCertificateStoreTest { + "-----END PGP SIGNATURE-----\n"); try { return PushCertificateParser.fromReader(new InputStreamReader( - new ByteArrayInputStream(Constants.encode(cert.toString())))); + new ByteArrayInputStream( + Constants.encode(cert.toString())), + UTF_8)); } catch (IOException e) { throw new IllegalArgumentException(e); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java index 4d3e162240..b6cf3564c1 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.transport; import static java.lang.Integer.valueOf; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.transport.SideBandOutputStream.CH_DATA; import static org.eclipse.jgit.transport.SideBandOutputStream.CH_ERROR; import static org.eclipse.jgit.transport.SideBandOutputStream.CH_PROGRESS; @@ -59,7 +60,6 @@ import java.io.OutputStream; import java.text.MessageFormat; import org.eclipse.jgit.internal.JGitText; -import org.eclipse.jgit.lib.Constants; import org.junit.Before; import org.junit.Test; @@ -259,8 +259,7 @@ public class SideBandOutputStreamTest { } } - private void assertBuffer(String exp) throws IOException { - assertEquals(exp, new String(rawOut.toByteArray(), - Constants.CHARACTER_ENCODING)); + private void assertBuffer(String exp) { + assertEquals(exp, new String(rawOut.toByteArray(), UTF_8)); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java index 953c9fc30a..1c4d0cfe24 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TestProtocolTest.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.transport; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.List; @@ -238,6 +239,7 @@ public class TestProtocolTest { .setRemote(user1Uri.toString()) .setRefSpecs(MASTER) .call(); + fail("accepted not permitted fetch"); } catch (InvalidRemoteException expected) { // Expected. } @@ -282,6 +284,7 @@ public class TestProtocolTest { .setRemote(user1Uri.toString()) .setRefSpecs(HEADS) .call(); + fail("accepted not permitted push"); } catch (TransportException expected) { assertTrue(expected.getMessage().contains( JGitText.get().pushNotPermitted)); 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 317ac32e6d..20fb12b3ef 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 @@ -27,6 +27,7 @@ import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription; import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.lib.NullProgressMonitor; +import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.ProgressMonitor; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; @@ -1191,6 +1192,59 @@ public class UploadPackTest { } @Test + public void testV2FetchShallowSince() throws Exception { + PersonIdent person = new PersonIdent(remote.getRepository()); + + RevCommit beyondBoundary = remote.commit() + .committer(new PersonIdent(person, 1510000000, 0)).create(); + RevCommit boundary = remote.commit().parent(beyondBoundary) + .committer(new PersonIdent(person, 1520000000, 0)).create(); + RevCommit tooOld = remote.commit() + .committer(new PersonIdent(person, 1500000000, 0)).create(); + RevCommit merge = remote.commit().parent(boundary).parent(tooOld) + .committer(new PersonIdent(person, 1530000000, 0)).create(); + + remote.update("branch1", merge); + + // Report that we only have "boundary" as a shallow boundary. + ByteArrayInputStream recvStream = uploadPackV2( + "command=fetch\n", + PacketLineIn.DELIM, + "shallow " + boundary.toObjectId().getName() + "\n", + "deepen-since 1510000\n", + "want " + merge.toObjectId().getName() + "\n", + "have " + boundary.toObjectId().getName() + "\n", + "done\n", + PacketLineIn.END); + PacketLineIn pckIn = new PacketLineIn(recvStream); + assertThat(pckIn.readString(), is("shallow-info")); + + // "merge" is shallow because one of its parents is committed + // earlier than the given deepen-since time. + assertThat(pckIn.readString(), is("shallow " + merge.toObjectId().getName())); + + // "boundary" is unshallow because its parent committed at or + // later than the given deepen-since time. + assertThat(pckIn.readString(), is("unshallow " + boundary.toObjectId().getName())); + + assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM)); + assertThat(pckIn.readString(), is("packfile")); + parsePack(recvStream); + + // The server does not send this because it is committed + // earlier than the given deepen-since time. + assertFalse(client.hasObject(tooOld.toObjectId())); + + // The server does not send this because the client claims to + // have it. + assertFalse(client.hasObject(boundary.toObjectId())); + + // The server sends both these commits. + assertTrue(client.hasObject(beyondBoundary.toObjectId())); + assertTrue(client.hasObject(merge.toObjectId())); + } + + @Test public void testV2FetchUnrecognizedArgument() throws Exception { thrown.expect(PackProtocolException.class); thrown.expectMessage("unexpected invalid-argument"); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java index f2fb0224ef..4750d15b3d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java @@ -651,7 +651,8 @@ public class WalkEncryptionTest { Properties props = Props.discover(); props.put(AmazonS3.Keys.PASSWORD, JGIT_PASS); props.put(AmazonS3.Keys.CRYPTO_ALG, algorithm); - try (PrintWriter writer = new PrintWriter(JGIT_CONF_FILE)) { + try (PrintWriter writer = new PrintWriter(JGIT_CONF_FILE, + UTF_8.name())) { props.store(writer, "JGIT S3 connection configuration file."); } } @@ -665,7 +666,8 @@ public class WalkEncryptionTest { static void configCreate(Properties source) throws Exception { Properties target = Props.discover(); target.putAll(source); - try (PrintWriter writer = new PrintWriter(JGIT_CONF_FILE)) { + try (PrintWriter writer = new PrintWriter(JGIT_CONF_FILE, + UTF_8.name())) { target.store(writer, "JGIT S3 connection configuration file."); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/AbstractTreeIteratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/AbstractTreeIteratorTest.java index 934984f7e5..8afd49ab45 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/AbstractTreeIteratorTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/AbstractTreeIteratorTest.java @@ -66,7 +66,7 @@ public class AbstractTreeIteratorTest { return s > 0 ? path.substring(0, s) : ""; } - public class FakeTreeIterator extends WorkingTreeIterator { + public static class FakeTreeIterator extends WorkingTreeIterator { public FakeTreeIterator(String pathName, FileMode fileMode) { super(prefix(pathName), new Config().get(WorkingTreeOptions.KEY)); mode = fileMode.getBits(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/InterIndexDiffFilterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/InterIndexDiffFilterTest.java index cba35d8042..ea5db09349 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/InterIndexDiffFilterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/InterIndexDiffFilterTest.java @@ -42,6 +42,7 @@ */ package org.eclipse.jgit.treewalk.filter; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -114,7 +115,7 @@ public class InterIndexDiffFilterTest extends LocalDiskRepositoryTestCase { } private ObjectId id(String data) { - byte[] bytes = data.getBytes(); + byte[] bytes = data.getBytes(UTF_8); return db.newObjectInserter().idFor(Constants.OBJ_BLOB, bytes); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java index 0a3de85f7c..dca9c57a64 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/BlockListTest.java @@ -47,6 +47,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.Iterator; @@ -84,18 +85,21 @@ public class BlockListTest { try { list.get(-1); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(-1), badIndex.getMessage()); } try { list.get(0); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(0), badIndex.getMessage()); } try { list.get(4); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(4), badIndex.getMessage()); } @@ -114,6 +118,7 @@ public class BlockListTest { try { list.get(3); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(3), badIndex.getMessage()); } @@ -125,18 +130,21 @@ public class BlockListTest { try { list.set(-1, "foo"); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(-1), badIndex.getMessage()); } try { list.set(0, "foo"); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(0), badIndex.getMessage()); } try { list.set(4, "foo"); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(4), badIndex.getMessage()); } @@ -161,6 +169,7 @@ public class BlockListTest { try { list.set(3, "bar"); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(3), badIndex.getMessage()); } @@ -323,12 +332,14 @@ public class BlockListTest { try { list.add(-1, Integer.valueOf(42)); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(-1), badIndex.getMessage()); } try { list.add(4, Integer.valueOf(42)); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(4), badIndex.getMessage()); } @@ -341,12 +352,14 @@ public class BlockListTest { try { list.remove(-1); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(-1), badIndex.getMessage()); } try { list.remove(4); + fail("accepted out-of-bounds index"); } catch (IndexOutOfBoundsException badIndex) { assertEquals(String.valueOf(4), badIndex.getMessage()); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/IOReadLineTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/IOReadLineTest.java index 928fb2ed9a..fa303ec286 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/IOReadLineTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/IOReadLineTest.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.util; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.BufferedReader; @@ -105,7 +106,7 @@ public class IOReadLineTest { private Reader newReader(String in) { Reader r = new InputStreamReader( - new ByteArrayInputStream(Constants.encode(in))); + new ByteArrayInputStream(Constants.encode(in)), UTF_8); if (buffered) { r = new BufferedReader(r); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java index 7c0985ef42..19af83611b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.util; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.ByteArrayInputStream; @@ -75,10 +76,10 @@ public class RunExternalScriptTest { File script = writeTempFile("cat -"); int rc = FS.DETECTED.runProcess( new ProcessBuilder("sh", script.getPath()), out, err, - new ByteArrayInputStream(inputStr.getBytes())); + new ByteArrayInputStream(inputStr.getBytes(UTF_8))); assertEquals(0, rc); - assertEquals(inputStr, new String(out.toByteArray())); - assertEquals("", new String(err.toByteArray())); + assertEquals(inputStr, new String(out.toByteArray(), UTF_8)); + assertEquals("", new String(err.toByteArray(), UTF_8)); } @Test @@ -88,8 +89,8 @@ public class RunExternalScriptTest { new ProcessBuilder("sh", script.getPath()), out, err, (InputStream) null); assertEquals(0, rc); - assertEquals("", new String(out.toByteArray())); - assertEquals("", new String(err.toByteArray())); + assertEquals("", new String(out.toByteArray(), UTF_8)); + assertEquals("", new String(err.toByteArray(), UTF_8)); } @Test @@ -99,8 +100,8 @@ public class RunExternalScriptTest { new ProcessBuilder("sh", script.getPath(), "a", "b", "c"), out, err, (InputStream) null); assertEquals(0, rc); - assertEquals("3,a,b,c,,,\n", new String(out.toByteArray())); - assertEquals("", new String(err.toByteArray())); + assertEquals("3,a,b,c,,,\n", new String(out.toByteArray(), UTF_8)); + assertEquals("", new String(err.toByteArray(), UTF_8)); } @Test @@ -110,8 +111,8 @@ public class RunExternalScriptTest { new ProcessBuilder("sh", script.getPath(), "a", "b", "c"), out, err, (InputStream) null); assertEquals(3, rc); - assertEquals("", new String(out.toByteArray())); - assertEquals("", new String(err.toByteArray())); + assertEquals("", new String(out.toByteArray(), UTF_8)); + assertEquals("", new String(err.toByteArray(), UTF_8)); } @Test @@ -121,8 +122,8 @@ public class RunExternalScriptTest { new ProcessBuilder("sh", script.getPath()), null, err, (InputStream) null); assertEquals(0, rc); - assertEquals("", new String(out.toByteArray())); - assertEquals("", new String(err.toByteArray())); + assertEquals("", new String(out.toByteArray(), UTF_8)); + assertEquals("", new String(err.toByteArray(), UTF_8)); } @Test @@ -132,8 +133,8 @@ public class RunExternalScriptTest { new ProcessBuilder("sh", script.getPath()), null, err, (InputStream) null); assertEquals(0, rc); - assertEquals("", new String(out.toByteArray())); - assertEquals("hi" + LF, new String(err.toByteArray())); + assertEquals("", new String(out.toByteArray(), UTF_8)); + assertEquals("hi" + LF, new String(err.toByteArray(), UTF_8)); } @Test @@ -142,10 +143,10 @@ public class RunExternalScriptTest { File script = writeTempFile("echo $#,$1,$2,$3,$4,$5,$6 >&2 ; cat -; exit 5"); int rc = FS.DETECTED.runProcess( new ProcessBuilder("sh", script.getPath(), "a", "b", "c"), - out, err, new ByteArrayInputStream(inputStr.getBytes())); + out, err, new ByteArrayInputStream(inputStr.getBytes(UTF_8))); assertEquals(5, rc); - assertEquals(inputStr, new String(out.toByteArray())); - assertEquals("3,a,b,c,,," + LF, new String(err.toByteArray())); + assertEquals(inputStr, new String(out.toByteArray(), UTF_8)); + assertEquals("3,a,b,c,,," + LF, new String(err.toByteArray(), UTF_8)); } @Test(expected = IOException.class) @@ -172,10 +173,11 @@ public class RunExternalScriptTest { File script = writeTempFile("cat -"); ProcessBuilder pb = new ProcessBuilder("sh", script.getPath()); ExecutionResult res = FS.DETECTED.execute(pb, - new ByteArrayInputStream(inputStr.getBytes())); + new ByteArrayInputStream(inputStr.getBytes(UTF_8))); assertEquals(0, res.getRc()); - assertEquals(inputStr, new String(res.getStdout().toByteArray())); - assertEquals("", new String(res.getStderr().toByteArray())); + assertEquals(inputStr, + new String(res.getStdout().toByteArray(), UTF_8)); + assertEquals("", new String(res.getStderr().toByteArray(), UTF_8)); } @Test @@ -184,8 +186,9 @@ public class RunExternalScriptTest { ProcessBuilder pb = new ProcessBuilder("sh", script.getPath()); ExecutionResult res = FS.DETECTED.execute(pb, null); assertEquals(0, res.getRc()); - assertEquals("", new String(res.getStdout().toByteArray())); - assertEquals("hi" + LF, new String(res.getStderr().toByteArray())); + assertEquals("", new String(res.getStdout().toByteArray(), UTF_8)); + assertEquals("hi" + LF, + new String(res.getStderr().toByteArray(), UTF_8)); } @Test @@ -197,11 +200,12 @@ public class RunExternalScriptTest { ProcessBuilder pb = new ProcessBuilder("sh", script.getPath(), "a", "b", "c"); ExecutionResult res = FS.DETECTED.execute(pb, - new ByteArrayInputStream(inputStr.getBytes())); + new ByteArrayInputStream(inputStr.getBytes(UTF_8))); assertEquals(5, res.getRc()); - assertEquals(inputStr, new String(res.getStdout().toByteArray())); + assertEquals(inputStr, + new String(res.getStdout().toByteArray(), UTF_8)); assertEquals("3,a,b,c,,," + LF, - new String(res.getStderr().toByteArray())); + new String(res.getStderr().toByteArray(), UTF_8)); } private File writeTempFile(String body) throws IOException { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java index 1272e16173..8f77c55af2 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java @@ -43,6 +43,8 @@ package org.eclipse.jgit.util.io; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -89,8 +91,8 @@ public class AutoCRLFInputStreamTest { private void assertNoCrLfHelper(String expect, String input) throws IOException { - byte[] inbytes = input.getBytes(); - byte[] expectBytes = expect.getBytes(); + byte[] inbytes = input.getBytes(UTF_8); + byte[] expectBytes = expect.getBytes(UTF_8); for (int i = 0; i < 5; ++i) { byte[] buf = new byte[i]; try (ByteArrayInputStream bis = new ByteArrayInputStream(inbytes); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java index 0655827310..3a3dc8117f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java @@ -44,6 +44,8 @@ package org.eclipse.jgit.util.io; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -91,8 +93,8 @@ public class AutoCRLFOutputStreamTest { private void assertNoCrLfHelper(String expect, String input) throws IOException { - byte[] inbytes = input.getBytes(); - byte[] expectBytes = expect.getBytes(); + byte[] inbytes = input.getBytes(UTF_8); + byte[] expectBytes = expect.getBytes(UTF_8); for (int i = -4; i < 5; ++i) { int size = Math.abs(i); byte[] buf = new byte[size]; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java index a63b1cb02a..c35f90ca7d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java @@ -282,7 +282,7 @@ public class TimeoutOutputStreamTest { return System.currentTimeMillis(); } - private final class FullPipeInputStream extends PipedInputStream { + private static final class FullPipeInputStream extends PipedInputStream { FullPipeInputStream(PipedOutputStream src) throws IOException { super(src); src.write(new byte[PIPE_SIZE]); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java index b824fae9fd..0bfa772bed 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java @@ -259,6 +259,11 @@ public class UnionInputStreamTest { public int read() throws IOException { throw new IOException("Expected"); } + + @Override + public int read(byte b[], int off, int len) throws IOException { + throw new IOException("Expected"); + } }; @SuppressWarnings("resource" /* java 7 */) final UnionInputStream u = new UnionInputStream( diff --git a/org.eclipse.jgit.ui/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit.ui/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit.ui/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit.ui/.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.ui/META-INF/MANIFEST.MF b/org.eclipse.jgit.ui/META-INF/MANIFEST.MF index c32f6a2538..889a62978f 100644 --- a/org.eclipse.jgit.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.ui/META-INF/MANIFEST.MF @@ -4,14 +4,14 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit.ui Bundle-SymbolicName: org.eclipse.jgit.ui -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Vendor: %provider_name Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Export-Package: org.eclipse.jgit.awtui;version="5.1.3" -Import-Package: org.eclipse.jgit.errors;version="[5.1.3,5.2.0)", - org.eclipse.jgit.lib;version="[5.1.3,5.2.0)", - org.eclipse.jgit.nls;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revplot;version="[5.1.3,5.2.0)", - org.eclipse.jgit.revwalk;version="[5.1.3,5.2.0)", - org.eclipse.jgit.transport;version="[5.1.3,5.2.0)", - org.eclipse.jgit.util;version="[5.1.3,5.2.0)" +Export-Package: org.eclipse.jgit.awtui;version="5.2.0" +Import-Package: org.eclipse.jgit.errors;version="[5.2.0,5.3.0)", + org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", + org.eclipse.jgit.nls;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revplot;version="[5.2.0,5.3.0)", + org.eclipse.jgit.revwalk;version="[5.2.0,5.3.0)", + org.eclipse.jgit.transport;version="[5.2.0,5.3.0)", + org.eclipse.jgit.util;version="[5.2.0,5.3.0)" diff --git a/org.eclipse.jgit.ui/pom.xml b/org.eclipse.jgit.ui/pom.xml index 5a4c8fc92d..08f9c10956 100644 --- a/org.eclipse.jgit.ui/pom.xml +++ b/org.eclipse.jgit.ui/pom.xml @@ -52,7 +52,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.ui</artifactId> diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters index 282d7e8962..e4b7ba7794 100644 --- a/org.eclipse.jgit/.settings/.api_filters +++ b/org.eclipse.jgit/.settings/.api_filters @@ -1,13 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <component id="org.eclipse.jgit" version="2"> - <resource path="META-INF/MANIFEST.MF"> - <filter id="924844039"> - <message_arguments> - <message_argument value="5.1.2"/> - <message_argument value="5.1.0"/> - </message_arguments> - </filter> - </resource> <resource path="src/org/eclipse/jgit/lib/GitmoduleEntry.java" type="org.eclipse.jgit.lib.GitmoduleEntry"> <filter id="1109393411"> <message_arguments> @@ -24,4 +16,12 @@ </message_arguments> </filter> </resource> + <resource path="src/org/eclipse/jgit/revwalk/DepthWalk.java" type="org.eclipse.jgit.revwalk.DepthWalk"> + <filter id="404000815"> + <message_arguments> + <message_argument value="org.eclipse.jgit.revwalk.DepthWalk"/> + <message_argument value="getDeepenSince()"/> + </message_arguments> + </filter> + </resource> </component> diff --git a/org.eclipse.jgit/.settings/org.eclipse.mylyn.team.ui.prefs b/org.eclipse.jgit/.settings/org.eclipse.mylyn.team.ui.prefs index 0cba949fb7..2fca432276 100644 --- a/org.eclipse.jgit/.settings/org.eclipse.mylyn.team.ui.prefs +++ b/org.eclipse.jgit/.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/META-INF/MANIFEST.MF b/org.eclipse.jgit/META-INF/MANIFEST.MF index 39494aedda..34bcdb95f2 100644 --- a/org.eclipse.jgit/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit/META-INF/MANIFEST.MF @@ -3,12 +3,12 @@ Bundle-ManifestVersion: 2 Bundle-Name: %plugin_name Automatic-Module-Name: org.eclipse.jgit Bundle-SymbolicName: org.eclipse.jgit -Bundle-Version: 5.1.3.qualifier +Bundle-Version: 5.2.0.qualifier Bundle-Localization: plugin Bundle-Vendor: %provider_name Bundle-ActivationPolicy: lazy -Export-Package: org.eclipse.jgit.annotations;version="5.1.3", - org.eclipse.jgit.api;version="5.1.3"; +Export-Package: org.eclipse.jgit.annotations;version="5.2.0", + org.eclipse.jgit.api;version="5.2.0"; uses:="org.eclipse.jgit.revwalk, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.diff, @@ -22,52 +22,52 @@ Export-Package: org.eclipse.jgit.annotations;version="5.1.3", org.eclipse.jgit.submodule, org.eclipse.jgit.transport, org.eclipse.jgit.merge", - org.eclipse.jgit.api.errors;version="5.1.3";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.errors", - org.eclipse.jgit.attributes;version="5.1.3", - org.eclipse.jgit.blame;version="5.1.3"; + org.eclipse.jgit.api.errors;version="5.2.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.errors", + org.eclipse.jgit.attributes;version="5.2.0", + org.eclipse.jgit.blame;version="5.2.0"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.revwalk, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.diff", - org.eclipse.jgit.diff;version="5.1.3"; + org.eclipse.jgit.diff;version="5.2.0"; uses:="org.eclipse.jgit.patch, org.eclipse.jgit.lib, org.eclipse.jgit.treewalk, org.eclipse.jgit.revwalk, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.util", - org.eclipse.jgit.dircache;version="5.1.3"; + org.eclipse.jgit.dircache;version="5.2.0"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.treewalk, org.eclipse.jgit.util, org.eclipse.jgit.events, org.eclipse.jgit.attributes", - org.eclipse.jgit.errors;version="5.1.3"; + org.eclipse.jgit.errors;version="5.2.0"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.internal.storage.pack, org.eclipse.jgit.transport, org.eclipse.jgit.dircache", - org.eclipse.jgit.events;version="5.1.3";uses:="org.eclipse.jgit.lib", - org.eclipse.jgit.fnmatch;version="5.1.3", - org.eclipse.jgit.gitrepo;version="5.1.3"; + org.eclipse.jgit.events;version="5.2.0";uses:="org.eclipse.jgit.lib", + org.eclipse.jgit.fnmatch;version="5.2.0", + org.eclipse.jgit.gitrepo;version="5.2.0"; uses:="org.eclipse.jgit.api, org.eclipse.jgit.lib, org.eclipse.jgit.revwalk, org.xml.sax.helpers, org.xml.sax", - org.eclipse.jgit.gitrepo.internal;version="5.1.3";x-internal:=true, - org.eclipse.jgit.hooks;version="5.1.3";uses:="org.eclipse.jgit.lib", - org.eclipse.jgit.ignore;version="5.1.3", - org.eclipse.jgit.ignore.internal;version="5.1.3";x-friends:="org.eclipse.jgit.test", - org.eclipse.jgit.internal;version="5.1.3";x-friends:="org.eclipse.jgit.test,org.eclipse.jgit.http.test", - org.eclipse.jgit.internal.fsck;version="5.1.3";x-friends:="org.eclipse.jgit.test", - org.eclipse.jgit.internal.ketch;version="5.1.3";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm", - org.eclipse.jgit.internal.storage.dfs;version="5.1.3"; + org.eclipse.jgit.gitrepo.internal;version="5.2.0";x-internal:=true, + org.eclipse.jgit.hooks;version="5.2.0";uses:="org.eclipse.jgit.lib", + org.eclipse.jgit.ignore;version="5.2.0", + org.eclipse.jgit.ignore.internal;version="5.2.0";x-friends:="org.eclipse.jgit.test", + org.eclipse.jgit.internal;version="5.2.0";x-friends:="org.eclipse.jgit.test,org.eclipse.jgit.http.test", + org.eclipse.jgit.internal.fsck;version="5.2.0";x-friends:="org.eclipse.jgit.test", + org.eclipse.jgit.internal.ketch;version="5.2.0";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm", + org.eclipse.jgit.internal.storage.dfs;version="5.2.0"; x-friends:="org.eclipse.jgit.test, org.eclipse.jgit.http.server, org.eclipse.jgit.http.test, org.eclipse.jgit.lfs.test", - org.eclipse.jgit.internal.storage.file;version="5.1.3"; + org.eclipse.jgit.internal.storage.file;version="5.2.0"; x-friends:="org.eclipse.jgit.test, org.eclipse.jgit.junit, org.eclipse.jgit.junit.http, @@ -75,12 +75,12 @@ Export-Package: org.eclipse.jgit.annotations;version="5.1.3", org.eclipse.jgit.lfs, org.eclipse.jgit.pgm, org.eclipse.jgit.pgm.test", - org.eclipse.jgit.internal.storage.io;version="5.1.3";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm", - org.eclipse.jgit.internal.storage.pack;version="5.1.3";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm", - org.eclipse.jgit.internal.storage.reftable;version="5.1.3"; + org.eclipse.jgit.internal.storage.io;version="5.2.0";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm", + org.eclipse.jgit.internal.storage.pack;version="5.2.0";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm", + org.eclipse.jgit.internal.storage.reftable;version="5.2.0"; x-friends:="org.eclipse.jgit.http.test,org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm", - org.eclipse.jgit.internal.storage.reftree;version="5.1.3";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm", - org.eclipse.jgit.lib;version="5.1.3"; + org.eclipse.jgit.internal.storage.reftree;version="5.2.0";x-friends:="org.eclipse.jgit.junit,org.eclipse.jgit.test,org.eclipse.jgit.pgm", + org.eclipse.jgit.lib;version="5.2.0"; uses:="org.eclipse.jgit.revwalk, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.util, @@ -90,33 +90,33 @@ Export-Package: org.eclipse.jgit.annotations;version="5.1.3", org.eclipse.jgit.treewalk, org.eclipse.jgit.transport, org.eclipse.jgit.submodule", - org.eclipse.jgit.lib.internal;version="5.1.3";x-internal:=true, - org.eclipse.jgit.merge;version="5.1.3"; + org.eclipse.jgit.lib.internal;version="5.2.0";x-internal:=true, + org.eclipse.jgit.merge;version="5.2.0"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.treewalk, org.eclipse.jgit.revwalk, org.eclipse.jgit.diff, org.eclipse.jgit.dircache, org.eclipse.jgit.api", - org.eclipse.jgit.nls;version="5.1.3", - org.eclipse.jgit.notes;version="5.1.3"; + org.eclipse.jgit.nls;version="5.2.0", + org.eclipse.jgit.notes;version="5.2.0"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.treewalk, org.eclipse.jgit.revwalk, org.eclipse.jgit.merge", - org.eclipse.jgit.patch;version="5.1.3";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.diff", - org.eclipse.jgit.revplot;version="5.1.3";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.revwalk", - org.eclipse.jgit.revwalk;version="5.1.3"; + org.eclipse.jgit.patch;version="5.2.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.diff", + org.eclipse.jgit.revplot;version="5.2.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.revwalk", + org.eclipse.jgit.revwalk;version="5.2.0"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.treewalk, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.diff, org.eclipse.jgit.revwalk.filter", - org.eclipse.jgit.revwalk.filter;version="5.1.3";uses:="org.eclipse.jgit.revwalk,org.eclipse.jgit.lib,org.eclipse.jgit.util", - org.eclipse.jgit.storage.file;version="5.1.3";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.util", - org.eclipse.jgit.storage.pack;version="5.1.3";uses:="org.eclipse.jgit.lib", - org.eclipse.jgit.submodule;version="5.1.3";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.treewalk.filter,org.eclipse.jgit.treewalk", - org.eclipse.jgit.transport;version="5.1.3"; + org.eclipse.jgit.revwalk.filter;version="5.2.0";uses:="org.eclipse.jgit.revwalk,org.eclipse.jgit.lib,org.eclipse.jgit.util", + org.eclipse.jgit.storage.file;version="5.2.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.util", + org.eclipse.jgit.storage.pack;version="5.2.0";uses:="org.eclipse.jgit.lib", + org.eclipse.jgit.submodule;version="5.2.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.treewalk.filter,org.eclipse.jgit.treewalk", + org.eclipse.jgit.transport;version="5.2.0"; uses:="org.eclipse.jgit.transport.resolver, org.eclipse.jgit.revwalk, org.eclipse.jgit.internal.storage.pack, @@ -128,24 +128,24 @@ Export-Package: org.eclipse.jgit.annotations;version="5.1.3", org.eclipse.jgit.transport.http, org.eclipse.jgit.errors, org.eclipse.jgit.storage.pack", - org.eclipse.jgit.transport.http;version="5.1.3";uses:="javax.net.ssl", - org.eclipse.jgit.transport.resolver;version="5.1.3";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.transport", - org.eclipse.jgit.treewalk;version="5.1.3"; + org.eclipse.jgit.transport.http;version="5.2.0";uses:="javax.net.ssl", + org.eclipse.jgit.transport.resolver;version="5.2.0";uses:="org.eclipse.jgit.lib,org.eclipse.jgit.transport", + org.eclipse.jgit.treewalk;version="5.2.0"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.revwalk, org.eclipse.jgit.attributes, org.eclipse.jgit.treewalk.filter, org.eclipse.jgit.util, org.eclipse.jgit.dircache", - org.eclipse.jgit.treewalk.filter;version="5.1.3";uses:="org.eclipse.jgit.treewalk", - org.eclipse.jgit.util;version="5.1.3"; + org.eclipse.jgit.treewalk.filter;version="5.2.0";uses:="org.eclipse.jgit.treewalk", + org.eclipse.jgit.util;version="5.2.0"; uses:="org.eclipse.jgit.lib, org.eclipse.jgit.transport.http, org.eclipse.jgit.storage.file, org.ietf.jgss", - org.eclipse.jgit.util.io;version="5.1.3", - org.eclipse.jgit.util.sha1;version="5.1.3", - org.eclipse.jgit.util.time;version="5.1.3" + org.eclipse.jgit.util.io;version="5.2.0", + org.eclipse.jgit.util.sha1;version="5.2.0", + org.eclipse.jgit.util.time;version="5.2.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: com.googlecode.javaewah;version="[1.1.6,2.0.0)", com.jcraft.jsch;version="[0.1.37,0.2.0)", diff --git a/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF b/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF index eec78019e6..53adf99da2 100644 --- a/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF +++ b/org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF @@ -3,5 +3,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: org.eclipse.jgit - Sources Bundle-SymbolicName: org.eclipse.jgit.source Bundle-Vendor: Eclipse.org - JGit -Bundle-Version: 5.1.3.qualifier -Eclipse-SourceBundle: org.eclipse.jgit;version="5.1.3.qualifier";roots="." +Bundle-Version: 5.2.0.qualifier +Eclipse-SourceBundle: org.eclipse.jgit;version="5.2.0.qualifier";roots="." diff --git a/org.eclipse.jgit/pom.xml b/org.eclipse.jgit/pom.xml index 7d8b326e8d..0b31c46a03 100644 --- a/org.eclipse.jgit/pom.xml +++ b/org.eclipse.jgit/pom.xml @@ -53,7 +53,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit</artifactId> diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java index 5b84032b15..c6f3c671a9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java @@ -42,11 +42,14 @@ */ package org.eclipse.jgit.api; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.File; import java.io.FileOutputStream; -import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; import java.nio.file.StandardCopyOption; import java.text.MessageFormat; import java.util.ArrayList; @@ -258,7 +261,8 @@ public class ApplyCommand extends GitCommand<ApplyResult> { if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } - try (FileWriter fw = new FileWriter(f)) { + try (Writer fw = new OutputStreamWriter(new FileOutputStream(f), + UTF_8)) { fw.write(sb.toString()); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java index 5c06bac1f2..73af8ba16d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java @@ -283,12 +283,11 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> { config.addURI(u); final String dst = (bare ? Constants.R_HEADS : Constants.R_REMOTES - + config.getName() + "/") + "*"; //$NON-NLS-1$//$NON-NLS-2$ - RefSpec refSpec = new RefSpec(); - refSpec = refSpec.setForceUpdate(true); - refSpec = refSpec.setSourceDestination(Constants.R_HEADS + "*", dst); //$NON-NLS-1$ + + config.getName() + '/') + '*'; + boolean fetchAll = cloneAllBranches || branchesToClone == null + || branchesToClone.isEmpty(); - config.addFetchRefSpec(refSpec); + config.setFetchRefSpecs(calculateRefSpecs(fetchAll, dst)); config.update(clonedRepo.getConfig()); clonedRepo.getConfig().save(); @@ -297,27 +296,25 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> { FetchCommand command = new FetchCommand(clonedRepo); command.setRemote(remote); command.setProgressMonitor(monitor); - command.setTagOpt(TagOpt.FETCH_TAGS); + command.setTagOpt(fetchAll ? TagOpt.FETCH_TAGS : TagOpt.AUTO_FOLLOW); configure(command); - List<RefSpec> specs = calculateRefSpecs(dst); - command.setRefSpecs(specs); - return command.call(); } - private List<RefSpec> calculateRefSpecs(String dst) { + private List<RefSpec> calculateRefSpecs(boolean fetchAll, String dst) { RefSpec wcrs = new RefSpec(); wcrs = wcrs.setForceUpdate(true); - wcrs = wcrs.setSourceDestination(Constants.R_HEADS + "*", dst); //$NON-NLS-1$ + wcrs = wcrs.setSourceDestination(Constants.R_HEADS + '*', dst); List<RefSpec> specs = new ArrayList<>(); - if (cloneAllBranches) - specs.add(wcrs); - else if (branchesToClone != null - && branchesToClone.size() > 0) { - for (String selectedRef : branchesToClone) - if (wcrs.matchSource(selectedRef)) + if (!fetchAll) { + for (String selectedRef : branchesToClone) { + if (wcrs.matchSource(selectedRef)) { specs.add(wcrs.expandFromSource(selectedRef)); + } + } + } else { + specs.add(wcrs); } return specs; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java index 28a27a90e0..29a51a0f02 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java @@ -44,6 +44,10 @@ */ package org.eclipse.jgit.api; +import static org.eclipse.jgit.lib.Constants.HEAD; +import static org.eclipse.jgit.lib.Constants.R_HEADS; +import static org.eclipse.jgit.lib.Constants.R_REMOTES; + import java.io.IOException; import java.text.MessageFormat; import java.util.ArrayList; @@ -56,7 +60,6 @@ import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.api.errors.RefNotFoundException; import org.eclipse.jgit.internal.JGitText; -import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; @@ -113,17 +116,18 @@ public class ListBranchCommand extends GitCommand<List<Ref>> { Collection<Ref> refs = new ArrayList<>(); // Also return HEAD if it's detached - Ref head = repo.exactRef(Constants.HEAD); - if (head != null && head.getLeaf().getName().equals(Constants.HEAD)) + Ref head = repo.exactRef(HEAD); + if (head != null && head.getLeaf().getName().equals(HEAD)) { refs.add(head); + } if (listMode == null) { - refs.addAll(getRefs(Constants.R_HEADS)); + refs.addAll(repo.getRefDatabase().getRefsByPrefix(R_HEADS)); } else if (listMode == ListMode.REMOTE) { - refs.addAll(getRefs(Constants.R_REMOTES)); + refs.addAll(repo.getRefDatabase().getRefsByPrefix(R_REMOTES)); } else { - refs.addAll(getRefs(Constants.R_HEADS)); - refs.addAll(getRefs(Constants.R_REMOTES)); + refs.addAll(repo.getRefDatabase().getRefsByPrefix(R_HEADS, + R_REMOTES)); } resultRefs = new ArrayList<>(filterRefs(refs)); } catch (IOException e) { @@ -185,8 +189,4 @@ public class ListBranchCommand extends GitCommand<List<Ref>> { this.containsCommitish = containsCommitish; return this; } - - private Collection<Ref> getRefs(String prefix) throws IOException { - return repo.getRefDatabase().getRefsByPrefix(prefix); - } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java index 1783c4193e..9653c365b2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java @@ -43,6 +43,8 @@ */ package org.eclipse.jgit.api; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; @@ -1015,8 +1017,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> { df.setRepository(repo); df.format(commitToPick.getParent(0), commitToPick); } - rebaseState.createFile(PATCH, new String(bos.toByteArray(), - Constants.CHARACTER_ENCODING)); + rebaseState.createFile(PATCH, new String(bos.toByteArray(), UTF_8)); rebaseState.createFile(STOPPED_SHA, repo.newObjectReader() .abbreviate( @@ -1733,7 +1734,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> { throws IOException { File file = new File(parentDir, name); try (FileOutputStream fos = new FileOutputStream(file)) { - fos.write(content.getBytes(Constants.CHARACTER_ENCODING)); + fos.write(content.getBytes(UTF_8)); fos.write('\n'); } } @@ -1741,7 +1742,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> { private static void appendToFile(File file, String content) throws IOException { try (FileOutputStream fos = new FileOutputStream(file, true)) { - fos.write(content.getBytes(Constants.CHARACTER_ENCODING)); + fos.write(content.getBytes(UTF_8)); fos.write('\n'); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheIterator.java index 19c916f810..6196e758a9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheIterator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheIterator.java @@ -44,6 +44,8 @@ package org.eclipse.jgit.dircache; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.IOException; import java.io.InputStream; import java.util.Collections; @@ -75,7 +77,7 @@ import org.eclipse.jgit.util.RawParseUtils; public class DirCacheIterator extends AbstractTreeIterator { /** Byte array holding ".gitattributes" string */ private static final byte[] DOT_GIT_ATTRIBUTES_BYTES = Constants.DOT_GIT_ATTRIBUTES - .getBytes(); + .getBytes(UTF_8); /** The cache this iterator was created to walk. */ protected final DirCache cache; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java index 45a239da0e..5a73cdc067 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java @@ -42,6 +42,7 @@ */ package org.eclipse.jgit.gitrepo; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME; import static org.eclipse.jgit.lib.Constants.R_REMOTES; @@ -606,8 +607,7 @@ public class RepoCommand extends GitCommand<RevCommit> { } objectId = inserter.insert(Constants.OBJ_BLOB, - link.getBytes( - Constants.CHARACTER_ENCODING)); + link.getBytes(UTF_8)); dcEntry = new DirCacheEntry(linkfile.dest); dcEntry.setObjectId(objectId); dcEntry.setFileMode(FileMode.SYMLINK); @@ -620,7 +620,7 @@ public class RepoCommand extends GitCommand<RevCommit> { // create a new DirCacheEntry for .gitmodules file. final DirCacheEntry dcEntry = new DirCacheEntry(Constants.DOT_GIT_MODULES); ObjectId objectId = inserter.insert(Constants.OBJ_BLOB, - content.getBytes(Constants.CHARACTER_ENCODING)); + content.getBytes(UTF_8)); dcEntry.setObjectId(objectId); dcEntry.setFileMode(FileMode.REGULAR_FILE); builder.add(dcEntry); @@ -629,7 +629,7 @@ public class RepoCommand extends GitCommand<RevCommit> { // create a new DirCacheEntry for .gitattributes file. final DirCacheEntry dcEntryAttr = new DirCacheEntry(Constants.DOT_GIT_ATTRIBUTES); ObjectId attrId = inserter.insert(Constants.OBJ_BLOB, - attributes.toString().getBytes(Constants.CHARACTER_ENCODING)); + attributes.toString().getBytes(UTF_8)); dcEntryAttr.setObjectId(attrId); dcEntryAttr.setFileMode(FileMode.REGULAR_FILE); builder.add(dcEntryAttr); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java index 24723d850c..4d5c1c0345 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.internal.storage.file; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.internal.storage.pack.PackExt.INDEX; import static org.eclipse.jgit.internal.storage.pack.PackExt.PACK; @@ -50,7 +51,6 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; import java.nio.file.AtomicMoveNotSupportedException; import java.nio.file.Files; @@ -1034,8 +1034,8 @@ public class ObjectDirectory extends FileObjectDatabase { } private static BufferedReader open(File f) - throws FileNotFoundException { - return new BufferedReader(new FileReader(f)); + throws IOException, FileNotFoundException { + return Files.newBufferedReader(f.toPath(), UTF_8); } private AlternateHandle openAlternate(String location) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java index 70695880d3..964cc4d120 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java @@ -207,7 +207,7 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex } /** An entry in the old PackBitmapIndex. */ - public final class Entry extends ObjectId { + public static final class Entry extends ObjectId { private final int flags; Entry(AnyObjectId src, int flags) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java index b666f21d0b..8558e3d0b2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java @@ -868,7 +868,7 @@ public class Config { boolean lastWasMatch = false; for (ConfigLine e : srcState.entryList) { - if (e.match(section, subsection)) { + if (e.includedFrom == null && e.match(section, subsection)) { // Skip this record, it's for the section we are removing. lastWasMatch = true; continue; @@ -923,7 +923,7 @@ public class Config { // while (entryIndex < entries.size() && valueIndex < values.size()) { final ConfigLine e = entries.get(entryIndex); - if (e.match(section, subsection, name)) { + if (e.includedFrom == null && e.match(section, subsection, name)) { entries.set(entryIndex, e.forValue(values.get(valueIndex++))); insertPosition = entryIndex + 1; } @@ -935,7 +935,8 @@ public class Config { if (valueIndex == values.size() && entryIndex < entries.size()) { while (entryIndex < entries.size()) { final ConfigLine e = entries.get(entryIndex++); - if (e.match(section, subsection, name)) + if (e.includedFrom == null + && e.match(section, subsection, name)) entries.remove(--entryIndex); } } @@ -948,7 +949,8 @@ public class Config { // is already a section available that matches. Insert // after the last key of that section. // - insertPosition = findSectionEnd(entries, section, subsection); + insertPosition = findSectionEnd(entries, section, subsection, + true); } if (insertPosition < 0) { // We didn't find any matching section header for this key, @@ -985,9 +987,14 @@ public class Config { } private static int findSectionEnd(final List<ConfigLine> entries, - final String section, final String subsection) { + final String section, final String subsection, + boolean skipIncludedLines) { for (int i = 0; i < entries.size(); i++) { ConfigLine e = entries.get(i); + if (e.includedFrom != null && skipIncludedLines) { + continue; + } + if (e.match(section, subsection, null)) { i++; while (i < entries.size()) { @@ -1011,6 +1018,8 @@ public class Config { public String toText() { final StringBuilder out = new StringBuilder(); for (ConfigLine e : state.get().entryList) { + if (e.includedFrom != null) + continue; if (e.prefix != null) out.append(e.prefix); if (e.section != null && e.name == null) { @@ -1060,11 +1069,11 @@ public class Config { * made to {@code this}. */ public void fromText(String text) throws ConfigInvalidException { - state.set(newState(fromTextRecurse(text, 1))); + state.set(newState(fromTextRecurse(text, 1, null))); } - private List<ConfigLine> fromTextRecurse(String text, int depth) - throws ConfigInvalidException { + private List<ConfigLine> fromTextRecurse(String text, int depth, + String includedFrom) throws ConfigInvalidException { if (depth > MAX_DEPTH) { throw new ConfigInvalidException( JGitText.get().tooManyIncludeRecursions); @@ -1073,6 +1082,7 @@ public class Config { final StringReader in = new StringReader(text); ConfigLine last = null; ConfigLine e = new ConfigLine(); + e.includedFrom = includedFrom; for (;;) { int input = in.read(); if (-1 == input) { @@ -1088,7 +1098,7 @@ public class Config { if (e.section != null) last = e; e = new ConfigLine(); - + e.includedFrom = includedFrom; } else if (e.suffix != null) { // Everything up until the end-of-line is in the suffix. e.suffix += c; @@ -1173,7 +1183,7 @@ public class Config { decoded = RawParseUtils.decode(bytes); } try { - newEntries.addAll(fromTextRecurse(decoded, depth + 1)); + newEntries.addAll(fromTextRecurse(decoded, depth + 1, line.value)); } catch (ConfigInvalidException e) { throw new ConfigInvalidException(MessageFormat .format(JGitText.get().cannotReadFile, line.value), e); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java index d4a0280da6..196ce64d04 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java @@ -432,4 +432,18 @@ public final class ConfigConstants { * @since 4.11 */ public static final String CONFIG_SECTION_LFS = "lfs"; + + /** + * The "i18n" section + * + * @since 5.2 + */ + public static final String CONFIG_SECTION_I18N = "i18n"; + + /** + * The "logOutputEncoding" key + * + * @since 5.2 + */ + public static final String CONFIG_KEY_LOG_OUTPUT_ENCODING = "logOutputEncoding"; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigLine.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigLine.java index 937ba925c5..e623a8cebc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigLine.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigLine.java @@ -73,6 +73,9 @@ class ConfigLine { /** The text content after entry. */ String suffix; + /** The source from which this line was included from. */ + String includedFrom; + ConfigLine forValue(String newValue) { final ConfigLine e = new ConfigLine(); e.prefix = prefix; @@ -81,6 +84,7 @@ class ConfigLine { e.name = name; e.value = newValue; e.suffix = suffix; + e.includedFrom = includedFrom; return e; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java index ed0055416b..4c55196961 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java @@ -232,11 +232,17 @@ public final class Constants { * * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} directly * instead. - **/ + */ @Deprecated public static final Charset CHARSET; - /** Native character encoding for commit messages, file names... */ + /** + * Native character encoding for commit messages, file names... + * + * @deprecated Use {@link java.nio.charset.StandardCharsets#UTF_8} directly + * instead. + */ + @Deprecated public static final String CHARACTER_ENCODING; /** Default main branch name */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java index 3170787dd9..68929b4220 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java @@ -415,6 +415,31 @@ public abstract class RefDatabase { } /** + * Returns refs whose names start with one of the given prefixes. + * <p> + * The default implementation uses {@link #getRefsByPrefix(String)}. + * Implementors of {@link RefDatabase} should override this method directly + * if a better implementation is possible. + * + * @param prefixes + * strings that names of refs should start with. + * @return immutable list of refs whose names start with one of + * {@code prefixes}. Refs can be unsorted and may contain duplicates + * if the prefixes overlap. + * @throws java.io.IOException + * the reference space cannot be accessed. + * @since 5.2 + */ + @NonNull + public List<Ref> getRefsByPrefix(String... prefixes) throws IOException { + List<Ref> result = new ArrayList<>(); + for (String prefix : prefixes) { + result.addAll(getRefsByPrefix(prefix)); + } + return Collections.unmodifiableList(result); + } + + /** * Check if any refs exist in the ref database. * <p> * This uses the same definition of refs as {@link #getRefs()}. In diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java index 5cd593ed5e..fc3ea8467a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java @@ -823,7 +823,7 @@ public abstract class RefUpdate { * Handle the abstraction of storing a ref update. This is because both * updating and deleting of a ref have merge testing in common. */ - private abstract class Store { + private static abstract class Store { abstract Result execute(Result status) throws IOException; } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java index d73c05e243..2a2699f906 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java @@ -49,6 +49,7 @@ package org.eclipse.jgit.lib; import static org.eclipse.jgit.lib.Constants.LOCK_SUFFIX; +import static java.nio.charset.StandardCharsets.UTF_8; import java.io.BufferedOutputStream; import java.io.File; @@ -1965,7 +1966,7 @@ public abstract class Repository implements AutoCloseable { private void writeCommitMsg(File msgFile, String msg) throws IOException { if (msg != null) { try (FileOutputStream fos = new FileOutputStream(msgFile)) { - fos.write(msg.getBytes(Constants.CHARACTER_ENCODING)); + fos.write(msg.getBytes(UTF_8)); } } else { FileUtils.delete(msgFile, FileUtils.SKIP_MISSING); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java index 036917e62a..479670873d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.merge; import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; @@ -63,7 +64,7 @@ public class MergeFormatter { * that are LF-separated lines. * * @param out - * the outputstream where to write the textual presentation + * the output stream where to write the textual presentation * @param res * the merge result which should be presented * @param seqName @@ -72,13 +73,44 @@ public class MergeFormatter { * " or ">>>>>>> " conflict markers. The * names for the sequences are given in this list * @param charsetName - * the name of the characterSet used when writing conflict + * the name of the character set used when writing conflict * metadata * @throws java.io.IOException + * @deprecated Use + * {@link #formatMerge(OutputStream, MergeResult, List, Charset)} + * instead. */ + @Deprecated public void formatMerge(OutputStream out, MergeResult<RawText> res, List<String> seqName, String charsetName) throws IOException { - new MergeFormatterPass(out, res, seqName, charsetName).formatMerge(); + formatMerge(out, res, seqName, Charset.forName(charsetName)); + } + + /** + * Formats the results of a merge of {@link org.eclipse.jgit.diff.RawText} + * objects in a Git conformant way. This method also assumes that the + * {@link org.eclipse.jgit.diff.RawText} objects being merged are line + * oriented files which use LF as delimiter. This method will also use LF to + * separate chunks and conflict metadata, therefore it fits only to texts + * that are LF-separated lines. + * + * @param out + * the output stream where to write the textual presentation + * @param res + * the merge result which should be presented + * @param seqName + * When a conflict is reported each conflicting range will get a + * name. This name is following the "<<<<<<< + * " or ">>>>>>> " conflict markers. The + * names for the sequences are given in this list + * @param charset + * the character set used when writing conflict metadata + * @throws java.io.IOException + * @since 5.2 + */ + public void formatMerge(OutputStream out, MergeResult<RawText> res, + List<String> seqName, Charset charset) throws IOException { + new MergeFormatterPass(out, res, seqName, charset).formatMerge(); } /** @@ -100,17 +132,51 @@ public class MergeFormatter { * @param theirsName * the name ranges from theirs should get * @param charsetName - * the name of the characterSet used when writing conflict + * the name of the character set used when writing conflict * metadata * @throws java.io.IOException + * @deprecated use + * {@link #formatMerge(OutputStream, MergeResult, String, String, String, Charset)} + * instead. */ - @SuppressWarnings("unchecked") + @Deprecated public void formatMerge(OutputStream out, MergeResult res, String baseName, String oursName, String theirsName, String charsetName) throws IOException { + formatMerge(out, res, baseName, oursName, theirsName, + Charset.forName(charsetName)); + } + + /** + * Formats the results of a merge of exactly two + * {@link org.eclipse.jgit.diff.RawText} objects in a Git conformant way. + * This convenience method accepts the names for the three sequences (base + * and the two merged sequences) as explicit parameters and doesn't require + * the caller to specify a List + * + * @param out + * the {@link java.io.OutputStream} where to write the textual + * presentation + * @param res + * the merge result which should be presented + * @param baseName + * the name ranges from the base should get + * @param oursName + * the name ranges from ours should get + * @param theirsName + * the name ranges from theirs should get + * @param charset + * the character set used when writing conflict metadata + * @throws java.io.IOException + * @since 5.2 + */ + @SuppressWarnings("unchecked") + public void formatMerge(OutputStream out, MergeResult res, String baseName, + String oursName, String theirsName, Charset charset) + throws IOException { List<String> names = new ArrayList<>(3); names.add(baseName); names.add(oursName); names.add(theirsName); - formatMerge(out, res, names, charsetName); + formatMerge(out, res, names, charset); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatterPass.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatterPass.java index 060f06884a..e1a8d3110e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatterPass.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatterPass.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.merge; import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.Charset; import java.util.List; import org.eclipse.jgit.diff.RawText; @@ -59,19 +60,33 @@ class MergeFormatterPass { private final List<String> seqName; - private final String charsetName; + private final Charset charset; private final boolean threeWayMerge; private String lastConflictingName; // is set to non-null whenever we are in // a conflict - MergeFormatterPass(OutputStream out, MergeResult<RawText> res, List<String> seqName, - String charsetName) { + /** + * @param out + * the {@link java.io.OutputStream} where to write the textual + * presentation + * @param res + * the merge result which should be presented + * @param seqName + * When a conflict is reported each conflicting range will get a + * name. This name is following the "<<<<<<< + * " or ">>>>>>> " conflict markers. The + * names for the sequences are given in this list + * @param charset + * the character set used when writing conflict metadata + */ + MergeFormatterPass(OutputStream out, MergeResult<RawText> res, + List<String> seqName, Charset charset) { this.out = new EolAwareOutputStream(out); this.res = res; this.seqName = seqName; - this.charsetName = charsetName; + this.charset = charset; this.threeWayMerge = (res.getSequences().size() == 3); } @@ -133,7 +148,7 @@ class MergeFormatterPass { private void writeln(String s) throws IOException { out.beginln(); - out.write((s + "\n").getBytes(charsetName)); //$NON-NLS-1$ + out.write((s + "\n").getBytes(charset)); //$NON-NLS-1$ } private void writeLine(RawText seq, int i) throws IOException { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java index f60c95f647..412d9bba73 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java @@ -46,10 +46,10 @@ */ package org.eclipse.jgit.merge; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.diff.DiffAlgorithm.SupportedAlgorithm.HISTOGRAM; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_DIFF_SECTION; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_ALGORITHM; -import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING; import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; import java.io.BufferedOutputStream; @@ -1026,7 +1026,7 @@ public class ResolveMerger extends ThreeWayMerger { db != null ? nonNullRepo().getDirectory() : null, inCoreLimit); try { new MergeFormatter().formatMerge(buf, result, - Arrays.asList(commitNames), CHARACTER_ENCODING); + Arrays.asList(commitNames), UTF_8); buf.close(); } catch (IOException e) { buf.destroy(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthGenerator.java index eaec305b47..6c6cc95c2e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthGenerator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthGenerator.java @@ -59,6 +59,8 @@ class DepthGenerator extends Generator { private final int depth; + private final int deepenSince; + private final RevWalk walk; /** @@ -91,6 +93,7 @@ class DepthGenerator extends Generator { walk = (RevWalk)w; this.depth = w.getDepth(); + this.deepenSince = w.getDeepenSince(); this.UNSHALLOW = w.getUnshallowFlag(); this.REINTERESTING = w.getReinterestingFlag(); @@ -142,12 +145,24 @@ class DepthGenerator extends Generator { // this depth is guaranteed to be the smallest value that // any path could produce. if (dp.depth == -1) { + boolean failsDeepenSince = false; + if (deepenSince != 0) { + if ((p.flags & RevWalk.PARSED) == 0) { + p.parseHeaders(walk); + } + failsDeepenSince = + p.getCommitTime() < deepenSince; + } + dp.depth = newDepth; // If the parent is not too deep, add it to the queue // so that we can produce it later - if (newDepth <= depth) + if (newDepth <= depth && !failsDeepenSince) { pending.add(p); + } else { + c.isBoundary = true; + } } // If the current commit has become unshallowed, everything @@ -160,8 +175,7 @@ class DepthGenerator extends Generator { } } - // Produce all commits less than the depth cutoff - boolean produce = c.depth <= depth; + boolean produce = true; // Unshallow commits are uninteresting, but still need to be sent // up to the PackWriter so that it will exclude objects correctly. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthWalk.java index 06a5272b98..3499572d07 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/DepthWalk.java @@ -63,6 +63,15 @@ public interface DepthWalk { */ public int getDepth(); + /** + * @return the deepen-since value; if not 0, this walk only returns commits + * whose commit time is at or after this limit + * @since 5.2 + */ + public default int getDeepenSince() { + return 0; + } + /** @return flag marking commits that should become unshallow. */ /** * Get flag marking commits that should become unshallow. @@ -83,12 +92,23 @@ public interface DepthWalk { /** Depth of this commit in the graph, via shortest path. */ int depth; + boolean isBoundary; + /** @return depth of this commit, as found by the shortest path. */ public int getDepth() { return depth; } /** + * @return true if at least one of this commit's children was excluded + * due to a depth or shallow-since restriction, false otherwise + * @since 5.2 + */ + public boolean isBoundary() { + return isBoundary; + } + + /** * Initialize a new commit. * * @param id @@ -104,6 +124,8 @@ public interface DepthWalk { public class RevWalk extends org.eclipse.jgit.revwalk.RevWalk implements DepthWalk { private final int depth; + private int deepenSince; + private final RevFlag UNSHALLOW; private final RevFlag REINTERESTING; @@ -159,6 +181,22 @@ public interface DepthWalk { } @Override + public int getDeepenSince() { + return deepenSince; + } + + /** + * Sets the deepen-since value. + * + * @param limit + * new deepen-since value + * @since 5.2 + */ + public void setDeepenSince(int limit) { + deepenSince = limit; + } + + @Override public RevFlag getUnshallowFlag() { return UNSHALLOW; } @@ -174,6 +212,7 @@ public interface DepthWalk { @Override public ObjectWalk toObjectWalkWithSameObjects() { ObjectWalk ow = new ObjectWalk(reader, depth); + ow.deepenSince = deepenSince; ow.objects = objects; ow.freeFlags = freeFlags; return ow; @@ -184,6 +223,8 @@ public interface DepthWalk { public class ObjectWalk extends org.eclipse.jgit.revwalk.ObjectWalk implements DepthWalk { private final int depth; + private int deepenSince; + private final RevFlag UNSHALLOW; private final RevFlag REINTERESTING; @@ -263,6 +304,11 @@ public interface DepthWalk { } @Override + public int getDeepenSince() { + return deepenSince; + } + + @Override public RevFlag getUnshallowFlag() { return UNSHALLOW; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java index f6ec4b90eb..c5661e5083 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java @@ -542,7 +542,7 @@ public class AmazonS3 { } buf = b.toByteArray(); if (buf.length > 0) { - err.initCause(new IOException("\n" + new String(buf))); //$NON-NLS-1$ + err.initCause(new IOException("\n" + new String(buf, UTF_8))); //$NON-NLS-1$ } } return err; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java index c43ab18c35..211707e9ad 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java @@ -44,6 +44,7 @@ package org.eclipse.jgit.transport; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.eclipse.jgit.transport.ReceiveCommand.Result.NOT_ATTEMPTED; import static org.eclipse.jgit.transport.ReceiveCommand.Result.OK; import static org.eclipse.jgit.transport.ReceiveCommand.Result.REJECTED_NONFASTFORWARD; @@ -337,7 +338,7 @@ class FetchProcess { try { if (lock.lock()) { try (Writer w = new OutputStreamWriter( - lock.getOutputStream())) { + lock.getOutputStream(), UTF_8)) { for (FetchHeadRecord h : fetchHeadUpdates) { h.write(w); result.add(h); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/NetRC.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/NetRC.java index e688f6340d..8562376aa9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/NetRC.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/NetRC.java @@ -42,10 +42,13 @@ package org.eclipse.jgit.transport; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedReader; import java.io.File; -import java.io.FileReader; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStreamReader; import java.util.Collection; import java.util.HashMap; import java.util.Locale; @@ -211,7 +214,8 @@ public class NetRC { this.hosts.clear(); this.lastModified = this.netrc.lastModified(); - try (BufferedReader r = new BufferedReader(new FileReader(netrc))) { + try (BufferedReader r = new BufferedReader( + new InputStreamReader(new FileInputStream(netrc), UTF_8))) { String line = null; NetRCEntry entry = new NetRCEntry(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java index 480055c2e4..a5fa3fee35 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/OpenSshConfig.java @@ -43,6 +43,8 @@ package org.eclipse.jgit.transport; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -241,7 +243,8 @@ public class OpenSshConfig implements ConfigRepository { private Map<String, HostEntry> parse(InputStream in) throws IOException { final Map<String, HostEntry> m = new LinkedHashMap<>(); - final BufferedReader br = new BufferedReader(new InputStreamReader(in)); + final BufferedReader br = new BufferedReader( + new InputStreamReader(in, UTF_8)); final List<HostEntry> current = new ArrayList<>(4); String line; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java index eae2c6edb9..da0fb9c447 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java @@ -53,6 +53,8 @@ import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_WANT_REF; import java.io.IOException; import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; import org.eclipse.jgit.errors.PackProtocolException; import org.eclipse.jgit.internal.JGitText; @@ -204,6 +206,51 @@ final class ProtocolV2Parser { } /** + * Parse the incoming ls-refs request arguments from the wire. This is meant + * for calling immediately after the caller has consumed a "command=ls-refs" + * line indicating the beginning of a ls-refs request. + * + * The incoming PacketLineIn is consumed until an END line, but the caller + * is responsible for closing it (if needed) + * + * @param pckIn + * incoming lines. This method will read until an END line. + * @return a LsRefsV2Request object with the data received in the wire. + * @throws PackProtocolException + * for inconsistencies in the protocol (e.g. unexpected lines) + * @throws IOException + * reporting problems reading the incoming messages from the + * wire + */ + LsRefsV2Request parseLsRefsRequest(PacketLineIn pckIn) + throws PackProtocolException, IOException { + LsRefsV2Request.Builder builder = LsRefsV2Request.builder(); + List<String> prefixes = new ArrayList<>(); + String line = pckIn.readString(); + // Currently, we do not support any capabilities, so the next + // line is DELIM if there are arguments or END if not. + if (line == PacketLineIn.DELIM) { + while ((line = pckIn.readString()) != PacketLineIn.END) { + if (line.equals("peel")) { //$NON-NLS-1$ + builder.setPeel(true); + } else if (line.equals("symrefs")) { //$NON-NLS-1$ + builder.setSymrefs(true); + } else if (line.startsWith("ref-prefix ")) { //$NON-NLS-1$ + prefixes.add(line.substring("ref-prefix ".length())); //$NON-NLS-1$ + } else { + throw new PackProtocolException(MessageFormat + .format(JGitText.get().unexpectedPacketLine, line)); + } + } + } else if (line != PacketLineIn.END) { + throw new PackProtocolException(MessageFormat + .format(JGitText.get().unexpectedPacketLine, line)); + } + + return builder.setRefPrefixes(prefixes).build(); + } + + /* * Process the content of "filter" line from the protocol. It has a shape * like "blob:none" or "blob:limit=N", with limit a positive number. * diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java index 90600cbb98..fde4401289 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java @@ -236,7 +236,7 @@ public class SideBandInputStream extends InputStream { messages.write(msg); if (out != null) - out.write(msg.getBytes()); + out.write(msg.getBytes(UTF_8)); } private void beginTask(int totalWorkUnits) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java index 026fd819c4..70fb1f0e56 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java @@ -48,10 +48,11 @@ package org.eclipse.jgit.transport; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.Serializable; -import java.io.UnsupportedEncodingException; import java.net.URISyntaxException; import java.net.URL; import java.util.BitSet; @@ -282,12 +283,7 @@ public class URIish implements Serializable { if (s.indexOf('%') < 0) return s; - byte[] bytes; - try { - bytes = s.getBytes(Constants.CHARACTER_ENCODING); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); // can't happen - } + byte[] bytes = s.getBytes(UTF_8); byte[] os = new byte[bytes.length]; int j = 0; @@ -335,12 +331,7 @@ public class URIish implements Serializable { if (s == null) return null; ByteArrayOutputStream os = new ByteArrayOutputStream(s.length()); - byte[] bytes; - try { - bytes = s.getBytes(Constants.CHARACTER_ENCODING); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); // cannot happen - } + byte[] bytes = s.getBytes(UTF_8); for (int i = 0; i < bytes.length; ++i) { int b = bytes[i] & 0xFF; if (b <= 32 || (encodeNonAscii && b > 127) || b == '%' diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java index cd7290edcd..213bfe504b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -215,6 +215,15 @@ public class UploadPack { } } + /* + * {@link java.util.function.Consumer} doesn't allow throwing checked + * exceptions. Define our own to propagate IOExceptions. + */ + @FunctionalInterface + private static interface IOConsumer<R> { + void accept(R t) throws IOException; + } + /** Database we read the objects from. */ private final Repository db; @@ -832,8 +841,15 @@ public class UploadPack { if (!clientShallowCommits.isEmpty()) verifyClientShallow(clientShallowCommits); - if (depth != 0) - processShallow(null, unshallowCommits, true); + if (depth != 0 || shallowSince != 0) { + computeShallowsAndUnshallows(wantIds, shallow -> { + pckOut.writeString("shallow " + shallow.name() + '\n'); //$NON-NLS-1$ + }, unshallow -> { + pckOut.writeString("unshallow " + unshallow.name() + '\n'); //$NON-NLS-1$ + unshallowCommits.add(unshallow); + }); + pckOut.end(); + } if (!clientShallowCommits.isEmpty()) walk.assumeShallow(clientShallowCommits); sendPack = negotiate(accumulator); @@ -891,30 +907,8 @@ public class UploadPack { } private void lsRefsV2() throws IOException { - LsRefsV2Request.Builder builder = LsRefsV2Request.builder(); - List<String> prefixes = new ArrayList<>(); - String line = pckIn.readString(); - // Currently, we do not support any capabilities, so the next - // line is DELIM if there are arguments or END if not. - if (line == PacketLineIn.DELIM) { - while ((line = pckIn.readString()) != PacketLineIn.END) { - if (line.equals("peel")) { //$NON-NLS-1$ - builder.setPeel(true); - } else if (line.equals("symrefs")) { //$NON-NLS-1$ - builder.setSymrefs(true); - } else if (line.startsWith("ref-prefix ")) { //$NON-NLS-1$ - prefixes.add(line.substring("ref-prefix ".length())); //$NON-NLS-1$ - } else { - throw new PackProtocolException(MessageFormat - .format(JGitText.get().unexpectedPacketLine, line)); - } - } - } else if (line != PacketLineIn.END) { - throw new PackProtocolException(MessageFormat - .format(JGitText.get().unexpectedPacketLine, line)); - } - LsRefsV2Request req = builder.setRefPrefixes(prefixes).build(); - + ProtocolV2Parser parser = new ProtocolV2Parser(transferConfig); + LsRefsV2Request req = parser.parseLsRefsRequest(pckIn); protocolV2Hook.onLsRefs(req); rawOut.stopBuffering(); @@ -928,10 +922,9 @@ public class UploadPack { refsToSend = getAdvertisedOrDefaultRefs(); } else { refsToSend = new HashMap<>(); - for (String refPrefix : req.getRefPrefixes()) { - for (Ref ref : db.getRefDatabase().getRefsByPrefix(refPrefix)) { - refsToSend.put(ref.getName(), ref); - } + String[] prefixes = req.getRefPrefixes().toArray(new String[0]); + for (Ref ref : db.getRefDatabase().getRefsByPrefix(prefixes)) { + refsToSend.put(ref.getName(), ref); } } if (req.getSymrefs()) { @@ -973,16 +966,19 @@ public class UploadPack { deepenNotRefs = req.getDeepenNotRefs(); boolean sectionSent = false; - @Nullable List<ObjectId> shallowCommits = null; + boolean mayHaveShallow = req.getDepth() != 0 + || req.getDeepenSince() != 0 + || !req.getDeepenNotRefs().isEmpty(); + List<ObjectId> shallowCommits = new ArrayList<>(); List<ObjectId> unshallowCommits = new ArrayList<>(); if (!req.getClientShallowCommits().isEmpty()) { verifyClientShallow(req.getClientShallowCommits()); } - if (req.getDepth() != 0 || req.getDeepenSince() != 0 - || !req.getDeepenNotRefs().isEmpty()) { - shallowCommits = new ArrayList<>(); - processShallow(shallowCommits, unshallowCommits, false); + if (mayHaveShallow) { + computeShallowsAndUnshallows(req.getWantsIds(), + shallowCommit -> shallowCommits.add(shallowCommit), + unshallowCommit -> unshallowCommits.add(unshallowCommit)); } if (!req.getClientShallowCommits().isEmpty()) walk.assumeShallow(req.getClientShallowCommits()); @@ -1008,7 +1004,7 @@ public class UploadPack { } if (req.wasDoneReceived() || okToGiveUp()) { - if (shallowCommits != null) { + if (mayHaveShallow) { if (sectionSent) pckOut.writeDelim(); pckOut.writeString("shallow-info\n"); //$NON-NLS-1$ @@ -1140,28 +1136,27 @@ public class UploadPack { } /* - * Determines what "shallow" and "unshallow" lines to send to the user. - * The information is written to shallowCommits (if not null) and - * unshallowCommits, and also written to #pckOut (if writeToPckOut is - * true). + * Determines what object ids must be marked as shallow or unshallow for the + * client. */ - private void processShallow(@Nullable List<ObjectId> shallowCommits, - List<ObjectId> unshallowCommits, - boolean writeToPckOut) throws IOException { - if (options.contains(OPTION_DEEPEN_RELATIVE) || - shallowSince != 0 || - !deepenNotRefs.isEmpty()) { - // TODO(jonathantanmy): Implement deepen-relative, deepen-since, + private void computeShallowsAndUnshallows(Iterable<ObjectId> wants, + IOConsumer<ObjectId> shallowFunc, + IOConsumer<ObjectId> unshallowFunc) + throws IOException { + if (options.contains(OPTION_DEEPEN_RELATIVE) || !deepenNotRefs.isEmpty()) { + // TODO(jonathantanmy): Implement deepen-relative // and deepen-not. throw new UnsupportedOperationException(); } - int walkDepth = depth - 1; + int walkDepth = depth == 0 ? Integer.MAX_VALUE : depth - 1; try (DepthWalk.RevWalk depthWalk = new DepthWalk.RevWalk( walk.getObjectReader(), walkDepth)) { + depthWalk.setDeepenSince(shallowSince); + // Find all the commits which will be shallow - for (ObjectId o : wantIds) { + for (ObjectId o : wants) { try { depthWalk.markRoot(depthWalk.parseCommit(o)); } catch (IncorrectObjectTypeException notCommit) { @@ -1173,32 +1168,21 @@ public class UploadPack { while ((o = depthWalk.next()) != null) { DepthWalk.Commit c = (DepthWalk.Commit) o; + boolean isBoundary = (c.getDepth() == walkDepth) || c.isBoundary(); + // Commits at the boundary which aren't already shallow in // the client need to be marked as such - if (c.getDepth() == walkDepth - && !clientShallowCommits.contains(c)) { - if (shallowCommits != null) { - shallowCommits.add(c.copy()); - } - if (writeToPckOut) { - pckOut.writeString("shallow " + o.name()); //$NON-NLS-1$ - } + if (isBoundary && !clientShallowCommits.contains(c)) { + shallowFunc.accept(c.copy()); } // Commits not on the boundary which are shallow in the client // need to become unshallowed - if (c.getDepth() < walkDepth - && clientShallowCommits.remove(c)) { - unshallowCommits.add(c.copy()); - if (writeToPckOut) { - pckOut.writeString("unshallow " + c.name()); //$NON-NLS-1$ - } + if (!isBoundary && clientShallowCommits.remove(c)) { + unshallowFunc.accept(c.copy()); } } } - if (writeToPckOut) { - pckOut.end(); - } } /* @@ -2004,9 +1988,11 @@ public class UploadPack { } RevWalk rw = walk; - if (depth > 0) { + if (depth > 0 || shallowSince != 0) { + int walkDepth = depth == 0 ? Integer.MAX_VALUE : depth - 1; pw.setShallowPack(depth, unshallowCommits); - rw = new DepthWalk.RevWalk(walk.getObjectReader(), depth - 1); + rw = new DepthWalk.RevWalk(walk.getObjectReader(), walkDepth); + ((DepthWalk.RevWalk) rw).setDeepenSince(shallowSince); rw.assumeShallow(clientShallowCommits); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java index 24b9ac086e..3d25c2314e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java @@ -46,6 +46,8 @@ package org.eclipse.jgit.treewalk; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; @@ -412,7 +414,7 @@ public class FileTreeIterator extends WorkingTreeIterator { public InputStream openInputStream() throws IOException { if (attributes.isSymbolicLink()) { return new ByteArrayInputStream(fs.readSymLink(getFile()) - .getBytes(Constants.CHARACTER_ENCODING)); + .getBytes(UTF_8)); } else { return new FileInputStream(getFile()); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index e5c2922cfa..7f0308f071 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -43,6 +43,8 @@ package org.eclipse.jgit.util; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.Closeable; @@ -1172,7 +1174,7 @@ public abstract class FS { OutputStream outRedirect, OutputStream errRedirect, String stdinArgs) throws IOException, InterruptedException { InputStream in = (stdinArgs == null) ? null : new ByteArrayInputStream( - stdinArgs.getBytes(Constants.CHARACTER_ENCODING)); + stdinArgs.getBytes(UTF_8)); return runProcess(processBuilder, outRedirect, errRedirect, in); } 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 6f92b37853..9190a5915a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java @@ -44,7 +44,7 @@ package org.eclipse.jgit.util; -import static org.eclipse.jgit.lib.Constants.CHARACTER_ENCODING; +import static java.nio.charset.StandardCharsets.UTF_8; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -181,7 +181,7 @@ public class HttpSupport { if (key == null || key.length() == 0) return; try { - urlstr.append(URLEncoder.encode(key, CHARACTER_ENCODING)); + urlstr.append(URLEncoder.encode(key, UTF_8.name())); } catch (UnsupportedEncodingException e) { throw new RuntimeException(JGitText.get().couldNotURLEncodeToUTF8, e); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java index 6d60ef3f4d..8c6cc52801 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java @@ -294,6 +294,11 @@ public class LfsFactory { return stream.read(); } + @Override + public int read(byte b[], int off, int len) throws IOException { + return stream.read(b, off, len); + } + /** * @return the length of the stream */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java index 822961f8de..d7c6bec219 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolStreamTypeUtil.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2015, Ivan Motsch <ivan.motsch@bsiag.com> + * 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 @@ -49,6 +50,7 @@ import org.eclipse.jgit.attributes.Attributes; import org.eclipse.jgit.lib.CoreConfig.EolStreamType; import org.eclipse.jgit.treewalk.TreeWalk.OperationType; import org.eclipse.jgit.treewalk.WorkingTreeOptions; +import org.eclipse.jgit.util.SystemReader; /** * Utility used to create input and output stream wrappers for @@ -57,7 +59,6 @@ import org.eclipse.jgit.treewalk.WorkingTreeOptions; * @since 4.3 */ public final class EolStreamTypeUtil { - private static final boolean FORCE_EOL_LF_ON_CHECKOUT = false; private EolStreamTypeUtil() { } @@ -164,11 +165,11 @@ public final class EolStreamTypeUtil { // old git system if (attrs.isSet("crlf")) {//$NON-NLS-1$ - return EolStreamType.TEXT_LF; + return EolStreamType.TEXT_LF; // Same as isSet("text") } else if (attrs.isUnset("crlf")) {//$NON-NLS-1$ - return EolStreamType.DIRECT; + return EolStreamType.DIRECT; // Same as isUnset("text") } else if ("input".equals(attrs.getValue("crlf"))) {//$NON-NLS-1$ //$NON-NLS-2$ - return EolStreamType.TEXT_LF; + return EolStreamType.TEXT_LF; // Same as eol=lf } // new git system @@ -196,6 +197,28 @@ public final class EolStreamTypeUtil { return EolStreamType.DIRECT; } + private static EolStreamType getOutputFormat(WorkingTreeOptions options) { + switch (options.getAutoCRLF()) { + case TRUE: + return EolStreamType.TEXT_CRLF; + default: + // no decision + } + switch (options.getEOL()) { + case CRLF: + return EolStreamType.TEXT_CRLF; + case NATIVE: + if (SystemReader.getInstance().isWindows()) { + return EolStreamType.TEXT_CRLF; + } + return EolStreamType.TEXT_LF; + case LF: + default: + break; + } + return EolStreamType.DIRECT; + } + private static EolStreamType checkOutStreamType(WorkingTreeOptions options, Attributes attrs) { if (attrs.isUnset("text")) {//$NON-NLS-1$ @@ -205,57 +228,35 @@ public final class EolStreamTypeUtil { // old git system if (attrs.isSet("crlf")) {//$NON-NLS-1$ - return FORCE_EOL_LF_ON_CHECKOUT ? EolStreamType.TEXT_LF - : EolStreamType.DIRECT; + return getOutputFormat(options); // Same as isSet("text") } else if (attrs.isUnset("crlf")) {//$NON-NLS-1$ - return EolStreamType.DIRECT; + return EolStreamType.DIRECT; // Same as isUnset("text") } else if ("input".equals(attrs.getValue("crlf"))) {//$NON-NLS-1$ //$NON-NLS-2$ - return EolStreamType.DIRECT; + return EolStreamType.DIRECT; // Same as eol=lf } // new git system String eol = attrs.getValue("eol"); //$NON-NLS-1$ - if (eol != null && "crlf".equals(eol)) //$NON-NLS-1$ - return EolStreamType.TEXT_CRLF; - if (eol != null && "lf".equals(eol)) //$NON-NLS-1$ - return FORCE_EOL_LF_ON_CHECKOUT ? EolStreamType.TEXT_LF - : EolStreamType.DIRECT; - - if (attrs.isSet("text")) { //$NON-NLS-1$ - switch (options.getAutoCRLF()) { - case TRUE: - return EolStreamType.TEXT_CRLF; - default: - // no decision - } - switch (options.getEOL()) { - case CRLF: + if (eol != null) { + if ("crlf".equals(eol)) {//$NON-NLS-1$ return EolStreamType.TEXT_CRLF; - case LF: - return FORCE_EOL_LF_ON_CHECKOUT ? EolStreamType.TEXT_LF - : EolStreamType.DIRECT; - case NATIVE: - default: + } else if ("lf".equals(eol)) { //$NON-NLS-1$ return EolStreamType.DIRECT; } } + if (attrs.isSet("text")) { //$NON-NLS-1$ + return getOutputFormat(options); + } if ("auto".equals(attrs.getValue("text"))) { //$NON-NLS-1$ //$NON-NLS-2$ - switch (options.getAutoCRLF()) { - case TRUE: + EolStreamType basic = getOutputFormat(options); + switch (basic) { + case TEXT_CRLF: return EolStreamType.AUTO_CRLF; + case TEXT_LF: + return EolStreamType.AUTO_LF; default: - // no decision - } - switch (options.getEOL()) { - case CRLF: - return EolStreamType.AUTO_CRLF; - case LF: - return FORCE_EOL_LF_ON_CHECKOUT ? EolStreamType.TEXT_LF - : EolStreamType.DIRECT; - case NATIVE: - default: - return EolStreamType.DIRECT; + return basic; } } @@ -51,7 +51,7 @@ <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> <packaging>pom</packaging> - <version>5.1.3-SNAPSHOT</version> + <version>5.2.0-SNAPSHOT</version> <name>JGit - Parent</name> <url>${jgit-url}</url> diff --git a/tools/BUILD b/tools/BUILD index e69de29bb2..b8a621f845 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -0,0 +1,107 @@ +load( + "@bazel_tools//tools/jdk:default_java_toolchain.bzl", + "JDK9_JVM_OPTS", + "default_java_toolchain", +) + +default_java_toolchain( + name = "error_prone_warnings_toolchain", + bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath9.jar"], + jvm_opts = JDK9_JVM_OPTS, + package_configuration = [ + ":error_prone", + ], + visibility = ["//visibility:public"], +) + +# This EP warnings list borrowed from here: +# https://github.com/bazelbuild/BUILD_file_generator/blob/master/tools/bazel_defs/java.bzl +java_package_configuration( + name = "error_prone", + javacopts = [ + "-XepDisableWarningsInGeneratedCode", + "-Xep:MissingCasesInEnumSwitch:ERROR", + "-Xep:ReferenceEquality:WARN", + "-Xep:StringEquality:WARN", + "-Xep:WildcardImport:WARN", + "-Xep:AmbiguousMethodReference:WARN", + "-Xep:BadAnnotationImplementation:WARN", + "-Xep:BadComparable:WARN", + "-Xep:BoxedPrimitiveConstructor:ERROR", + "-Xep:CannotMockFinalClass:WARN", + "-Xep:ClassCanBeStatic:WARN", + "-Xep:ClassNewInstance:WARN", + "-Xep:DefaultCharset:ERROR", + "-Xep:DoubleCheckedLocking:WARN", + "-Xep:ElementsCountedInLoop:WARN", + "-Xep:EqualsHashCode:WARN", + "-Xep:EqualsIncompatibleType:WARN", + "-Xep:ExpectedExceptionChecker:ERROR", + "-Xep:Finally:WARN", + "-Xep:FloatingPointLiteralPrecision:WARN", + "-Xep:FragmentInjection:WARN", + "-Xep:FragmentNotInstantiable:WARN", + "-Xep:FunctionalInterfaceClash:WARN", + "-Xep:FutureReturnValueIgnored:WARN", + "-Xep:GetClassOnEnum:WARN", + "-Xep:ImmutableAnnotationChecker:WARN", + "-Xep:ImmutableEnumChecker:WARN", + "-Xep:IncompatibleModifiers:WARN", + "-Xep:InjectOnConstructorOfAbstractClass:WARN", + "-Xep:InputStreamSlowMultibyteRead:WARN", + "-Xep:IterableAndIterator:WARN", + "-Xep:JUnit3FloatingPointComparisonWithoutDelta:WARN", + "-Xep:JUnitAmbiguousTestClass:WARN", + "-Xep:LiteralClassName:WARN", + "-Xep:MissingFail:ERROR", + "-Xep:MissingOverride:WARN", + "-Xep:MutableConstantField:WARN", + "-Xep:NarrowingCompoundAssignment:WARN", + "-Xep:NonAtomicVolatileUpdate:WARN", + "-Xep:NonOverridingEquals:WARN", + "-Xep:NullableConstructor:WARN", + "-Xep:NullablePrimitive:WARN", + "-Xep:NullableVoid:WARN", + "-Xep:OperatorPrecedence:WARN", + "-Xep:OverridesGuiceInjectableMethod:WARN", + "-Xep:PreconditionsInvalidPlaceholder:WARN", + "-Xep:ProtoFieldPreconditionsCheckNotNull:WARN", + "-Xep:ProtocolBufferOrdinal:WARN", + "-Xep:RequiredModifiers:WARN", + "-Xep:ShortCircuitBoolean:WARN", + "-Xep:SimpleDateFormatConstant:WARN", + "-Xep:StaticGuardedByInstance:WARN", + "-Xep:SynchronizeOnNonFinalField:WARN", + "-Xep:TruthConstantAsserts:WARN", + "-Xep:TypeParameterShadowing:WARN", + "-Xep:TypeParameterUnusedInFormals:WARN", + "-Xep:URLEqualsHashCode:WARN", + "-Xep:UnsynchronizedOverridesSynchronized:WARN", + "-Xep:WaitNotInLoop:WARN", + ], + packages = ["error_prone_packages"], +) + +package_group( + name = "error_prone_packages", + packages = [ + "//org.eclipse.jgit/...", + "//org.eclipse.jgit.ant/...", + "//org.eclipse.jgit.ant.test/...", + "//org.eclipse.jgit.archive/...", + "//org.eclipse.jgit.http.apache/...", + "//org.eclipse.jgit.http.server/...", + "//org.eclipse.jgit.http.test/...", + "//org.eclipse.jgit.junit/...", + "//org.eclipse.jgit.junit.http/...", + "//org.eclipse.jgit.lfs/...", + "//org.eclipse.jgit.lfs.server/...", + "//org.eclipse.jgit.lfs.server.test/...", + "//org.eclipse.jgit.lfs.test/...", + "//org.eclipse.jgit.packaging/...", + "//org.eclipse.jgit.pgm/...", + "//org.eclipse.jgit.pgm.test/...", + "//org.eclipse.jgit.test/...", + "//org.eclipse.jgit.ui/...", + ], +) |