Browse Source

Enable and fix "Statement unnecessarily nested within else clause" warnings

Since [1] the gerrit project includes jgit as a submodule, and has this
warning enabled, resulting in 100s of warnings in the console.

Also enable the warning here, and fix them.

At the same time, add missing braces around adjacent and nearby one-line
blocks.

[1] https://gerrit-review.googlesource.com/c/gerrit/+/227897

Change-Id: I81df3fc7ed6eedf6874ce1a3bedfa727a1897e4c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
next
David Pursehouse 5 years ago
parent
commit
98cdca9b5a
  1. 2
      org.eclipse.jgit.ant.test/.settings/org.eclipse.jdt.core.prefs
  2. 2
      org.eclipse.jgit.ant/.settings/org.eclipse.jdt.core.prefs
  3. 2
      org.eclipse.jgit.archive/.settings/org.eclipse.jdt.core.prefs
  4. 2
      org.eclipse.jgit.http.apache/.settings/org.eclipse.jdt.core.prefs
  5. 2
      org.eclipse.jgit.http.server/.settings/org.eclipse.jdt.core.prefs
  6. 4
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java
  7. 3
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java
  8. 2
      org.eclipse.jgit.http.test/.settings/org.eclipse.jdt.core.prefs
  9. 3
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
  10. 2
      org.eclipse.jgit.junit.http/.settings/org.eclipse.jdt.core.prefs
  11. 4
      org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java
  12. 2
      org.eclipse.jgit.junit.ssh/.settings/org.eclipse.jdt.core.prefs
  13. 2
      org.eclipse.jgit.junit/.settings/org.eclipse.jdt.core.prefs
  14. 3
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
  15. 2
      org.eclipse.jgit.lfs.server.test/.settings/org.eclipse.jdt.core.prefs
  16. 2
      org.eclipse.jgit.lfs.server/.settings/org.eclipse.jdt.core.prefs
  17. 3
      org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java
  18. 3
      org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java
  19. 2
      org.eclipse.jgit.lfs.test/.settings/org.eclipse.jdt.core.prefs
  20. 2
      org.eclipse.jgit.lfs/.settings/org.eclipse.jdt.core.prefs
  21. 6
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java
  22. 6
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java
  23. 6
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java
  24. 4
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java
  25. 2
      org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs
  26. 2
      org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.core.prefs
  27. 17
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java
  28. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
  29. 3
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
  30. 3
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java
  31. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java
  32. 2
      org.eclipse.jgit.ssh.apache.test/.settings/org.eclipse.jdt.core.prefs
  33. 2
      org.eclipse.jgit.ssh.apache/.settings/org.eclipse.jdt.core.prefs
  34. 6
      org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java
  35. 3
      org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyDatabase.java
  36. 6
      org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpParser.java
  37. 3
      org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/Socks5ClientConnector.java
  38. 3
      org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java
  39. 2
      org.eclipse.jgit.test/.settings/org.eclipse.jdt.core.prefs
  40. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java
  41. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectIdSerializerTest.java
  42. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefDatabaseConflictingNamesTest.java
  43. 9
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java
  44. 18
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java
  45. 2
      org.eclipse.jgit.ui/.settings/org.eclipse.jdt.core.prefs
  46. 2
      org.eclipse.jgit/.settings/org.eclipse.jdt.core.prefs
  47. 5
      org.eclipse.jgit/src/org/eclipse/jgit/api/BlameCommand.java
  48. 20
      org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java
  49. 10
      org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
  50. 3
      org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java
  51. 21
      org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
  52. 9
      org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java
  53. 12
      org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
  54. 4
      org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
  55. 4
      org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java
  56. 6
      org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameResult.java
  57. 2
      org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
  58. 12
      org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
  59. 10
      org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
  60. 24
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
  61. 4
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
  62. 4
      org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java
  63. 4
      org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/FileNameMatcher.java
  64. 7
      org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
  65. 3
      org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java
  66. 4
      org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java
  67. 3
      org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/PathMatcher.java
  68. 6
      org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java
  69. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/ketch/LagCheck.java
  70. 9
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java
  71. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
  72. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java
  73. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
  74. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
  75. 12
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
  76. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java
  77. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogEntryImpl.java
  78. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
  79. 10
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObjectCache.java
  80. 8
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
  81. 8
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java
  82. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java
  83. 3
      org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/http/NetscapeCookieFileCache.java
  84. 6
      org.eclipse.jgit/src/org/eclipse/jgit/internal/transport/ssh/OpenSshConfigFile.java
  85. 4
      org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java
  86. 17
      org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
  87. 4
      org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java
  88. 3
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java
  89. 6
      org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java
  90. 7
      org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java
  91. 6
      org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java
  92. 22
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
  93. 8
      org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.java
  94. 7
      org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java
  95. 34
      org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
  96. 6
      org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.java
  97. 13
      org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java
  98. 18
      org.eclipse.jgit/src/org/eclipse/jgit/notes/LeafBucket.java
  99. 4
      org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java
  100. 4
      org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMapMerger.java
  101. Some files were not shown because too many files have changed in this diff Show More

2
org.eclipse.jgit.ant.test/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error

2
org.eclipse.jgit.ant/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning

2
org.eclipse.jgit.archive/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning

2
org.eclipse.jgit.http.apache/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning

2
org.eclipse.jgit.http.server/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning

4
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/ServletBinderImpl.java

@ -86,9 +86,9 @@ abstract class ServletBinderImpl implements ServletBinder {
* @return the configured servlet, or singleton returning 404 if none. * @return the configured servlet, or singleton returning 404 if none.
*/ */
protected HttpServlet getServlet() { protected HttpServlet getServlet() {
if (httpServlet != null) if (httpServlet != null) {
return httpServlet; return httpServlet;
else }
return new ErrorServlet(HttpServletResponse.SC_NOT_FOUND); return new ErrorServlet(HttpServletResponse.SC_NOT_FOUND);
} }

3
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java

@ -83,8 +83,7 @@ public class DefaultUploadPackFactory implements
up.setExtraParameters(Arrays.asList(params)); up.setExtraParameters(Arrays.asList(params));
} }
return up; return up;
} else {
throw new ServiceNotEnabledException();
} }
throw new ServiceNotEnabledException();
} }
} }

2
org.eclipse.jgit.http.test/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error

3
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java

@ -331,9 +331,8 @@ public class SmartClientSmartServerTest extends AllFactoriesHttpTestCase {
String fragment = u.getRawFragment(); String fragment = u.getRawFragment();
if (fragment != null) { if (fragment != null) {
return u.getRawPath() + '#' + fragment; return u.getRawPath() + '#' + fragment;
} else {
return u.getRawPath();
} }
return u.getRawPath();
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
return url; return url;
} }

2
org.eclipse.jgit.junit.http/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error

4
org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java

