From 9be93b7991d6c1d82ba606d60bfd3b2971a60123 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 19 Feb 2020 13:04:08 +0900 Subject: [PATCH 1/9] Remove redundant "static" qualifier from enum declarations Nested enum types are implicitly static. Change-Id: Id3d7886087494fb67bc0d080b4a3491fb4baac19 Signed-off-by: David Pursehouse --- .../src/org/eclipse/jgit/pgm/debug/LfsStore.java | 4 ++-- .../org/eclipse/jgit/pgm/debug/ShowCommands.java | 2 +- .../tst/org/eclipse/jgit/lib/ConfigTest.java | 2 +- .../src/org/eclipse/jgit/api/CheckoutCommand.java | 2 +- .../src/org/eclipse/jgit/attributes/Attribute.java | 2 +- .../src/org/eclipse/jgit/diff/DiffConfig.java | 2 +- .../src/org/eclipse/jgit/diff/DiffEntry.java | 4 ++-- .../src/org/eclipse/jgit/diff/Edit.java | 2 +- .../eclipse/jgit/errors/NoMergeBaseException.java | 2 +- .../src/org/eclipse/jgit/ignore/IgnoreNode.java | 2 +- .../org/eclipse/jgit/ignore/internal/Strings.java | 2 +- .../eclipse/jgit/internal/ketch/KetchLeader.java | 2 +- .../jgit/internal/storage/dfs/DfsObjDatabase.java | 2 +- .../internal/storage/file/FileObjectDatabase.java | 2 +- .../jgit/internal/storage/pack/PackWriter.java | 2 +- .../src/org/eclipse/jgit/lib/CoreConfig.java | 14 +++++++------- .../src/org/eclipse/jgit/lib/IndexDiff.java | 2 +- .../src/org/eclipse/jgit/lib/RebaseTodoLine.java | 2 +- .../src/org/eclipse/jgit/lib/RefUpdate.java | 2 +- .../src/org/eclipse/jgit/patch/BinaryHunk.java | 2 +- .../src/org/eclipse/jgit/patch/FileHeader.java | 2 +- .../src/org/eclipse/jgit/patch/FormatError.java | 2 +- .../jgit/transport/GitProtocolConstants.java | 2 +- .../src/org/eclipse/jgit/transport/PackParser.java | 2 +- .../org/eclipse/jgit/transport/PacketLineIn.java | 2 +- .../org/eclipse/jgit/transport/ReceiveCommand.java | 4 ++-- .../eclipse/jgit/transport/RemoteRefUpdate.java | 2 +- .../eclipse/jgit/transport/TransportProtocol.java | 2 +- .../src/org/eclipse/jgit/transport/UploadPack.java | 2 +- .../src/org/eclipse/jgit/treewalk/TreeWalk.java | 2 +- .../org/eclipse/jgit/util/GitDateFormatter.java | 2 +- .../src/org/eclipse/jgit/util/ProcessResult.java | 2 +- 32 files changed, 41 insertions(+), 41 deletions(-) diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/LfsStore.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/LfsStore.java index 973b0d765..fe203e311 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/LfsStore.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/LfsStore.java @@ -161,11 +161,11 @@ class LfsStore extends TextBuiltin { } } - private static enum StoreType { + private enum StoreType { FS, S3; } - private static enum StorageClass { + private enum StorageClass { REDUCED_REDUNDANCY, STANDARD } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java index af56d65c0..d526a5312 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java @@ -83,7 +83,7 @@ class ShowCommands extends TextBuiltin { errw.println(); } - static enum Format { + enum Format { /** */ USAGE { @Override 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 e83954525..5eb4e6bf2 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 @@ -341,7 +341,7 @@ public class ConfigTest { assertFalse(c.getBoolean("s", "b", true)); } - static enum TestEnum { + enum TestEnum { ONE_TWO; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java index e05f6f1bd..6d157bd0a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java @@ -137,7 +137,7 @@ public class CheckoutCommand extends GitCommand { /** * Stage to check out, see {@link CheckoutCommand#setStage(Stage)}. */ - public static enum Stage { + public enum Stage { /** * Base stage (#1) */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/attributes/Attribute.java b/org.eclipse.jgit/src/org/eclipse/jgit/attributes/Attribute.java index f1df0da45..b732050bb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/attributes/Attribute.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/attributes/Attribute.java @@ -67,7 +67,7 @@ public final class Attribute { * The attribute value state * see also https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html */ - public static enum State { + public enum State { /** the attribute is set */ SET, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffConfig.java index ca37a10c5..9071aeb09 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffConfig.java @@ -59,7 +59,7 @@ public class DiffConfig { public static final Config.SectionParser KEY = DiffConfig::new; /** Permissible values for {@code diff.renames}. */ - public static enum RenameDetectionType { + public enum RenameDetectionType { /** Rename detection is disabled. */ FALSE, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java index 5c8343f92..9f660ec1c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffEntry.java @@ -72,7 +72,7 @@ public class DiffEntry { public static final String DEV_NULL = "/dev/null"; //$NON-NLS-1$ /** General type of change a single file-level patch describes. */ - public static enum ChangeType { + public enum ChangeType { /** Add a new file to the project */ ADD, @@ -90,7 +90,7 @@ public class DiffEntry { } /** Specify the old or new side for more generalized access. */ - public static enum Side { + public enum Side { /** The old side of a DiffEntry. */ OLD, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java index 831074d2e..b4e09636c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java @@ -64,7 +64,7 @@ package org.eclipse.jgit.diff; */ public class Edit { /** Type of edit */ - public static enum Type { + public enum Type { /** Sequence B has inserted the region. */ INSERT, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoMergeBaseException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoMergeBaseException.java index 97214b0ed..023dfe965 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoMergeBaseException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/NoMergeBaseException.java @@ -63,7 +63,7 @@ public class NoMergeBaseException extends IOException { * An enum listing the different reason why no merge base could be * determined. */ - public static enum MergeBaseFailureReason { + public enum MergeBaseFailureReason { /** * Multiple merge bases have been found (e.g. the commits to be merged * have multiple common predecessors) but the merge strategy doesn't diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java index 864f8bfc0..d47ffc21a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IgnoreNode.java @@ -59,7 +59,7 @@ import java.util.List; */ public class IgnoreNode { /** Result from {@link IgnoreNode#isIgnored(String, boolean)}. */ - public static enum MatchResult { + public enum MatchResult { /** The file is not ignored, due to a rule saying its not ignored. */ NOT_IGNORED, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java index b18aed982..d9f4f5ae3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java @@ -229,7 +229,7 @@ public class Strings { return PatternState.COMPLEX; } - static enum PatternState { + enum PatternState { LEADING_ASTERISK_ONLY, TRAILING_ASTERISK_ONLY, COMPLEX, NONE } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/KetchLeader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/KetchLeader.java index c0364acdd..67cb2f694 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/KetchLeader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/KetchLeader.java @@ -126,7 +126,7 @@ public abstract class KetchLeader { private static final Logger log = LoggerFactory.getLogger(KetchLeader.class); /** Current state of the leader instance. */ - public static enum State { + public enum State { /** Newly created instance trying to elect itself leader. */ CANDIDATE, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java index 09d59376a..df1729cde 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java @@ -97,7 +97,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase { * comparator based on {@link Enum#compareTo}. Prefer {@link * #DEFAULT_COMPARATOR} or your own {@link ComparatorBuilder}. */ - public static enum PackSource { + public enum PackSource { /** The pack is created by ObjectInserter due to local activity. */ INSERT, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileObjectDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileObjectDatabase.java index 1f6b20aac..db5b1279b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileObjectDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileObjectDatabase.java @@ -60,7 +60,7 @@ import org.eclipse.jgit.lib.ObjectReader; import org.eclipse.jgit.util.FS; abstract class FileObjectDatabase extends ObjectDatabase { - static enum InsertLooseObjectResult { + enum InsertLooseObjectResult { INSERTED, EXISTS_PACKED, EXISTS_LOOSE, FAILURE; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java index e4536643a..11e6c803e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java @@ -2432,7 +2432,7 @@ public class PackWriter implements AutoCloseable { } /** Possible states that a PackWriter can be in. */ - public static enum PackingPhase { + public enum PackingPhase { /** Counting objects phase. */ COUNTING, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java index cdfa949ca..0056ad763 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java @@ -60,7 +60,7 @@ public class CoreConfig { public static final Config.SectionParser KEY = CoreConfig::new; /** Permissible values for {@code core.autocrlf}. */ - public static enum AutoCRLF { + public enum AutoCRLF { /** Automatic CRLF->LF conversion is disabled. */ FALSE, @@ -78,7 +78,7 @@ public class CoreConfig { * * @since 4.3 */ - public static enum EOL { + public enum EOL { /** Check in with LF, check out with CRLF. */ CRLF, @@ -94,7 +94,7 @@ public class CoreConfig { * * @since 4.3 */ - public static enum EolStreamType { + public enum EolStreamType { /** Convert to CRLF without binary detection. */ TEXT_CRLF, @@ -116,7 +116,7 @@ public class CoreConfig { * * @since 3.0 */ - public static enum CheckStat { + public enum CheckStat { /** * Only check the size and whole second part of time stamp when * comparing the stat info in the dircache with actual file stat info. @@ -135,7 +135,7 @@ public class CoreConfig { * * @since 5.6 */ - public static enum LogRefUpdates { + public enum LogRefUpdates { /** Don't create ref logs; default for bare repositories. */ FALSE, @@ -164,7 +164,7 @@ public class CoreConfig { * * @since 3.3 */ - public static enum SymLinks { + public enum SymLinks { /** Check out symbolic links as plain files . */ FALSE, @@ -177,7 +177,7 @@ public class CoreConfig { * * @since 3.5 */ - public static enum HideDotFiles { + public enum HideDotFiles { /** Do not hide .files. */ FALSE, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java index 167d0e08a..eb13bba87 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java @@ -108,7 +108,7 @@ public class IndexDiff { * @see IndexDiff#getConflictingStageStates() * @since 3.0 */ - public static enum StageState { + public enum StageState { /** * Exists in base, but neither in ours nor in theirs. */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoLine.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoLine.java index 4e235b05c..2ffa65c05 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoLine.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoLine.java @@ -58,7 +58,7 @@ public class RebaseTodoLine { * Describes rebase actions */ @SuppressWarnings("nls") - public static enum Action { + public enum Action { /** Use commit */ PICK("pick", "p"), 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 eca15c032..9ccd3ed1f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java @@ -66,7 +66,7 @@ public abstract class RefUpdate { * unknown values are failures, and may generally treat them the same as * {@link #REJECTED_OTHER_REASON}. */ - public static enum Result { + public enum Result { /** The ref update/delete has not been attempted by the caller. */ NOT_ATTEMPTED, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/BinaryHunk.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/BinaryHunk.java index 95391ec56..c1ee701cf 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/BinaryHunk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/BinaryHunk.java @@ -58,7 +58,7 @@ public class BinaryHunk { private static final byte[] DELTA = encodeASCII("delta "); //$NON-NLS-1$ /** Type of information stored in a binary hunk. */ - public static enum Type { + public enum Type { /** The full content is stored, deflated. */ LITERAL_DEFLATED, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java index 1f4beb017..959109c2e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java @@ -104,7 +104,7 @@ public class FileHeader extends DiffEntry { static final byte[] NEW_NAME = encodeASCII("+++ "); //$NON-NLS-1$ /** Type of patch used by this file. */ - public static enum PatchType { + public enum PatchType { /** A traditional unified diff style patch of a text file. */ UNIFIED, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/FormatError.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/FormatError.java index 10ea77834..389668733 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/FormatError.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/FormatError.java @@ -54,7 +54,7 @@ import org.eclipse.jgit.util.RawParseUtils; */ public class FormatError { /** Classification of an error. */ - public static enum Severity { + public enum Severity { /** The error is unexpected, but can be worked around. */ WARNING, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/GitProtocolConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/GitProtocolConstants.java index e3c0bc629..2fd074674 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/GitProtocolConstants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/GitProtocolConstants.java @@ -280,7 +280,7 @@ public final class GitProtocolConstants { */ public static final String COMMAND_FETCH = "fetch"; //$NON-NLS-1$ - static enum MultiAck { + enum MultiAck { OFF, CONTINUE, DETAILED; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java index 2b2795fef..a9cd67766 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java @@ -103,7 +103,7 @@ public abstract class PackParser { private static final int BUFFER_SIZE = 8192; /** Location data is being obtained from. */ - public static enum Source { + public enum Source { /** Data is read from the incoming stream. */ INPUT, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java index d73e1939a..bbdd55583 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java @@ -95,7 +95,7 @@ public class PacketLineIn { @Deprecated public static final String DELIM = new StringBuilder(0).toString(); /* must not string pool */ - static enum AckNackResult { + enum AckNackResult { /** NAK */ NAK, /** ACK */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java index 0616b64d2..d58bc6953 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceiveCommand.java @@ -72,7 +72,7 @@ import org.eclipse.jgit.revwalk.RevWalk; */ public class ReceiveCommand { /** Type of operation requested. */ - public static enum Type { + public enum Type { /** Create a new ref; the ref must not already exist. */ CREATE, @@ -98,7 +98,7 @@ public class ReceiveCommand { } /** Result of the update command. */ - public static enum Result { + public enum Result { /** The command has not yet been attempted by the server. */ NOT_ATTEMPTED, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java index c34e3b8e6..faa2c7698 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java @@ -72,7 +72,7 @@ public class RemoteRefUpdate { /** * Represent current status of a remote ref update. */ - public static enum Status { + public enum Status { /** * Push process hasn't yet attempted to update this ref. This is the * default status, prior to push process execution. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportProtocol.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportProtocol.java index de58aa9e1..5a8cd32a9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportProtocol.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportProtocol.java @@ -90,7 +90,7 @@ import org.eclipse.jgit.lib.Repository; */ public abstract class TransportProtocol { /** Fields within a {@link URIish} that a transport uses. */ - public static enum URIishField { + public enum URIishField { /** the user field */ USER, /** the pass (aka password) field */ 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 6ee280b81..8eac06388 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -137,7 +137,7 @@ import org.eclipse.jgit.util.io.TimeoutOutputStream; */ public class UploadPack { /** Policy the server uses to validate client requests */ - public static enum RequestPolicy { + public enum RequestPolicy { /** Client may only ask for objects the server advertised a reference for. */ ADVERTISED, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java index 65d851217..e545565e8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/TreeWalk.java @@ -111,7 +111,7 @@ public class TreeWalk implements AutoCloseable, AttributesProvider { /** * @since 4.2 */ - public static enum OperationType { + public enum OperationType { /** * Represents a checkout operation (for example a checkout or reset * operation). diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateFormatter.java index e461902a3..e9f65d2cd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateFormatter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/GitDateFormatter.java @@ -68,7 +68,7 @@ public class GitDateFormatter { /** * Git and JGit formats */ - static public enum Format { + public enum Format { /** * Git format: Time and original time zone diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/ProcessResult.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/ProcessResult.java index 9267a325f..1180d4c2a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/ProcessResult.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/ProcessResult.java @@ -51,7 +51,7 @@ public class ProcessResult { /** * Status of a process' execution. */ - public static enum Status { + public enum Status { /** * The script was found and launched properly. It may still have exited * with a non-zero {@link #exitCode}. From 2d1acae6d8a5e90e7bb5192ce1b99f2e2f436775 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 19 Feb 2020 13:06:18 +0900 Subject: [PATCH 2/9] GitmoduleEntry: Remove redundant import of class from same package Change-Id: I613489a937dd53780b0abfd6b1bd0ed964a5ddd8 Signed-off-by: David Pursehouse --- org.eclipse.jgit/src/org/eclipse/jgit/lib/GitmoduleEntry.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitmoduleEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitmoduleEntry.java index bded52751..4f2e558b2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitmoduleEntry.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GitmoduleEntry.java @@ -42,8 +42,6 @@ */ package org.eclipse.jgit.lib; -import org.eclipse.jgit.lib.AnyObjectId; - /** * A .gitmodules file found in the pack. Store the blob of the file itself (e.g. * to access its contents) and the tree where it was found (e.g. to check if it From 064834d350d38f672a69947cf924f56d52bd1274 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 19 Feb 2020 13:15:43 +0900 Subject: [PATCH 3/9] Reorder modifiers to follow Java Language Specification The Java Language Specification recommends listing modifiers in the following order: 1. Annotations 2. public 3. protected 4. private 5. abstract 6. static 7. final 8. transient 9. volatile 10. synchronized 11. native 12. strictfp Not following this convention has no technical impact, but will reduce the code's readability because most developers are used to the standard order. This was detected using SonarLint. Change-Id: I9cddecb4f4234dae1021b677e915be23d349a380 Signed-off-by: David Pursehouse --- .../jgit/http/server/ObjectFileServlet.java | 2 +- .../src/org/eclipse/jgit/lfs/CleanFilter.java | 2 +- .../src/org/eclipse/jgit/lfs/SmudgeFilter.java | 2 +- .../org/eclipse/jgit/pgm/debug/DiffAlgorithms.java | 2 +- .../eclipse/jgit/pgm/debug/TextHashFunctions.java | 4 ++-- .../eclipse/jgit/patch/EGitPatchHistoryTest.java | 2 +- .../internal/storage/file/GcOrphanFilesTest.java | 12 ++++++------ .../jgit/util/GitDateParserBadlyFormattedTest.java | 2 +- .../src/org/eclipse/jgit/api/PullCommand.java | 2 +- .../jgit/errors/TranslationBundleException.java | 4 ++-- .../org/eclipse/jgit/ignore/FastIgnoreRule.java | 2 +- .../org/eclipse/jgit/ignore/internal/Strings.java | 6 +++--- .../jgit/internal/storage/dfs/DfsObjDatabase.java | 2 +- .../org/eclipse/jgit/internal/storage/file/GC.java | 2 +- .../jgit/internal/storage/file/LockFile.java | 2 +- .../internal/storage/file/ObjectDirectory.java | 2 +- .../jgit/internal/storage/file/PackFile.java | 2 +- .../jgit/internal/storage/file/RefDirectory.java | 10 +++++----- .../jgit/internal/storage/pack/PackExt.java | 2 +- .../internal/storage/reftable/BlockWriter.java | 2 +- .../storage/reftable/ReftableDatabase.java | 2 +- .../src/org/eclipse/jgit/lib/IndexDiff.java | 6 +++--- .../src/org/eclipse/jgit/lib/InflaterCache.java | 2 +- .../src/org/eclipse/jgit/lib/ObjectIdOwnerMap.java | 2 +- .../src/org/eclipse/jgit/lib/ObjectInserter.java | 2 +- .../src/org/eclipse/jgit/lib/ObjectLoader.java | 2 +- .../src/org/eclipse/jgit/lib/ObjectReader.java | 2 +- .../src/org/eclipse/jgit/lib/RebaseTodoLine.java | 2 +- .../src/org/eclipse/jgit/lib/RefUpdate.java | 2 +- .../src/org/eclipse/jgit/lib/RepositoryCache.java | 2 +- .../src/org/eclipse/jgit/merge/MergeAlgorithm.java | 2 +- org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java | 4 ++-- .../org/eclipse/jgit/patch/CombinedHunkHeader.java | 2 +- .../eclipse/jgit/storage/file/FileBasedConfig.java | 2 +- .../org/eclipse/jgit/transport/ReceivePack.java | 2 +- .../org/eclipse/jgit/transport/WalkEncryption.java | 2 +- .../eclipse/jgit/treewalk/FileTreeIterator.java | 4 ++-- .../eclipse/jgit/treewalk/WorkingTreeIterator.java | 2 +- .../src/org/eclipse/jgit/util/Base64.java | 12 ++++++------ org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 4 ++-- .../src/org/eclipse/jgit/util/FS_POSIX.java | 2 +- .../src/org/eclipse/jgit/util/FS_Win32.java | 2 +- .../src/org/eclipse/jgit/util/FS_Win32_Cygwin.java | 2 +- .../src/org/eclipse/jgit/util/Monitoring.java | 2 +- .../eclipse/jgit/util/RelativeDateFormatter.java | 14 +++++++------- .../src/org/eclipse/jgit/util/SystemReader.java | 2 +- 46 files changed, 75 insertions(+), 75 deletions(-) diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java index 5a27be643..922a98add 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java @@ -83,7 +83,7 @@ abstract class ObjectFileServlet extends HttpServlet { } } - private static abstract class PackData extends ObjectFileServlet { + private abstract static class PackData extends ObjectFileServlet { private static final long serialVersionUID = 1L; PackData(String contentType) { diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java index 2329ade29..27be4f600 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java @@ -78,7 +78,7 @@ public class CleanFilter extends FilterCommand { * The factory is responsible for creating instances of * {@link org.eclipse.jgit.lfs.CleanFilter} */ - public final static FilterCommandFactory FACTORY = CleanFilter::new; + public static final FilterCommandFactory FACTORY = CleanFilter::new; /** * Registers this filter by calling 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 6b30da343..3551ee1c7 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 @@ -92,7 +92,7 @@ public class SmudgeFilter extends FilterCommand { * The factory is responsible for creating instances of * {@link org.eclipse.jgit.lfs.SmudgeFilter} */ - public final static FilterCommandFactory FACTORY = SmudgeFilter::new; + public static final FilterCommandFactory FACTORY = SmudgeFilter::new; /** * Register this filter in JGit diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java index 85a74448f..61cf2abc3 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java @@ -350,7 +350,7 @@ class DiffAlgorithms extends TextBuiltin { return false; } - private static abstract class Algorithm { + private abstract static class Algorithm { String name; abstract DiffAlgorithm create(); 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 1242bb754..73ea2a006 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 @@ -443,7 +443,7 @@ class TextHashFunctions extends TextBuiltin { } /** Base class for any hashCode function to be tested. */ - private static abstract class Hash extends RawTextComparator { + private abstract static class Hash extends RawTextComparator { String name; @Override @@ -453,7 +453,7 @@ class TextHashFunctions extends TextBuiltin { } /** Base class for any hashCode folding function to be tested. */ - private static abstract class Fold { + private abstract static class Fold { String name; /** diff --git a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java index f597f2fe3..6a006e289 100644 --- a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java +++ b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java @@ -185,7 +185,7 @@ public class EGitPatchHistoryTest { } } - static abstract class CommitReader { + abstract static class CommitReader { private Process proc; CommitReader(String[] args) throws IOException { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcOrphanFilesTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcOrphanFilesTest.java index 79d72c56d..78b830e64 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcOrphanFilesTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcOrphanFilesTest.java @@ -53,17 +53,17 @@ import org.junit.Before; import org.junit.Test; public class GcOrphanFilesTest extends GcTestCase { - private final static String PACK = "pack"; + private static final String PACK = "pack"; - private final static String BITMAP_File_1 = PACK + "-1.bitmap"; + private static final String BITMAP_File_1 = PACK + "-1.bitmap"; - private final static String IDX_File_2 = PACK + "-2.idx"; + private static final String IDX_File_2 = PACK + "-2.idx"; - private final static String IDX_File_malformed = PACK + "-1234idx"; + private static final String IDX_File_malformed = PACK + "-1234idx"; - private final static String PACK_File_2 = PACK + "-2.pack"; + private static final String PACK_File_2 = PACK + "-2.pack"; - private final static String PACK_File_3 = PACK + "-3.pack"; + private static final String PACK_File_3 = PACK + "-3.pack"; private File packDir; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserBadlyFormattedTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserBadlyFormattedTest.java index a6af3a514..57d2c5edd 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserBadlyFormattedTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserBadlyFormattedTest.java @@ -79,7 +79,7 @@ public class GitDateParserBadlyFormattedTest { } @DataPoints - static public String[] getDataPoints() { + public static String[] getDataPoints() { return new String[] { "", "1970", "3000.3000.3000", "3 yesterday ago", "now yesterday ago", "yesterdays", "3.day. 2.week.ago", "day ago", "Gra Feb 21 15:35:00 2007 +0100", diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java index 834b68d6d..ea3e2d9f8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java @@ -90,7 +90,7 @@ import org.eclipse.jgit.transport.TagOpt; */ public class PullCommand extends TransportCommand { - private final static String DOT = "."; //$NON-NLS-1$ + private static final String DOT = "."; //$NON-NLS-1$ private ProgressMonitor monitor = NullProgressMonitor.INSTANCE; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationBundleException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationBundleException.java index 70760f36b..6d18c7c51 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationBundleException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/TranslationBundleException.java @@ -78,7 +78,7 @@ public abstract class TranslationBundleException extends RuntimeException { * * @return bundle class for which the exception occurred */ - final public Class getBundleClass() { + public final Class getBundleClass() { return bundleClass; } @@ -87,7 +87,7 @@ public abstract class TranslationBundleException extends RuntimeException { * * @return locale for which the exception occurred */ - final public Locale getLocale() { + public final Locale getLocale() { return locale; } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java index 31e173bf2..4bc926ae1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java @@ -62,7 +62,7 @@ import org.slf4j.LoggerFactory; * @since 3.6 */ public class FastIgnoreRule { - private final static Logger LOG = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(FastIgnoreRule.class); /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java index d9f4f5ae3..132109b6c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java @@ -233,7 +233,7 @@ public class Strings { LEADING_ASTERISK_ONLY, TRAILING_ASTERISK_ONLY, COMPLEX, NONE } - final static List POSIX_CHAR_CLASSES = Arrays.asList( + static final List POSIX_CHAR_CLASSES = Arrays.asList( "alnum", "alpha", "blank", "cntrl", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ // [:alnum:] [:alpha:] [:blank:] [:cntrl:] "digit", "graph", "lower", "print", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ @@ -248,7 +248,7 @@ public class Strings { private static final String DL = "\\p{javaDigit}\\p{javaLetter}"; //$NON-NLS-1$ - final static List JAVA_CHAR_CLASSES = Arrays + static final List JAVA_CHAR_CLASSES = Arrays .asList("\\p{Alnum}", "\\p{javaLetter}", "\\p{Blank}", "\\p{Cntrl}", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ // [:alnum:] [:alpha:] [:blank:] [:cntrl:] "\\p{javaDigit}", "[\\p{Graph}" + DL + "]", "\\p{Ll}", "[\\p{Print}" + DL + "]", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ @@ -261,7 +261,7 @@ public class Strings { // Collating symbols [[.a.]] or equivalence class expressions [[=a=]] are // not supported by CLI git (at least not by 1.9.1) - final static Pattern UNSUPPORTED = Pattern + static final Pattern UNSUPPORTED = Pattern .compile("\\[\\[[.=]\\w+[.=]\\]\\]"); //$NON-NLS-1$ /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java index df1729cde..0ee8135fa 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java @@ -705,7 +705,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase { } /** Snapshot of packs scanned in a single pass. */ - public static abstract class PackList { + public abstract static class PackList { /** All known packs, sorted. */ public final DfsPackFile[] packs; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java index 79ba4a1b0..0619dfd83 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java @@ -131,7 +131,7 @@ import org.slf4j.LoggerFactory; * adapted to FileRepositories. */ public class GC { - private final static Logger LOG = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(GC.class); private static final String PRUNE_EXPIRE_DEFAULT = "2.weeks.ago"; //$NON-NLS-1$ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java index 6af41256d..6bcd7c070 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java @@ -83,7 +83,7 @@ import org.slf4j.LoggerFactory; * name. */ public class LockFile { - private final static Logger LOG = LoggerFactory.getLogger(LockFile.class); + private static final Logger LOG = LoggerFactory.getLogger(LockFile.class); /** * Unlock the given file. 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 968ade670..b4cad35dd 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 @@ -109,7 +109,7 @@ import org.slf4j.LoggerFactory; * considered. */ public class ObjectDirectory extends FileObjectDatabase { - private final static Logger LOG = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(ObjectDirectory.class); private static final PackList NO_PACKS = new PackList( diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java index 9b9c3a7de..f096908eb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java @@ -103,7 +103,7 @@ import org.slf4j.LoggerFactory; * objects are similar. */ public class PackFile implements Iterable { - private final static Logger LOG = LoggerFactory.getLogger(PackFile.class); + private static final Logger LOG = LoggerFactory.getLogger(PackFile.class); /** Sorts PackFiles to be most recently created to least recently created. */ public static final Comparator SORT = new Comparator() { @Override diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java index 7733df15f..0cec5a483 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java @@ -130,7 +130,7 @@ import org.slf4j.LoggerFactory; * overall size of a Git repository on disk. */ public class RefDirectory extends RefDatabase { - private final static Logger LOG = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(RefDirectory.class); /** Magic string denoting the start of a symbolic reference file. */ @@ -1406,7 +1406,7 @@ public class RefDirectory extends RefDatabase { LooseRef peel(ObjectIdRef newLeaf); } - private final static class LoosePeeledTag extends ObjectIdRef.PeeledTag + private static final class LoosePeeledTag extends ObjectIdRef.PeeledTag implements LooseRef { private final FileSnapshot snapShot; @@ -1427,7 +1427,7 @@ public class RefDirectory extends RefDatabase { } } - private final static class LooseNonTag extends ObjectIdRef.PeeledNonTag + private static final class LooseNonTag extends ObjectIdRef.PeeledNonTag implements LooseRef { private final FileSnapshot snapShot; @@ -1448,7 +1448,7 @@ public class RefDirectory extends RefDatabase { } } - private final static class LooseUnpeeled extends ObjectIdRef.Unpeeled + private static final class LooseUnpeeled extends ObjectIdRef.Unpeeled implements LooseRef { private FileSnapshot snapShot; @@ -1483,7 +1483,7 @@ public class RefDirectory extends RefDatabase { } } - private final static class LooseSymbolicRef extends SymbolicRef implements + private static final class LooseSymbolicRef extends SymbolicRef implements LooseRef { private final FileSnapshot snapShot; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java index 292fd368c..b4143c900 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackExt.java @@ -81,7 +81,7 @@ public class PackExt { * the file extension. * @return the PackExt for the ext */ - public synchronized static PackExt newPackExt(String ext) { + public static synchronized PackExt newPackExt(String ext) { PackExt[] dst = new PackExt[VALUES.length + 1]; for (int i = 0; i < VALUES.length; i++) { PackExt packExt = VALUES[i]; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java index b3173e838..1ed180167 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockWriter.java @@ -286,7 +286,7 @@ class BlockWriter { return aLen - bLen; } - static abstract class Entry { + abstract static class Entry { static int compare(Entry ea, Entry eb) { byte[] a = ea.key; byte[] b = eb.key; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java index c08f1814d..696347e8f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java @@ -80,7 +80,7 @@ public abstract class ReftableDatabase { * @throws IOException * on I/O problems. */ - abstract protected MergedReftable openMergedReftable() throws IOException; + protected abstract MergedReftable openMergedReftable() throws IOException; /** * @return the next available logical timestamp for an additional reftable diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java index eb13bba87..cbb3e5490 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java @@ -243,11 +243,11 @@ public class IndexDiff { } } - private final static int TREE = 0; + private static final int TREE = 0; - private final static int INDEX = 1; + private static final int INDEX = 1; - private final static int WORKDIR = 2; + private static final int WORKDIR = 2; private final Repository repository; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/InflaterCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/InflaterCache.java index dd0f18e16..314bde2c8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/InflaterCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/InflaterCache.java @@ -73,7 +73,7 @@ public class InflaterCache { return r != null ? r : new Inflater(false); } - private synchronized static Inflater getImpl() { + private static synchronized Inflater getImpl() { if (openInflaterCount > 0) { final Inflater r = inflaterCache[--openInflaterCount]; inflaterCache[openInflaterCount] = null; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdOwnerMap.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdOwnerMap.java index 74c712c46..8730d66ec 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdOwnerMap.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdOwnerMap.java @@ -355,7 +355,7 @@ public class ObjectIdOwnerMap } /** Type of entry stored in the {@link ObjectIdOwnerMap}. */ - public static abstract class Entry extends ObjectId { + public abstract static class Entry extends ObjectId { transient Entry next; /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectInserter.java index 77fa1b234..edbb4b1c8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectInserter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectInserter.java @@ -98,7 +98,7 @@ public abstract class ObjectInserter implements AutoCloseable { } /** Wraps a delegate ObjectInserter. */ - public static abstract class Filter extends ObjectInserter { + public abstract static class Filter extends ObjectInserter { /** @return delegate ObjectInserter to handle all processing. */ protected abstract ObjectInserter delegate(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java index 2e52f031c..b4734210f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectLoader.java @@ -333,7 +333,7 @@ public abstract class ObjectLoader { * * @since 4.10 */ - public static abstract class Filter extends ObjectLoader { + public abstract static class Filter extends ObjectLoader { /** * @return delegate ObjectLoader to handle all processing. * @since 4.10 diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java index e14fb102b..6d544670b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java @@ -495,7 +495,7 @@ public abstract class ObjectReader implements AutoCloseable { * * @since 4.4 */ - public static abstract class Filter extends ObjectReader { + public abstract static class Filter extends ObjectReader { /** * @return delegate ObjectReader to handle all processing. * @since 4.4 diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoLine.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoLine.java index 2ffa65c05..f893fd1bf 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoLine.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoLine.java @@ -105,7 +105,7 @@ public class RebaseTodoLine { * @param token * @return the Action */ - static public Action parse(String token) { + public static Action parse(String token) { for (Action action : Action.values()) { if (action.token.equals(token) || action.shortToken.equals(token)) 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 9ccd3ed1f..eb5e13954 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java @@ -827,7 +827,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 static abstract class Store { + private abstract static class Store { abstract Result execute(Result status) throws IOException; } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java index fc74f5324..5a6063e9a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java @@ -66,7 +66,7 @@ import org.slf4j.LoggerFactory; * Cache of active {@link org.eclipse.jgit.lib.Repository} instances. */ public class RepositoryCache { - private final static Logger LOG = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(RepositoryCache.class); private static final RepositoryCache cache = new RepositoryCache(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java index a77cb4ffb..3ff38dc33 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeAlgorithm.java @@ -83,7 +83,7 @@ public final class MergeAlgorithm { // An special edit which acts as a sentinel value by marking the end the // list of edits - private final static Edit END_EDIT = new Edit(Integer.MAX_VALUE, + private static final Edit END_EDIT = new Edit(Integer.MAX_VALUE, Integer.MAX_VALUE); @SuppressWarnings("ReferenceEquality") diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java b/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java index 375cd3204..d9fb1b3a0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java @@ -133,8 +133,8 @@ public class NLS { return b.get(type); } - final private Locale locale; - final private ConcurrentHashMap map = new ConcurrentHashMap<>(); + private final Locale locale; + private final ConcurrentHashMap map = new ConcurrentHashMap<>(); private NLS(Locale locale) { this.locale = locale; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java index 74eec8120..244f80483 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/CombinedHunkHeader.java @@ -58,7 +58,7 @@ import org.eclipse.jgit.util.MutableInteger; * Hunk header for a hunk appearing in a "diff --cc" style patch. */ public class CombinedHunkHeader extends HunkHeader { - private static abstract class CombinedOldImage extends OldImage { + private abstract static class CombinedOldImage extends OldImage { int nContext; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java index 5bb8153a5..f1ff9e6ba 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java @@ -77,7 +77,7 @@ import org.slf4j.LoggerFactory; * The configuration file that is stored in the file of the file system. */ public class FileBasedConfig extends StoredConfig { - private final static Logger LOG = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(FileBasedConfig.class); private final File configFile; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java index 16fbbd42f..fab9890c7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java @@ -2003,7 +2003,7 @@ public class ReceivePack { } /** Interface for reporting status messages. */ - static abstract class Reporter { + abstract static class Reporter { abstract void sendString(String s) throws IOException; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java index 7a973aff3..fb8a55f1b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java @@ -324,7 +324,7 @@ abstract class WalkEncryption { * Base implementation of JGit symmetric encryption. Supports V2 properties * format. */ - static abstract class SymmetricEncryption extends WalkEncryption + abstract static class SymmetricEncryption extends WalkEncryption implements Keys, Vals { /** Encryption profile, root name of group of related properties. */ 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 6969ae45a..5f5da5877 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java @@ -275,7 +275,7 @@ public class FileTreeIterator extends WorkingTreeIterator { /** * a singleton instance of the default FileModeStrategy */ - public final static DefaultFileModeStrategy INSTANCE = + public static final DefaultFileModeStrategy INSTANCE = new DefaultFileModeStrategy(); @Override @@ -308,7 +308,7 @@ public class FileTreeIterator extends WorkingTreeIterator { /** * a singleton instance of the default FileModeStrategy */ - public final static NoGitlinksStrategy INSTANCE = new NoGitlinksStrategy(); + public static final NoGitlinksStrategy INSTANCE = new NoGitlinksStrategy(); @Override public FileMode getMode(File f, FS.Attributes attributes) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java index 88b76f712..7f2d5365a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java @@ -1180,7 +1180,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator { * * @since 5.0 */ - public static abstract class Entry { + public abstract static class Entry { byte[] encodedName; int encodedNameLen; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java index 69f854745..119c96e02 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java @@ -28,26 +28,26 @@ import org.eclipse.jgit.internal.JGitText; */ public class Base64 { /** The equals sign (=) as a byte. */ - private final static byte EQUALS_SIGN = (byte) '='; + private static final byte EQUALS_SIGN = (byte) '='; /** Indicates equals sign in encoding. */ - private final static byte EQUALS_SIGN_DEC = -1; + private static final byte EQUALS_SIGN_DEC = -1; /** Indicates white space in encoding. */ - private final static byte WHITE_SPACE_DEC = -2; + private static final byte WHITE_SPACE_DEC = -2; /** Indicates an invalid byte during decoding. */ - private final static byte INVALID_DEC = -3; + private static final byte INVALID_DEC = -3; /** The 64 valid Base64 values. */ - private final static byte[] ENC; + private static final byte[] ENC; /** * Translates a Base64 value to either its 6-bit reconstruction value or a * negative number indicating some other meaning. The table is only 7 bits * wide, as the 8th bit is discarded during decoding. */ - private final static byte[] DEC; + private static final byte[] DEC; static { ENC = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" // //$NON-NLS-1$ 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 b6c88503b..b2fba51d6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -213,7 +213,7 @@ public abstract class FS { * * @since 5.1.9 */ - public final static class FileStoreAttributes { + public static final class FileStoreAttributes { private static final Duration UNDEFINED_DURATION = Duration .ofNanos(Long.MAX_VALUE); @@ -691,7 +691,7 @@ public abstract class FS { /** The auto-detected implementation selected for this operating system and JRE. */ public static final FS DETECTED = detect(); - private volatile static FSFactory factory; + private static volatile FSFactory factory; /** * Auto-detect the appropriate file system abstraction. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java index 5c2d8277c..79c095fc1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java @@ -85,7 +85,7 @@ import org.slf4j.LoggerFactory; * @since 3.0 */ public class FS_POSIX extends FS { - private final static Logger LOG = LoggerFactory.getLogger(FS_POSIX.class); + private static final Logger LOG = LoggerFactory.getLogger(FS_POSIX.class); private static final int DEFAULT_UMASK = 0022; private volatile int umask = -1; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java index 1e64a38bb..aedf43c9e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java @@ -72,7 +72,7 @@ import org.slf4j.LoggerFactory; * @since 3.0 */ public class FS_Win32 extends FS { - private final static Logger LOG = LoggerFactory.getLogger(FS_Win32.class); + private static final Logger LOG = LoggerFactory.getLogger(FS_Win32.class); /** * Constructor diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java index ac3248cb6..10be26f79 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java @@ -65,7 +65,7 @@ import org.slf4j.LoggerFactory; * @since 3.0 */ public class FS_Win32_Cygwin extends FS_Win32 { - private final static Logger LOG = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(FS_Win32_Cygwin.class); private static String cygpath; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java index 83bf695f7..cd2a8e672 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/Monitoring.java @@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory; * @since 5.1.13 */ public class Monitoring { - private final static Logger LOG = LoggerFactory.getLogger(Monitoring.class); + private static final Logger LOG = LoggerFactory.getLogger(Monitoring.class); /** * Register a MBean with the platform MBean server diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/RelativeDateFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/RelativeDateFormatter.java index 83c60c63b..55f39c265 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/RelativeDateFormatter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/RelativeDateFormatter.java @@ -52,19 +52,19 @@ import org.eclipse.jgit.internal.JGitText; * in the format defined by {@code git log --relative-date}. */ public class RelativeDateFormatter { - final static long SECOND_IN_MILLIS = 1000; + static final long SECOND_IN_MILLIS = 1000; - final static long MINUTE_IN_MILLIS = 60 * SECOND_IN_MILLIS; + static final long MINUTE_IN_MILLIS = 60 * SECOND_IN_MILLIS; - final static long HOUR_IN_MILLIS = 60 * MINUTE_IN_MILLIS; + static final long HOUR_IN_MILLIS = 60 * MINUTE_IN_MILLIS; - final static long DAY_IN_MILLIS = 24 * HOUR_IN_MILLIS; + static final long DAY_IN_MILLIS = 24 * HOUR_IN_MILLIS; - final static long WEEK_IN_MILLIS = 7 * DAY_IN_MILLIS; + static final long WEEK_IN_MILLIS = 7 * DAY_IN_MILLIS; - final static long MONTH_IN_MILLIS = 30 * DAY_IN_MILLIS; + static final long MONTH_IN_MILLIS = 30 * DAY_IN_MILLIS; - final static long YEAR_IN_MILLIS = 365 * DAY_IN_MILLIS; + static final long YEAR_IN_MILLIS = 365 * DAY_IN_MILLIS; /** * Get age of given {@link java.util.Date} compared to now formatted in the diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java index e16a88655..87ce4752b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java @@ -85,7 +85,7 @@ import org.slf4j.LoggerFactory; */ public abstract class SystemReader { - private final static Logger LOG = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(SystemReader.class); private static final SystemReader DEFAULT; From 6a72f2943d31d0e5a3ed402b5b769dde17f691f5 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 19 Feb 2020 13:23:14 +0900 Subject: [PATCH 4/9] Use indexOf(char) and lastIndexOf(char) rather than String versions An indexOf or lastIndexOf call with a single letter String can be made more performant by switching to a call with a char argument. Found with SonarLint. As a side-effect of this change, we no longer need to suppress the NON-NLS warnings. Change-Id: Id44cb996bb74ed30edd560aa91fd8525aafdc8dd Signed-off-by: David Pursehouse --- org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java | 2 +- org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java | 5 +++-- .../src/org/eclipse/jgit/attributes/AttributesRule.java | 2 +- .../src/org/eclipse/jgit/diff/SimilarityRenameDetector.java | 4 ++-- .../org/eclipse/jgit/transport/BasePackPushConnection.java | 2 +- org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java index 915b9860b..b32f7ab20 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java @@ -524,7 +524,7 @@ public class CommitCommand extends GitCommand { int position = Collections.binarySearch(only, p); if (position >= 0) return position; - int l = p.lastIndexOf("/"); //$NON-NLS-1$ + int l = p.lastIndexOf('/'); if (l < 1) break; p = p.substring(0, l); 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 715d9768d..6eed0b3f6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java @@ -833,7 +833,8 @@ public class RebaseCommand extends GitCommand { sb.append("# This is a combination of ").append(count) .append(" commits.\n"); // Add the previous message without header (i.e first line) - sb.append(currSquashMessage.substring(currSquashMessage.indexOf("\n") + 1)); + sb.append(currSquashMessage + .substring(currSquashMessage.indexOf('\n') + 1)); sb.append("\n"); if (isSquash) { sb.append("# This is the ").append(count).append(ordinal) @@ -871,7 +872,7 @@ public class RebaseCommand extends GitCommand { static int parseSquashFixupSequenceCount(String currSquashMessage) { String regex = "This is a combination of (.*) commits"; //$NON-NLS-1$ String firstLine = currSquashMessage.substring(0, - currSquashMessage.indexOf("\n")); //$NON-NLS-1$ + currSquashMessage.indexOf('\n')); Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(firstLine); if (!matcher.find()) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesRule.java b/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesRule.java index a91d8c282..ead99c79c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesRule.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesRule.java @@ -91,7 +91,7 @@ public class AttributesRule { continue; } - final int equalsIndex = attribute.indexOf("="); //$NON-NLS-1$ + final int equalsIndex = attribute.indexOf('='); if (equalsIndex == -1) result.add(new Attribute(attribute, State.SET)); else { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java index d8a05c34e..5c07f88a5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java @@ -335,8 +335,8 @@ class SimilarityRenameDetector { } static int nameScore(String a, String b) { - int aDirLen = a.lastIndexOf("/") + 1; //$NON-NLS-1$ - int bDirLen = b.lastIndexOf("/") + 1; //$NON-NLS-1$ + int aDirLen = a.lastIndexOf('/') + 1; + int bDirLen = b.lastIndexOf('/') + 1; int dirMin = Math.min(aDirLen, bDirLen); int dirMax = Math.max(aDirLen, bDirLen); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java index 35ea35ecb..12ade4d19 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java @@ -391,7 +391,7 @@ public abstract class BasePackPushConnection extends BasePackConnection implemen refNameEnd = refLine.length(); } else if (refLine.startsWith("ng ")) { //$NON-NLS-1$ ok = false; - refNameEnd = refLine.indexOf(" ", 3); //$NON-NLS-1$ + refNameEnd = refLine.indexOf(' ', 3); } if (refNameEnd == -1) throw new PackProtocolException(MessageFormat.format(JGitText.get().unexpectedReportLine2 diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java index 66f996554..957cb5af6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java @@ -181,7 +181,7 @@ public class ChangeIdUtil { ret.append(CHANGE_ID); ret.append(" I"); //$NON-NLS-1$ ret.append(ObjectId.toString(changeId)); - int indexOfNextLineBreak = message.indexOf("\n", //$NON-NLS-1$ + int indexOfNextLineBreak = message.indexOf('\n', indexOfChangeId); if (indexOfNextLineBreak > 0) ret.append(message.substring(indexOfNextLineBreak)); From fdabbe67e2db88d6c0bb9cf696ff681a0812814a Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 19 Feb 2020 20:34:13 +0900 Subject: [PATCH 5/9] SimilarityRenameDetector: Fix inconsistent indentation Replace space indentation with tab indentation Change-Id: Ic130d3bde5d3a73d8f5c6225974153573722d05b Signed-off-by: David Pursehouse --- .../org/eclipse/jgit/diff/SimilarityRenameDetector.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java index 5c07f88a5..1b7babcec 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityRenameDetector.java @@ -338,11 +338,11 @@ class SimilarityRenameDetector { int aDirLen = a.lastIndexOf('/') + 1; int bDirLen = b.lastIndexOf('/') + 1; - int dirMin = Math.min(aDirLen, bDirLen); - int dirMax = Math.max(aDirLen, bDirLen); + int dirMin = Math.min(aDirLen, bDirLen); + int dirMax = Math.max(aDirLen, bDirLen); - final int dirScoreLtr; - final int dirScoreRtl; + final int dirScoreLtr; + final int dirScoreRtl; if (dirMax == 0) { dirScoreLtr = 100; From f2b67be62aa02facd23a6b09a3b759abedcb9e10 Mon Sep 17 00:00:00 2001 From: Thomas Wolf Date: Wed, 19 Feb 2020 23:02:28 +0100 Subject: [PATCH 6/9] Make the IMatcher public API Provide a static factory method to create a PathMatcher. Bug: 559526 Change-Id: Ib7a4a1bcc658ac2f2a09d365b5b891669dfd7570 Signed-off-by: Thomas Wolf --- .../jgit/attributes/AttributesRule.java | 4 +- .../eclipse/jgit/ignore/FastIgnoreRule.java | 3 +- .../jgit/ignore/{internal => }/IMatcher.java | 37 +++++++++++++++---- .../jgit/ignore/internal/AbstractMatcher.java | 2 + .../jgit/ignore/internal/PathMatcher.java | 1 + 5 files changed, 36 insertions(+), 11 deletions(-) rename org.eclipse.jgit/src/org/eclipse/jgit/ignore/{internal => }/IMatcher.java (60%) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesRule.java b/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesRule.java index 53812442b..2f9929591 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesRule.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/attributes/AttributesRule.java @@ -9,7 +9,7 @@ */ package org.eclipse.jgit.attributes; -import static org.eclipse.jgit.ignore.internal.IMatcher.NO_MATCH; +import static org.eclipse.jgit.ignore.IMatcher.NO_MATCH; import java.util.ArrayList; import java.util.Collections; @@ -18,7 +18,7 @@ import java.util.List; import org.eclipse.jgit.attributes.Attribute.State; import org.eclipse.jgit.errors.InvalidPatternException; import org.eclipse.jgit.ignore.FastIgnoreRule; -import org.eclipse.jgit.ignore.internal.IMatcher; +import org.eclipse.jgit.ignore.IMatcher; import org.eclipse.jgit.ignore.internal.PathMatcher; /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java index a1866c85a..26bbd41b7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java @@ -9,13 +9,12 @@ */ package org.eclipse.jgit.ignore; -import static org.eclipse.jgit.ignore.internal.IMatcher.NO_MATCH; +import static org.eclipse.jgit.ignore.IMatcher.NO_MATCH; import static org.eclipse.jgit.ignore.internal.Strings.isDirectoryPattern; import static org.eclipse.jgit.ignore.internal.Strings.stripTrailing; import static org.eclipse.jgit.ignore.internal.Strings.stripTrailingWhitespace; import org.eclipse.jgit.errors.InvalidPatternException; -import org.eclipse.jgit.ignore.internal.IMatcher; import org.eclipse.jgit.ignore.internal.PathMatcher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/IMatcher.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IMatcher.java similarity index 60% rename from org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/IMatcher.java rename to org.eclipse.jgit/src/org/eclipse/jgit/ignore/IMatcher.java index d93cc9a8a..3cbb069ff 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/IMatcher.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/IMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014, 2017 Andrey Loskutov and others + * Copyright (C) 2014, 2020 Andrey Loskutov and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0 which is available at @@ -7,10 +7,16 @@ * * SPDX-License-Identifier: BSD-3-Clause */ -package org.eclipse.jgit.ignore.internal; +package org.eclipse.jgit.ignore; + +import org.eclipse.jgit.annotations.NonNull; +import org.eclipse.jgit.errors.InvalidPatternException; +import org.eclipse.jgit.ignore.internal.PathMatcher; /** - * Generic string matcher + * Generic path matcher. + * + * @since 5.7 */ public interface IMatcher { @@ -18,6 +24,7 @@ public interface IMatcher { * Matcher that does not match any pattern. */ public static final IMatcher NO_MATCH = new IMatcher() { + @Override public boolean matches(String path, boolean assumeDirectory, boolean pathMatch) { @@ -30,6 +37,25 @@ public interface IMatcher { } }; + /** + * Creates a path matcher for the given pattern. A pattern may contain the + * wildcards "?", "*", and "**". The directory separator is '/'. + * + * @param pattern + * to match + * @param dirOnly + * whether to match only directories + * @return a matcher for the given pattern + * @throws InvalidPatternException + * if the pattern is invalid + */ + @NonNull + public static IMatcher createPathMatcher(@NonNull String pattern, + boolean dirOnly) throws InvalidPatternException { + return PathMatcher.createPathMatcher(pattern, + Character.valueOf(FastIgnoreRule.PATH_SEPARATOR), dirOnly); + } + /** * Matches entire given string * @@ -40,10 +66,7 @@ public interface IMatcher { * with a slash) * @param pathMatch * {@code true} if the match is for the full path: prefix-only - * matches are not allowed, and - * {@link org.eclipse.jgit.ignore.internal.NameMatcher}s must - * match only the last component (if they can -- they may not, if - * they are anchored at the beginning) + * matches are not allowed * @return true if this matcher pattern matches given string */ boolean matches(String path, boolean assumeDirectory, boolean pathMatch); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/AbstractMatcher.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/AbstractMatcher.java index a77061f50..0737ed887 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/AbstractMatcher.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/AbstractMatcher.java @@ -9,6 +9,8 @@ */ package org.eclipse.jgit.ignore.internal; +import org.eclipse.jgit.ignore.IMatcher; + /** * Base class for default methods as {@link #toString()} and such. *

diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/PathMatcher.java b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/PathMatcher.java index 8226a5247..ba77b3dd8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/PathMatcher.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/PathMatcher.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.jgit.errors.InvalidPatternException; +import org.eclipse.jgit.ignore.IMatcher; import org.eclipse.jgit.ignore.internal.Strings.PatternState; /** From 40555223594005481cba95d09b32c4f6bb5dcff3 Mon Sep 17 00:00:00 2001 From: Michael Dardis Date: Fri, 14 Feb 2020 12:07:19 +1100 Subject: [PATCH 7/9] Remove use of org.bouncycastle.util.io.TeeOutputStream Bug: 559106 Change-Id: Ife06f21a00d258780a2030745738194098c631cf Signed-off-by: Michael Dardis Signed-off-by: Matthias Sohn --- .../jgit/util/io/TeeOutputStreamTest.java | 81 +++++++++++++++++++ org.eclipse.jgit/META-INF/MANIFEST.MF | 1 - .../src/org/eclipse/jgit/hooks/GitHook.java | 2 +- .../eclipse/jgit/util/io/TeeOutputStream.java | 74 +++++++++++++++++ 4 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TeeOutputStreamTest.java create mode 100644 org.eclipse.jgit/src/org/eclipse/jgit/util/io/TeeOutputStream.java diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TeeOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TeeOutputStreamTest.java new file mode 100644 index 000000000..bb1c97445 --- /dev/null +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TeeOutputStreamTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2020, Michael Dardis. and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0 which is available at + * https://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +package org.eclipse.jgit.util.io; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import org.eclipse.jgit.lib.Constants; +import org.junit.Test; + +public class TeeOutputStreamTest { + + @Test + public void test() throws IOException { + byte[] data = Constants.encode("Hello World"); + + TestOutput first = new TestOutput(); + TestOutput second = new TestOutput(); + try (TeeOutputStream tee = new TeeOutputStream(first, second)) { + tee.write(data); + assertArrayEquals("Stream output must match", first.toByteArray(), + second.toByteArray()); + + tee.write(1); + assertArrayEquals("Stream output must match", first.toByteArray(), + second.toByteArray()); + + tee.write(data, 1, 4); // Test partial write methods + assertArrayEquals("Stream output must match", first.toByteArray(), + second.toByteArray()); + } + assertTrue("First stream should be closed", first.closed); + assertTrue("Second stream should be closed", second.closed); + } + + @Test + public void testCloseException() { + TestOutput first = new TestOutput() { + @Override + public void close() throws IOException { + throw new IOException(); + } + + }; + TestOutput second = new TestOutput(); + + @SuppressWarnings("resource") + TeeOutputStream tee = new TeeOutputStream(first, second); + try { + tee.close(); + } catch (IOException ex) { + // Expected from first closed + } + assertFalse("First stream should not be closed", first.closed); + assertTrue("Second stream should still be closed if first close failed", + second.closed); + } + + private static class TestOutput extends ByteArrayOutputStream { + + private boolean closed; + + @Override + public void close() throws IOException { + closed = true; + super.close(); + } + } + +} diff --git a/org.eclipse.jgit/META-INF/MANIFEST.MF b/org.eclipse.jgit/META-INF/MANIFEST.MF index 1fd25780d..dbf122ef9 100644 --- a/org.eclipse.jgit/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit/META-INF/MANIFEST.MF @@ -172,7 +172,6 @@ Import-Package: com.googlecode.javaewah;version="[1.1.6,2.0.0)", org.bouncycastle.openpgp.operator;version="[1.61.0,2.0.0)", org.bouncycastle.openpgp.operator.jcajce;version="[1.61.0,2.0.0)", org.bouncycastle.util.encoders;version="[1.61.0,2.0.0)", - org.bouncycastle.util.io;version="[1.61.0,2.0.0)", org.slf4j;version="[1.7.0,2.0.0)", org.xml.sax, org.xml.sax.helpers diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java b/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java index ed9c38a4d..4059b16b3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java @@ -17,11 +17,11 @@ import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.util.concurrent.Callable; -import org.bouncycastle.util.io.TeeOutputStream; import org.eclipse.jgit.api.errors.AbortedByHookException; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.ProcessResult; +import org.eclipse.jgit.util.io.TeeOutputStream; /** * Git can fire off custom scripts when certain important actions occur. These diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TeeOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TeeOutputStream.java new file mode 100644 index 000000000..e6fdd709b --- /dev/null +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TeeOutputStream.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2020, Michael Dardis. and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0 which is available at + * https://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +package org.eclipse.jgit.util.io; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * An output stream that writes all data to two streams. + * + * @since 5.7 + */ +public class TeeOutputStream extends OutputStream { + + private final OutputStream stream1; + private final OutputStream stream2; + + /** + * Initialize a tee output stream. + * + * @param stream1 first output stream + * @param stream2 second output stream + */ + public TeeOutputStream(OutputStream stream1, OutputStream stream2) { + this.stream1 = stream1; + this.stream2 = stream2; + } + + /** {@inheritDoc} */ + @Override + public void write(byte[] buf) throws IOException { + this.stream1.write(buf); + this.stream2.write(buf); + } + + /** {@inheritDoc} */ + @Override + public void write(byte[] buf, int off, int len) throws IOException { + this.stream1.write(buf, off, len); + this.stream2.write(buf, off, len); + } + + /** {@inheritDoc} */ + @Override + public void write(int b) throws IOException { + this.stream1.write(b); + this.stream2.write(b); + } + + /** {@inheritDoc} */ + @Override + public void flush() throws IOException { + this.stream1.flush(); + this.stream2.flush(); + } + + /** {@inheritDoc} */ + @Override + public void close() throws IOException { + try { + this.stream1.close(); + } finally { + this.stream2.close(); + } + } +} From 67b9effc655d8ba75acb7db5e49687224d1c7a6a Mon Sep 17 00:00:00 2001 From: Michael Dardis Date: Fri, 14 Feb 2020 12:09:37 +1100 Subject: [PATCH 8/9] Remove use of org.bouncycastle.util.encoders.Hex Change-Id: I5c1ed0397ef99eb5d4f120da331b66c2d0f1707a Signed-off-by: Michael Dardis Signed-off-by: Matthias Sohn --- org.eclipse.jgit.test/META-INF/MANIFEST.MF | 1 - .../tst/org/eclipse/jgit/util/HexTest.java | 49 +++++++++++++++ .../jgit/transport/WalkEncryption.java | 2 +- .../src/org/eclipse/jgit/util/Hex.java | 63 +++++++++++++++++++ 4 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java create mode 100644 org.eclipse.jgit/src/org/eclipse/jgit/util/Hex.java diff --git a/org.eclipse.jgit.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.test/META-INF/MANIFEST.MF index 18f16d91f..cfd1a0414 100644 --- a/org.eclipse.jgit.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.test/META-INF/MANIFEST.MF @@ -18,7 +18,6 @@ Import-Package: com.googlecode.javaewah;version="[1.1.6,2.0.0)", org.apache.commons.compress.compressors.gzip;version="[1.15.0,2.0)", org.apache.commons.compress.compressors.xz;version="[1.15.0,2.0)", org.assertj.core.api;version="[3.14.0,4.0.0)", - org.bouncycastle.util.encoders;version="[1.61.0,2.0.0)", org.eclipse.jgit.annotations;version="[5.7.0,5.8.0)", org.eclipse.jgit.api;version="[5.7.0,5.8.0)", org.eclipse.jgit.api.errors;version="[5.7.0,5.8.0)", diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java new file mode 100644 index 000000000..32af07f25 --- /dev/null +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HexTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2010, Google Inc. + * Copyright (C) 2020 Michael Dardis and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0 which is available at + * https://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +package org.eclipse.jgit.util; + +import static org.eclipse.jgit.util.Hex.decode; +import static org.eclipse.jgit.util.Hex.toHexString; +import static org.junit.Assert.assertEquals; + +import org.eclipse.jgit.junit.JGitTestUtil; +import org.eclipse.jgit.lib.Constants; +import org.junit.Test; + +public class HexTest { + @Test + public void testEncode() { + assertEquals("68690a", toHexString(b("hi\n"))); + assertEquals("0001020d0a0971", toHexString(b("\0\1\2\r\n\tq"))); + } + + @Test + public void testDecode() { + JGitTestUtil.assertEquals(b("hi\n"), decode("68690a")); + JGitTestUtil.assertEquals(b("\0\1\2\r\n\tq"), decode("0001020d0a0971")); + JGitTestUtil.assertEquals(b("\u000EB"), decode("0E42")); + } + + @Test + public void testEncodeMatchesDecode() { + String[] testStrings = { "", "cow", "a", "a secret string", + "\0\1\2\r\n\t" }; + for (String e : testStrings) { + JGitTestUtil.assertEquals(b(e), decode(toHexString(b(e)))); + } + } + + private static byte[] b(String str) { + return Constants.encode(str); + } + +} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java index df9f11ecf..d079a51bb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkEncryption.java @@ -34,9 +34,9 @@ import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEParameterSpec; import javax.crypto.spec.SecretKeySpec; -import org.bouncycastle.util.encoders.Hex; import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.util.Base64; +import org.eclipse.jgit.util.Hex; abstract class WalkEncryption { static final WalkEncryption NONE = new NoEncryption(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/Hex.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/Hex.java new file mode 100644 index 000000000..935903652 --- /dev/null +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/Hex.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2020, Michael Dardis. and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0 which is available at + * https://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +package org.eclipse.jgit.util; + +/** + * Encodes and decodes to and from hexadecimal notation. + * + * @since 5.7 + */ +public final class Hex { + + private static final char[] HEX = "0123456789abcdef".toCharArray(); //$NON-NLS-1$ + + /** Defeats instantiation. */ + private Hex() { + // empty + } + + /** + * Decode a hexadecimal string to a byte array. + * + * Note this method performs no validation on input content. + * + * @param s hexadecimal string + * @return decoded array + */ + public static byte[] decode(String s) { + int len = s.length(); + byte[] b = new byte[len / 2]; + + for (int i = 0; i < len; i += 2) { + b[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) | Character.digit(s.charAt(i + 1), 16)); + } + return b; + } + + /** + * Encode a byte array to a hexadecimal string. + * + * @param b byte array + * @return hexadecimal string + */ + public static String toHexString(byte[] b) { + char[] c = new char[b.length * 2]; + + for (int i = 0; i < b.length; i++) { + int v = b[i] & 0xFF; + + c[i * 2] = HEX[v >>> 4]; + c[i * 2 + 1] = HEX[v & 0x0F]; + } + + return new String(c); + } +} From abb461533fccfd59117c3415cf9c0ed06e460473 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sat, 22 Feb 2020 22:51:32 +0100 Subject: [PATCH 9/9] Revert "Prepend hostname to subsection used to store file timestamp resolution" This reverts commit e102bbed995f0e6d3a1a8e5db6d08f9804fd3260. Resolving the hostname comes with a performance penalty. We no longer store the timestamp resolution in the global git config which might be copied around to other machines but in a dedicated jgit config meant for automatically determined options like timestamp resolution. Hence there is no strong reason anymore to have a hardware specific identifier in the subsection name of file timestamp resolution options. Bug: 560414 Change-Id: If8dcabe981eb1792db84643850faa6033f14b1cf Signed-off-by: Matthias Sohn --- org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 b2fba51d6..a2b53a253 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -246,9 +246,8 @@ public abstract class FS { background.set(async); } - private static final String javaVersionPrefix = SystemReader - .getInstance().getHostname() + '|' - + System.getProperty("java.vendor") + '|' //$NON-NLS-1$ + private static final String javaVersionPrefix = System + .getProperty("java.vendor") + '|' //$NON-NLS-1$ + System.getProperty("java.version") + '|'; //$NON-NLS-1$ private static final Duration FALLBACK_MIN_RACY_INTERVAL = Duration