aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/BlameCommand.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java30
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java37
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameResult.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java46
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/FileNameMatcher.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java21
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/PathMatcher.java37
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java28
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LagCheck.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java14
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java14
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogEntryImpl.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java102
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObjectCache.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java20
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/http/NetscapeCookieFileCache.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java19
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java28
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java92
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java33
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/notes/LeafBucket.java38
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMapMerger.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteParser.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java22
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteConfig.java16
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java27
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathSuffixFilter.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java23
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java25
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java31
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/RefMap.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/SshSupport.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/LimitedInputStream.java18
76 files changed, 552 insertions, 592 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/BlameCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/BlameCommand.java
index f7576e9e9b..0c765b01cb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/BlameCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/BlameCommand.java
@@ -275,13 +275,12 @@ public class BlameCommand extends GitCommand<BlameResult> {
byte[] buffer = new byte[upperSizeLimit];
try {
int read = IO.readFully(source, buffer, 0);
- if (read == upperSizeLimit)
+ if (read == upperSizeLimit) {
return buffer;
- else {
- byte[] copy = new byte[read];
- System.arraycopy(buffer, 0, copy, 0, read);
- return copy;
}
+ byte[] copy = new byte[read];
+ System.arraycopy(buffer, 0, copy, 0, read);
+ return copy;
} finally {
source.close();
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java
index f65b5735de..1c3c79041e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java
@@ -136,28 +136,32 @@ public class DiffCommand extends GitCommand<List<DiffEntry>> {
}
newTree = new DirCacheIterator(repo.readDirCache());
} else {
- if (oldTree == null)
+ if (oldTree == null) {
oldTree = new DirCacheIterator(repo.readDirCache());
- if (newTree == null)
+ }
+ if (newTree == null) {
newTree = new FileTreeIterator(repo);
+ }
}
diffFmt.setPathFilter(pathFilter);
List<DiffEntry> result = diffFmt.scan(oldTree, newTree);
- if (showNameAndStatusOnly)
- return result;
- else {
- if (contextLines >= 0)
- diffFmt.setContext(contextLines);
- if (destinationPrefix != null)
- diffFmt.setNewPrefix(destinationPrefix);
- if (sourcePrefix != null)
- diffFmt.setOldPrefix(sourcePrefix);
- diffFmt.format(result);
- diffFmt.flush();
+ if (showNameAndStatusOnly) {
return result;
}
+ if (contextLines >= 0) {
+ diffFmt.setContext(contextLines);
+ }
+ if (destinationPrefix != null) {
+ diffFmt.setNewPrefix(destinationPrefix);
+ }
+ if (sourcePrefix != null) {
+ diffFmt.setOldPrefix(sourcePrefix);
+ }
+ diffFmt.format(result);
+ diffFmt.flush();
+ return result;
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
index 2c9c5f20cc..9020c58d46 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
@@ -360,17 +360,17 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
* @return whether to remove refs which no longer exist in the source
*/
public boolean isRemoveDeletedRefs() {
- if (removeDeletedRefs != null)
+ if (removeDeletedRefs != null) {
return removeDeletedRefs.booleanValue();
- else { // fall back to configuration
- boolean result = false;
- StoredConfig config = repo.getConfig();
- result = config.getBoolean(ConfigConstants.CONFIG_FETCH_SECTION,
- null, ConfigConstants.CONFIG_KEY_PRUNE, result);
- result = config.getBoolean(ConfigConstants.CONFIG_REMOTE_SECTION,
- remote, ConfigConstants.CONFIG_KEY_PRUNE, result);
- return result;
}
+ // fall back to configuration
+ boolean result = false;
+ StoredConfig config = repo.getConfig();
+ result = config.getBoolean(ConfigConstants.CONFIG_FETCH_SECTION, null,
+ ConfigConstants.CONFIG_KEY_PRUNE, result);
+ result = config.getBoolean(ConfigConstants.CONFIG_REMOTE_SECTION,
+ remote, ConfigConstants.CONFIG_KEY_PRUNE, result);
+ return result;
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
index 7ea277157d..474e2f5736 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
@@ -243,9 +243,8 @@ public class GarbageCollectCommand extends GitCommand<Properties> {
if (repo instanceof FileRepository) {
GC gc = new GC((FileRepository) repo);
return toProperties(gc.getStatistics());
- } else {
- return new Properties();
}
+ return new Properties();
} catch (IOException e) {
throw new JGitInternalException(
JGitText.get().couldNotGetRepoStatistics, e);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
index f9a9baf919..9a843f63a0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
@@ -409,27 +409,24 @@ public class MergeCommand extends GitCommand<MergeResult> {
new ObjectId[] { headCommit.getId(),
srcCommit.getId() }, mergeStatus,
mergeStrategy, null, msg);
- } else {
- if (failingPaths != null) {
- repo.writeMergeCommitMsg(null);
- repo.writeMergeHeads(null);
- return new MergeResult(null, merger.getBaseCommitId(),
- new ObjectId[] {
- headCommit.getId(), srcCommit.getId() },
- MergeStatus.FAILED, mergeStrategy,
- lowLevelResults, failingPaths, null);
- } else {
- String mergeMessageWithConflicts = new MergeMessageFormatter()
- .formatWithConflicts(mergeMessage,
- unmergedPaths);
- repo.writeMergeCommitMsg(mergeMessageWithConflicts);
- return new MergeResult(null, merger.getBaseCommitId(),
- new ObjectId[] { headCommit.getId(),
- srcCommit.getId() },
- MergeStatus.CONFLICTING, mergeStrategy,
- lowLevelResults, null);
- }
}
+ if (failingPaths != null) {
+ repo.writeMergeCommitMsg(null);
+ repo.writeMergeHeads(null);
+ return new MergeResult(null, merger.getBaseCommitId(),
+ new ObjectId[] { headCommit.getId(),
+ srcCommit.getId() },
+ MergeStatus.FAILED, mergeStrategy, lowLevelResults,
+ failingPaths, null);
+ }
+ String mergeMessageWithConflicts = new MergeMessageFormatter()
+ .formatWithConflicts(mergeMessage, unmergedPaths);
+ repo.writeMergeCommitMsg(mergeMessageWithConflicts);
+ return new MergeResult(null, merger.getBaseCommitId(),
+ new ObjectId[] { headCommit.getId(),
+ srcCommit.getId() },
+ MergeStatus.CONFLICTING, mergeStrategy, lowLevelResults,
+ null);
}
} catch (org.eclipse.jgit.errors.CheckoutConflictException e) {
List<String> conflicts = (dco == null) ? Collections
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 bdb2d1bbc5..834b68d6d0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java
@@ -315,23 +315,24 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> {
Ref r = null;
if (fetchRes != null) {
r = fetchRes.getAdvertisedRef(remoteBranchName);
- if (r == null)
+ if (r == null) {
r = fetchRes.getAdvertisedRef(Constants.R_HEADS
+ remoteBranchName);
+ }
}
if (r == null) {
throw new RefNotAdvertisedException(MessageFormat.format(
JGitText.get().couldNotGetAdvertisedRef, remote,
remoteBranchName));
- } else {
- commitToMerge = r.getObjectId();
}
+ commitToMerge = r.getObjectId();
} else {
try {
commitToMerge = repo.resolve(remoteBranchName);
- if (commitToMerge == null)
+ if (commitToMerge == null) {
throw new RefNotFoundException(MessageFormat.format(
JGitText.get().refNotResolved, remoteBranchName));
+ }
} catch (IOException e) {
throw new JGitInternalException(
JGitText.get().exceptionCaughtDuringExecutionOfPullCommand,
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 0dacd4dfbf..715d9768d8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
@@ -509,10 +509,10 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
monitor.beginTask(MessageFormat.format(
JGitText.get().applyingCommit,
commitToPick.getShortMessage()), ProgressMonitor.UNKNOWN);
- if (preserveMerges)
+ if (preserveMerges) {
return cherryPickCommitPreservingMerges(commitToPick);
- else
- return cherryPickCommitFlattening(commitToPick);
+ }
+ return cherryPickCommitFlattening(commitToPick);
} finally {
monitor.endTask();
}
@@ -539,11 +539,11 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
.call();
switch (cherryPickResult.getStatus()) {
case FAILED:
- if (operation == Operation.BEGIN)
+ if (operation == Operation.BEGIN) {
return abort(RebaseResult
.failed(cherryPickResult.getFailingPaths()));
- else
- return stop(commitToPick, Status.STOPPED);
+ }
+ return stop(commitToPick, Status.STOPPED);
case CONFLICTING:
return stop(commitToPick, Status.STOPPED);
case OK:
@@ -599,11 +599,11 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
CherryPickResult cherryPickResult = pickCommand.call();
switch (cherryPickResult.getStatus()) {
case FAILED:
- if (operation == Operation.BEGIN)
+ if (operation == Operation.BEGIN) {
return abort(RebaseResult.failed(
cherryPickResult.getFailingPaths()));
- else
- return stop(commitToPick, Status.STOPPED);
+ }
+ return stop(commitToPick, Status.STOPPED);
case CONFLICTING:
return stop(commitToPick, Status.STOPPED);
case OK:
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
index d7c9ad5e04..3031a197a8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
@@ -334,10 +334,10 @@ public class ResetCommand extends GitCommand<Ref> {
}
private String getRefOrHEAD() {
- if (ref != null)
+ if (ref != null) {
return ref;
- else
- return Constants.HEAD;
+ }
+ return Constants.HEAD;
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java
index 52393695d9..74def9e897 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java
@@ -106,10 +106,10 @@ public class SubmoduleSyncCommand extends GitCommand<Map<String, String>> {
*/
protected String getHeadBranch(Repository subRepo) throws IOException {
Ref head = subRepo.exactRef(Constants.HEAD);
- if (head != null && head.isSymbolic())
+ if (head != null && head.isSymbolic()) {
return Repository.shortenRefName(head.getLeaf().getName());
- else
- return null;
+ }
+ return null;
}
/** {@inheritDoc} */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameResult.java b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameResult.java
index 5fb77501fa..394aba6a59 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameResult.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameResult.java
@@ -267,18 +267,18 @@ public class BlameResult {
*/
public int computeNext() throws IOException {
BlameGenerator gen = generator;
- if (gen == null)
+ if (gen == null) {
return -1;
+ }
if (gen.next()) {
loadFrom(gen);
lastLength = gen.getRegionLength();
return gen.getResultStart();
- } else {
- gen.close();
- generator = null;
- return -1;
}
+ gen.close();
+ generator = null;
+ return -1;
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
index 1cecff6fb0..fa552aabe1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
@@ -489,8 +489,8 @@ public class DiffFormatter implements AutoCloseable {
CanonicalTreeParser parser = new CanonicalTreeParser();
parser.reset(reader, tree);
return parser;
- } else
- return new EmptyTreeIterator();
+ }
+ return new EmptyTreeIterator();
}
/**
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 5c876e87fd..831074d2e1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
@@ -125,17 +125,17 @@ public class Edit {
*/
public final Type getType() {
if (beginA < endA) {
- if (beginB < endB)
+ if (beginB < endB) {
return Type.REPLACE;
- else /* if (beginB == endB) */
- return Type.DELETE;
-
- } else /* if (beginA == endA) */{
- if (beginB < endB)
- return Type.INSERT;
- else /* if (beginB == endB) */
- return Type.EMPTY;
+ }
+ return Type.DELETE;
+
+ }
+ if (beginB < endB) {
+ return Type.INSERT;
}
+ // beginB == endB)
+ return Type.EMPTY;
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
index 6c0d90ebad..219da0e9b9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
@@ -383,15 +383,17 @@ public class RawText extends Sequence {
* @return the line delimiter or <code>null</code>
*/
public String getLineDelimiter() {
- if (size() == 0)
+ if (size() == 0) {
return null;
+ }
int e = getEnd(0);
- if (content[e - 1] != '\n')
+ if (content[e - 1] != '\n') {
return null;
- if (content.length > 1 && e > 1 && content[e - 2] == '\r')
+ }
+ if (content.length > 1 && e > 1 && content[e - 2] == '\r') {
return "\r\n"; //$NON-NLS-1$
- else
- return "\n"; //$NON-NLS-1$
+ }
+ return "\n"; //$NON-NLS-1$
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
index 6bc2946078..1334949eb4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
@@ -517,10 +517,10 @@ public class DirCacheCheckout {
prescanOneTree();
if (!conflicts.isEmpty()) {
- if (failOnConflict)
+ if (failOnConflict) {
throw new CheckoutConflictException(conflicts.toArray(new String[0]));
- else
- cleanUpConflicts();
+ }
+ cleanUpConflicts();
}
// update our index
@@ -895,15 +895,14 @@ public class DirCacheCheckout {
// the workingtree entry doesn't exist or also contains a folder
// -> no problem
return;
- } else {
- // the workingtree entry exists and is not a folder
- if (!idEqual(h, m)) {
- // Because HEAD and MERGE differ we will try to update the
- // workingtree with a folder -> return a conflict
- conflict(name, null, null, null);
- }
- return;
}
+ // the workingtree entry exists and is not a folder
+ if (!idEqual(h, m)) {
+ // Because HEAD and MERGE differ we will try to update the
+ // workingtree with a folder -> return a conflict
+ conflict(name, null, null, null);
+ }
+ return;
}
if ((ffMask == 0x00F) && f != null && FileMode.TREE.equals(f.getEntryFileMode())) {
@@ -1083,15 +1082,15 @@ public class DirCacheCheckout {
// Something in Head
if (!FileMode.TREE.equals(f.getEntryFileMode())
- && FileMode.TREE.equals(iMode))
+ && FileMode.TREE.equals(iMode)) {
// The workingtree contains a file and the index semantically contains a folder.
// Git considers the workingtree file as untracked. Just keep the untracked file.
return;
- else
- // -> file is dirty and tracked but is should be
- // removed. That's a conflict
- conflict(name, dce, h, m);
- } else
+ }
+ // -> file is dirty and tracked but is should be
+ // removed. That's a conflict
+ conflict(name, dce, h, m);
+ } else {
// file doesn't exist or is clean
// Index contains the same as Head
// Something different from a submodule in Index
@@ -1099,7 +1098,8 @@ public class DirCacheCheckout {
// Something in Head
// -> Remove from index and delete the file
remove(name);
- } else
+ }
+ } else {
// Index contains something different from Head
// Something different from a submodule in Index
// Nothing in Merge
@@ -1108,6 +1108,7 @@ public class DirCacheCheckout {
// filesystem). But Merge wants the path to be removed.
// Report a conflict
conflict(name, dce, h, m);
+ }
}
} else {
// Something in Merge
@@ -1340,13 +1341,14 @@ public class DirCacheCheckout {
private boolean isModified_IndexTree(String path, ObjectId iId,
FileMode iMode, ObjectId tId, FileMode tMode, ObjectId rootTree)
throws CorruptObjectException, IOException {
- if (iMode != tMode)
+ if (iMode != tMode) {
return true;
+ }
if (FileMode.TREE.equals(iMode)
- && (iId == null || ObjectId.zeroId().equals(iId)))
+ && (iId == null || ObjectId.zeroId().equals(iId))) {
return isModifiedSubtree_IndexTree(path, rootTree);
- else
- return !equalIdAndMode(iId, iMode, tId, tMode);
+ }
+ return !equalIdAndMode(iId, iMode, tId, tMode);
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
index 0e91f0d748..cbf96e468c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
@@ -824,10 +824,10 @@ public class DirCacheEntry {
}
private int getExtendedFlags() {
- if (isExtended())
+ if (isExtended()) {
return NB.decodeUInt16(info, infoOffset + P_FLAGS2) << 16;
- else
- return 0;
+ }
+ return 0;
}
private static void checkPath(byte[] path) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java b/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java
index 60669bb955..2c93d55f4d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java
@@ -82,10 +82,10 @@ abstract class AbstractHead implements Head {
/** {@inheritDoc} */
@Override
public List<Head> getNextHeads(char c) {
- if (matches(c))
+ if (matches(c)) {
return newHeads;
- else
- return FileNameMatcher.EMPTY_HEAD_LIST;
+ }
+ return FileNameMatcher.EMPTY_HEAD_LIST;
}
boolean isStar() {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/FileNameMatcher.java b/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/FileNameMatcher.java
index bfcc580ba4..8125c356a6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/FileNameMatcher.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/FileNameMatcher.java
@@ -304,11 +304,11 @@ public class FileNameMatcher {
private static AbstractHead createWildCardHead(
final Character invalidWildgetCharacter, final boolean star) {
- if (invalidWildgetCharacter != null)
+ if (invalidWildgetCharacter != null) {
return new RestrictedWildCardHead(invalidWildgetCharacter
.charValue(), star);
- else
- return new WildCardHead(star);
+ }
+ return new WildCardHead(star);
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
index 8e463415b8..febdb92091 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
@@ -293,13 +293,12 @@ public class ManifestParser extends DefaultHandler {
String revision = defaultRevision;
if (remote == null) {
if (defaultRemote == null) {
- if (filename != null)
+ if (filename != null) {
throw new SAXException(MessageFormat.format(
RepoText.get().errorNoDefaultFilename,
filename));
- else
- throw new SAXException(
- RepoText.get().errorNoDefault);
+ }
+ throw new SAXException(RepoText.get().errorNoDefault);
}
remote = defaultRemote;
} else {
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 cb62925a1f..7288678007 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
@@ -761,18 +761,17 @@ public class RepoCommand extends GitCommand<RevCommit> {
} catch (GitAPIException | IOException e) {
throw new ManifestErrorException(e);
}
- } else {
- try (Git git = new Git(repo)) {
- for (RepoProject proj : filteredProjects) {
- addSubmodule(proj.getName(), proj.getUrl(), proj.getPath(),
- proj.getRevision(), proj.getCopyFiles(),
- proj.getLinkFiles(), git);
- }
- return git.commit().setMessage(RepoText.get().repoCommitMessage)
- .call();
- } catch (GitAPIException | IOException e) {
- throw new ManifestErrorException(e);
+ }
+ try (Git git = new Git(repo)) {
+ for (RepoProject proj : filteredProjects) {
+ addSubmodule(proj.getName(), proj.getUrl(), proj.getPath(),
+ proj.getRevision(), proj.getCopyFiles(),
+ proj.getLinkFiles(), git);
}
+ return git.commit().setMessage(RepoText.get().repoCommitMessage)
+ .call();
+ } catch (GitAPIException | IOException e) {
+ throw new ManifestErrorException(e);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java
index d79dfa8b2f..684d1e457f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java
@@ -422,10 +422,10 @@ public class RepoProject implements Comparable<RepoProject> {
}
private String getPathWithSlash() {
- if (path.endsWith("/")) //$NON-NLS-1$
+ if (path.endsWith("/")) { //$NON-NLS-1$
return path;
- else
- return path + "/"; //$NON-NLS-1$
+ }
+ return path + "/"; //$NON-NLS-1$
}
/**
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 3c0f17ab3d..b7d6acce14 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
@@ -291,26 +291,25 @@ public class PathMatcher extends AbstractMatcher {
// We had a prefix match here.
if (!pathMatch) {
return true;
+ }
+ if (right == endExcl - 1) {
+ // Extra slash at the end: actually a full match.
+ // Must meet directory expectations
+ return !dirOnly || assumeDirectory;
+ }
+ // Prefix matches only if pattern ended with /**
+ if (wasWild) {
+ return true;
+ }
+ if (lastWildmatch >= 0) {
+ // Consider pattern **/x and input x/x.
+ // We've matched the prefix x/ so far: we
+ // must try to extend the **!
+ matcher = lastWildmatch + 1;
+ right = wildmatchBacktrackPos;
+ wildmatchBacktrackPos = -1;
} else {
- if (right == endExcl - 1) {
- // Extra slash at the end: actually a full match.
- // Must meet directory expectations
- return !dirOnly || assumeDirectory;
- }
- // Prefix matches only if pattern ended with /**
- if (wasWild) {
- return true;
- }
- if (lastWildmatch >= 0) {
- // Consider pattern **/x and input x/x.
- // We've matched the prefix x/ so far: we
- // must try to extend the **!
- matcher = lastWildmatch + 1;
- right = wildmatchBacktrackPos;
- wildmatchBacktrackPos = -1;
- } else {
- return false;
- }
+ return false;
}
}
} else if (lastWildmatch != -1) {
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 41923eed18..b18aed9828 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
@@ -192,22 +192,20 @@ public class Strings {
}
if (pattern.indexOf('?') != -1) {
return true;
- } else {
- // check if the backslash escapes one of the glob special characters
- // if not, backslash is not part of a regex and treated literally
- int backSlash = pattern.indexOf('\\');
- if (backSlash >= 0) {
- int nextIdx = backSlash + 1;
- if (pattern.length() == nextIdx) {
- return false;
- }
- char nextChar = pattern.charAt(nextIdx);
- if (escapedByBackslash(nextChar)) {
- return true;
- } else {
- return false;
- }
+ }
+ // check if the backslash escapes one of the glob special characters
+ // if not, backslash is not part of a regex and treated literally
+ int backSlash = pattern.indexOf('\\');
+ if (backSlash >= 0) {
+ int nextIdx = backSlash + 1;
+ if (pattern.length() == nextIdx) {
+ return false;
+ }
+ char nextChar = pattern.charAt(nextIdx);
+ if (escapedByBackslash(nextChar)) {
+ return true;
}
+ return false;
}
return false;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LagCheck.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LagCheck.java
index 53fd198006..a27a9bc446 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LagCheck.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LagCheck.java
@@ -132,9 +132,8 @@ class LagCheck implements AutoCloseable {
// TODO(sop) Check term to see if my leader was deposed.
if (rw.isMergedInto(head, remote)) {
return AHEAD;
- } else {
- return DIVERGENT;
}
+ return DIVERGENT;
} catch (IOException err) {
KetchReplica.log.error(String.format(
"Cannot compare %s", //$NON-NLS-1$
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java
index 732cd4d1c6..b3b9e39375 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java
@@ -191,14 +191,11 @@ public abstract class DfsRefDatabase extends RefDatabase {
rw.peel(obj).copy(),
hasVersioning() ? leaf.getUpdateIndex()
: UNDEFINED_UPDATE_INDEX);
- } else {
- return new ObjectIdRef.PeeledNonTag(
- leaf.getStorage(),
- leaf.getName(),
- leaf.getObjectId(),
- hasVersioning() ? leaf.getUpdateIndex()
- : UNDEFINED_UPDATE_INDEX);
}
+ return new ObjectIdRef.PeeledNonTag(leaf.getStorage(),
+ leaf.getName(), leaf.getObjectId(),
+ hasVersioning() ? leaf.getUpdateIndex()
+ : UNDEFINED_UPDATE_INDEX);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
index 4f5f8a613e..130e39b149 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
@@ -358,9 +358,8 @@ public class FileRepository extends Repository {
File directory = getDirectory();
if (directory != null) {
return directory.getPath();
- } else {
- throw new IllegalStateException();
}
+ throw new IllegalStateException();
}
/** {@inheritDoc} */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java
index 82458c1acf..13b9e79be8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java
@@ -152,11 +152,10 @@ class GcLog {
boolean commit() {
if (nonEmpty) {
return lock.commit();
- } else {
- logFile.delete();
- lock.unlock();
- return true;
}
+ logFile.delete();
+ lock.unlock();
+ return true;
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
index e5a54e372c..09f2021686 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
@@ -109,10 +109,9 @@ class ObjectDirectoryInserter extends ObjectInserter {
ObjectId id = idFor(type, data, off, len);
if (!createDuplicate && db.has(id)) {
return id;
- } else {
- File tmp = toTemp(type, data, off, len);
- return insertOneObject(tmp, id, createDuplicate);
}
+ File tmp = toTemp(type, data, off, len);
+ return insertOneObject(tmp, id, createDuplicate);
}
/** {@inheritDoc} */
@@ -141,12 +140,11 @@ class ObjectDirectoryInserter extends ObjectInserter {
int actLen = IO.readFully(is, buf, 0);
return insert(type, buf, 0, actLen, createDuplicate);
- } else {
- SHA1 md = digest();
- File tmp = toTemp(md, type, len, is);
- ObjectId id = md.toObjectId();
- return insertOneObject(tmp, id, createDuplicate);
}
+ SHA1 md = digest();
+ File tmp = toTemp(md, type, len, is);
+ ObjectId id = md.toObjectId();
+ return insertOneObject(tmp, id, createDuplicate);
}
private ObjectId insertOneObject(
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 88e05af414..9b9c3a7dec 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
@@ -844,19 +844,20 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
case Constants.OBJ_TREE:
case Constants.OBJ_BLOB:
case Constants.OBJ_TAG: {
- if (delta != null || sz < curs.getStreamFileThreshold())
+ if (delta != null || sz < curs.getStreamFileThreshold()) {
data = decompress(pos + p, (int) sz, curs);
+ }
if (delta != null) {
type = typeCode;
break SEARCH;
}
- if (data != null)
+ if (data != null) {
return new ObjectLoader.SmallObject(typeCode, data);
- else
- return new LargePackedWholeObject(typeCode, sz, pos, p,
- this, curs.db);
+ }
+ return new LargePackedWholeObject(typeCode, sz, pos, p,
+ this, curs.db);
}
case Constants.OBJ_OFS_DELTA: {
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 e5cea6c010..7733df15f9 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
@@ -594,10 +594,9 @@ public class RefDirectory extends RefDatabase {
if (obj instanceof RevTag) {
return new ObjectIdRef.PeeledTag(leaf.getStorage(), leaf
.getName(), leaf.getObjectId(), rw.peel(obj).copy());
- } else {
- return new ObjectIdRef.PeeledNonTag(leaf.getStorage(), leaf
- .getName(), leaf.getObjectId());
}
+ return new ObjectIdRef.PeeledNonTag(leaf.getStorage(),
+ leaf.getName(), leaf.getObjectId());
}
}
@@ -894,10 +893,9 @@ public class RefDirectory extends RefDatabase {
if (peeledObjectId != null) {
return new ObjectIdRef.PeeledTag(PACKED, f.getName(),
f.getObjectId(), peeledObjectId);
- } else {
- return new ObjectIdRef.PeeledNonTag(PACKED, f.getName(),
- f.getObjectId());
}
+ return new ObjectIdRef.PeeledNonTag(PACKED, f.getName(),
+ f.getObjectId());
}
void log(boolean force, RefUpdate update, String msg, boolean deref)
@@ -1480,10 +1478,8 @@ public class RefDirectory extends RefDatabase {
if (peeledObjectId != null) {
return new LoosePeeledTag(snapShot, getName(),
objectId, peeledObjectId);
- } else {
- return new LooseNonTag(snapShot, getName(),
- objectId);
}
+ return new LooseNonTag(snapShot, getName(), objectId);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java
index 1a0d6953ab..dc4967fe4e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java
@@ -90,9 +90,8 @@ class RefDirectoryUpdate extends RefUpdate {
dst = database.findRef(name);
setOldObjectId(dst != null ? dst.getObjectId() : null);
return true;
- } else {
- return false;
}
+ return false;
}
/** {@inheritDoc} */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogEntryImpl.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogEntryImpl.java
index 08a14b28d2..3cdd90408e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogEntryImpl.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogEntryImpl.java
@@ -140,9 +140,9 @@ public class ReflogEntryImpl implements Serializable, ReflogEntry {
/** {@inheritDoc} */
@Override
public CheckoutEntry parseCheckout() {
- if (getComment().startsWith(CheckoutEntryImpl.CHECKOUT_MOVING_FROM))
+ if (getComment().startsWith(CheckoutEntryImpl.CHECKOUT_MOVING_FROM)) {
return new CheckoutEntryImpl(this);
- else
- return null;
+ }
+ return null;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
index 79f1307578..fb06623d7e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
@@ -139,49 +139,48 @@ public class UnpackedObject {
}
return new LargeObject(type, size, path, id, wc.db);
- } else {
- readSome(in, hdr, 2, 18);
- int c = hdr[0] & 0xff;
- int type = (c >> 4) & 7;
- long size = c & 15;
- int shift = 4;
- int p = 1;
- while ((c & 0x80) != 0) {
- c = hdr[p++] & 0xff;
- size += ((long) (c & 0x7f)) << shift;
- shift += 7;
- }
+ }
+ readSome(in, hdr, 2, 18);
+ int c = hdr[0] & 0xff;
+ int type = (c >> 4) & 7;
+ long size = c & 15;
+ int shift = 4;
+ int p = 1;
+ while ((c & 0x80) != 0) {
+ c = hdr[p++] & 0xff;
+ size += ((long) (c & 0x7f)) << shift;
+ shift += 7;
+ }
- switch (type) {
- case Constants.OBJ_COMMIT:
- case Constants.OBJ_TREE:
- case Constants.OBJ_BLOB:
- case Constants.OBJ_TAG:
- // Acceptable types for a loose object.
- break;
- default:
- throw new CorruptObjectException(id,
- JGitText.get().corruptObjectInvalidType);
- }
+ switch (type) {
+ case Constants.OBJ_COMMIT:
+ case Constants.OBJ_TREE:
+ case Constants.OBJ_BLOB:
+ case Constants.OBJ_TAG:
+ // Acceptable types for a loose object.
+ break;
+ default:
+ throw new CorruptObjectException(id,
+ JGitText.get().corruptObjectInvalidType);
+ }
- if (path == null && Integer.MAX_VALUE < size) {
- LargeObjectException.ExceedsByteArrayLimit e;
- e = new LargeObjectException.ExceedsByteArrayLimit();
- e.setObjectId(id);
- throw e;
- }
- if (size < wc.getStreamFileThreshold() || path == null) {
- in.reset();
- IO.skipFully(in, p);
- Inflater inf = wc.inflater();
- InputStream zIn = inflate(in, inf);
- byte[] data = new byte[(int) size];
- IO.readFully(zIn, data, 0, data.length);
- checkValidEndOfStream(in, inf, id, hdr);
- return new ObjectLoader.SmallObject(type, data);
- }
- return new LargeObject(type, size, path, id, wc.db);
+ if (path == null && Integer.MAX_VALUE < size) {
+ LargeObjectException.ExceedsByteArrayLimit e;
+ e = new LargeObjectException.ExceedsByteArrayLimit();
+ e.setObjectId(id);
+ throw e;
}
+ if (size < wc.getStreamFileThreshold() || path == null) {
+ in.reset();
+ IO.skipFully(in, p);
+ Inflater inf = wc.inflater();
+ InputStream zIn = inflate(in, inf);
+ byte[] data = new byte[(int) size];
+ IO.readFully(zIn, data, 0, data.length);
+ checkValidEndOfStream(in, inf, id, hdr);
+ return new ObjectLoader.SmallObject(type, data);
+ }
+ return new LargeObject(type, size, path, id, wc.db);
} catch (ZipException badStream) {
throw new CorruptObjectException(id,
JGitText.get().corruptObjectBadStream);
@@ -213,19 +212,18 @@ public class UnpackedObject {
JGitText.get().corruptObjectNegativeSize);
return size;
- } else {
- readSome(in, hdr, 2, 18);
- int c = hdr[0] & 0xff;
- long size = c & 15;
- int shift = 4;
- int p = 1;
- while ((c & 0x80) != 0) {
- c = hdr[p++] & 0xff;
- size += ((long) (c & 0x7f)) << shift;
- shift += 7;
- }
- return size;
}
+ readSome(in, hdr, 2, 18);
+ int c = hdr[0] & 0xff;
+ long size = c & 15;
+ int shift = 4;
+ int p = 1;
+ while ((c & 0x80) != 0) {
+ c = hdr[p++] & 0xff;
+ size += ((long) (c & 0x7f)) << shift;
+ shift += 7;
+ }
+ return size;
} catch (ZipException badStream) {
throw new CorruptObjectException(id,
JGitText.get().corruptObjectBadStream);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObjectCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObjectCache.java
index ea0d269053..616447a651 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObjectCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObjectCache.java
@@ -126,17 +126,19 @@ class UnpackedObjectCache {
for (int n = 0; n < MAX_CHAIN;) {
ObjectId obj = ids.get(i);
if (obj == null) {
- if (ids.compareAndSet(i, null, toAdd.copy()))
+ if (ids.compareAndSet(i, null, toAdd.copy())) {
return true;
- else
- continue;
+ }
+ continue;
}
- if (AnyObjectId.isEqual(obj, toAdd))
+ if (AnyObjectId.isEqual(obj, toAdd)) {
return true;
+ }
- if (++i == ids.length())
+ if (++i == ids.length()) {
i = 0;
+ }
n++;
}
return false;
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 2f770e96fb..e4536643a7 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
@@ -1751,23 +1751,23 @@ public class PackWriter implements AutoCloseable {
NullProgressMonitor.INSTANCE,
Collections.singleton(otp));
continue;
- } else {
- // Object writing already started, we cannot recover.
- //
- CorruptObjectException coe;
- coe = new CorruptObjectException(otp, ""); //$NON-NLS-1$
- coe.initCause(gone);
- throw coe;
}
+ // Object writing already started, we cannot recover.
+ //
+ CorruptObjectException coe;
+ coe = new CorruptObjectException(otp, ""); //$NON-NLS-1$
+ coe.initCause(gone);
+ throw coe;
}
}
// If we reached here, reuse wasn't possible.
//
- if (otp.isDeltaRepresentation())
+ if (otp.isDeltaRepresentation()) {
writeDeltaObjectDeflate(out, otp);
- else
+ } else {
writeWholeObjectDeflate(out, otp);
+ }
out.endObject();
otp.setCRC((int) crc32.getValue());
}
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 6c8d4fc03e..ce6ddb9cc6 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
@@ -87,16 +87,14 @@ public abstract class ReftableDatabase {
if (newRef.isSymbolic()) {
return ReceiveCommand.link(oldRef.getTarget().getName(),
newRef.getTarget().getName(), name);
- } else {
- // This should pass in oldId for compat with
- // RefDirectoryUpdate
- return ReceiveCommand.unlink(oldRef.getTarget().getName(),
- newId, name);
}
- } else {
+ // This should pass in oldId for compat with
+ // RefDirectoryUpdate
return ReceiveCommand.unlink(oldRef.getTarget().getName(),
- ObjectId.zeroId(), name);
+ newId, name);
}
+ return ReceiveCommand.unlink(oldRef.getTarget().getName(),
+ ObjectId.zeroId(), name);
}
if (newRef != null && newRef.isSymbolic()) {
@@ -104,14 +102,12 @@ public abstract class ReftableDatabase {
if (oldRef.isSymbolic()) {
return ReceiveCommand.link(oldRef.getTarget().getName(),
newRef.getTarget().getName(), name);
- } else {
- return ReceiveCommand.link(oldId,
- newRef.getTarget().getName(), name);
}
- } else {
- return ReceiveCommand.link(ObjectId.zeroId(),
+ return ReceiveCommand.link(oldId,
newRef.getTarget().getName(), name);
}
+ return ReceiveCommand.link(ObjectId.zeroId(),
+ newRef.getTarget().getName(), name);
}
return new ReceiveCommand(oldId, newId, name);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java
index da98e3fadd..9c5423fb0e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java
@@ -102,9 +102,8 @@ class RefTreeBatch extends BatchRefUpdate {
if (isAtomic()) {
ReceiveCommand.abort(getCommands());
return;
- } else {
- continue;
}
+ continue;
}
}
todo.add(new Command(rw, c));
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/http/NetscapeCookieFileCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/http/NetscapeCookieFileCache.java
index 882b2d055b..39a67afae3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/http/NetscapeCookieFileCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/http/NetscapeCookieFileCache.java
@@ -82,9 +82,8 @@ public class NetscapeCookieFileCache {
public static NetscapeCookieFileCache getInstance(HttpConfig config) {
if (instance == null) {
return new NetscapeCookieFileCache(config);
- } else {
- return instance;
}
+ return instance;
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java
index c1e94a0a3e..ee6adeee98 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java
@@ -384,9 +384,8 @@ public class OpenSshConfigFile {
private static boolean isHostMatch(String pattern, String name) {
if (pattern.startsWith("!")) { //$NON-NLS-1$
return !patternMatchesHost(pattern.substring(1), name);
- } else {
- return patternMatchesHost(pattern, name);
}
+ return patternMatchesHost(pattern, name);
}
private static boolean patternMatchesHost(String pattern, String name) {
@@ -399,10 +398,9 @@ public class OpenSshConfigFile {
}
fn.append(name);
return fn.isMatch();
- } else {
- // Not a pattern but a full host name
- return pattern.equals(name);
}
+ // Not a pattern but a full host name
+ return pattern.equals(name);
}
private static String dequote(String value) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java
index 4f90e69008..24850ee44c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java
@@ -302,10 +302,10 @@ public abstract class AnyObjectId implements Comparable<AnyObjectId> {
/** {@inheritDoc} */
@Override
public final boolean equals(Object o) {
- if (o instanceof AnyObjectId)
+ if (o instanceof AnyObjectId) {
return equals((AnyObjectId) o);
- else
- return false;
+ }
+ return false;
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
index 96e50667b3..98a46f3e54 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
@@ -103,25 +103,29 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
private static File getSymRef(File workTree, File dotGit, FS fs)
throws IOException {
byte[] content = IO.readFully(dotGit);
- if (!isSymRef(content))
+ if (!isSymRef(content)) {
throw new IOException(MessageFormat.format(
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
+ }
int pathStart = 8;
int lineEnd = RawParseUtils.nextLF(content, pathStart);
while (content[lineEnd - 1] == '\n' ||
- (content[lineEnd - 1] == '\r' && SystemReader.getInstance().isWindows()))
+ (content[lineEnd - 1] == '\r'
+ && SystemReader.getInstance().isWindows())) {
lineEnd--;
- if (lineEnd == pathStart)
+ }
+ if (lineEnd == pathStart) {
throw new IOException(MessageFormat.format(
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
+ }
String gitdirPath = RawParseUtils.decode(content, pathStart, lineEnd);
File gitdirFile = fs.resolve(workTree, gitdirPath);
- if (gitdirFile.isAbsolute())
+ if (gitdirFile.isAbsolute()) {
return gitdirFile;
- else
- return new File(workTree, gitdirPath).getCanonicalFile();
+ }
+ return new File(workTree, gitdirPath).getCanonicalFile();
}
private FS fs;
@@ -723,9 +727,8 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
.getAbsolutePath(), err.getMessage()));
}
return cfg;
- } else {
- return new Config();
}
+ return new Config();
}
private File guessWorkTreeOrFail() throws IOException {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
index be53c4b4f6..cad747bcff 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
@@ -232,9 +232,9 @@ public class BranchConfig {
private String getRemoteOrDefault() {
String remote = getRemote();
- if (remote == null)
+ if (remote == null) {
return Constants.DEFAULT_REMOTE_NAME;
- else
- return remote;
+ }
+ return remote;
}
}
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 16db717032..938fa2394e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
@@ -1395,12 +1395,11 @@ public class Config {
}
trailingSpaces.append(cc);
continue;
- } else {
- inLeadingSpace = false;
- if (trailingSpaces != null) {
- value.append(trailingSpaces);
- trailingSpaces.setLength(0);
- }
+ }
+ inLeadingSpace = false;
+ if (trailingSpaces != null) {
+ value.append(trailingSpaces);
+ trailingSpaces.setLength(0);
}
if ('\\' == c) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java
index e865da83b1..23e8de0e35 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java
@@ -134,11 +134,9 @@ public class DefaultTypedConfigGetter implements TypedConfigGetter {
throw new IllegalArgumentException(
MessageFormat.format(JGitText.get().enumValueNotSupported3,
section, subsection, name, value));
- } else {
- throw new IllegalArgumentException(
- MessageFormat.format(JGitText.get().enumValueNotSupported2,
- section, name, value));
}
+ throw new IllegalArgumentException(MessageFormat.format(
+ JGitText.get().enumValueNotSupported2, section, name, value));
}
/** {@inheritDoc} */
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 88d0859842..b87a031f58 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
@@ -606,16 +606,17 @@ public class IndexDiff {
}
// consume the remaining work
- if (monitor != null)
+ if (monitor != null) {
monitor.endTask();
+ }
ignored = indexDiffFilter.getIgnoredPaths();
if (added.isEmpty() && changed.isEmpty() && removed.isEmpty()
&& missing.isEmpty() && modified.isEmpty()
- && untracked.isEmpty())
+ && untracked.isEmpty()) {
return false;
- else
- return true;
+ }
+ return true;
}
private boolean hasFiles(File directory) {
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 700b9dbe85..e14fb102b7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java
@@ -293,9 +293,8 @@ public abstract class ObjectReader implements AutoCloseable {
if (idItr.hasNext()) {
cur = idItr.next();
return true;
- } else {
- return false;
}
+ return false;
}
@Override
@@ -383,9 +382,8 @@ public abstract class ObjectReader implements AutoCloseable {
cur = idItr.next();
sz = getObjectSize(cur, OBJ_ANY);
return true;
- } else {
- return false;
}
+ return false;
}
@Override
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 68866ea279..0e9cf58cf2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
@@ -503,9 +503,8 @@ public abstract class Repository implements AutoCloseable {
if (resolved instanceof String) {
final Ref ref = findRef((String) resolved);
return ref != null ? ref.getLeaf().getObjectId() : null;
- } else {
- return (ObjectId) resolved;
}
+ return (ObjectId) resolved;
}
}
@@ -527,11 +526,12 @@ public abstract class Repository implements AutoCloseable {
try (RevWalk rw = new RevWalk(this)) {
rw.setRetainBody(true);
Object resolved = resolve(rw, revstr);
- if (resolved != null)
- if (resolved instanceof String)
+ if (resolved != null) {
+ if (resolved instanceof String) {
return (String) resolved;
- else
- return ((AnyObjectId) resolved).getName();
+ }
+ return ((AnyObjectId) resolved).getName();
+ }
return null;
}
}
@@ -760,15 +760,15 @@ public abstract class Repository implements AutoCloseable {
if (name == null)
throw new RevisionSyntaxException(revstr);
} else if (time.matches("^-\\d+$")) { //$NON-NLS-1$
- if (name != null)
+ if (name != null) {
throw new RevisionSyntaxException(revstr);
- else {
- String previousCheckout = resolveReflogCheckout(-Integer
- .parseInt(time));
- if (ObjectId.isId(previousCheckout))
- rev = parseSimple(rw, previousCheckout);
- else
- name = previousCheckout;
+ }
+ String previousCheckout = resolveReflogCheckout(
+ -Integer.parseInt(time));
+ if (ObjectId.isId(previousCheckout)) {
+ rev = parseSimple(rw, previousCheckout);
+ } else {
+ name = previousCheckout;
}
} else {
if (name == null)
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.java
index cdbe3cd26c..12f353e0da 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.java
@@ -166,10 +166,10 @@ public class MergeConfig {
String mergeOptions = config.getString(
ConfigConstants.CONFIG_BRANCH_SECTION, branch,
ConfigConstants.CONFIG_KEY_MERGEOPTIONS);
- if (mergeOptions != null)
+ if (mergeOptions != null) {
return mergeOptions.split("\\s"); //$NON-NLS-1$
- else
- return new String[0];
+ }
+ return new String[0];
}
private static class MergeConfigSectionParser implements
@@ -188,10 +188,10 @@ public class MergeConfig {
@Override
public boolean equals(Object obj) {
- if (obj instanceof MergeConfigSectionParser)
+ if (obj instanceof MergeConfigSectionParser) {
return branch.equals(((MergeConfigSectionParser) obj).branch);
- else
- return false;
+ }
+ return false;
}
@Override
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java
index ca0e18a0ef..ca2f37abee 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java
@@ -153,15 +153,16 @@ public class MergeMessageFormatter {
private static void addConflictsMessage(List<String> conflictingPaths,
StringBuilder sb) {
sb.append("Conflicts:\n"); //$NON-NLS-1$
- for (String conflictingPath : conflictingPaths)
+ for (String conflictingPath : conflictingPaths) {
sb.append('\t').append(conflictingPath).append('\n');
+ }
}
private static String joinNames(List<String> names, String singular,
String plural) {
- if (names.size() == 1)
+ if (names.size() == 1) {
return singular + " " + names.get(0); //$NON-NLS-1$
- else
- return plural + " " + StringUtils.join(names, ", ", " and "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ return plural + " " + StringUtils.join(names, ", ", " and "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
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 0b423fb5d4..e0b00c0bd7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
@@ -652,42 +652,40 @@ public class ResolveMerger extends ThreeWayMerger {
keep(ourDce);
// no checkout needed!
return true;
- } else {
- // same content but different mode on OURS and THEIRS.
- // Try to merge the mode and report an error if this is
- // not possible.
- int newMode = mergeFileModes(modeB, modeO, modeT);
- if (newMode != FileMode.MISSING.getBits()) {
- if (newMode == modeO)
- // ours version is preferred
- keep(ourDce);
- else {
- // the preferred version THEIRS has a different mode
- // than ours. Check it out!
- if (isWorktreeDirty(work, ourDce))
- return false;
- // we know about length and lastMod only after we have written the new content.
- // This will happen later. Set these values to 0 for know.
- DirCacheEntry e = add(tw.getRawPath(), theirs,
- DirCacheEntry.STAGE_0, EPOCH, 0);
- addToCheckout(tw.getPathString(), e, attributes);
- }
- return true;
+ }
+ // same content but different mode on OURS and THEIRS.
+ // Try to merge the mode and report an error if this is
+ // not possible.
+ int newMode = mergeFileModes(modeB, modeO, modeT);
+ if (newMode != FileMode.MISSING.getBits()) {
+ if (newMode == modeO) {
+ // ours version is preferred
+ keep(ourDce);
} else {
- // FileModes are not mergeable. We found a conflict on modes.
- // For conflicting entries we don't know lastModified and length.
- add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0);
- add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0);
- add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH,
- 0);
- unmergedPaths.add(tw.getPathString());
- mergeResults.put(
- tw.getPathString(),
- new MergeResult<>(Collections
- .<RawText> emptyList()));
+ // the preferred version THEIRS has a different mode
+ // than ours. Check it out!
+ if (isWorktreeDirty(work, ourDce)) {
+ return false;
+ }
+ // we know about length and lastMod only after we have
+ // written the new content.
+ // This will happen later. Set these values to 0 for know.
+ DirCacheEntry e = add(tw.getRawPath(), theirs,
+ DirCacheEntry.STAGE_0, EPOCH, 0);
+ addToCheckout(tw.getPathString(), e, attributes);
}
return true;
}
+ // FileModes are not mergeable. We found a conflict on modes.
+ // For conflicting entries we don't know lastModified and
+ // length.
+ add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0);
+ add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0);
+ add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0);
+ unmergedPaths.add(tw.getPathString());
+ mergeResults.put(tw.getPathString(),
+ new MergeResult<>(Collections.<RawText> emptyList()));
+ return true;
}
if (modeB == modeT && tw.idEqual(T_BASE, T_THEIRS)) {
@@ -716,21 +714,20 @@ public class ResolveMerger extends ThreeWayMerger {
addToCheckout(tw.getPathString(), e, attributes);
}
return true;
- } else {
- // we want THEIRS ... but THEIRS contains a folder or the
- // deletion of the path. Delete what's in the working tree,
- // which we know to be clean.
- if (tw.getTreeCount() > T_FILE && tw.getRawMode(T_FILE) == 0) {
- // Not present in working tree, so nothing to delete
- return true;
- }
- if (modeT != 0 && modeT == modeB) {
- // Base, ours, and theirs all contain a folder: don't delete
- return true;
- }
- addDeletion(tw.getPathString(), nonTree(modeO), attributes);
+ }
+ // we want THEIRS ... but THEIRS contains a folder or the
+ // deletion of the path. Delete what's in the working tree,
+ // which we know to be clean.
+ if (tw.getTreeCount() > T_FILE && tw.getRawMode(T_FILE) == 0) {
+ // Not present in working tree, so nothing to delete
return true;
}
+ if (modeT != 0 && modeT == modeB) {
+ // Base, ours, and theirs all contain a folder: don't delete
+ return true;
+ }
+ addDeletion(tw.getPathString(), nonTree(modeO), attributes);
+ return true;
}
if (tw.isSubtree()) {
@@ -1310,10 +1307,9 @@ public class ResolveMerger extends ThreeWayMerger {
if (getUnmergedPaths().isEmpty() && !failed()) {
resultTree = dircache.writeTree(getObjectInserter());
return true;
- } else {
- resultTree = null;
- return false;
}
+ resultTree = null;
+ return false;
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.java
index 2fc0f4f073..d56e5c0c1e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.java
@@ -143,17 +143,17 @@ public abstract class ThreeWayMerger extends Merger {
* @throws java.io.IOException
*/
protected AbstractTreeIterator mergeBase() throws IOException {
- if (baseTree != null)
+ if (baseTree != null) {
return openTree(baseTree);
+ }
RevCommit baseCommit = (baseCommitId != null) ? walk
.parseCommit(baseCommitId) : getBaseCommit(sourceCommits[0],
sourceCommits[1]);
if (baseCommit == null) {
baseCommitId = null;
return new EmptyTreeIterator();
- } else {
- baseCommitId = baseCommit.toObjectId();
- return openTree(baseCommit.getTree());
}
+ baseCommitId = baseCommit.toObjectId();
+ return openTree(baseCommit.getTree());
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java b/org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java
index 7827a9aa05..c1616b3ed8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java
@@ -167,10 +167,10 @@ class FanoutBucket extends InMemoryNoteBucket {
@Override
public Note next() {
- if (hasNext())
+ if (hasNext()) {
return itr.next();
- else
- throw new NoSuchElementException();
+ }
+ throw new NoSuchElementException();
}
@Override
@@ -214,30 +214,31 @@ class FanoutBucket extends InMemoryNoteBucket {
NoteBucket b = table[cell];
if (b == null) {
- if (noteData == null)
+ if (noteData == null) {
return this;
+ }
LeafBucket n = new LeafBucket(prefixLen + 2);
table[cell] = n.set(noteOn, noteData, or);
cnt++;
return this;
- } else {
- NoteBucket n = b.set(noteOn, noteData, or);
- if (n == null) {
- table[cell] = null;
- cnt--;
+ }
+ NoteBucket n = b.set(noteOn, noteData, or);
+ if (n == null) {
+ table[cell] = null;
+ cnt--;
- if (cnt == 0)
- return null;
+ if (cnt == 0) {
+ return null;
+ }
- return contractIfTooSmall(noteOn, or);
+ return contractIfTooSmall(noteOn, or);
- } else if (n != b) {
- table[cell] = n;
- }
- return this;
+ } else if (n != b) {
+ table[cell] = n;
}
+ return this;
}
InMemoryNoteBucket contractIfTooSmall(AnyObjectId noteOn, ObjectReader or)
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/notes/LeafBucket.java b/org.eclipse.jgit/src/org/eclipse/jgit/notes/LeafBucket.java
index 6723b6309c..0fa2a6306c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/notes/LeafBucket.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/notes/LeafBucket.java
@@ -129,10 +129,10 @@ class LeafBucket extends InMemoryNoteBucket {
@Override
public Note next() {
- if (hasNext())
+ if (hasNext()) {
return notes[idx++];
- else
- throw new NoSuchElementException();
+ }
+ throw new NoSuchElementException();
}
@Override
@@ -156,25 +156,23 @@ class LeafBucket extends InMemoryNoteBucket {
notes[p].setData(noteData.copy());
return this;
- } else {
- System.arraycopy(notes, p + 1, notes, p, cnt - p - 1);
- cnt--;
- return 0 < cnt ? this : null;
}
+ System.arraycopy(notes, p + 1, notes, p, cnt - p - 1);
+ cnt--;
+ return 0 < cnt ? this : null;
} else if (noteData != null) {
if (shouldSplit()) {
return split().set(noteOn, noteData, or);
-
- } else {
- growIfFull();
- p = -(p + 1);
- if (p < cnt)
- System.arraycopy(notes, p, notes, p + 1, cnt - p);
- notes[p] = new Note(noteOn, noteData.copy());
- cnt++;
- return this;
}
+ growIfFull();
+ p = -(p + 1);
+ if (p < cnt) {
+ System.arraycopy(notes, p, notes, p + 1, cnt - p);
+ }
+ notes[p] = new Note(noteOn, noteData.copy());
+ cnt++;
+ return this;
} else {
return this;
@@ -234,12 +232,10 @@ class LeafBucket extends InMemoryNoteBucket {
InMemoryNoteBucket append(Note note) {
if (shouldSplit()) {
return split().append(note);
-
- } else {
- growIfFull();
- notes[cnt++] = note;
- return this;
}
+ growIfFull();
+ notes[cnt++] = note;
+ return this;
}
private void growIfFull() {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java
index cbef61338f..e4eef433d8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java
@@ -278,10 +278,10 @@ public class NoteMap implements Iterable<Note> {
public byte[] getCachedBytes(AnyObjectId id, int sizeLimit)
throws LargeObjectException, MissingObjectException, IOException {
ObjectId dataId = get(id);
- if (dataId != null)
+ if (dataId != null) {
return reader.open(dataId).getCachedBytes(sizeLimit);
- else
- return null;
+ }
+ return null;
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMapMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMapMerger.java
index ba7223b8f0..6ff1402900 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMapMerger.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMapMerger.java
@@ -307,10 +307,10 @@ public class NoteMapMerger {
private static InMemoryNoteBucket addIfNotNull(InMemoryNoteBucket result,
Note note) {
- if (note != null)
+ if (note != null) {
return result.append(note);
- else
- return result;
+ }
+ return result;
}
private NonNoteEntry mergeNonNotes(NonNoteEntry baseList,
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteParser.java
index 8ef3af10ad..7dfc47deb0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteParser.java
@@ -181,9 +181,8 @@ final class NoteParser extends CanonicalTreeParser {
} catch (ArrayIndexOutOfBoundsException notHex) {
return -1;
}
- } else {
- return -1;
}
+ return -1;
}
private void storeNonNote() {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
index 45508ce027..2bb45c55dc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
@@ -391,11 +391,10 @@ public class PlotCommitList<L extends PlotLane> extends
return pos.intValue();
}
return positionsAllocated++;
- } else {
- final Integer min = freePositions.first();
- freePositions.remove(min);
- return min.intValue();
}
+ final Integer min = freePositions.first();
+ freePositions.remove(min);
+ return min.intValue();
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java
index ee18fe7c2f..19e40b562b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java
@@ -176,11 +176,10 @@ public class PlotWalk extends RevWalk {
Collection<Ref> list = reverseRefMap.get(commitId);
if (list == null) {
return PlotCommit.NO_REFS;
- } else {
- Ref[] tags = list.toArray(new Ref[0]);
- Arrays.sort(tags, new PlotRefComparator());
- return tags;
}
+ Ref[] tags = list.toArray(new Ref[0]);
+ Arrays.sort(tags, new PlotRefComparator());
+ return tags;
}
class PlotRefComparator implements Comparator<Ref> {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java
index f7c3218850..090d1e110c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java
@@ -169,19 +169,19 @@ public class TreeRevFilter extends RevFilter {
//
c.flags |= rewriteFlag;
return false;
- } else {
- // We have interesting items, but neither of the special
- // cases denoted above.
+ }
+
+ // We have interesting items, but neither of the special
+ // cases denoted above.
+ //
+ if (adds > 0 && tw.getFilter() instanceof FollowFilter) {
+ // One of the paths we care about was added in this
+ // commit. We need to update our filter to its older
+ // name, if we can discover it. Find out what that is.
//
- if (adds > 0 && tw.getFilter() instanceof FollowFilter) {
- // One of the paths we care about was added in this
- // commit. We need to update our filter to its older
- // name, if we can discover it. Find out what that is.
- //
- updateFollowFilter(trees, ((FollowFilter) tw.getFilter()).cfg);
- }
- return true;
+ updateFollowFilter(trees, ((FollowFilter) tw.getFilter()).cfg);
}
+ return true;
} else if (nParents == 0) {
// We have no parents to compare against. Consider us to be
// REWRITE only if we have no paths matching our filter.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
index 954359ebaa..d4fa17e25e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
@@ -1579,14 +1579,15 @@ public abstract class BaseReceivePack {
RevObject o;
while ((o = ow.nextObject()) != null) {
checking.update(1);
- if (o.has(RevFlag.UNINTERESTING))
+ if (o.has(RevFlag.UNINTERESTING)) {
continue;
+ }
if (providedObjects != null) {
- if (providedObjects.contains(o))
+ if (providedObjects.contains(o)) {
continue;
- else
- throw new MissingObjectException(o, o.getType());
+ }
+ throw new MissingObjectException(o, o.getType());
}
if (o instanceof RevBlob && !db.getObjectDatabase().has(o))
@@ -1597,8 +1598,9 @@ public abstract class BaseReceivePack {
if (baseObjects != null) {
for (ObjectId id : baseObjects) {
o = ow.parseAny(id);
- if (!o.has(RevFlag.UNINTERESTING))
+ if (!o.has(RevFlag.UNINTERESTING)) {
throw new MissingObjectException(o, o.getType());
+ }
}
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java
index d901021788..6325a23530 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/CredentialsProviderUserInfo.java
@@ -107,10 +107,9 @@ public class CredentialsProviderUserInfo implements UserInfo,
if (provider.get(uri, v)) {
passphrase = v.getValue();
return true;
- } else {
- passphrase = null;
- return false;
}
+ passphrase = null;
+ return false;
}
/** {@inheritDoc} */
@@ -120,10 +119,9 @@ public class CredentialsProviderUserInfo implements UserInfo,
if (provider.get(uri, p)) {
password = new String(p.getValue());
return true;
- } else {
- password = null;
- return false;
}
+ password = null;
+ return false;
}
private CredentialItem.StringType newPrompt(String msg) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
index 01f6fec7e4..72e95e6ba3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HMACSHA1NonceGenerator.java
@@ -135,9 +135,8 @@ public class HMACSHA1NonceGenerator implements NonceGenerator {
if (nonceStampSlop <= slop) {
return NonceStatus.OK;
- } else {
- return NonceStatus.SLOP;
}
+ return NonceStatus.SLOP;
}
private static final String HEX = "0123456789ABCDEF"; //$NON-NLS-1$
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteConfig.java
index 0a621f19e1..4474d1a858 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteConfig.java
@@ -292,22 +292,26 @@ public class RemoteConfig implements Serializable {
private String replaceUri(final String uri,
final Map<String, String> replacements) {
- if (replacements.isEmpty())
+ if (replacements.isEmpty()) {
return uri;
+ }
Entry<String, String> match = null;
for (Entry<String, String> replacement : replacements.entrySet()) {
// Ignore current entry if not longer than previous match
if (match != null
- && match.getKey().length() > replacement.getKey().length())
+ && match.getKey().length() > replacement.getKey()
+ .length()) {
continue;
- if (!uri.startsWith(replacement.getKey()))
+ }
+ if (!uri.startsWith(replacement.getKey())) {
continue;
+ }
match = replacement;
}
- if (match != null)
+ if (match != null) {
return match.getValue() + uri.substring(match.getKey().length());
- else
- return uri;
+ }
+ return uri;
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
index 0b7907035e..2382f4c3af 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
@@ -302,11 +302,12 @@ public abstract class Transport implements AutoCloseable {
URISyntaxException, TransportException {
if (local != null) {
final RemoteConfig cfg = new RemoteConfig(local.getConfig(), remote);
- if (doesNotExist(cfg))
+ if (doesNotExist(cfg)) {
return open(local, new URIish(remote), null);
+ }
return open(local, cfg, op);
- } else
- return open(new URIish(remote));
+ }
+ return open(new URIish(remote));
}
@@ -708,11 +709,11 @@ public abstract class Transport implements AutoCloseable {
// try to find matching tracking refs
for (RefSpec fetchSpec : fetchSpecs) {
if (fetchSpec.matchSource(remoteName)) {
- if (fetchSpec.isWildcard())
+ if (fetchSpec.isWildcard()) {
return fetchSpec.expandFromSource(remoteName)
.getDestination();
- else
- return fetchSpec.getDestination();
+ }
+ return fetchSpec.getDestination();
}
}
return null;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
index 3029327c52..2637a0273a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
@@ -698,9 +698,8 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
public CredentialItem[] items() {
if (forRepo == null) {
return new CredentialItem[] { message, now, always };
- } else {
- return new CredentialItem[] { message, now, forRepo, always };
}
+ return new CredentialItem[] { message, now, forRepo, always };
}
}
@@ -1076,13 +1075,11 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
host = host.toLowerCase(Locale.ROOT);
if (host.equals(cookieDomain)) {
return true;
- } else {
- if (!host.endsWith(cookieDomain)) {
- return false;
- }
- return host
- .charAt(host.length() - cookieDomain.length() - 1) == '.';
}
+ if (!host.endsWith(cookieDomain)) {
+ return false;
+ }
+ return host.charAt(host.length() - cookieDomain.length() - 1) == '.';
}
/**
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 7ca9cc134c..d5e03ebd57 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
@@ -351,10 +351,7 @@ public class URIish implements Serializable {
}
private String n2e(String s) {
- if (s == null)
- return ""; //$NON-NLS-1$
- else
- return s;
+ return s == null ? "" : s; //$NON-NLS-1$
}
// takes care to cut of a leading slash if a windows drive letter or a
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java
index b4a7af094d..9a08c080c3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/resolver/FileResolver.java
@@ -124,8 +124,8 @@ public class FileResolver<C> implements RepositoryResolver<C> {
// are responsible for closing the repository if we
// complete successfully.
return db;
- } else
- throw new ServiceNotEnabledException();
+ }
+ throw new ServiceNotEnabledException();
} catch (RuntimeException | IOException e) {
db.close();
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 4f3eb05b11..6969ae45af 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
@@ -285,9 +285,8 @@ public class FileTreeIterator extends WorkingTreeIterator {
} else if (attributes.isDirectory()) {
if (new File(f, Constants.DOT_GIT).exists()) {
return FileMode.GITLINK;
- } else {
- return FileMode.TREE;
}
+ return FileMode.TREE;
} else if (attributes.isExecutable()) {
return FileMode.EXECUTABLE_FILE;
} else {
@@ -425,9 +424,8 @@ public class FileTreeIterator extends WorkingTreeIterator {
if (attributes.isSymbolicLink()) {
return new ByteArrayInputStream(fs.readSymLink(getFile())
.getBytes(UTF_8));
- } else {
- return new FileInputStream(getFile());
}
+ return new FileInputStream(getFile());
}
/**
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 3155916232..88b76f7121 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
@@ -685,10 +685,10 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
public InputStream openEntryStream() throws IOException {
InputStream rawis = current().openInputStream();
if (getCleanFilterCommand() == null
- && getEolStreamType() == EolStreamType.DIRECT)
+ && getEolStreamType() == EolStreamType.DIRECT) {
return rawis;
- else
- return filterClean(rawis);
+ }
+ return filterClean(rawis);
}
/**
@@ -979,13 +979,13 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
MetadataDiff diff = compareMetadata(entry);
switch (diff) {
case DIFFER_BY_TIMESTAMP:
- if (forceContentCheck)
+ if (forceContentCheck) {
// But we are told to look at content even though timestamps
// tell us about modification
return contentCheck(entry, reader);
- else
- // We are told to assume a modification if timestamps differs
- return true;
+ }
+ // We are told to assume a modification if timestamps differs
+ return true;
case SMUDGED:
// The file is clean by timestamps but the entry was smudged.
// Lets do a content check
@@ -1086,14 +1086,13 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
entry.setLength((int) getEntryLength());
return false;
- } else {
- if (mode == FileMode.SYMLINK.getBits()) {
- return !new File(readSymlinkTarget(current())).equals(
- new File(readContentAsNormalizedString(entry, reader)));
- }
- // Content differs: that's a real change
- return true;
}
+ if (mode == FileMode.SYMLINK.getBits()) {
+ return !new File(readSymlinkTarget(current())).equals(
+ new File(readContentAsNormalizedString(entry, reader)));
+ }
+ // Content differs: that's a real change
+ return true;
}
private static String readContentAsNormalizedString(DirCacheEntry entry,
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java
index 6cca582b3b..52fb888291 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/IndexDiffFilter.java
@@ -212,10 +212,9 @@ public class IndexDiffFilter extends TreeFilter {
// If i is cnt then the path does not appear in any other tree,
// and this working tree entry can be safely ignored.
return i != cnt;
- } else {
- // In working tree and not ignored, and not in DirCache.
- return true;
}
+ // In working tree and not ignored, and not in DirCache.
+ return true;
}
// Always include subtrees as WorkingTreeIterator cannot provide
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathSuffixFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathSuffixFilter.java
index 3d9f875e99..11896e4242 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathSuffixFilter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/PathSuffixFilter.java
@@ -99,10 +99,10 @@ public class PathSuffixFilter extends TreeFilter {
@Override
public boolean include(TreeWalk walker) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
- if (walker.isSubtree())
+ if (walker.isSubtree()) {
return true;
- else
- return walker.isPathSuffix(pathRaw, pathRaw.length);
+ }
+ return walker.isPathSuffix(pathRaw, pathRaw.length);
}
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 c8e6645f57..66f996554f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/ChangeIdUtil.java
@@ -173,20 +173,19 @@ public class ChangeIdUtil {
boolean replaceExisting) {
int indexOfChangeId = indexOfChangeId(message, "\n"); //$NON-NLS-1$
if (indexOfChangeId > 0) {
- if (!replaceExisting)
+ if (!replaceExisting) {
return message;
- else {
- StringBuilder ret = new StringBuilder(message.substring(0,
- indexOfChangeId));
- ret.append(CHANGE_ID);
- ret.append(" I"); //$NON-NLS-1$
- ret.append(ObjectId.toString(changeId));
- int indexOfNextLineBreak = message.indexOf("\n", //$NON-NLS-1$
- indexOfChangeId);
- if (indexOfNextLineBreak > 0)
- ret.append(message.substring(indexOfNextLineBreak));
- return ret.toString();
}
+ StringBuilder ret = new StringBuilder(
+ message.substring(0, indexOfChangeId));
+ ret.append(CHANGE_ID);
+ ret.append(" I"); //$NON-NLS-1$
+ ret.append(ObjectId.toString(changeId));
+ int indexOfNextLineBreak = message.indexOf("\n", //$NON-NLS-1$
+ indexOfChangeId);
+ if (indexOfNextLineBreak > 0)
+ ret.append(message.substring(indexOfNextLineBreak));
+ return ret.toString();
}
String[] lines = message.split("\n"); //$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 29519298c4..068e6450fe 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -147,15 +147,15 @@ public abstract class FS {
*/
public FS detect(Boolean cygwinUsed) {
if (SystemReader.getInstance().isWindows()) {
- if (cygwinUsed == null)
+ if (cygwinUsed == null) {
cygwinUsed = Boolean.valueOf(FS_Win32_Cygwin.isCygwin());
- if (cygwinUsed.booleanValue())
+ }
+ if (cygwinUsed.booleanValue()) {
return new FS_Win32_Cygwin();
- else
- return new FS_Win32();
- } else {
- return new FS_POSIX();
+ }
+ return new FS_Win32();
}
+ return new FS_POSIX();
}
}
@@ -1197,14 +1197,13 @@ public abstract class FS {
gobbler.join();
if (rc == 0 && !gobbler.fail.get()) {
return r;
- } else {
- if (debug) {
- LOG.debug("readpipe rc=" + rc); //$NON-NLS-1$
- }
- throw new CommandFailedException(rc,
- gobbler.errorMessage.get(),
- gobbler.exception.get());
}
+ if (debug) {
+ LOG.debug("readpipe rc=" + rc); //$NON-NLS-1$
+ }
+ throw new CommandFailedException(rc,
+ gobbler.errorMessage.get(),
+ gobbler.exception.get());
} catch (InterruptedException ie) {
// Stop bothering me, I have a zombie to reap.
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java
index a07a4fd1a5..391598d8ae 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java
@@ -345,13 +345,14 @@ public class IO {
c = s.charAt(++i);
l.add(sb.toString());
sb.setLength(0);
- if (c != '\n')
+ if (c != '\n') {
sb.append(c);
+ }
continue;
- } else { // EOF
- l.add(sb.toString());
- break;
}
+ // EOF
+ l.add(sb.toString());
+ break;
}
sb.append(c);
}
@@ -401,20 +402,18 @@ public class IO {
}
resetAndSkipFully(in, n);
}
- } else {
- StringBuilder buf = sizeHint > 0
- ? new StringBuilder(sizeHint)
- : new StringBuilder();
- int i;
- while ((i = in.read()) != -1) {
- char c = (char) i;
- buf.append(c);
- if (c == '\n') {
- break;
- }
+ }
+ StringBuilder buf = sizeHint > 0 ? new StringBuilder(sizeHint)
+ : new StringBuilder();
+ int i;
+ while ((i = in.read()) != -1) {
+ char c = (char) i;
+ buf.append(c);
+ if (c == '\n') {
+ break;
}
- return buf.toString();
}
+ return buf.toString();
}
private static void resetAndSkipFully(Reader fd, long toSkip) throws IOException {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/RefMap.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/RefMap.java
index 9663e3cef5..ce1308f334 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/RefMap.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/RefMap.java
@@ -191,12 +191,11 @@ public class RefMap extends AbstractMap<String, Ref> {
Ref prior = loose.get(name);
loose = loose.set(idx, value);
return prior;
- } else {
- Ref prior = get(keyName);
- loose = loose.add(idx, value);
- sizeIsValid = false;
- return prior;
}
+ Ref prior = get(keyName);
+ loose = loose.add(idx, value);
+ sizeIsValid = false;
+ return prior;
}
/** {@inheritDoc} */
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/SshSupport.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/SshSupport.java
index 913aa72867..84db786b16 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/SshSupport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/SshSupport.java
@@ -109,9 +109,8 @@ public class SshSupport {
// wrong exception type :(
if (process.waitFor() == 0) {
return stdout.toString();
- } else {
- return null; // still running after timeout
}
+ return null; // still running after timeout
} catch (InterruptedException e) {
return null; // error
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/LimitedInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/LimitedInputStream.java
index 9ab2caa1ac..e437c1114b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/LimitedInputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/LimitedInputStream.java
@@ -98,15 +98,16 @@ public abstract class LimitedInputStream extends FilterInputStream {
@Override
public int read() throws IOException {
if (left == 0) {
- if (in.available() == 0)
+ if (in.available() == 0) {
return -1;
- else
- limitExceeded();
+ }
+ limitExceeded();
}
int result = in.read();
- if (result != -1)
+ if (result != -1) {
--left;
+ }
return result;
}
@@ -114,16 +115,17 @@ public abstract class LimitedInputStream extends FilterInputStream {
@Override
public int read(byte[] b, int off, int len) throws IOException {
if (left == 0) {
- if (in.available() == 0)
+ if (in.available() == 0) {
return -1;
- else
- limitExceeded();
+ }
+ limitExceeded();
}
len = (int) Math.min(len, left);
int result = in.read(b, off, len);
- if (result != -1)
+ if (result != -1) {
left -= result;
+ }
return result;
}