@ -308,9 +308,9 @@ public class AppServer {
@Override @Override
protected String[] loadRoleInfo(UserPrincipal user) { protected String[] loadRoleInfo(UserPrincipal user) {
if (users.get(user.getName()) == null) if (users.get(user.getName()) == null) {
return null; return null;
else }
return new String[] { role }; return new String[] { role };
} }

2
org.eclipse.jgit.junit.ssh/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error

2
org.eclipse.jgit.junit/.settings/org.eclipse.jdt.core.prefs

@ -103,7 +103,7 @@ org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning

3
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java

@ -782,9 +782,8 @@ public class TestRepository<R extends Repository> implements AutoCloseable {
} }
update(Constants.HEAD, result); update(Constants.HEAD, result);
return pool.parseCommit(result); return pool.parseCommit(result);
} else {
throw new IOException("Merge conflict");
} }
throw new IOException("Merge conflict");
} }
/** /**

2
org.eclipse.jgit.lfs.server.test/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error

2
org.eclipse.jgit.lfs.server/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning

3
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java

@ -110,9 +110,8 @@ public class FileLfsRepository implements LargeFileRepository {
Path p = getPath(id); Path p = getPath(id);
if (Files.exists(p)) { if (Files.exists(p)) {
return Files.size(p); return Files.size(p);
} else {
return -1;
} }
return -1;
} }
/** /**

3
org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/s3/SignerV4.java

@ -352,9 +352,8 @@ class SignerV4 {
String encodedPath = urlEncode(path, true); String encodedPath = urlEncode(path, true);
if (encodedPath.startsWith("/")) { //$NON-NLS-1$ if (encodedPath.startsWith("/")) { //$NON-NLS-1$
return encodedPath; return encodedPath;
} else {
return "/" + encodedPath; //$NON-NLS-1$
} }
return "/" + encodedPath; //$NON-NLS-1$
} }
private static byte[] hash(String s) { private static byte[] hash(String s) {

2
org.eclipse.jgit.lfs.test/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error

2
org.eclipse.jgit.lfs/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning

6
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java

@ -83,9 +83,8 @@ public class BuiltinLFS extends LfsFactory {
Attribute attribute) throws IOException { Attribute attribute) throws IOException {
if (isEnabled(db) && (attribute == null || isEnabled(db, attribute))) { if (isEnabled(db) && (attribute == null || isEnabled(db, attribute))) {
return LfsBlobFilter.smudgeLfsBlob(db, loader); return LfsBlobFilter.smudgeLfsBlob(db, loader);
} else {
return loader;
} }
return loader;
} }
@Override @Override
@ -93,9 +92,8 @@ public class BuiltinLFS extends LfsFactory {
long length, Attribute attribute) throws IOException { long length, Attribute attribute) throws IOException {
if (isEnabled(db, attribute)) { if (isEnabled(db, attribute)) {
return new LfsInputStream(LfsBlobFilter.cleanLfsBlob(db, input)); return new LfsInputStream(LfsBlobFilter.cleanLfsBlob(db, input));
} else {
return new LfsInputStream(input, length);
} }
return new LfsInputStream(input, length);
} }
@Override @Override

6
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/CleanFilter.java

@ -138,7 +138,7 @@ public class CleanFilter extends FilterCommand {
aOut.write(buf, 0, length); aOut.write(buf, 0, length);
size += length; size += length;
return length; return length;
} else { }
aOut.close(); aOut.close();
AnyLongObjectId loid = aOut.getId(); AnyLongObjectId loid = aOut.getId();
aOut = null; aOut = null;
@ -147,9 +147,8 @@ public class CleanFilter extends FilterCommand {
long fsSize = Files.size(mediaFile); long fsSize = Files.size(mediaFile);
if (fsSize != size) { if (fsSize != size) {
throw new CorruptMediaFile(mediaFile, size, fsSize); throw new CorruptMediaFile(mediaFile, size, fsSize);
} else {
FileUtils.delete(tmpFile.toFile());
} }
FileUtils.delete(tmpFile.toFile());
} else { } else {
Path parent = mediaFile.getParent(); Path parent = mediaFile.getParent();
if (parent != null) { if (parent != null) {
@ -163,7 +162,6 @@ public class CleanFilter extends FilterCommand {
in.close(); in.close();
out.close(); out.close();
return -1; return -1;
}
} catch (IOException e) { } catch (IOException e) {
if (aOut != null) { if (aOut != null) {
aOut.abort(); aOut.abort();

6
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java

@ -179,9 +179,8 @@ public class LfsConnectionFactory {
remoteUrl, u); remoteUrl, u);
additionalHeaders.putAll(action.header); additionalHeaders.putAll(action.header);
return action.href; return action.href;
} else {
return remoteUrl + Protocol.INFO_LFS_ENDPOINT;
} }
return remoteUrl + Protocol.INFO_LFS_ENDPOINT;
} }
private static Protocol.ExpiringAction getSshAuthentication( private static Protocol.ExpiringAction getSshAuthentication(
@ -262,9 +261,8 @@ public class LfsConnectionFactory {
if (path.endsWith(org.eclipse.jgit.lib.Constants.DOT_GIT)) { if (path.endsWith(org.eclipse.jgit.lib.Constants.DOT_GIT)) {
return path.substring(0, path.length() - 4); return path.substring(0, path.length() - 4);
} else {
return path;
} }
return path;
} }
/** /**

4
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java

@ -303,9 +303,9 @@ public abstract class AnyLongObjectId implements Comparable<AnyLongObjectId> {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final boolean equals(Object o) { public final boolean equals(Object o) {
if (o instanceof AnyLongObjectId) if (o instanceof AnyLongObjectId) {
return equals((AnyLongObjectId) o); return equals((AnyLongObjectId) o);
else }
return false; return false;
} }

2
org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error

2
org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning

17
org.eclipse.jgit.pgm/src/org/eclipse/jgit/console/ConsoleCredentialsProvider.java

@ -136,18 +136,15 @@ public class ConsoleCredentialsProvider extends CredentialsProvider {
if (v != null) { if (v != null) {
item.setValue(new String(v)); item.setValue(new String(v));
return true; return true;
} else { }
return false; return false;
} }
} else {
String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$ String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
if (v != null) { if (v != null) {
item.setValue(v); item.setValue(v);
return true; return true;
} else {
return false;
}
} }
return false;
} }
private boolean get(CredentialItem.CharArrayType item) { private boolean get(CredentialItem.CharArrayType item) {
@ -156,18 +153,15 @@ public class ConsoleCredentialsProvider extends CredentialsProvider {
if (v != null) { if (v != null) {
item.setValueNoCopy(v); item.setValueNoCopy(v);
return true; return true;
} else { }
return false; return false;
} }
} else {
String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$ String v = cons.readLine("%s: ", item.getPromptText()); //$NON-NLS-1$
if (v != null) { if (v != null) {
item.setValueNoCopy(v.toCharArray()); item.setValueNoCopy(v.toCharArray());
return true; return true;
} else {
return false;
}
} }
return false;
} }
private boolean get(CredentialItem.InformationalMessage item) { private boolean get(CredentialItem.InformationalMessage item) {
@ -182,8 +176,7 @@ public class ConsoleCredentialsProvider extends CredentialsProvider {
if (r != null) { if (r != null) {
item.setValue(CLIText.get().answerYes.equalsIgnoreCase(r)); item.setValue(CLIText.get().answerYes.equalsIgnoreCase(r));
return true; return true;
} else {
return false;
} }
return false;
} }
} }

2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java

@ -306,7 +306,7 @@ class Status extends TextBuiltin {
} }
outw.flush(); outw.flush();
return list.size(); return list.size();
} else }
return 0; return 0;
} }

3
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java

@ -189,9 +189,8 @@ class RebuildCommitGraph extends TextBuiltin {
// rewritten. // rewritten.
queue.add(t); queue.add(t);
continue REWRITE; continue REWRITE;
} else {
newParents[k] = p.newId;
} }
newParents[k] = p.newId;
} else { } else {
// We have the old parent object. Use it. // We have the old parent object. Use it.
// //

3
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/TextHashFunctions.java

@ -138,9 +138,8 @@ class TextHashFunctions extends TextBuiltin {
Arrays.fill(buf16, (byte) 0); Arrays.fill(buf16, (byte) 0);
System.arraycopy(raw, ptr, buf16, 0, end - ptr); System.arraycopy(raw, ptr, buf16, 0, end - ptr);
return rabin(buf16, 0); return rabin(buf16, 0);
} else {
return rabin(raw, ptr);
} }
return rabin(raw, ptr);
} }
private int rabin(byte[] raw, int ptr) { private int rabin(byte[] raw, int ptr) {

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/CmdLineParser.java

@ -299,9 +299,9 @@ public class CmdLineParser extends org.kohsuke.args4j.CmdLineParser {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected OptionHandler createOptionHandler(OptionDef o, Setter setter) { protected OptionHandler createOptionHandler(OptionDef o, Setter setter) {
if (o instanceof NamedOptionDef) if (o instanceof NamedOptionDef) {
return super.createOptionHandler(o, setter); return super.createOptionHandler(o, setter);
else }
return super.createOptionHandler(new MyOptionDef(o), setter); return super.createOptionHandler(new MyOptionDef(o), setter);
} }

2
org.eclipse.jgit.ssh.apache.test/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error

2
org.eclipse.jgit.ssh.apache/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning

6
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitClientSession.java

@ -179,9 +179,8 @@ public class JGitClientSession extends ClientSessionImpl {
} catch (Exception other) { } catch (Exception other) {
throw new IOException(other.getLocalizedMessage(), other); throw new IOException(other.getLocalizedMessage(), other);
} }
} else {
return super.sendIdentification(ident);
} }
return super.sendIdentification(ident);
} }
@Override @Override
@ -205,9 +204,8 @@ public class JGitClientSession extends ClientSessionImpl {
} catch (Exception other) { } catch (Exception other) {
throw new IOException(other.getLocalizedMessage(), other); throw new IOException(other.getLocalizedMessage(), other);
} }
} else {
return super.sendKexInit();
} }
return super.sendKexInit();
} }
/** /**

3
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyDatabase.java

@ -453,9 +453,8 @@ public class OpenSshServerKeyDatabase
prompt); prompt);
items.add(answer); items.add(answer);
return provider.get(uri, items) && answer.getValue(); return provider.get(uri, items) && answer.getValue();
} else {
return provider.get(uri, items);
} }
return provider.get(uri, items);
} }
private Check checkMode(SocketAddress remoteAddress, boolean changed) { private Check checkMode(SocketAddress remoteAddress, boolean changed) {

6
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpParser.java

@ -207,12 +207,11 @@ public final class HttpParser {
next++; next++;
} }
return next; return next;
} else { }
// This token must be the name of the next authentication // This token must be the name of the next authentication
// scheme. // scheme.
return start; return start;
} }
}
int nextStart = skipWhiteSpace(header, next + 1); int nextStart = skipWhiteSpace(header, next + 1);
if (nextStart >= length) { if (nextStart >= length) {
if (next == end) { if (next == end) {
@ -244,11 +243,10 @@ public final class HttpParser {
// token, and the equals sign is part of the token // token, and the equals sign is part of the token
challenge.setToken(header.substring(start, end + 1)); challenge.setToken(header.substring(start, end + 1));
return nextStart + 1; return nextStart + 1;
} else { }
// Key without value... // Key without value...
challenge.addArgument(header.substring(start, end), null); challenge.addArgument(header.substring(start, end), null);
start = nextStart + 1; start = nextStart + 1;
}
} else { } else {
if (header.charAt(nextStart) == '"') { if (header.charAt(nextStart) == '"') {
int nextEnd[] = { nextStart + 1 }; int nextEnd[] = { nextStart + 1 };

3
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/Socks5ClientConnector.java

@ -281,12 +281,11 @@ public class Socks5ClientConnector extends AbstractClientProxyConnector {
} }
if (i == proposals.length) { if (i == proposals.length) {
return proposals; return proposals;
} else { }
byte[] result = new byte[i]; byte[] result = new byte[i];
System.arraycopy(proposals, 0, result, 0, i); System.arraycopy(proposals, 0, result, 0, i);
return result; return result;
} }
}
private void sendConnectInfo(IoSession session) throws Exception { private void sendConnectInfo(IoSession session) throws Exception {
GssApiMechanisms.closeContextSilently(context); GssApiMechanisms.closeContextSilently(context);

3
org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSession.java

@ -354,9 +354,8 @@ public class SshdSession implements RemoteSession {
if (path.charAt(0) != '/') { if (path.charAt(0) != '/') {
if (cwd.charAt(cwd.length() - 1) == '/') { if (cwd.charAt(cwd.length() - 1) == '/') {
return cwd + path; return cwd + path;
} else {
return cwd + '/' + path;
} }
return cwd + '/' + path;
} }
return path; return path;
} }

2
org.eclipse.jgit.test/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=error

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackFileSnapshotTest.java

@ -295,9 +295,8 @@ public class PackFileSnapshotTest extends RepositoryTestCase {
Files.copy(src, dstOut); Files.copy(src, dstOut);
return dst; return dst;
} }
} else {
return Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);
} }
return Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);
} }
private Path copyPack(Path base, String srcSuffix, String dstSuffix) private Path copyPack(Path base, String srcSuffix, String dstSuffix)

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectIdSerializerTest.java

@ -88,9 +88,8 @@ public class ObjectIdSerializerTest {
try (InputStream in = new FileInputStream(file)) { try (InputStream in = new FileInputStream(file)) {
if (objectId == null) { if (objectId == null) {
return ObjectIdSerializer.read(in); return ObjectIdSerializer.read(in);
} else {
return ObjectIdSerializer.readWithoutMarker(in);
} }
return ObjectIdSerializer.readWithoutMarker(in);
} }
} }
} }

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefDatabaseConflictingNamesTest.java

@ -67,9 +67,8 @@ public class RefDatabaseConflictingNamesTest {
existing.put("refs/heads/a/b", null /* not used */); existing.put("refs/heads/a/b", null /* not used */);
existing.put("refs/heads/q", null /* not used */); existing.put("refs/heads/q", null /* not used */);
return existing; return existing;
} else {
return Collections.emptyMap();
} }
return Collections.emptyMap();
} }
@Override @Override

9
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/HttpAuthTest.java

@ -133,16 +133,15 @@ public class HttpAuthTest {
@Override @Override
public String getHeaderField(String name) { public String getHeaderField(String name) {
if (!headerFields.containsKey(name)) if (!headerFields.containsKey(name)) {
return null; return null;
else { }
int n = headerFields.get(name).size(); int n = headerFields.get(name).size();
if (n > 0) if (n > 0) {
return headerFields.get(name).get(n - 1); return headerFields.get(name).get(n - 1);
else
return null;
} }
return null;
} }
@Override @Override

18
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java

@ -239,9 +239,8 @@ public class WalkEncryptionTest {
loadEnvVar(ENV_SECRET_KEY, SECRET_KEY, props); loadEnvVar(ENV_SECRET_KEY, SECRET_KEY, props);
loadEnvVar(ENV_BUCKET_NAME, TEST_BUCKET, props); loadEnvVar(ENV_BUCKET_NAME, TEST_BUCKET, props);
return props; return props;
} else {
return null;
} }
return null;
} }
static Properties fromEnvFile() throws Exception { static Properties fromEnvFile() throws Exception {
@ -250,13 +249,11 @@ public class WalkEncryptionTest {
props.load(new FileInputStream(ENV_CONFIG_FILE)); props.load(new FileInputStream(ENV_CONFIG_FILE));
if (checkTestProps(props)) { if (checkTestProps(props)) {
return props; return props;
} else { }
throw new Error("Environment config file is incomplete."); throw new Error("Environment config file is incomplete.");
} }
} else {
return null; return null;
} }
}
static Properties fromSysProps() { static Properties fromSysProps() {
if (haveSysProp(SYS_ACCESS_KEY) && haveSysProp(SYS_SECRET_KEY) if (haveSysProp(SYS_ACCESS_KEY) && haveSysProp(SYS_SECRET_KEY)
@ -266,9 +263,8 @@ public class WalkEncryptionTest {
loadSysProp(SYS_SECRET_KEY, SECRET_KEY, props); loadSysProp(SYS_SECRET_KEY, SECRET_KEY, props);
loadSysProp(SYS_BUCKET_NAME, TEST_BUCKET, props); loadSysProp(SYS_BUCKET_NAME, TEST_BUCKET, props);
return props; return props;
} else {
return null;
} }
return null;
} }
static Properties fromSysFile() throws Exception { static Properties fromSysFile() throws Exception {
@ -277,13 +273,11 @@ public class WalkEncryptionTest {
props.load(new FileInputStream(SYS_CONFIG_FILE)); props.load(new FileInputStream(SYS_CONFIG_FILE));
if (checkTestProps(props)) { if (checkTestProps(props)) {
return props; return props;
} else { }
throw new Error("System props config file is incomplete."); throw new Error("System props config file is incomplete.");
} }
} else {
return null; return null;
} }
}
static Properties fromConfigFile(String path) throws Exception { static Properties fromConfigFile(String path) throws Exception {
File file = new File(path); File file = new File(path);
@ -292,13 +286,11 @@ public class WalkEncryptionTest {
props.load(new FileInputStream(file)); props.load(new FileInputStream(file));
if (checkTestProps(props)) { if (checkTestProps(props)) {
return props; return props;
} else { }
throw new Error("Props config file is incomplete: " + path); throw new Error("Props config file is incomplete: " + path);
} }
} else {
return null; return null;
} }
}
/** /**
* Find test properties from various sources in order of priority. * Find test properties from various sources in order of priority.

2
org.eclipse.jgit.ui/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning

2
org.eclipse.jgit/.settings/org.eclipse.jdt.core.prefs

@ -92,7 +92,7 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning

5
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]; byte[] buffer = new byte[upperSizeLimit];
try { try {
int read = IO.readFully(source, buffer, 0); int read = IO.readFully(source, buffer, 0);
if (read == upperSizeLimit) if (read == upperSizeLimit) {
return buffer; return buffer;
else { }
byte[] copy = new byte[read]; byte[] copy = new byte[read];
System.arraycopy(buffer, 0, copy, 0, read); System.arraycopy(buffer, 0, copy, 0, read);
return copy; return copy;
}
} finally { } finally {
source.close(); source.close();
} }

20
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()); newTree = new DirCacheIterator(repo.readDirCache());
} else { } else {
if (oldTree == null) if (oldTree == null) {
oldTree = new DirCacheIterator(repo.readDirCache()); oldTree = new DirCacheIterator(repo.readDirCache());
if (newTree == null) }
if (newTree == null) {
newTree = new FileTreeIterator(repo); newTree = new FileTreeIterator(repo);
} }
}
diffFmt.setPathFilter(pathFilter); diffFmt.setPathFilter(pathFilter);
List<DiffEntry> result = diffFmt.scan(oldTree, newTree); List<DiffEntry> result = diffFmt.scan(oldTree, newTree);
if (showNameAndStatusOnly) if (showNameAndStatusOnly) {
return result; return result;
else { }
if (contextLines >= 0) if (contextLines >= 0) {
diffFmt.setContext(contextLines); diffFmt.setContext(contextLines);
if (destinationPrefix != null) }
if (destinationPrefix != null) {
diffFmt.setNewPrefix(destinationPrefix); diffFmt.setNewPrefix(destinationPrefix);
if (sourcePrefix != null) }
if (sourcePrefix != null) {
diffFmt.setOldPrefix(sourcePrefix); diffFmt.setOldPrefix(sourcePrefix);
}
diffFmt.format(result); diffFmt.format(result);
diffFmt.flush(); diffFmt.flush();
return result; return result;
}
} catch (IOException e) { } catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e); throw new JGitInternalException(e.getMessage(), e);
} }

10
org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java

@ -360,18 +360,18 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
* @return whether to remove refs which no longer exist in the source * @return whether to remove refs which no longer exist in the source
*/ */
public boolean isRemoveDeletedRefs() { public boolean isRemoveDeletedRefs() {
if (removeDeletedRefs != null) if (removeDeletedRefs != null) {
return removeDeletedRefs.booleanValue(); return removeDeletedRefs.booleanValue();
else { // fall back to configuration }
// fall back to configuration
boolean result = false; boolean result = false;
StoredConfig config = repo.getConfig(); StoredConfig config = repo.getConfig();
result = config.getBoolean(ConfigConstants.CONFIG_FETCH_SECTION, result = config.getBoolean(ConfigConstants.CONFIG_FETCH_SECTION, null,
null, ConfigConstants.CONFIG_KEY_PRUNE, result); ConfigConstants.CONFIG_KEY_PRUNE, result);
result = config.getBoolean(ConfigConstants.CONFIG_REMOTE_SECTION, result = config.getBoolean(ConfigConstants.CONFIG_REMOTE_SECTION,
remote, ConfigConstants.CONFIG_KEY_PRUNE, result); remote, ConfigConstants.CONFIG_KEY_PRUNE, result);
return result; return result;
} }
}
/** /**
* If set to {@code true}, refs are removed which no longer exist in the * If set to {@code true}, refs are removed which no longer exist in the

3
org.eclipse.jgit/src/org/eclipse/jgit/api/GarbageCollectCommand.java

@ -243,9 +243,8 @@ public class GarbageCollectCommand extends GitCommand<Properties> {
if (repo instanceof FileRepository) { if (repo instanceof FileRepository) {
GC gc = new GC((FileRepository) repo); GC gc = new GC((FileRepository) repo);
return toProperties(gc.getStatistics()); return toProperties(gc.getStatistics());
} else {
return new Properties();
} }
return new Properties();
} catch (IOException e) { } catch (IOException e) {
throw new JGitInternalException( throw new JGitInternalException(
JGitText.get().couldNotGetRepoStatistics, e); JGitText.get().couldNotGetRepoStatistics, e);

21
org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java

@ -409,27 +409,24 @@ public class MergeCommand extends GitCommand<MergeResult> {
new ObjectId[] { headCommit.getId(), new ObjectId[] { headCommit.getId(),
srcCommit.getId() }, mergeStatus, srcCommit.getId() }, mergeStatus,
mergeStrategy, null, msg); mergeStrategy, null, msg);
} else { }
if (failingPaths != null) { if (failingPaths != null) {
repo.writeMergeCommitMsg(null); repo.writeMergeCommitMsg(null);
repo.writeMergeHeads(null); repo.writeMergeHeads(null);
return new MergeResult(null, merger.getBaseCommitId(), return new MergeResult(null, merger.getBaseCommitId(),
new ObjectId[] { new ObjectId[] { headCommit.getId(),
headCommit.getId(), srcCommit.getId() }, srcCommit.getId() },
MergeStatus.FAILED, mergeStrategy, MergeStatus.FAILED, mergeStrategy, lowLevelResults,
lowLevelResults, failingPaths, null); failingPaths, null);
} else { }
String mergeMessageWithConflicts = new MergeMessageFormatter() String mergeMessageWithConflicts = new MergeMessageFormatter()
.formatWithConflicts(mergeMessage, .formatWithConflicts(mergeMessage, unmergedPaths);
unmergedPaths);
repo.writeMergeCommitMsg(mergeMessageWithConflicts); repo.writeMergeCommitMsg(mergeMessageWithConflicts);
return new MergeResult(null, merger.getBaseCommitId(), return new MergeResult(null, merger.getBaseCommitId(),
new ObjectId[] { headCommit.getId(), new ObjectId[] { headCommit.getId(),
srcCommit.getId() }, srcCommit.getId() },
MergeStatus.CONFLICTING, mergeStrategy, MergeStatus.CONFLICTING, mergeStrategy, lowLevelResults,
lowLevelResults, null); null);
}
}
} }
} catch (org.eclipse.jgit.errors.CheckoutConflictException e) { } catch (org.eclipse.jgit.errors.CheckoutConflictException e) {
List<String> conflicts = (dco == null) ? Collections List<String> conflicts = (dco == null) ? Collections

9
org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java

@ -315,23 +315,24 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> {
Ref r = null; Ref r = null;
if (fetchRes != null) { if (fetchRes != null) {
r = fetchRes.getAdvertisedRef(remoteBranchName); r = fetchRes.getAdvertisedRef(remoteBranchName);
if (r == null) if (r == null) {
r = fetchRes.getAdvertisedRef(Constants.R_HEADS r = fetchRes.getAdvertisedRef(Constants.R_HEADS
+ remoteBranchName); + remoteBranchName);
} }
}
if (r == null) { if (r == null) {
throw new RefNotAdvertisedException(MessageFormat.format( throw new RefNotAdvertisedException(MessageFormat.format(
JGitText.get().couldNotGetAdvertisedRef, remote, JGitText.get().couldNotGetAdvertisedRef, remote,
remoteBranchName)); remoteBranchName));
} else {
commitToMerge = r.getObjectId();
} }
commitToMerge = r.getObjectId();
} else { } else {
try { try {
commitToMerge = repo.resolve(remoteBranchName); commitToMerge = repo.resolve(remoteBranchName);
if (commitToMerge == null) if (commitToMerge == null) {
throw new RefNotFoundException(MessageFormat.format( throw new RefNotFoundException(MessageFormat.format(
JGitText.get().refNotResolved, remoteBranchName)); JGitText.get().refNotResolved, remoteBranchName));
}
} catch (IOException e) { } catch (IOException e) {
throw new JGitInternalException( throw new JGitInternalException(
JGitText.get().exceptionCaughtDuringExecutionOfPullCommand, JGitText.get().exceptionCaughtDuringExecutionOfPullCommand,

12
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java

@ -509,9 +509,9 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
monitor.beginTask(MessageFormat.format( monitor.beginTask(MessageFormat.format(
JGitText.get().applyingCommit, JGitText.get().applyingCommit,
commitToPick.getShortMessage()), ProgressMonitor.UNKNOWN); commitToPick.getShortMessage()), ProgressMonitor.UNKNOWN);
if (preserveMerges) if (preserveMerges) {
return cherryPickCommitPreservingMerges(commitToPick); return cherryPickCommitPreservingMerges(commitToPick);
else }
return cherryPickCommitFlattening(commitToPick); return cherryPickCommitFlattening(commitToPick);
} finally { } finally {
monitor.endTask(); monitor.endTask();
@ -539,10 +539,10 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
.call(); .call();
switch (cherryPickResult.getStatus()) { switch (cherryPickResult.getStatus()) {
case FAILED: case FAILED:
if (operation == Operation.BEGIN) if (operation == Operation.BEGIN) {
return abort(RebaseResult return abort(RebaseResult
.failed(cherryPickResult.getFailingPaths())); .failed(cherryPickResult.getFailingPaths()));
else }
return stop(commitToPick, Status.STOPPED); return stop(commitToPick, Status.STOPPED);
case CONFLICTING: case CONFLICTING:
return stop(commitToPick, Status.STOPPED); return stop(commitToPick, Status.STOPPED);
@ -599,10 +599,10 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
CherryPickResult cherryPickResult = pickCommand.call(); CherryPickResult cherryPickResult = pickCommand.call();
switch (cherryPickResult.getStatus()) { switch (cherryPickResult.getStatus()) {
case FAILED: case FAILED:
if (operation == Operation.BEGIN) if (operation == Operation.BEGIN) {
return abort(RebaseResult.failed( return abort(RebaseResult.failed(
cherryPickResult.getFailingPaths())); cherryPickResult.getFailingPaths()));
else }
return stop(commitToPick, Status.STOPPED); return stop(commitToPick, Status.STOPPED);
case CONFLICTING: case CONFLICTING:
return stop(commitToPick, Status.STOPPED); return stop(commitToPick, Status.STOPPED);

4
org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java

@ -334,9 +334,9 @@ public class ResetCommand extends GitCommand<Ref> {
} }
private String getRefOrHEAD() { private String getRefOrHEAD() {
if (ref != null) if (ref != null) {
return ref; return ref;
else }
return Constants.HEAD; return Constants.HEAD;
} }

4
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java

@ -106,9 +106,9 @@ public class SubmoduleSyncCommand extends GitCommand<Map<String, String>> {
*/ */
protected String getHeadBranch(Repository subRepo) throws IOException { protected String getHeadBranch(Repository subRepo) throws IOException {
Ref head = subRepo.exactRef(Constants.HEAD); Ref head = subRepo.exactRef(Constants.HEAD);
if (head != null && head.isSymbolic()) if (head != null && head.isSymbolic()) {
return Repository.shortenRefName(head.getLeaf().getName()); return Repository.shortenRefName(head.getLeaf().getName());
else }
return null; return null;
} }

6
org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameResult.java

@ -267,19 +267,19 @@ public class BlameResult {
*/ */
public int computeNext() throws IOException { public int computeNext() throws IOException {
BlameGenerator gen = generator; BlameGenerator gen = generator;
if (gen == null) if (gen == null) {
return -1; return -1;
}
if (gen.next()) { if (gen.next()) {
loadFrom(gen); loadFrom(gen);
lastLength = gen.getRegionLength(); lastLength = gen.getRegionLength();
return gen.getResultStart(); return gen.getResultStart();
} else { }
gen.close(); gen.close();
generator = null; generator = null;
return -1; return -1;
} }
}
/** /**
* Get last length * Get last length

2
org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java

@ -489,7 +489,7 @@ public class DiffFormatter implements AutoCloseable {
CanonicalTreeParser parser = new CanonicalTreeParser(); CanonicalTreeParser parser = new CanonicalTreeParser();
parser.reset(reader, tree); parser.reset(reader, tree);
return parser; return parser;
} else }
return new EmptyTreeIterator(); return new EmptyTreeIterator();
} }

12
org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java

@ -125,17 +125,17 @@ public class Edit {
*/ */
public final Type getType() { public final Type getType() {
if (beginA < endA) { if (beginA < endA) {
if (beginB < endB) if (beginB < endB) {
return Type.REPLACE; return Type.REPLACE;
else /* if (beginB == endB) */ }
return Type.DELETE; return Type.DELETE;
} else /* if (beginA == endA) */{ }
if (beginB < endB) if (beginB < endB) {
return Type.INSERT; return Type.INSERT;
else /* if (beginB == endB) */
return Type.EMPTY;
} }
// beginB == endB)
return Type.EMPTY;
} }
/** /**

10
org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java

@ -383,14 +383,16 @@ public class RawText extends Sequence {
* @return the line delimiter or <code>null</code> * @return the line delimiter or <code>null</code>
*/ */
public String getLineDelimiter() { public String getLineDelimiter() {
if (size() == 0) if (size() == 0) {
return null; return null;
}
int e = getEnd(0); int e = getEnd(0);
if (content[e - 1] != '\n') if (content[e - 1] != '\n') {
return null; 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$ return "\r\n"; //$NON-NLS-1$
else }
return "\n"; //$NON-NLS-1$ return "\n"; //$NON-NLS-1$
} }

24
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java vendored

@ -517,9 +517,9 @@ public class DirCacheCheckout {
prescanOneTree(); prescanOneTree();
if (!conflicts.isEmpty()) { if (!conflicts.isEmpty()) {
if (failOnConflict) if (failOnConflict) {
throw new CheckoutConflictException(conflicts.toArray(new String[0])); throw new CheckoutConflictException(conflicts.toArray(new String[0]));
else }
cleanUpConflicts(); cleanUpConflicts();
} }
@ -895,7 +895,7 @@ public class DirCacheCheckout {
// the workingtree entry doesn't exist or also contains a folder // the workingtree entry doesn't exist or also contains a folder
// -> no problem // -> no problem
return; return;
} else { }
// the workingtree entry exists and is not a folder // the workingtree entry exists and is not a folder
if (!idEqual(h, m)) { if (!idEqual(h, m)) {
// Because HEAD and MERGE differ we will try to update the // Because HEAD and MERGE differ we will try to update the
@ -904,7 +904,6 @@ public class DirCacheCheckout {
} }
return; return;
} }
}
if ((ffMask == 0x00F) && f != null && FileMode.TREE.equals(f.getEntryFileMode())) { if ((ffMask == 0x00F) && f != null && FileMode.TREE.equals(f.getEntryFileMode())) {
// File/Directory conflict case #20 // File/Directory conflict case #20
@ -1083,15 +1082,15 @@ public class DirCacheCheckout {
// Something in Head // Something in Head
if (!FileMode.TREE.equals(f.getEntryFileMode()) 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. // The workingtree contains a file and the index semantically contains a folder.
// Git considers the workingtree file as untracked. Just keep the untracked file. // Git considers the workingtree file as untracked. Just keep the untracked file.
return; return;
else }
// -> file is dirty and tracked but is should be // -> file is dirty and tracked but is should be
// removed. That's a conflict // removed. That's a conflict
conflict(name, dce, h, m); conflict(name, dce, h, m);
} else } else {
// file doesn't exist or is clean // file doesn't exist or is clean
// Index contains the same as Head // Index contains the same as Head
// Something different from a submodule in Index // Something different from a submodule in Index
@ -1099,7 +1098,8 @@ public class DirCacheCheckout {
// Something in Head // Something in Head
// -> Remove from index and delete the file // -> Remove from index and delete the file
remove(name); remove(name);
} else }
} else {
// Index contains something different from Head // Index contains something different from Head
// Something different from a submodule in Index // Something different from a submodule in Index
// Nothing in Merge // Nothing in Merge
@ -1109,6 +1109,7 @@ public class DirCacheCheckout {
// Report a conflict // Report a conflict
conflict(name, dce, h, m); conflict(name, dce, h, m);
} }
}
} else { } else {
// Something in Merge // Something in Merge
// Something in Head // Something in Head
@ -1340,12 +1341,13 @@ public class DirCacheCheckout {
private boolean isModified_IndexTree(String path, ObjectId iId, private boolean isModified_IndexTree(String path, ObjectId iId,
FileMode iMode, ObjectId tId, FileMode tMode, ObjectId rootTree) FileMode iMode, ObjectId tId, FileMode tMode, ObjectId rootTree)
throws CorruptObjectException, IOException { throws CorruptObjectException, IOException {
if (iMode != tMode) if (iMode != tMode) {
return true; return true;
}
if (FileMode.TREE.equals(iMode) if (FileMode.TREE.equals(iMode)
&& (iId == null || ObjectId.zeroId().equals(iId))) && (iId == null || ObjectId.zeroId().equals(iId))) {
return isModifiedSubtree_IndexTree(path, rootTree); return isModifiedSubtree_IndexTree(path, rootTree);
else }
return !equalIdAndMode(iId, iMode, tId, tMode); return !equalIdAndMode(iId, iMode, tId, tMode);
} }

4
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java vendored

@ -824,9 +824,9 @@ public class DirCacheEntry {
} }
private int getExtendedFlags() { private int getExtendedFlags() {
if (isExtended()) if (isExtended()) {
return NB.decodeUInt16(info, infoOffset + P_FLAGS2) << 16; return NB.decodeUInt16(info, infoOffset + P_FLAGS2) << 16;
else }
return 0; return 0;
} }

4
org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/AbstractHead.java

@ -82,9 +82,9 @@ abstract class AbstractHead implements Head {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public List<Head> getNextHeads(char c) { public List<Head> getNextHeads(char c) {
if (matches(c)) if (matches(c)) {
return newHeads; return newHeads;
else }
return FileNameMatcher.EMPTY_HEAD_LIST; return FileNameMatcher.EMPTY_HEAD_LIST;
} }

4
org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/FileNameMatcher.java

@ -304,10 +304,10 @@ public class FileNameMatcher {
private static AbstractHead createWildCardHead( private static AbstractHead createWildCardHead(
final Character invalidWildgetCharacter, final boolean star) { final Character invalidWildgetCharacter, final boolean star) {
if (invalidWildgetCharacter != null) if (invalidWildgetCharacter != null) {
return new RestrictedWildCardHead(invalidWildgetCharacter return new RestrictedWildCardHead(invalidWildgetCharacter
.charValue(), star); .charValue(), star);
else }
return new WildCardHead(star); return new WildCardHead(star);
} }

7
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java

@ -293,13 +293,12 @@ public class ManifestParser extends DefaultHandler {
String revision = defaultRevision; String revision = defaultRevision;
if (remote == null) { if (remote == null) {
if (defaultRemote == null) { if (defaultRemote == null) {
if (filename != null) if (filename != null) {
throw new SAXException(MessageFormat.format( throw new SAXException(MessageFormat.format(
RepoText.get().errorNoDefaultFilename, RepoText.get().errorNoDefaultFilename,
filename)); filename));
else }
throw new SAXException( throw new SAXException(RepoText.get().errorNoDefault);
RepoText.get().errorNoDefault);
} }
remote = defaultRemote; remote = defaultRemote;
} else { } else {

3
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java

@ -761,7 +761,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
} catch (GitAPIException | IOException e) { } catch (GitAPIException | IOException e) {
throw new ManifestErrorException(e); throw new ManifestErrorException(e);
} }
} else { }
try (Git git = new Git(repo)) { try (Git git = new Git(repo)) {
for (RepoProject proj : filteredProjects) { for (RepoProject proj : filteredProjects) {
addSubmodule(proj.getName(), proj.getUrl(), proj.getPath(), addSubmodule(proj.getName(), proj.getUrl(), proj.getPath(),
@ -774,7 +774,6 @@ public class RepoCommand extends GitCommand<RevCommit> {
throw new ManifestErrorException(e); throw new ManifestErrorException(e);
} }
} }
}
private void addSubmodule(String name, String url, String path, private void addSubmodule(String name, String url, String path,
String revision, List<CopyFile> copyfiles, List<LinkFile> linkfiles, String revision, List<CopyFile> copyfiles, List<LinkFile> linkfiles,

4
org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoProject.java

@ -422,9 +422,9 @@ public class RepoProject implements Comparable<RepoProject> {
} }
private String getPathWithSlash() { private String getPathWithSlash() {
if (path.endsWith("/")) //$NON-NLS-1$ if (path.endsWith("/")) { //$NON-NLS-1$
return path; return path;
else }
return path + "/"; //$NON-NLS-1$ return path + "/"; //$NON-NLS-1$
} }

3
org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/PathMatcher.java

@ -291,7 +291,7 @@ public class PathMatcher extends AbstractMatcher {
// We had a prefix match here. // We had a prefix match here.
if (!pathMatch) { if (!pathMatch) {
return true; return true;
} else { }
if (right == endExcl - 1) { if (right == endExcl - 1) {
// Extra slash at the end: actually a full match. // Extra slash at the end: actually a full match.
// Must meet directory expectations // Must meet directory expectations
@ -312,7 +312,6 @@ public class PathMatcher extends AbstractMatcher {
return false; return false;
} }
} }
}
} else if (lastWildmatch != -1) { } else if (lastWildmatch != -1) {
matcher = lastWildmatch + 1; matcher = lastWildmatch + 1;
right = wildmatchBacktrackPos; right = wildmatchBacktrackPos;

6
org.eclipse.jgit/src/org/eclipse/jgit/ignore/internal/Strings.java

@ -192,7 +192,7 @@ public class Strings {
} }
if (pattern.indexOf('?') != -1) { if (pattern.indexOf('?') != -1) {
return true; return true;
} else { }
// check if the backslash escapes one of the glob special characters // check if the backslash escapes one of the glob special characters
// if not, backslash is not part of a regex and treated literally // if not, backslash is not part of a regex and treated literally
int backSlash = pattern.indexOf('\\'); int backSlash = pattern.indexOf('\\');
@ -204,10 +204,8 @@ public class Strings {
char nextChar = pattern.charAt(nextIdx); char nextChar = pattern.charAt(nextIdx);
if (escapedByBackslash(nextChar)) { if (escapedByBackslash(nextChar)) {
return true; return true;
} else {
return false;
}
} }
return false;
} }
return false; return false;
} }

3
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. // TODO(sop) Check term to see if my leader was deposed.
if (rw.isMergedInto(head, remote)) { if (rw.isMergedInto(head, remote)) {
return AHEAD; return AHEAD;
} else {
return DIVERGENT;
} }
return DIVERGENT;
} catch (IOException err) { } catch (IOException err) {
KetchReplica.log.error(String.format( KetchReplica.log.error(String.format(
"Cannot compare %s", //$NON-NLS-1$ "Cannot compare %s", //$NON-NLS-1$

9
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsRefDatabase.java

@ -191,16 +191,13 @@ public abstract class DfsRefDatabase extends RefDatabase {
rw.peel(obj).copy(), rw.peel(obj).copy(),
hasVersioning() ? leaf.getUpdateIndex() hasVersioning() ? leaf.getUpdateIndex()
: UNDEFINED_UPDATE_INDEX); : UNDEFINED_UPDATE_INDEX);
} else { }
return new ObjectIdRef.PeeledNonTag( return new ObjectIdRef.PeeledNonTag(leaf.getStorage(),
leaf.getStorage(), leaf.getName(), leaf.getObjectId(),
leaf.getName(),
leaf.getObjectId(),
hasVersioning() ? leaf.getUpdateIndex() hasVersioning() ? leaf.getUpdateIndex()
: UNDEFINED_UPDATE_INDEX); : UNDEFINED_UPDATE_INDEX);
} }
} }
}
static Ref recreate(Ref old, Ref leaf, boolean hasVersioning) { static Ref recreate(Ref old, Ref leaf, boolean hasVersioning) {
if (old.isSymbolic()) { if (old.isSymbolic()) {

3
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java

@ -358,9 +358,8 @@ public class FileRepository extends Repository {
File directory = getDirectory(); File directory = getDirectory();
if (directory != null) { if (directory != null) {
return directory.getPath(); return directory.getPath();
} else {
throw new IllegalStateException();
} }
throw new IllegalStateException();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */

3
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GcLog.java

@ -152,12 +152,11 @@ class GcLog {
boolean commit() { boolean commit() {
if (nonEmpty) { if (nonEmpty) {
return lock.commit(); return lock.commit();
} else { }
logFile.delete(); logFile.delete();
lock.unlock(); lock.unlock();
return true; return true;
} }
}
/** /**
* Write to the pending gc log. Content will be committed upon a call to * Write to the pending gc log. Content will be committed upon a call to

6
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java

@ -109,11 +109,10 @@ class ObjectDirectoryInserter extends ObjectInserter {
ObjectId id = idFor(type, data, off, len); ObjectId id = idFor(type, data, off, len);
if (!createDuplicate && db.has(id)) { if (!createDuplicate && db.has(id)) {
return id; return id;
} else { }
File tmp = toTemp(type, data, off, len); File tmp = toTemp(type, data, off, len);
return insertOneObject(tmp, id, createDuplicate); return insertOneObject(tmp, id, createDuplicate);
} }
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
@ -141,13 +140,12 @@ class ObjectDirectoryInserter extends ObjectInserter {
int actLen = IO.readFully(is, buf, 0); int actLen = IO.readFully(is, buf, 0);
return insert(type, buf, 0, actLen, createDuplicate); return insert(type, buf, 0, actLen, createDuplicate);
} else { }
SHA1 md = digest(); SHA1 md = digest();
File tmp = toTemp(md, type, len, is); File tmp = toTemp(md, type, len, is);
ObjectId id = md.toObjectId(); ObjectId id = md.toObjectId();
return insertOneObject(tmp, id, createDuplicate); return insertOneObject(tmp, id, createDuplicate);
} }
}
private ObjectId insertOneObject( private ObjectId insertOneObject(
File tmp, ObjectId id, boolean createDuplicate) File tmp, ObjectId id, boolean createDuplicate)

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java

@ -844,17 +844,18 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
case Constants.OBJ_TREE: case Constants.OBJ_TREE:
case Constants.OBJ_BLOB: case Constants.OBJ_BLOB:
case Constants.OBJ_TAG: { case Constants.OBJ_TAG: {
if (delta != null || sz < curs.getStreamFileThreshold()) if (delta != null || sz < curs.getStreamFileThreshold()) {
data = decompress(pos + p, (int) sz, curs); data = decompress(pos + p, (int) sz, curs);
}
if (delta != null) { if (delta != null) {
type = typeCode; type = typeCode;
break SEARCH; break SEARCH;
} }
if (data != null) if (data != null) {
return new ObjectLoader.SmallObject(typeCode, data); return new ObjectLoader.SmallObject(typeCode, data);
else }
return new LargePackedWholeObject(typeCode, sz, pos, p, return new LargePackedWholeObject(typeCode, sz, pos, p,
this, curs.db); this, curs.db);
} }

12
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) { if (obj instanceof RevTag) {
return new ObjectIdRef.PeeledTag(leaf.getStorage(), leaf return new ObjectIdRef.PeeledTag(leaf.getStorage(), leaf
.getName(), leaf.getObjectId(), rw.peel(obj).copy()); .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,11 +893,10 @@ public class RefDirectory extends RefDatabase {
if (peeledObjectId != null) { if (peeledObjectId != null) {
return new ObjectIdRef.PeeledTag(PACKED, f.getName(), return new ObjectIdRef.PeeledTag(PACKED, f.getName(),
f.getObjectId(), peeledObjectId); f.getObjectId(), peeledObjectId);
} else { }
return new ObjectIdRef.PeeledNonTag(PACKED, f.getName(), return new ObjectIdRef.PeeledNonTag(PACKED, f.getName(),
f.getObjectId()); f.getObjectId());
} }
}
void log(boolean force, RefUpdate update, String msg, boolean deref) void log(boolean force, RefUpdate update, String msg, boolean deref)
throws IOException { throws IOException {
@ -1480,10 +1478,8 @@ public class RefDirectory extends RefDatabase {
if (peeledObjectId != null) { if (peeledObjectId != null) {
return new LoosePeeledTag(snapShot, getName(), return new LoosePeeledTag(snapShot, getName(),
objectId, peeledObjectId); objectId, peeledObjectId);
} else {
return new LooseNonTag(snapShot, getName(),
objectId);
} }
return new LooseNonTag(snapShot, getName(), objectId);
} }
} }

3
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectoryUpdate.java

@ -90,9 +90,8 @@ class RefDirectoryUpdate extends RefUpdate {
dst = database.findRef(name); dst = database.findRef(name);
setOldObjectId(dst != null ? dst.getObjectId() : null); setOldObjectId(dst != null ? dst.getObjectId() : null);
return true; return true;
} else {
return false;
} }
return false;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ReflogEntryImpl.java

@ -140,9 +140,9 @@ public class ReflogEntryImpl implements Serializable, ReflogEntry {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public CheckoutEntry parseCheckout() { public CheckoutEntry parseCheckout() {
if (getComment().startsWith(CheckoutEntryImpl.CHECKOUT_MOVING_FROM)) if (getComment().startsWith(CheckoutEntryImpl.CHECKOUT_MOVING_FROM)) {
return new CheckoutEntryImpl(this); return new CheckoutEntryImpl(this);
else }
return null; return null;
} }
} }

6
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java

@ -139,7 +139,7 @@ public class UnpackedObject {
} }
return new LargeObject(type, size, path, id, wc.db); return new LargeObject(type, size, path, id, wc.db);
} else { }
readSome(in, hdr, 2, 18); readSome(in, hdr, 2, 18);
int c = hdr[0] & 0xff; int c = hdr[0] & 0xff;
int type = (c >> 4) & 7; int type = (c >> 4) & 7;
@ -181,7 +181,6 @@ public class UnpackedObject {
return new ObjectLoader.SmallObject(type, data); return new ObjectLoader.SmallObject(type, data);
} }
return new LargeObject(type, size, path, id, wc.db); return new LargeObject(type, size, path, id, wc.db);
}
} catch (ZipException badStream) { } catch (ZipException badStream) {
throw new CorruptObjectException(id, throw new CorruptObjectException(id,
JGitText.get().corruptObjectBadStream); JGitText.get().corruptObjectBadStream);
@ -213,7 +212,7 @@ public class UnpackedObject {
JGitText.get().corruptObjectNegativeSize); JGitText.get().corruptObjectNegativeSize);
return size; return size;
} else { }
readSome(in, hdr, 2, 18); readSome(in, hdr, 2, 18);
int c = hdr[0] & 0xff; int c = hdr[0] & 0xff;
long size = c & 15; long size = c & 15;
@ -225,7 +224,6 @@ public class UnpackedObject {
shift += 7; shift += 7;
} }
return size; return size;
}
} catch (ZipException badStream) { } catch (ZipException badStream) {
throw new CorruptObjectException(id, throw new CorruptObjectException(id,
JGitText.get().corruptObjectBadStream); JGitText.get().corruptObjectBadStream);

10
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;) { for (int n = 0; n < MAX_CHAIN;) {
ObjectId obj = ids.get(i); ObjectId obj = ids.get(i);
if (obj == null) { if (obj == null) {
if (ids.compareAndSet(i, null, toAdd.copy())) if (ids.compareAndSet(i, null, toAdd.copy())) {
return true; return true;
else }
continue; continue;
} }
if (AnyObjectId.isEqual(obj, toAdd)) if (AnyObjectId.isEqual(obj, toAdd)) {
return true; return true;
}
if (++i == ids.length()) if (++i == ids.length()) {
i = 0; i = 0;
}
n++; n++;
} }
return false; return false;

8
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java

@ -1751,7 +1751,7 @@ public class PackWriter implements AutoCloseable {
NullProgressMonitor.INSTANCE, NullProgressMonitor.INSTANCE,
Collections.singleton(otp)); Collections.singleton(otp));
continue; continue;
} else { }
// Object writing already started, we cannot recover. // Object writing already started, we cannot recover.
// //
CorruptObjectException coe; CorruptObjectException coe;
@ -1760,14 +1760,14 @@ public class PackWriter implements AutoCloseable {
throw coe; throw coe;
} }
} }
}
// If we reached here, reuse wasn't possible. // If we reached here, reuse wasn't possible.
// //
if (otp.isDeltaRepresentation()) if (otp.isDeltaRepresentation()) {
writeDeltaObjectDeflate(out, otp); writeDeltaObjectDeflate(out, otp);
else } else {
writeWholeObjectDeflate(out, otp); writeWholeObjectDeflate(out, otp);
}
out.endObject(); out.endObject();
otp.setCRC((int) crc32.getValue()); otp.setCRC((int) crc32.getValue());
} }

8
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java

@ -87,32 +87,28 @@ public abstract class ReftableDatabase {
if (newRef.isSymbolic()) { if (newRef.isSymbolic()) {
return ReceiveCommand.link(oldRef.getTarget().getName(), return ReceiveCommand.link(oldRef.getTarget().getName(),
newRef.getTarget().getName(), name); newRef.getTarget().getName(), name);
} else { }
// This should pass in oldId for compat with // This should pass in oldId for compat with
// RefDirectoryUpdate // RefDirectoryUpdate
return ReceiveCommand.unlink(oldRef.getTarget().getName(), return ReceiveCommand.unlink(oldRef.getTarget().getName(),
newId, name); newId, name);
} }
} else {
return ReceiveCommand.unlink(oldRef.getTarget().getName(), return ReceiveCommand.unlink(oldRef.getTarget().getName(),
ObjectId.zeroId(), name); ObjectId.zeroId(), name);
} }
}
if (newRef != null && newRef.isSymbolic()) { if (newRef != null && newRef.isSymbolic()) {
if (oldRef != null) { if (oldRef != null) {
if (oldRef.isSymbolic()) { if (oldRef.isSymbolic()) {
return ReceiveCommand.link(oldRef.getTarget().getName(), return ReceiveCommand.link(oldRef.getTarget().getName(),
newRef.getTarget().getName(), name); newRef.getTarget().getName(), name);
} else { }
return ReceiveCommand.link(oldId, return ReceiveCommand.link(oldId,
newRef.getTarget().getName(), name); newRef.getTarget().getName(), name);
} }
} else {
return ReceiveCommand.link(ObjectId.zeroId(), return ReceiveCommand.link(ObjectId.zeroId(),
newRef.getTarget().getName(), name); newRef.getTarget().getName(), name);
} }
}
return new ReceiveCommand(oldId, newId, name); return new ReceiveCommand(oldId, newId, name);
} }

3
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/RefTreeBatch.java

@ -102,9 +102,8 @@ class RefTreeBatch extends BatchRefUpdate {
if (isAtomic()) { if (isAtomic()) {
ReceiveCommand.abort(getCommands()); ReceiveCommand.abort(getCommands());
return; return;
} else {
continue;
} }
continue;
} }
} }
todo.add(new Command(rw, c)); todo.add(new Command(rw, c));

3
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) { public static NetscapeCookieFileCache getInstance(HttpConfig config) {
if (instance == null) { if (instance == null) {
return new NetscapeCookieFileCache(config); return new NetscapeCookieFileCache(config);
} else {
return instance;
} }
return instance;
} }
/** /**

6
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) { private static boolean isHostMatch(String pattern, String name) {
if (pattern.startsWith("!")) { //$NON-NLS-1$ if (pattern.startsWith("!")) { //$NON-NLS-1$
return !patternMatchesHost(pattern.substring(1), name); return !patternMatchesHost(pattern.substring(1), name);
} else {
return patternMatchesHost(pattern, name);
} }
return patternMatchesHost(pattern, name);
} }
private static boolean patternMatchesHost(String pattern, String name) { private static boolean patternMatchesHost(String pattern, String name) {
@ -399,11 +398,10 @@ public class OpenSshConfigFile {
} }
fn.append(name); fn.append(name);
return fn.isMatch(); return fn.isMatch();
} else { }
// Not a pattern but a full host name // Not a pattern but a full host name
return pattern.equals(name); return pattern.equals(name);
} }
}
private static String dequote(String value) { private static String dequote(String value) {
if (value.startsWith("\"") && value.endsWith("\"") //$NON-NLS-1$ //$NON-NLS-2$ if (value.startsWith("\"") && value.endsWith("\"") //$NON-NLS-1$ //$NON-NLS-2$

4
org.eclipse.jgit/src/org/eclipse/jgit/lib/AnyObjectId.java

@ -302,9 +302,9 @@ public abstract class AnyObjectId implements Comparable<AnyObjectId> {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final boolean equals(Object o) { public final boolean equals(Object o) {
if (o instanceof AnyObjectId) if (o instanceof AnyObjectId) {
return equals((AnyObjectId) o); return equals((AnyObjectId) o);
else }
return false; return false;
} }

17
org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java

@ -103,24 +103,28 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
private static File getSymRef(File workTree, File dotGit, FS fs) private static File getSymRef(File workTree, File dotGit, FS fs)
throws IOException { throws IOException {
byte[] content = IO.readFully(dotGit); byte[] content = IO.readFully(dotGit);
if (!isSymRef(content)) if (!isSymRef(content)) {
throw new IOException(MessageFormat.format( throw new IOException(MessageFormat.format(
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath())); JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
}
int pathStart = 8; int pathStart = 8;
int lineEnd = RawParseUtils.nextLF(content, pathStart); int lineEnd = RawParseUtils.nextLF(content, pathStart);
while (content[lineEnd - 1] == '\n' || while (content[lineEnd - 1] == '\n' ||
(content[lineEnd - 1] == '\r' && SystemReader.getInstance().isWindows())) (content[lineEnd - 1] == '\r'
&& SystemReader.getInstance().isWindows())) {
lineEnd--; lineEnd--;
if (lineEnd == pathStart) }
if (lineEnd == pathStart) {
throw new IOException(MessageFormat.format( throw new IOException(MessageFormat.format(
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath())); JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
}
String gitdirPath = RawParseUtils.decode(content, pathStart, lineEnd); String gitdirPath = RawParseUtils.decode(content, pathStart, lineEnd);
File gitdirFile = fs.resolve(workTree, gitdirPath); File gitdirFile = fs.resolve(workTree, gitdirPath);
if (gitdirFile.isAbsolute()) if (gitdirFile.isAbsolute()) {
return gitdirFile; return gitdirFile;
else }
return new File(workTree, gitdirPath).getCanonicalFile(); return new File(workTree, gitdirPath).getCanonicalFile();
} }
@ -723,9 +727,8 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
.getAbsolutePath(), err.getMessage())); .getAbsolutePath(), err.getMessage()));
} }
return cfg; return cfg;
} else {
return new Config();
} }
return new Config();
} }
private File guessWorkTreeOrFail() throws IOException { private File guessWorkTreeOrFail() throws IOException {

4
org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchConfig.java

@ -232,9 +232,9 @@ public class BranchConfig {
private String getRemoteOrDefault() { private String getRemoteOrDefault() {
String remote = getRemote(); String remote = getRemote();
if (remote == null) if (remote == null) {
return Constants.DEFAULT_REMOTE_NAME; return Constants.DEFAULT_REMOTE_NAME;
else }
return remote; return remote;
} }
} }

3
org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java

@ -1395,13 +1395,12 @@ public class Config {
} }
trailingSpaces.append(cc); trailingSpaces.append(cc);
continue; continue;
} else { }
inLeadingSpace = false; inLeadingSpace = false;
if (trailingSpaces != null) { if (trailingSpaces != null) {
value.append(trailingSpaces); value.append(trailingSpaces);
trailingSpaces.setLength(0); trailingSpaces.setLength(0);
} }
}
if ('\\' == c) { if ('\\' == c) {
c = in.read(); c = in.read();

6
org.eclipse.jgit/src/org/eclipse/jgit/lib/DefaultTypedConfigGetter.java

@ -134,11 +134,9 @@ public class DefaultTypedConfigGetter implements TypedConfigGetter {
throw new IllegalArgumentException( throw new IllegalArgumentException(
MessageFormat.format(JGitText.get().enumValueNotSupported3, MessageFormat.format(JGitText.get().enumValueNotSupported3,
section, subsection, name, value)); 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} */ /** {@inheritDoc} */

7
org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java

@ -606,15 +606,16 @@ public class IndexDiff {
} }
// consume the remaining work // consume the remaining work
if (monitor != null) if (monitor != null) {
monitor.endTask(); monitor.endTask();
}
ignored = indexDiffFilter.getIgnoredPaths(); ignored = indexDiffFilter.getIgnoredPaths();
if (added.isEmpty() && changed.isEmpty() && removed.isEmpty() if (added.isEmpty() && changed.isEmpty() && removed.isEmpty()
&& missing.isEmpty() && modified.isEmpty() && missing.isEmpty() && modified.isEmpty()
&& untracked.isEmpty()) && untracked.isEmpty()) {
return false; return false;
else }
return true; return true;
} }

6
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java

@ -293,9 +293,8 @@ public abstract class ObjectReader implements AutoCloseable {
if (idItr.hasNext()) { if (idItr.hasNext()) {
cur = idItr.next(); cur = idItr.next();
return true; return true;
} else {
return false;
} }
return false;
} }
@Override @Override
@ -383,9 +382,8 @@ public abstract class ObjectReader implements AutoCloseable {
cur = idItr.next(); cur = idItr.next();
sz = getObjectSize(cur, OBJ_ANY); sz = getObjectSize(cur, OBJ_ANY);
return true; return true;
} else {
return false;
} }
return false;
} }
@Override @Override

22
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

@ -503,9 +503,8 @@ public abstract class Repository implements AutoCloseable {
if (resolved instanceof String) { if (resolved instanceof String) {
final Ref ref = findRef((String) resolved); final Ref ref = findRef((String) resolved);
return ref != null ? ref.getLeaf().getObjectId() : null; 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)) { try (RevWalk rw = new RevWalk(this)) {
rw.setRetainBody(true); rw.setRetainBody(true);
Object resolved = resolve(rw, revstr); Object resolved = resolve(rw, revstr);
if (resolved != null) if (resolved != null) {
if (resolved instanceof String) if (resolved instanceof String) {
return (String) resolved; return (String) resolved;
else }
return ((AnyObjectId) resolved).getName(); return ((AnyObjectId) resolved).getName();
}
return null; return null;
} }
} }
@ -760,14 +760,14 @@ public abstract class Repository implements AutoCloseable {
if (name == null) if (name == null)
throw new RevisionSyntaxException(revstr); throw new RevisionSyntaxException(revstr);
} else if (time.matches("^-\\d+$")) { //$NON-NLS-1$ } else if (time.matches("^-\\d+$")) { //$NON-NLS-1$
if (name != null) if (name != null) {
throw new RevisionSyntaxException(revstr); throw new RevisionSyntaxException(revstr);
else { }
String previousCheckout = resolveReflogCheckout(-Integer String previousCheckout = resolveReflogCheckout(
.parseInt(time)); -Integer.parseInt(time));
if (ObjectId.isId(previousCheckout)) if (ObjectId.isId(previousCheckout)) {
rev = parseSimple(rw, previousCheckout); rev = parseSimple(rw, previousCheckout);
else } else {
name = previousCheckout; name = previousCheckout;
} }
} else { } else {

8
org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeConfig.java

@ -166,9 +166,9 @@ public class MergeConfig {
String mergeOptions = config.getString( String mergeOptions = config.getString(
ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_BRANCH_SECTION, branch,
ConfigConstants.CONFIG_KEY_MERGEOPTIONS); ConfigConstants.CONFIG_KEY_MERGEOPTIONS);
if (mergeOptions != null) if (mergeOptions != null) {
return mergeOptions.split("\\s"); //$NON-NLS-1$ return mergeOptions.split("\\s"); //$NON-NLS-1$
else }
return new String[0]; return new String[0];
} }
@ -188,9 +188,9 @@ public class MergeConfig {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof MergeConfigSectionParser) if (obj instanceof MergeConfigSectionParser) {
return branch.equals(((MergeConfigSectionParser) obj).branch); return branch.equals(((MergeConfigSectionParser) obj).branch);
else }
return false; return false;
} }

7
org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeMessageFormatter.java

@ -153,15 +153,16 @@ public class MergeMessageFormatter {
private static void addConflictsMessage(List<String> conflictingPaths, private static void addConflictsMessage(List<String> conflictingPaths,
StringBuilder sb) { StringBuilder sb) {
sb.append("Conflicts:\n"); //$NON-NLS-1$ sb.append("Conflicts:\n"); //$NON-NLS-1$
for (String conflictingPath : conflictingPaths) for (String conflictingPath : conflictingPaths) {
sb.append('\t').append(conflictingPath).append('\n'); sb.append('\t').append(conflictingPath).append('\n');
} }
}
private static String joinNames(List<String> names, String singular, private static String joinNames(List<String> names, String singular,
String plural) { String plural) {
if (names.size() == 1) if (names.size() == 1) {
return singular + " " + names.get(0); //$NON-NLS-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$
} }
} }

34
org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

@ -652,43 +652,41 @@ public class ResolveMerger extends ThreeWayMerger {
keep(ourDce); keep(ourDce);
// no checkout needed! // no checkout needed!
return true; return true;
} else { }
// same content but different mode on OURS and THEIRS. // same content but different mode on OURS and THEIRS.
// Try to merge the mode and report an error if this is // Try to merge the mode and report an error if this is
// not possible. // not possible.
int newMode = mergeFileModes(modeB, modeO, modeT); int newMode = mergeFileModes(modeB, modeO, modeT);
if (newMode != FileMode.MISSING.getBits()) { if (newMode != FileMode.MISSING.getBits()) {
if (newMode == modeO) if (newMode == modeO) {
// ours version is preferred // ours version is preferred
keep(ourDce); keep(ourDce);
else { } else {
// the preferred version THEIRS has a different mode // the preferred version THEIRS has a different mode
// than ours. Check it out! // than ours. Check it out!
if (isWorktreeDirty(work, ourDce)) if (isWorktreeDirty(work, ourDce)) {
return false; return false;
// we know about length and lastMod only after we have written the new content. }
// 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. // This will happen later. Set these values to 0 for know.
DirCacheEntry e = add(tw.getRawPath(), theirs, DirCacheEntry e = add(tw.getRawPath(), theirs,
DirCacheEntry.STAGE_0, EPOCH, 0); DirCacheEntry.STAGE_0, EPOCH, 0);
addToCheckout(tw.getPathString(), e, attributes); addToCheckout(tw.getPathString(), e, attributes);
} }
return true; return true;
} else { }
// FileModes are not mergeable. We found a conflict on modes. // FileModes are not mergeable. We found a conflict on modes.
// For conflicting entries we don't know lastModified and length. // For conflicting entries we don't know lastModified and
// length.
add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0); add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, EPOCH, 0);
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0); add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, EPOCH, 0);
add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, EPOCH, 0);
0);
unmergedPaths.add(tw.getPathString()); unmergedPaths.add(tw.getPathString());
mergeResults.put( mergeResults.put(tw.getPathString(),
tw.getPathString(), new MergeResult<>(Collections.<RawText> emptyList()));
new MergeResult<>(Collections
.<RawText> emptyList()));
}
return true; return true;
} }
}
if (modeB == modeT && tw.idEqual(T_BASE, T_THEIRS)) { if (modeB == modeT && tw.idEqual(T_BASE, T_THEIRS)) {
// THEIRS was not changed compared to BASE. All changes must be in // THEIRS was not changed compared to BASE. All changes must be in
@ -716,7 +714,7 @@ public class ResolveMerger extends ThreeWayMerger {
addToCheckout(tw.getPathString(), e, attributes); addToCheckout(tw.getPathString(), e, attributes);
} }
return true; return true;
} else { }
// we want THEIRS ... but THEIRS contains a folder or the // we want THEIRS ... but THEIRS contains a folder or the
// deletion of the path. Delete what's in the working tree, // deletion of the path. Delete what's in the working tree,
// which we know to be clean. // which we know to be clean.
@ -731,7 +729,6 @@ public class ResolveMerger extends ThreeWayMerger {
addDeletion(tw.getPathString(), nonTree(modeO), attributes); addDeletion(tw.getPathString(), nonTree(modeO), attributes);
return true; return true;
} }
}
if (tw.isSubtree()) { if (tw.isSubtree()) {
// file/folder conflicts: here I want to detect only file/folder // file/folder conflicts: here I want to detect only file/folder
@ -1310,11 +1307,10 @@ public class ResolveMerger extends ThreeWayMerger {
if (getUnmergedPaths().isEmpty() && !failed()) { if (getUnmergedPaths().isEmpty() && !failed()) {
resultTree = dircache.writeTree(getObjectInserter()); resultTree = dircache.writeTree(getObjectInserter());
return true; return true;
} else { }
resultTree = null; resultTree = null;
return false; return false;
} }
}
/** /**
* Process the given TreeWalk's entries. * Process the given TreeWalk's entries.

6
org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.java

@ -143,17 +143,17 @@ public abstract class ThreeWayMerger extends Merger {
* @throws java.io.IOException * @throws java.io.IOException
*/ */
protected AbstractTreeIterator mergeBase() throws IOException { protected AbstractTreeIterator mergeBase() throws IOException {
if (baseTree != null) if (baseTree != null) {
return openTree(baseTree); return openTree(baseTree);
}
RevCommit baseCommit = (baseCommitId != null) ? walk RevCommit baseCommit = (baseCommitId != null) ? walk
.parseCommit(baseCommitId) : getBaseCommit(sourceCommits[0], .parseCommit(baseCommitId) : getBaseCommit(sourceCommits[0],
sourceCommits[1]); sourceCommits[1]);
if (baseCommit == null) { if (baseCommit == null) {
baseCommitId = null; baseCommitId = null;
return new EmptyTreeIterator(); return new EmptyTreeIterator();
} else { }
baseCommitId = baseCommit.toObjectId(); baseCommitId = baseCommit.toObjectId();
return openTree(baseCommit.getTree()); return openTree(baseCommit.getTree());
} }
} }
}

13
org.eclipse.jgit/src/org/eclipse/jgit/notes/FanoutBucket.java

@ -167,9 +167,9 @@ class FanoutBucket extends InMemoryNoteBucket {
@Override @Override
public Note next() { public Note next() {
if (hasNext()) if (hasNext()) {
return itr.next(); return itr.next();
else }
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
@ -214,22 +214,24 @@ class FanoutBucket extends InMemoryNoteBucket {
NoteBucket b = table[cell]; NoteBucket b = table[cell];
if (b == null) { if (b == null) {
if (noteData == null) if (noteData == null) {
return this; return this;
}
LeafBucket n = new LeafBucket(prefixLen + 2); LeafBucket n = new LeafBucket(prefixLen + 2);
table[cell] = n.set(noteOn, noteData, or); table[cell] = n.set(noteOn, noteData, or);
cnt++; cnt++;
return this; return this;
} else { }
NoteBucket n = b.set(noteOn, noteData, or); NoteBucket n = b.set(noteOn, noteData, or);
if (n == null) { if (n == null) {
table[cell] = null; table[cell] = null;
cnt--; cnt--;
if (cnt == 0) if (cnt == 0) {
return null; return null;
}
return contractIfTooSmall(noteOn, or); return contractIfTooSmall(noteOn, or);
@ -238,7 +240,6 @@ class FanoutBucket extends InMemoryNoteBucket {
} }
return this; return this;
} }
}
InMemoryNoteBucket contractIfTooSmall(AnyObjectId noteOn, ObjectReader or) InMemoryNoteBucket contractIfTooSmall(AnyObjectId noteOn, ObjectReader or)
throws IOException { throws IOException {

18
org.eclipse.jgit/src/org/eclipse/jgit/notes/LeafBucket.java

@ -129,9 +129,9 @@ class LeafBucket extends InMemoryNoteBucket {
@Override @Override
public Note next() { public Note next() {
if (hasNext()) if (hasNext()) {
return notes[idx++]; return notes[idx++];
else }
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
@ -156,25 +156,23 @@ class LeafBucket extends InMemoryNoteBucket {
notes[p].setData(noteData.copy()); notes[p].setData(noteData.copy());
return this; return this;
} else { }
System.arraycopy(notes, p + 1, notes, p, cnt - p - 1); System.arraycopy(notes, p + 1, notes, p, cnt - p - 1);
cnt--; cnt--;
return 0 < cnt ? this : null; return 0 < cnt ? this : null;
}
} else if (noteData != null) { } else if (noteData != null) {
if (shouldSplit()) { if (shouldSplit()) {
return split().set(noteOn, noteData, or); return split().set(noteOn, noteData, or);
}
} else {
growIfFull(); growIfFull();
p = -(p + 1); p = -(p + 1);
if (p < cnt) if (p < cnt) {
System.arraycopy(notes, p, notes, p + 1, cnt - p); System.arraycopy(notes, p, notes, p + 1, cnt - p);
}
notes[p] = new Note(noteOn, noteData.copy()); notes[p] = new Note(noteOn, noteData.copy());
cnt++; cnt++;
return this; return this;
}
} else { } else {
return this; return this;
@ -234,13 +232,11 @@ class LeafBucket extends InMemoryNoteBucket {
InMemoryNoteBucket append(Note note) { InMemoryNoteBucket append(Note note) {
if (shouldSplit()) { if (shouldSplit()) {
return split().append(note); return split().append(note);
}
} else {
growIfFull(); growIfFull();
notes[cnt++] = note; notes[cnt++] = note;
return this; return this;
} }
}
private void growIfFull() { private void growIfFull() {
if (notes.length == cnt) { if (notes.length == cnt) {

4
org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMap.java

@ -278,9 +278,9 @@ public class NoteMap implements Iterable<Note> {
public byte[] getCachedBytes(AnyObjectId id, int sizeLimit) public byte[] getCachedBytes(AnyObjectId id, int sizeLimit)
throws LargeObjectException, MissingObjectException, IOException { throws LargeObjectException, MissingObjectException, IOException {
ObjectId dataId = get(id); ObjectId dataId = get(id);
if (dataId != null) if (dataId != null) {
return reader.open(dataId).getCachedBytes(sizeLimit); return reader.open(dataId).getCachedBytes(sizeLimit);
else }
return null; return null;
} }

4
org.eclipse.jgit/src/org/eclipse/jgit/notes/NoteMapMerger.java

@ -307,9 +307,9 @@ public class NoteMapMerger {
private static InMemoryNoteBucket addIfNotNull(InMemoryNoteBucket result, private static InMemoryNoteBucket addIfNotNull(InMemoryNoteBucket result,
Note note) { Note note) {
if (note != null) if (note != null) {
return result.append(note); return result.append(note);
else }
return result; return result;
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save