Browse Source

Merge branch 'master' into stable-5.0

* master:
  DescribeCommand: Refactor to not use deprecated Repository#peel
  Repository: Deprecate #peel method
  Repository: Make #exactRef and #findRef final
  Skip ignored directories in FileTreeIterator
  Repository: Deprecate getTags method
  InfoRefsServlet: Refactor to not use deprecated methods
  RefAdvertiser: Add send(Collection<Ref>) and deprecate send(Map<String, Ref>)
  Remove deprecated Repository#notifyIndexChanged
  Implementors should override Repository#notifyIndexChanged(boolean)
  Revive Repository#notifyIndexChanged()
  Remove further unnecessary 'final' keywords
  Execute AdvertiseRefsHook only for protocol v0 and v1
  Add protocol v2 support in "jgit daemon"
  Teach UploadPack "ofs-delta" in "fetch"
  Teach UploadPack "include-tag" in "fetch"
  Avoid using #refs in UploadPack#sendPack
  FileRepository: Don't use deprecated RefDatabase#getRefs(String)
  BatchRefUpdate: Don't use deprecated RefDatabase#getRefs(String)

Change-Id: I16c5da62d09262d3f4070aa0f466dd6c8352b5ea
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.0
Matthias Sohn 7 years ago
parent
commit
ce5cdea143
  1. 2
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/AsIsFileFilter.java
  2. 2
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java
  3. 8
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java
  4. 6
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java
  5. 2
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java
  6. 2
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java
  7. 2
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java
  8. 6
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java
  9. 4
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/SuffixPipeline.java
  10. 8
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/UrlPipeline.java
  11. 2
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java
  12. 2
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java
  13. 2
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java
  14. 2
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AsIsServiceTest.java
  15. 2
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultReceivePackFactoryTest.java
  16. 2
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultUploadPackFactoryTest.java
  17. 2
      org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AccessEvent.java
  18. 4
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
  19. 2
      org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java
  20. 2
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AbbreviatedLongObjectId.java
  21. 2
      org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AnyLongObjectId.java
  22. 2
      org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java
  23. 11
      org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/TagTest.java
  24. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
  25. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java
  26. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java
  27. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java
  28. 6
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java
  29. 10
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java
  30. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java
  31. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java
  32. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
  33. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java
  34. 6
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java
  35. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java
  36. 6
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
  37. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
  38. 20
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java
  39. 6
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java
  40. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java
  41. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java
  42. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
  43. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java
  44. 10
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java
  45. 10
      org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java
  46. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java
  47. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LogCommandTest.java
  48. 26
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java
  49. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java
  50. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java
  51. 14
      org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java
  52. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java
  53. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/CGitIgnoreTest.java
  54. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java
  55. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ConcurrentRepackTest.java
  56. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java
  57. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java
  58. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java
  59. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/XInputStream.java
  60. 113
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java
  61. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java
  62. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevObjectTest.java
  63. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter6012Test.java
  64. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushProcessTest.java
  65. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java
  66. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java
  67. 82
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
  68. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java
  69. 12
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/PostOrderTreeWalkTest.java
  70. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathFilterGroupTest.java
  71. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathSuffixFilterTest.java
  72. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java
  73. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java
  74. 6
      org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AWTPlotRenderer.java
  75. 4
      org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java
  76. 6
      org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
  77. 14
      org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java
  78. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
  79. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
  80. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
  81. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/RmCommand.java
  82. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/StashCreateCommand.java
  83. 2
      org.eclipse.jgit/src/org/eclipse/jgit/blame/ReverseWalk.java
  84. 18
      org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java
  85. 2
      org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java
  86. 10
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
  87. 6
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java
  88. 2
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheIterator.java
  89. 6
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java
  90. 2
      org.eclipse.jgit/src/org/eclipse/jgit/errors/CompoundException.java
  91. 2
      org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java
  92. 4
      org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/GroupHead.java
  93. 2
      org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/RestrictedWildCardHead.java
  94. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java
  95. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjectToPack.java
  96. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteArrayWindow.java
  97. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteBufferWindow.java
  98. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteWindow.java
  99. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/CachedObjectDirectory.java
  100. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/DeltaBaseCache.java
  101. Some files were not shown because too many files have changed in this diff Show More

2
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/AsIsFileFilter.java

@ -66,7 +66,7 @@ import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
class AsIsFileFilter implements Filter {
private final AsIsFileService asIs;
AsIsFileFilter(final AsIsFileService getAnyFile) {
AsIsFileFilter(AsIsFileService getAnyFile) {
this.asIs = getAnyFile;
}

2
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java

@ -84,7 +84,7 @@ final class FileSender {
private long end;
FileSender(final File path) throws FileNotFoundException {
FileSender(File path) throws FileNotFoundException {
this.path = path;
this.source = new RandomAccessFile(path, "r");

8
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/InfoRefsServlet.java

@ -44,18 +44,15 @@
package org.eclipse.jgit.http.server;
import static org.eclipse.jgit.http.server.ServletUtils.getRepository;
import static org.eclipse.jgit.lib.RefDatabase.ALL;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Map;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.RefAdvertiser;
import org.eclipse.jgit.util.HttpSupport;
@ -94,10 +91,7 @@ class InfoRefsServlet extends HttpServlet {
};
adv.init(db);
adv.setDerefTags(true);
Map<String, Ref> refs = db.getRefDatabase().getRefs(ALL);
refs.remove(Constants.HEAD);
adv.send(refs);
adv.send(db.getRefDatabase().getRefsByPrefix(Constants.R_REFS));
}
}
}

6
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java

@ -75,7 +75,7 @@ abstract class ObjectFileServlet extends HttpServlet {
}
@Override
String etag(final FileSender sender) throws IOException {
String etag(FileSender sender) throws IOException {
return Long.toHexString(sender.getLastModified());
}
}
@ -88,7 +88,7 @@ abstract class ObjectFileServlet extends HttpServlet {
}
@Override
String etag(final FileSender sender) throws IOException {
String etag(FileSender sender) throws IOException {
return sender.getTailChecksum();
}
}
@ -111,7 +111,7 @@ abstract class ObjectFileServlet extends HttpServlet {
private final String contentType;
ObjectFileServlet(final String contentType) {
ObjectFileServlet(String contentType) {
this.contentType = contentType;
}

2
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java

@ -238,7 +238,7 @@ public final class ServletUtils {
return content;
}
static boolean acceptsGzipEncoding(final HttpServletRequest req) {
static boolean acceptsGzipEncoding(HttpServletRequest req) {
return acceptsGzipEncoding(req.getHeader(HDR_ACCEPT_ENCODING));
}

2
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartServiceInfoRefs.java

@ -75,7 +75,7 @@ abstract class SmartServiceInfoRefs implements Filter {
private final Filter[] filters;
SmartServiceInfoRefs(final String service, final List<Filter> filters) {
SmartServiceInfoRefs(String service, List<Filter> filters) {
this.svc = service;
this.filters = filters.toArray(new Filter[filters.size()]);
}

2
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/TextFileServlet.java

@ -64,7 +64,7 @@ class TextFileServlet extends HttpServlet {
private final String fileName;
TextFileServlet(final String name) {
TextFileServlet(String name) {
this.fileName = name;
}

6
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/RegexPipeline.java

@ -87,11 +87,11 @@ class RegexPipeline extends UrlPipeline {
static class Binder extends ServletBinderImpl {
private final Pattern pattern;
Binder(final String p) {
Binder(String p) {
pattern = Pattern.compile(p);
}
Binder(final Pattern p) {
Binder(Pattern p) {
pattern = p;
}
@ -110,7 +110,7 @@ class RegexPipeline extends UrlPipeline {
}
@Override
boolean match(final HttpServletRequest req) {
boolean match(HttpServletRequest req) {
final String pathInfo = req.getPathInfo();
return pathInfo != null && pattern.matcher(pathInfo).matches();
}

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

@ -67,7 +67,7 @@ class SuffixPipeline extends UrlPipeline {
static class Binder extends ServletBinderImpl {
private final String suffix;
Binder(final String suffix) {
Binder(String suffix) {
this.suffix = suffix;
}
@ -89,7 +89,7 @@ class SuffixPipeline extends UrlPipeline {
}
@Override
boolean match(final HttpServletRequest req) {
boolean match(HttpServletRequest req) {
final String pathInfo = req.getPathInfo();
return pathInfo != null && pathInfo.endsWith(suffix);
}

8
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/glue/UrlPipeline.java

@ -79,7 +79,7 @@ abstract class UrlPipeline {
/** Instance that must generate the response; never null. */
private final HttpServlet servlet;
UrlPipeline(final Filter[] filters, final HttpServlet servlet) {
UrlPipeline(Filter[] filters, HttpServlet servlet) {
this.filters = filters;
this.servlet = servlet;
}
@ -99,7 +99,7 @@ abstract class UrlPipeline {
* @throws ServletException
* a filter or servlet is unable to initialize.
*/
void init(final ServletContext context, final Set<Object> inited)
void init(ServletContext context, Set<Object> inited)
throws ServletException {
for (Filter ref : filters)
initFilter(ref, context, inited);
@ -165,7 +165,7 @@ abstract class UrlPipeline {
* destroyed a second time. Filters and servlets that are first
* destroyed by this pipeline will be added to this set.
*/
void destroy(final Set<Object> destroyed) {
void destroy(Set<Object> destroyed) {
for (Filter ref : filters)
destroyFilter(ref, destroyed);
destroyServlet(servlet, destroyed);
@ -230,7 +230,7 @@ abstract class UrlPipeline {
private int filterIdx;
Chain(final Filter[] filters, final HttpServlet servlet) {
Chain(Filter[] filters, HttpServlet servlet) {
this.filters = filters;
this.servlet = servlet;
}

2
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java

@ -73,7 +73,7 @@ public class AsIsFileService {
private static class ServiceConfig {
final boolean enabled;
ServiceConfig(final Config cfg) {
ServiceConfig(Config cfg) {
enabled = cfg.getBoolean("http", "getanyfile", true);
}
}

2
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java

@ -74,7 +74,7 @@ public class DefaultReceivePackFactory implements
final boolean enabled;
ServiceConfig(final Config cfg) {
ServiceConfig(Config cfg) {
set = cfg.getString("http", null, "receivepack") != null;
enabled = cfg.getBoolean("http", "receivepack", false);
}

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

@ -64,7 +64,7 @@ public class DefaultUploadPackFactory implements
private static class ServiceConfig {
final boolean enabled;
ServiceConfig(final Config cfg) {
ServiceConfig(Config cfg) {
enabled = cfg.getBoolean("http", "uploadpack", true);
}
}

2
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AsIsServiceTest.java

@ -133,7 +133,7 @@ public class AsIsServiceTest extends LocalDiskRepositoryTestCase {
private final String host;
R(final String user, final String host) {
R(String user, String host) {
super(new Request(null, null) /* can't pass null, sigh */);
this.user = user;
this.host = host;

2
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultReceivePackFactoryTest.java

@ -205,7 +205,7 @@ public class DefaultReceivePackFactoryTest extends LocalDiskRepositoryTestCase {
private final String host;
R(final String user, final String host) {
R(String user, String host) {
super(new Request(null, null) /* can't pass null, sigh */);
this.user = user;
this.host = host;

2
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DefaultUploadPackFactoryTest.java

@ -161,7 +161,7 @@ public class DefaultUploadPackFactoryTest extends LocalDiskRepositoryTestCase {
private final String host;
R(final String user, final String host) {
R(String user, String host) {
super(new Request(null, null) /* can't pass null, sigh */);
this.user = user;
this.host = host;

2
org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AccessEvent.java

@ -67,7 +67,7 @@ public class AccessEvent {
private final Map<String, String> responseHeaders;
AccessEvent(final Request req, final Response rsp) {
AccessEvent(Request req, Response rsp) {
method = req.getMethod();
uri = req.getRequestURI();
requestHeaders = cloneHeaders(req);

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

@ -318,7 +318,7 @@ public class TestRepository<R extends Repository> {
public RevTree tree(DirCacheEntry... entries) throws Exception {
final DirCache dc = DirCache.newInCore();
final DirCacheBuilder b = dc.builder();
for (final DirCacheEntry e : entries)
for (DirCacheEntry e : entries)
b.add(e);
b.finish();
ObjectId root;
@ -962,7 +962,7 @@ public class TestRepository<R extends Repository> {
public class BranchBuilder {
private final String ref;
BranchBuilder(final String ref) {
BranchBuilder(String ref) {
this.ref = ref;
}

2
org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/UploadTest.java

@ -122,7 +122,7 @@ public class UploadTest extends LfsServerTest {
ExecutorService e = Executors.newFixedThreadPool(count);
try {
for (final Path p : paths) {
for (Path p : paths) {
e.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {

2
org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/lib/AbbreviatedLongObjectId.java

@ -173,7 +173,7 @@ public final class AbbreviatedLongObjectId implements Serializable {
return r << (16 - n) * 4;
}
static long mask(final int nibbles, final long word, final long v) {
static long mask(int nibbles, long word, long v) {
final long b = (word - 1) * 16;
if (b + 16 <= nibbles) {
// We have all of the bits required for this word.

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

@ -476,7 +476,7 @@ public abstract class AnyLongObjectId implements Comparable<AnyLongObjectId> {
private static final char[] hexchar = { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
static void formatHexChar(final char[] dst, final int p, long w) {
static void formatHexChar(char[] dst, int p, long w) {
int o = p + 15;
while (o >= p && w != 0) {
dst[o--] = hexchar[(int) (w & 0xf)];

2
org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java

@ -157,7 +157,7 @@ public class CLIGitCommand extends Main {
}
@Override
void init(final TextBuiltin cmd) throws IOException {
void init(TextBuiltin cmd) throws IOException {
cmd.outs = result.out;
cmd.errs = result.err;
super.init(cmd);

11
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/TagTest.java

@ -43,10 +43,11 @@
package org.eclipse.jgit.pgm;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.CLIRepositoryTestCase;
import org.eclipse.jgit.lib.Ref;
import org.junit.Before;
import org.junit.Test;
@ -75,13 +76,9 @@ public class TagTest extends CLIRepositoryTestCase {
@Test
public void testTagDelete() throws Exception {
git.tag().setName("test").call();
Ref ref = git.getRepository().getTags().get("test");
assertEquals("refs/tags/test", ref.getName());
assertNotNull(git.getRepository().exactRef("refs/tags/test"));
assertEquals("", executeUnchecked("git tag -d test")[0]);
Ref deletedRef = git.getRepository().getTags().get("test");
assertEquals(null, deletedRef);
assertNull(git.getRepository().exactRef("refs/tags/test"));
}
@Test

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

@ -77,7 +77,7 @@ abstract class AbstractFetchCommand extends TextBuiltin {
protected void showFetchResult(FetchResult r) throws IOException {
try (ObjectReader reader = db.newObjectReader()) {
boolean shownURI = false;
for (final TrackingRefUpdate u : r.getTrackingRefUpdates()) {
for (TrackingRefUpdate u : r.getTrackingRefUpdates()) {
if (!verbose && u.getResult() == RefUpdate.Result.NO_CHANGE)
continue;

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

@ -105,7 +105,7 @@ class AmazonS3Client extends TextBuiltin {
}
} else if ("ls".equals(op) || "list".equals(op)) { //$NON-NLS-1$//$NON-NLS-2$
for (final String k : s3.list(bucket, key))
for (String k : s3.list(bucket, key))
outw.println(k);
} else if ("rm".equals(op) || "delete".equals(op)) { //$NON-NLS-1$ //$NON-NLS-2$

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java

@ -292,7 +292,7 @@ class Branch extends TextBuiltin {
addRefs(refs, Constants.R_REMOTES);
try (ObjectReader reader = db.newObjectReader()) {
for (final Entry<String, Ref> e : printRefs.entrySet()) {
for (Entry<String, Ref> e : printRefs.entrySet()) {
final Ref ref = e.getValue();
printHead(reader, e.getKey(),
current.equals(ref.getName()), ref);
@ -303,7 +303,7 @@ class Branch extends TextBuiltin {
}
private void addRefs(Collection<Ref> refs, String prefix) {
for (final Ref ref : RefComparator.sort(refs)) {
for (Ref ref : RefComparator.sort(refs)) {
final String name = ref.getName();
if (name.startsWith(prefix))
addRef(name.substring(name.indexOf('/', 5) + 1), ref);

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

@ -107,7 +107,7 @@ public class CommandCatalog {
*/
public static CommandRef[] common() {
final ArrayList<CommandRef> common = new ArrayList<>();
for (final CommandRef c : INSTANCE.commands.values())
for (CommandRef c : INSTANCE.commands.values())
if (c.isCommon())
common.add(c);
return toSortedArray(common);

6
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandRef.java

@ -66,11 +66,11 @@ public class CommandRef {
boolean common;
CommandRef(final Class<? extends TextBuiltin> clazz) {
CommandRef(Class<? extends TextBuiltin> clazz) {
this(clazz, guessName(clazz));
}
CommandRef(final Class<? extends TextBuiltin> clazz, final Command cmd) {
CommandRef(Class<? extends TextBuiltin> clazz, Command cmd) {
this(clazz, cmd.name().length() > 0 ? cmd.name() : guessName(clazz));
usage = cmd.usage();
common = cmd.common();
@ -88,7 +88,7 @@ public class CommandRef {
s.append("debug-"); //$NON-NLS-1$
boolean lastWasDash = true;
for (final char c : clazz.getSimpleName().toCharArray()) {
for (char c : clazz.getSimpleName().toCharArray()) {
if (Character.isUpperCase(c)) {
if (!lastWasDash)
s.append('-');

10
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java

@ -142,7 +142,7 @@ class Daemon extends TextBuiltin {
packConfig.setExecutor(Executors.newFixedThreadPool(threads));
final FileResolver<DaemonClient> resolver = new FileResolver<>();
for (final File f : directory) {
for (File f : directory) {
outw.println(MessageFormat.format(CLIText.get().exporting, f.getAbsolutePath()));
resolver.exportDirectory(f);
}
@ -157,14 +157,14 @@ class Daemon extends TextBuiltin {
if (0 <= timeout)
d.setTimeout(timeout);
for (final String n : enable)
for (String n : enable)
service(d, n).setEnabled(true);
for (final String n : disable)
for (String n : disable)
service(d, n).setEnabled(false);
for (final String n : canOverride)
for (String n : canOverride)
service(d, n).setOverridable(true);
for (final String n : forbidOverride)
for (String n : forbidOverride)
service(d, n).setOverridable(false);
if (ketchServerType == KetchServerType.LEADER) {
startKetchLeader(d);

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java

@ -75,9 +75,9 @@ class DiffTree extends TextBuiltin {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
try (final TreeWalk walk = new TreeWalk(db)) {
try (TreeWalk walk = new TreeWalk(db)) {
walk.setRecursive(recursive);
for (final AbstractTreeIterator i : trees)
for (AbstractTreeIterator i : trees)
walk.addTree(i);
walk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, pathFilter));

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

@ -266,7 +266,7 @@ class Log extends RevWalkTextBuiltin {
outw.println();
final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$
for (final String s : lines) {
for (String s : lines) {
outw.print(" "); //$NON-NLS-1$
outw.print(s);
outw.println();

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

@ -83,7 +83,7 @@ class LsRemote extends TextBuiltin {
}
});
refs.addAll(command.call());
for (final Ref r : refs) {
for (Ref r : refs) {
show(r.getObjectId(), r.getName());
if (r.getPeeledObjectId() != null)
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$

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

@ -73,7 +73,7 @@ class LsTree extends TextBuiltin {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
try (final TreeWalk walk = new TreeWalk(db)) {
try (TreeWalk walk = new TreeWalk(db)) {
walk.reset(); // drop the first empty tree, which we do not need here
if (paths.size() > 0)
walk.setFilter(PathFilterGroup.createFromStrings(paths));

6
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java

@ -256,12 +256,12 @@ public class Main {
writer.println(CLIText.get().mostCommonlyUsedCommandsAre);
final CommandRef[] common = CommandCatalog.common();
int width = 0;
for (final CommandRef c : common) {
for (CommandRef c : common) {
width = Math.max(width, c.getName().length());
}
width += 2;
for (final CommandRef c : common) {
for (CommandRef c : common) {
writer.print(' ');
writer.print(c.getName());
for (int i = c.getName().length(); i < width; i++) {
@ -296,7 +296,7 @@ public class Main {
}
}
void init(final TextBuiltin cmd) throws IOException {
void init(TextBuiltin cmd) throws IOException {
if (cmd.requiresRepository()) {
cmd.init(openGitDir(gitdir), null);
} else {

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

@ -68,7 +68,7 @@ class MergeBase extends TextBuiltin {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
for (final RevCommit c : commits)
for (RevCommit c : commits)
argWalk.markStart(c);
argWalk.setRevFilter(RevFilter.MERGE_BASE);
int max = all ? Integer.MAX_VALUE : 1;

6
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java

@ -149,7 +149,7 @@ class Push extends TextBuiltin {
boolean everythingUpToDate = true;
// at first, print up-to-date ones...
for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
for (RemoteRefUpdate rru : result.getRemoteUpdates()) {
if (rru.getStatus() == Status.UP_TO_DATE) {
if (verbose)
printRefUpdateResult(reader, uri, result, rru);
@ -157,13 +157,13 @@ class Push extends TextBuiltin {
everythingUpToDate = false;
}
for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
for (RemoteRefUpdate rru : result.getRemoteUpdates()) {
// ...then successful updates...
if (rru.getStatus() == Status.OK)
printRefUpdateResult(reader, uri, result, rru);
}
for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
for (RemoteRefUpdate rru : result.getRemoteUpdates()) {
// ...finally, others (problematic)
if (rru.getStatus() != Status.OK
&& rru.getStatus() != Status.UP_TO_DATE)

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

@ -87,7 +87,7 @@ class RevParse extends TextBuiltin {
CLIText.format(CLIText.get().needSingleRevision));
}
for (final ObjectId o : commits) {
for (ObjectId o : commits) {
outw.println(o.name());
}
}

20
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java

@ -99,22 +99,22 @@ abstract class RevWalkTextBuiltin extends TextBuiltin {
}
@Option(name = "--date-order")
void enableDateOrder(final boolean on) {
void enableDateOrder(boolean on) {
enableRevSort(RevSort.COMMIT_TIME_DESC, on);
}
@Option(name = "--topo-order")
void enableTopoOrder(final boolean on) {
void enableTopoOrder(boolean on) {
enableRevSort(RevSort.TOPO, on);
}
@Option(name = "--reverse")
void enableReverse(final boolean on) {
void enableReverse(boolean on) {
enableRevSort(RevSort.REVERSE, on);
}
@Option(name = "--boundary")
void enableBoundary(final boolean on) {
void enableBoundary(boolean on) {
enableRevSort(RevSort.BOUNDARY, on);
}
@ -130,17 +130,17 @@ abstract class RevWalkTextBuiltin extends TextBuiltin {
private final List<RevFilter> revLimiter = new ArrayList<>();
@Option(name = "--author")
void addAuthorRevFilter(final String who) {
void addAuthorRevFilter(String who) {
revLimiter.add(AuthorRevFilter.create(who));
}
@Option(name = "--committer")
void addCommitterRevFilter(final String who) {
void addCommitterRevFilter(String who) {
revLimiter.add(CommitterRevFilter.create(who));
}
@Option(name = "--grep")
void addCMessageRevFilter(final String msg) {
void addCMessageRevFilter(String msg) {
revLimiter.add(MessageRevFilter.create(msg));
}
@ -151,7 +151,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin {
@Override
protected void run() throws Exception {
walk = createWalk();
for (final RevSort s : sorting)
for (RevSort s : sorting)
walk.sort(s, true);
if (pathFilter == TreeFilter.ALL) {
@ -187,7 +187,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin {
throw die(MessageFormat.format(CLIText.get().cannotResolve, Constants.HEAD));
commits.add(walk.parseCommit(head));
}
for (final RevCommit c : commits) {
for (RevCommit c : commits) {
final RevCommit real = argWalk == walk ? c : walk.parseCommit(c);
if (c.has(RevFlag.UNINTERESTING))
walk.markUninteresting(real);
@ -233,7 +233,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin {
*/
protected int walkLoop() throws Exception {
int n = 0;
for (final RevCommit c : walk) {
for (RevCommit c : walk) {
if (++n > maxCount && maxCount >= 0)
break;
show(c);

6
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java

@ -248,7 +248,7 @@ class Show extends TextBuiltin {
outw.println();
final String[] lines = tag.getFullMessage().split("\n"); //$NON-NLS-1$
for (final String s : lines) {
for (String s : lines) {
outw.print(" "); //$NON-NLS-1$
outw.print(s);
outw.println();
@ -259,7 +259,7 @@ class Show extends TextBuiltin {
private void show(RevTree obj) throws MissingObjectException,
IncorrectObjectTypeException, CorruptObjectException, IOException {
try (final TreeWalk walk = new TreeWalk(db)) {
try (TreeWalk walk = new TreeWalk(db)) {
walk.reset();
walk.addTree(obj);
@ -292,7 +292,7 @@ class Show extends TextBuiltin {
outw.println();
final String[] lines = c.getFullMessage().split("\n"); //$NON-NLS-1$
for (final String s : lines) {
for (String s : lines) {
outw.print(" "); //$NON-NLS-1$
outw.print(s);
outw.println();

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

@ -57,7 +57,7 @@ class ShowRef extends TextBuiltin {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
for (final Ref r : getSortedRefs()) {
for (Ref r : getSortedRefs()) {
show(r.getObjectId(), r.getName());
if (r.getPeeledObjectId() != null)
show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java

@ -129,7 +129,7 @@ public abstract class TextBuiltin {
/** RevWalk used during command line parsing, if it was required. */
protected RevWalk argWalk;
final void setCommandName(final String name) {
final void setCommandName(String name) {
commandName = name;
}
@ -361,7 +361,7 @@ public abstract class TextBuiltin {
return db;
}
ObjectId resolve(final String s) throws IOException {
ObjectId resolve(String s) throws IOException {
final ObjectId r = db.resolve(s);
if (r == null)
throw die(MessageFormat.format(CLIText.get().notARevision, s));

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

@ -222,7 +222,7 @@ class RebuildCommitGraph extends TextBuiltin {
ObjectId newId;
ToRewrite(final ObjectId o, final long t, final ObjectId[] p) {
ToRewrite(ObjectId o, long t, ObjectId[] p) {
oldId = o;
commitTime = t;
oldParents = p;

2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java

@ -161,7 +161,7 @@ class RebuildRefTree extends TextBuiltin {
}
cmds.add(new org.eclipse.jgit.internal.storage.reftree.Command(
null,
db.peel(r)));
db.getRefDatabase().peel(r)));
}
tree.apply(cmds);
return tree;

10
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/ShowCommands.java

@ -65,11 +65,11 @@ class ShowCommands extends TextBuiltin {
final CommandRef[] list = CommandCatalog.all();
int width = 0;
for (final CommandRef c : list)
for (CommandRef c : list)
width = Math.max(width, c.getName().length());
width += 2;
for (final CommandRef c : list) {
for (CommandRef c : list) {
errw.print(c.isCommon() ? '*' : ' ');
errw.print(' ');
@ -87,7 +87,7 @@ class ShowCommands extends TextBuiltin {
/** */
USAGE {
@Override
void print(ThrowingPrintWriter err, final CommandRef c) throws IOException {
void print(ThrowingPrintWriter err, CommandRef c) throws IOException {
String usage = c.getUsage();
if (usage != null && usage.length() > 0)
err.print(CLIText.get().resourceBundle().getString(usage));
@ -97,7 +97,7 @@ class ShowCommands extends TextBuiltin {
/** */
CLASSES {
@Override
void print(ThrowingPrintWriter err, final CommandRef c) throws IOException {
void print(ThrowingPrintWriter err, CommandRef c) throws IOException {
err.print(c.getImplementationClassName());
}
},
@ -105,7 +105,7 @@ class ShowCommands extends TextBuiltin {
/** */
URLS {
@Override
void print(ThrowingPrintWriter err, final CommandRef c) throws IOException {
void print(ThrowingPrintWriter err, CommandRef c) throws IOException {
final ClassLoader ldr = c.getImplementationClassLoader();
String cn = c.getImplementationClassName();

10
org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java

@ -85,7 +85,7 @@ public class EGitPatchHistoryTest {
int errors;
PatchReader(final HashMap<String, HashMap<String, StatInfo>> s)
PatchReader(HashMap<String, HashMap<String, StatInfo>> s)
throws IOException {
super(new String[] { "-p" });
stats = s;
@ -103,7 +103,7 @@ public class EGitPatchHistoryTest {
p.parse(buf, 0, buf.length - 1);
assertEquals("File count " + cid, files.size(), p.getFiles().size());
if (!p.getErrors().isEmpty()) {
for (final FormatError e : p.getErrors()) {
for (FormatError e : p.getErrors()) {
System.out.println("error " + e.getMessage());
System.out.println(" at " + e.getLineText());
}
@ -111,7 +111,7 @@ public class EGitPatchHistoryTest {
fail("Unexpected error in " + cid);
}
for (final FileHeader fh : p.getFiles()) {
for (FileHeader fh : p.getFiles()) {
final String fileName;
if (fh.getChangeType() != FileHeader.ChangeType.DELETE)
fileName = fh.getNewPath();
@ -121,7 +121,7 @@ public class EGitPatchHistoryTest {
final String nid = fileName + " in " + cid;
assertNotNull("No " + nid, s);
int added = 0, deleted = 0;
for (final HunkHeader h : fh.getHunks()) {
for (HunkHeader h : fh.getHunks()) {
added += h.getOldImage().getLinesAdded();
deleted += h.getOldImage().getLinesDeleted();
}
@ -188,7 +188,7 @@ public class EGitPatchHistoryTest {
static abstract class CommitReader {
private Process proc;
CommitReader(final String[] args) throws IOException {
CommitReader(String[] args) throws IOException {
final String[] realArgs = new String[3 + args.length + 1];
realArgs[0] = "git";
realArgs[1] = "log";

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitOnlyTest.java

@ -1289,7 +1289,7 @@ public class CommitOnlyTest extends RepositoryTestCase {
return null;
}
static private String getHead(final Git git, final String path)
static private String getHead(Git git, String path)
throws Exception {
try {
final Repository repo = git.getRepository();

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LogCommandTest.java

@ -116,7 +116,7 @@ public class LogCommandTest extends RepositoryTestCase {
Iterator<RevCommit> log = git.log().all().call().iterator();
assertTrue(log.hasNext());
RevCommit commit = log.next();
tag = db.peel(tag);
tag = db.getRefDatabase().peel(tag);
assertEquals(commit.getName(), tag.getPeeledObjectId().getName());
assertTrue(commits.contains(commit));

26
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java

@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.api;
import static org.eclipse.jgit.lib.Constants.R_TAGS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@ -66,19 +67,22 @@ public class TagCommandTest extends RepositoryTestCase {
RevWalk walk = new RevWalk(db)) {
RevCommit commit = git.commit().setMessage("initial commit").call();
Ref tagRef = git.tag().setName("tag").call();
assertEquals(commit.getId(), db.peel(tagRef).getPeeledObjectId());
assertEquals(commit.getId(),
db.getRefDatabase().peel(tagRef).getPeeledObjectId());
assertEquals("tag", walk.parseTag(tagRef.getObjectId()).getTagName());
}
}
@Test
public void testTagging() throws GitAPIException, JGitInternalException {
public void testTagging()
throws GitAPIException, JGitInternalException, IOException {
try (Git git = new Git(db)) {
git.commit().setMessage("initial commit").call();
RevCommit commit = git.commit().setMessage("second commit").call();
git.commit().setMessage("third commit").call();
Ref tagRef = git.tag().setObjectId(commit).setName("tag").call();
assertEquals(commit.getId(), db.peel(tagRef).getPeeledObjectId());
assertEquals(commit.getId(),
db.getRefDatabase().peel(tagRef).getPeeledObjectId());
}
}
@ -135,26 +139,30 @@ public class TagCommandTest extends RepositoryTestCase {
}
}
private List<Ref> getTags() throws Exception {
return db.getRefDatabase().getRefsByPrefix(R_TAGS);
}
@Test
public void testDelete() throws Exception {
try (Git git = new Git(db)) {
git.commit().setMessage("initial commit").call();
Ref tagRef = git.tag().setName("tag").call();
assertEquals(1, db.getTags().size());
assertEquals(1, getTags().size());
List<String> deleted = git.tagDelete().setTags(tagRef.getName())
.call();
assertEquals(1, deleted.size());
assertEquals(tagRef.getName(), deleted.get(0));
assertEquals(0, db.getTags().size());
assertEquals(0, getTags().size());
Ref tagRef1 = git.tag().setName("tag1").call();
Ref tagRef2 = git.tag().setName("tag2").call();
assertEquals(2, db.getTags().size());
assertEquals(2, getTags().size());
deleted = git.tagDelete().setTags(tagRef1.getName(), tagRef2.getName())
.call();
assertEquals(2, deleted.size());
assertEquals(0, db.getTags().size());
assertEquals(0, getTags().size());
}
}
@ -163,13 +171,13 @@ public class TagCommandTest extends RepositoryTestCase {
try (Git git = new Git(db)) {
git.commit().setMessage("initial commit").call();
Ref tagRef = git.tag().setName("tag").call();
assertEquals(1, db.getTags().size());
assertEquals(1, getTags().size());
List<String> deleted = git.tagDelete()
.setTags(Repository.shortenRefName(tagRef.getName())).call();
assertEquals(1, deleted.size());
assertEquals(tagRef.getName(), deleted.get(0));
assertEquals(0, db.getTags().size());
assertEquals(0, getTags().size());
}
}

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheBuilderIteratorTest.java vendored

@ -78,7 +78,7 @@ public class DirCacheBuilderIteratorTest extends RepositoryTestCase {
final int expIdx = 2;
final DirCacheBuilder b = dc.builder();
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new DirCacheBuildIterator(b));
tw.setRecursive(true);
tw.setFilter(PathFilterGroup.createFromStrings(Collections

8
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java vendored

@ -99,7 +99,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase {
assertEquals(ls.size(), dc.getEntryCount());
{
final Iterator<CGitIndexRecord> rItr = ls.values().iterator();
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.setRecursive(true);
tw.addTree(new DirCacheIterator(dc));
while (rItr.hasNext()) {
@ -180,7 +180,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase {
assertEquals(cList.size(), jTree.getEntrySpan());
final ArrayList<CGitLsTreeRecord> subtrees = new ArrayList<>();
for (final CGitLsTreeRecord r : cTree.values()) {
for (CGitLsTreeRecord r : cTree.values()) {
if (FileMode.TREE.equals(r.mode))
subtrees.add(r);
}
@ -268,7 +268,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase {
final String path;
CGitIndexRecord(final String line) {
CGitIndexRecord(String line) {
final int tab = line.indexOf('\t');
final int sp1 = line.indexOf(' ');
final int sp2 = line.indexOf(' ', sp1 + 1);
@ -286,7 +286,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase {
final String path;
CGitLsTreeRecord(final String line) {
CGitLsTreeRecord(String line) {
final int tab = line.indexOf('\t');
final int sp1 = line.indexOf(' ');
final int sp2 = line.indexOf(' ', sp1 + 1);

14
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheIteratorTest.java vendored

@ -76,7 +76,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
final DirCache dc = DirCache.newInCore();
assertEquals(0, dc.getEntryCount());
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new DirCacheIterator(dc));
assertFalse(tw.next());
}
@ -126,7 +126,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
b.finish();
final DirCacheIterator i = new DirCacheIterator(dc);
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(i);
int pathIdx = 0;
while (tw.next()) {
@ -164,7 +164,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
final int expPos[] = { 0, -1, 4 };
final DirCacheIterator i = new DirCacheIterator(dc);
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(i);
tw.setRecursive(false);
int pathIdx = 0;
@ -205,7 +205,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
b.finish();
final DirCacheIterator i = new DirCacheIterator(dc);
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(i);
tw.setRecursive(true);
int pathIdx = 0;
@ -240,7 +240,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
b.add(ents[i]);
b.finish();
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new DirCacheIterator(dc));
tw.setRecursive(true);
int pathIdx = 0;
@ -402,7 +402,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
b.add(ents[i]);
b.finish();
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
for (int victimIdx = 0; victimIdx < paths.length; victimIdx++) {
tw.reset();
tw.addTree(new DirCacheIterator(dc));
@ -430,7 +430,7 @@ public class DirCacheIteratorTest extends RepositoryTestCase {
final DirCache dc = DirCache.read(path, FS.DETECTED);
assertEquals(2, dc.getEntryCount());
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.setRecursive(true);
tw.addTree(new DirCacheIterator(dc));

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java

@ -160,7 +160,7 @@ public class RepoCommandTest extends RepositoryTestCase {
Ref ref = r.findRef(refname);
if (ref == null) return null;
ref = r.peel(ref);
ref = r.getRefDatabase().peel(ref);
ObjectId id = ref.getObjectId();
return id;
} catch (IOException e) {

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/CGitIgnoreTest.java

@ -141,7 +141,9 @@ public class CGitIgnoreTest extends RepositoryTestCase {
// Do a tree walk that does descend into ignored directories and return
// a list of all ignored files
try (TreeWalk walk = new TreeWalk(db)) {
walk.addTree(new FileTreeIterator(db));
FileTreeIterator iter = new FileTreeIterator(db);
iter.setWalkIgnoredDirectories(true);
walk.addTree(iter);
walk.setRecursive(true);
while (walk.next()) {
if (walk.getTree(WorkingTreeIterator.class).isEntryIgnored()) {

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java

@ -732,7 +732,9 @@ public class IgnoreNodeTest extends RepositoryTestCase {
private void beginWalk() {
walk = new TreeWalk(db);
walk.addTree(new FileTreeIterator(db));
FileTreeIterator iter = new FileTreeIterator(db);
iter.setWalkIgnoredDirectories(true);
walk.addTree(iter);
}
private void endWalk() throws IOException {

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ConcurrentRepackTest.java

@ -220,7 +220,7 @@ public class ConcurrentRepackTest extends RepositoryTestCase {
private File[] pack(Repository src, RevObject... list)
throws IOException {
try (PackWriter pw = new PackWriter(src)) {
for (final RevObject o : list) {
for (RevObject o : list) {
pw.addObject(o);
}
@ -253,7 +253,7 @@ public class ConcurrentRepackTest extends RepositoryTestCase {
private static void delete(File[] list) throws IOException {
final long begin = list[0].getParentFile().lastModified();
for (final File f : list) {
for (File f : list) {
FileUtils.delete(f);
assertFalse(f + " was removed", f.exists());
}

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java

@ -368,7 +368,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
ObjectId.fromString("902d5476fa249b7abc9d84c611577a81381f0327"),
ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3") ,
ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259") };
try (final RevWalk parser = new RevWalk(db)) {
try (RevWalk parser = new RevWalk(db)) {
final RevObject forcedOrderRevs[] = new RevObject[forcedOrder.length];
for (int i = 0; i < forcedOrder.length; i++)
forcedOrderRevs[i] = parser.parseAny(forcedOrder[i]);

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java

@ -305,7 +305,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
// object (as it already exists in the pack).
//
final Repository newdb = createBareRepository();
try (final ObjectInserter oi = newdb.newObjectInserter()) {
try (ObjectInserter oi = newdb.newObjectInserter()) {
final ObjectId treeId = oi.insert(new TreeFormatter());
assertEquals("4b825dc642cb6eb9a060e54bf8d69288fbee4904",
treeId.name());
@ -373,7 +373,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
@Test
public void test007_Open() throws IOException {
try (final FileRepository db2 = new FileRepository(db.getDirectory())) {
try (FileRepository db2 = new FileRepository(db.getDirectory())) {
assertEquals(db.getDirectory(), db2.getDirectory());
assertEquals(db.getObjectDatabase().getDirectory(), db2
.getObjectDatabase().getDirectory());
@ -557,7 +557,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase {
@Test
public void test026_CreateCommitMultipleparents() throws IOException {
final ObjectId treeId;
try (final ObjectInserter oi = db.newObjectInserter()) {
try (ObjectInserter oi = db.newObjectInserter()) {
final ObjectId blobId = oi.insert(Constants.OBJ_BLOB,
"and this is the data in me\n".getBytes(Constants.CHARSET
.name()));

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/WindowCacheGetTest.java

@ -133,7 +133,7 @@ public class WindowCacheGetTest extends SampleDataRepositoryTestCase {
}
private void doCacheTests() throws IOException {
for (final TestObject o : toLoad) {
for (TestObject o : toLoad) {
final ObjectLoader or = db.open(o.id, o.type);
assertNotNull(or);
assertEquals(o.type, or.getType());
@ -145,7 +145,7 @@ public class WindowCacheGetTest extends SampleDataRepositoryTestCase {
int type;
void setType(final String typeStr) throws CorruptObjectException {
void setType(String typeStr) throws CorruptObjectException {
final byte[] typeRaw = Constants.encode(typeStr + " ");
final MutableInteger ptr = new MutableInteger();
type = Constants.decodeTypeString(id, typeRaw, (byte) ' ', ptr);

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/XInputStream.java

@ -53,7 +53,7 @@ import org.eclipse.jgit.util.NB;
class XInputStream extends BufferedInputStream {
private final byte[] intbuf = new byte[8];
XInputStream(final InputStream s) {
XInputStream(InputStream s) {
super(s);
}
@ -63,7 +63,7 @@ class XInputStream extends BufferedInputStream {
return b;
}
synchronized void readFully(final byte[] b, int o, int len)
synchronized void readFully(byte[] b, int o, int len)
throws IOException {
int r;
while (len > 0 && (r = read(b, o, len)) > 0) {

113
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java

@ -78,8 +78,10 @@ import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.TestRepository.BranchBuilder;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.treewalk.AbstractTreeIterator;
import org.eclipse.jgit.treewalk.FileTreeIterator;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.WorkingTreeIterator;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils;
import org.junit.Assume;
@ -1904,6 +1906,117 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
assertUpdated(longFileName);
}
@Test
public void testIgnoredDirectory() throws Exception {
writeTrashFile(".gitignore", "src/ignored");
writeTrashFile("src/ignored/sub/foo.txt", "1");
try (Git git = new Git(db)) {
git.add().addFilepattern(".").call();
RevCommit commit = git.commit().setMessage("adding .gitignore")
.call();
writeTrashFile("foo.txt", "2");
writeTrashFile("zzz.txt", "3");
git.add().addFilepattern("foo.txt").call();
git.commit().setMessage("add file").call();
assertEquals("Should not have entered ignored directory", 1,
resetHardAndCount(commit));
}
}
@Test
public void testIgnoredDirectoryWithTrackedContent() throws Exception {
writeTrashFile("src/ignored/sub/foo.txt", "1");
try (Git git = new Git(db)) {
git.add().addFilepattern(".").call();
git.commit().setMessage("adding foo.txt").call();
writeTrashFile(".gitignore", "src/ignored");
writeTrashFile("src/ignored/sub/foo.txt", "2");
writeTrashFile("src/ignored/other/bar.txt", "3");
git.add().addFilepattern(".").call();
RevCommit commit = git.commit().setMessage("adding .gitignore")
.call();
writeTrashFile("foo.txt", "2");
writeTrashFile("zzz.txt", "3");
git.add().addFilepattern("foo.txt").call();
git.commit().setMessage("add file").call();
File file = writeTrashFile("src/ignored/sub/foo.txt", "3");
assertEquals("Should have entered ignored directory", 3,
resetHardAndCount(commit));
checkFile(file, "2");
}
}
@Test
public void testResetWithChangeInGitignore() throws Exception {
writeTrashFile(".gitignore", "src/ignored");
writeTrashFile("src/ignored/sub/foo.txt", "1");
try (Git git = new Git(db)) {
git.add().addFilepattern(".").call();
RevCommit initial = git.commit().setMessage("initial").call();
writeTrashFile("src/newignored/foo.txt", "2");
writeTrashFile("src/.gitignore", "newignored");
git.add().addFilepattern(".").call();
RevCommit commit = git.commit().setMessage("newignored").call();
assertEquals("Should not have entered src/newignored directory", 1,
resetHardAndCount(initial));
assertEquals("Should have entered src/newignored directory", 2,
resetHardAndCount(commit));
deleteTrashFile("src/.gitignore");
git.rm().addFilepattern("src/.gitignore").call();
RevCommit top = git.commit().setMessage("Unignore newignore")
.call();
assertEquals("Should have entered src/newignored directory", 2,
resetHardAndCount(initial));
assertEquals("Should have entered src/newignored directory", 2,
resetHardAndCount(commit));
assertEquals("Should not have entered src/newignored directory", 1,
resetHardAndCount(top));
}
}
private static class TestFileTreeIterator extends FileTreeIterator {
// For assertions only
private final int[] count;
public TestFileTreeIterator(Repository repo, int[] count) {
super(repo);
this.count = count;
}
protected TestFileTreeIterator(final WorkingTreeIterator p,
final File root, FS fs, FileModeStrategy fileModeStrategy,
int[] count) {
super(p, root, fs, fileModeStrategy);
this.count = count;
}
@Override
protected AbstractTreeIterator enterSubtree() {
count[0] += 1;
return new TestFileTreeIterator(this,
((FileEntry) current()).getFile(), fs, fileModeStrategy,
count);
}
}
private int resetHardAndCount(RevCommit commit) throws Exception {
int[] callCount = { 0 };
DirCache cache = db.lockDirCache();
FileTreeIterator workingTreeIterator = new TestFileTreeIterator(db,
callCount);
try {
DirCacheCheckout checkout = new DirCacheCheckout(db, null, cache,
commit.getTree().getId(), workingTreeIterator);
checkout.setFailOnConflict(false);
checkout.checkout();
} finally {
cache.unlock();
}
return callCount[0];
}
public void assertWorkDir(Map<String, String> i)
throws CorruptObjectException,
IOException {

5
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java

@ -470,7 +470,8 @@ public class IndexDiffTest extends RepositoryTestCase {
}
/**
* Test that ignored folders aren't listed as untracked
* Test that ignored folders aren't listed as untracked, but are listed as
* ignored.
*
* @throws Exception
*/
@ -499,6 +500,8 @@ public class IndexDiffTest extends RepositoryTestCase {
diff.diff();
assertEquals(new HashSet<>(Arrays.asList("src")),
diff.getUntrackedFolders());
assertEquals(new HashSet<>(Arrays.asList("sr", "target")),
diff.getIgnoredNotInIndex());
git.add().addFilepattern("src").call();
writeTrashFile("sr/com/X1.java", "");

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevObjectTest.java

@ -76,7 +76,7 @@ public class RevObjectTest extends RevWalkTestCase {
final RevCommit a2;
final RevCommit b2;
try (final RevWalk rw2 = new RevWalk(db)) {
try (RevWalk rw2 = new RevWalk(db)) {
a2 = rw2.parseCommit(a1);
b2 = rw2.parseCommit(b1);
}

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkPathFilter6012Test.java

@ -105,14 +105,14 @@ public class RevWalkPathFilter6012Test extends RevWalkTestCase {
protected void check(RevCommit... order) throws Exception {
markStart(i);
final StringBuilder act = new StringBuilder();
for (final RevCommit z : rw) {
for (RevCommit z : rw) {
final String name = byName.get(z);
assertNotNull(name);
act.append(name);
act.append(' ');
}
final StringBuilder exp = new StringBuilder();
for (final RevCommit z : order) {
for (RevCommit z : order) {
final String name = byName.get(z);
assertNotNull(name);
exp.append(name);

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushProcessTest.java

@ -422,7 +422,7 @@ public class PushProcessTest extends SampleDataRepositoryTestCase {
PushConnection {
MockPushConnection() {
final Map<String, Ref> refsMap = new HashMap<>();
for (final Ref r : advertisedRefs)
for (Ref r : advertisedRefs)
refsMap.put(r.getName(), r);
available(refsMap);
}
@ -443,7 +443,7 @@ public class PushProcessTest extends SampleDataRepositoryTestCase {
public void push(ProgressMonitor monitor,
Map<String, RemoteRefUpdate> refsToUpdate)
throws TransportException {
for (final RemoteRefUpdate rru : refsToUpdate.values()) {
for (RemoteRefUpdate rru : refsToUpdate.values()) {
assertEquals(Status.NOT_ATTEMPTED, rru.getStatus());
rru.setStatus(connectionUpdateStatus);
}

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java

@ -136,7 +136,7 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas
try (TransportLocal t = new TransportLocal(src, uriOf(dst),
dst.getDirectory()) {
@Override
ReceivePack createReceivePack(final Repository db) {
ReceivePack createReceivePack(Repository db) {
db.close();
dst.incrementOpen();
@ -203,7 +203,7 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas
throws Exception {
return new TransportLocal(src, uriOf(dst), dst.getDirectory()) {
@Override
ReceivePack createReceivePack(final Repository db) {
ReceivePack createReceivePack(Repository db) {
db.close();
dst.incrementOpen();

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java

@ -142,7 +142,7 @@ public class TransportTest extends SampleDataRepositoryTestCase {
assertEquals(12, result.size());
boolean foundA = false;
boolean foundB = false;
for (final RemoteRefUpdate rru : result) {
for (RemoteRefUpdate rru : result) {
if ("refs/heads/a".equals(rru.getSrcRef())
&& "refs/heads/test/a".equals(rru.getRemoteName()))
foundA = true;
@ -174,7 +174,7 @@ public class TransportTest extends SampleDataRepositoryTestCase {
assertEquals(2, result.size());
boolean foundA = false;
boolean foundC = false;
for (final RemoteRefUpdate rru : result) {
for (RemoteRefUpdate rru : result) {
if ("refs/heads/a".equals(rru.getSrcRef())
&& "refs/heads/b".equals(rru.getRemoteName()))
foundA = true;
@ -233,7 +233,7 @@ public class TransportTest extends SampleDataRepositoryTestCase {
assertEquals(2, result.size());
boolean foundA = false;
boolean foundC = false;
for (final RemoteRefUpdate rru : result) {
for (RemoteRefUpdate rru : result) {
if ("refs/heads/a".equals(rru.getSrcRef())
&& "refs/heads/b".equals(rru.getRemoteName())) {
foundA = true;

82
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java

@ -518,15 +518,18 @@ public class UploadPackTest {
* Parse multiplexed packfile output from upload-pack using protocol V2
* into the client repository.
*/
private void parsePack(ByteArrayInputStream recvStream) throws Exception {
parsePack(recvStream, NullProgressMonitor.INSTANCE);
private ReceivedPackStatistics parsePack(ByteArrayInputStream recvStream) throws Exception {
return parsePack(recvStream, NullProgressMonitor.INSTANCE);
}
private void parsePack(ByteArrayInputStream recvStream, ProgressMonitor pm)
private ReceivedPackStatistics parsePack(ByteArrayInputStream recvStream, ProgressMonitor pm)
throws Exception {
SideBandInputStream sb = new SideBandInputStream(
recvStream, pm, new StringWriter(), NullOutputStream.INSTANCE);
client.newObjectInserter().newPackParser(sb).parse(NullProgressMonitor.INSTANCE);
recvStream, pm,
new StringWriter(), NullOutputStream.INSTANCE);
PackParser pp = client.newObjectInserter().newPackParser(sb);
pp.parse(NullProgressMonitor.INSTANCE);
return pp.getReceivedPackStatistics();
}
@Test
@ -805,6 +808,75 @@ public class UploadPackTest {
assertTrue(sw.toString().isEmpty());
}
@Test
public void testV2FetchIncludeTag() throws Exception {
RevCommit commit = remote.commit().message("x").create();
RevTag tag = remote.tag("tag", commit);
remote.update("branch1", commit);
remote.update("refs/tags/tag", tag);
// Without include-tag.
ByteArrayInputStream recvStream = uploadPackV2(
"command=fetch\n",
PacketLineIn.DELIM,
"want " + commit.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
assertFalse(client.hasObject(tag.toObjectId()));
// With tag.
recvStream = uploadPackV2(
"command=fetch\n",
PacketLineIn.DELIM,
"want " + commit.toObjectId().getName() + "\n",
"include-tag\n",
"done\n",
PacketLineIn.END);
pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
assertTrue(client.hasObject(tag.toObjectId()));
}
@Test
public void testV2FetchOfsDelta() throws Exception {
String commonInBlob = "abcdefghijklmnopqrstuvwxyz";
RevBlob parentBlob = remote.blob(commonInBlob + "a");
RevCommit parent = remote.commit(remote.tree(remote.file("foo", parentBlob)));
RevBlob childBlob = remote.blob(commonInBlob + "b");
RevCommit child = remote.commit(remote.tree(remote.file("foo", childBlob)), parent);
remote.update("branch1", child);
// Without ofs-delta.
ByteArrayInputStream recvStream = uploadPackV2(
"command=fetch\n",
PacketLineIn.DELIM,
"want " + child.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
ReceivedPackStatistics stats = parsePack(recvStream);
assertTrue(stats.getNumOfsDelta() == 0);
// With ofs-delta.
recvStream = uploadPackV2(
"command=fetch\n",
PacketLineIn.DELIM,
"want " + child.toObjectId().getName() + "\n",
"ofs-delta\n",
"done\n",
PacketLineIn.END);
pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
stats = parsePack(recvStream);
assertTrue(stats.getNumOfsDelta() != 0);
}
private static class RejectAllRefFilter implements RefFilter {
@Override
public Map<String, Ref> filter(Map<String, Ref> refs) {

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/CanonicalTreeParserTest.java

@ -93,7 +93,7 @@ public class CanonicalTreeParserTest {
private static byte[] mktree(byte[]... data) throws Exception {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
for (final byte[] e : data)
for (byte[] e : data)
out.write(e);
return out.toByteArray();
}

12
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/PostOrderTreeWalkTest.java

@ -60,14 +60,14 @@ import org.junit.Test;
public class PostOrderTreeWalkTest extends RepositoryTestCase {
@Test
public void testInitialize_NoPostOrder() throws Exception {
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
assertFalse(tw.isPostOrderTraversal());
}
}
@Test
public void testInitialize_TogglePostOrder() throws Exception {
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
assertFalse(tw.isPostOrderTraversal());
tw.setPostOrderTraversal(true);
assertTrue(tw.isPostOrderTraversal());
@ -78,7 +78,7 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase {
@Test
public void testResetDoesNotAffectPostOrder() throws Exception {
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.setPostOrderTraversal(true);
assertTrue(tw.isPostOrderTraversal());
tw.reset();
@ -104,7 +104,7 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase {
b.finish();
assertEquals(4, tree.getEntryCount());
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.setPostOrderTraversal(false);
tw.addTree(new DirCacheIterator(tree));
@ -132,7 +132,7 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase {
b.finish();
assertEquals(4, tree.getEntryCount());
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.setPostOrderTraversal(true);
tw.addTree(new DirCacheIterator(tree));
@ -166,7 +166,7 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase {
b.finish();
assertEquals(4, tree.getEntryCount());
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.setPostOrderTraversal(true);
tw.addTree(new DirCacheIterator(tree));

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathFilterGroupTest.java

@ -254,7 +254,7 @@ public class PathFilterGroupTest {
}
}
TreeWalk fakeWalk(final String path) throws IOException {
TreeWalk fakeWalk(String path) throws IOException {
DirCache dc = DirCache.newInCore();
DirCacheEditor dce = dc.editor();
dce.add(new DirCacheEditor.PathEdit(path) {
@ -274,7 +274,7 @@ public class PathFilterGroupTest {
return ret;
}
TreeWalk fakeWalkAtSubtree(final String path) throws IOException {
TreeWalk fakeWalkAtSubtree(String path) throws IOException {
DirCache dc = DirCache.newInCore();
DirCacheEditor dce = dc.editor();
dce.add(new DirCacheEditor.PathEdit(path + "/README") {

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/PathSuffixFilterTest.java

@ -113,7 +113,7 @@ public class PathSuffixFilterTest extends RepositoryTestCase {
private List<String> getMatchingPaths(String suffixFilter,
final ObjectId treeId, boolean recursiveWalk) throws IOException {
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.setFilter(PathSuffixFilter.create(suffixFilter));
tw.setRecursive(recursiveWalk);
tw.addTree(treeId);

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/TreeFilterTest.java

@ -55,7 +55,7 @@ import org.junit.Test;
public class TreeFilterTest extends RepositoryTestCase {
@Test
public void testALL_IncludesAnything() throws Exception {
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new EmptyTreeIterator());
assertTrue(TreeFilter.ALL.include(tw));
}
@ -73,7 +73,7 @@ public class TreeFilterTest extends RepositoryTestCase {
@Test
public void testNotALL_IncludesNothing() throws Exception {
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new EmptyTreeIterator());
assertFalse(TreeFilter.ALL.negate().include(tw));
}
@ -81,7 +81,7 @@ public class TreeFilterTest extends RepositoryTestCase {
@Test
public void testANY_DIFF_IncludesSingleTreeCase() throws Exception {
try (final TreeWalk tw = new TreeWalk(db)) {
try (TreeWalk tw = new TreeWalk(db)) {
tw.addTree(new EmptyTreeIterator());
assertTrue(TreeFilter.ANY_DIFF.include(tw));
}

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java

@ -248,7 +248,7 @@ public class TemporaryBufferTest {
public void testInCoreInputStream() throws IOException {
final int cnt = 256;
final byte[] test = new TestRng(getName()).nextBytes(cnt);
try (final TemporaryBuffer.Heap b = new TemporaryBuffer.Heap(cnt + 4)) {
try (TemporaryBuffer.Heap b = new TemporaryBuffer.Heap(cnt + 4)) {
b.write(test);
InputStream in = b.openInputStream();
byte[] act = new byte[cnt];

6
org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/AWTPlotRenderer.java

@ -66,11 +66,11 @@ final class AWTPlotRenderer extends AbstractPlotRenderer<SwingLane, Color>
transient Graphics2D g;
AWTPlotRenderer(final GraphCellRender c) {
AWTPlotRenderer(GraphCellRender c) {
cell = c;
}
void paint(final Graphics in, final PlotCommit<SwingLane> commit) {
void paint(Graphics in, PlotCommit<SwingLane> commit) {
g = (Graphics2D) in.create();
try {
final int h = cell.getHeight();
@ -138,7 +138,7 @@ final class AWTPlotRenderer extends AbstractPlotRenderer<SwingLane, Color>
return myLane != null ? myLane.color : Color.black;
}
void paintTriangleDown(final int cx, final int y, final int h) {
void paintTriangleDown(int cx, int y, int h) {
final int tipX = cx;
final int tipY = y + h;
final int baseX1 = cx - 10 / 2;

4
org.eclipse.jgit.ui/src/org/eclipse/jgit/awtui/CommitGraphPane.java

@ -175,7 +175,7 @@ public class CommitGraphPane extends JTable {
}
}
PersonIdent authorFor(final PlotCommit<SwingLane> c) {
PersonIdent authorFor(PlotCommit<SwingLane> c) {
if (c != lastCommit) {
lastCommit = c;
lastAuthor = c.getAuthorIdent();
@ -259,7 +259,7 @@ public class CommitGraphPane extends JTable {
strokeCache[i] = new BasicStroke(i);
}
static Stroke stroke(final int width) {
static Stroke stroke(int width) {
if (width < strokeCache.length)
return strokeCache[width];
return new BasicStroke(width);

6
org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java

@ -315,7 +315,7 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
specs.add(wcrs);
else if (branchesToClone != null
&& branchesToClone.size() > 0) {
for (final String selectedRef : branchesToClone)
for (String selectedRef : branchesToClone)
if (wcrs.matchSource(selectedRef))
specs.add(wcrs.expandFromSource(selectedRef));
}
@ -410,7 +410,7 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
}
Ref foundBranch = null;
for (final Ref r : result.getAdvertisedRefs()) {
for (Ref r : result.getAdvertisedRefs()) {
final String n = r.getName();
if (!n.startsWith(Constants.R_HEADS))
continue;
@ -444,7 +444,7 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
final RevCommit commit;
try (final RevWalk rw = new RevWalk(clonedRepo)) {
try (RevWalk rw = new RevWalk(clonedRepo)) {
commit = rw.parseCommit(ref.getObjectId());
}
return commit;

14
org.eclipse.jgit/src/org/eclipse/jgit/api/DescribeCommand.java

@ -224,12 +224,16 @@ public class DescribeCommand extends GitCommand<String> {
}
}
private ObjectId getObjectIdFromRef(Ref r) {
ObjectId key = repo.peel(r).getPeeledObjectId();
if (key == null) {
key = r.getObjectId();
private ObjectId getObjectIdFromRef(Ref r) throws JGitInternalException {
try {
ObjectId key = repo.getRefDatabase().peel(r).getPeeledObjectId();
if (key == null) {
key = r.getObjectId();
}
return key;
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);
}
return key;
}
/**

2
org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java

@ -274,7 +274,7 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> {
public LogCommand all() throws IOException {
for (Ref ref : getRepository().getRefDatabase().getRefs()) {
if(!ref.isPeeled())
ref = getRepository().peel(ref);
ref = getRepository().getRefDatabase().peel(ref);
ObjectId objectId = ref.getPeeledObjectId();
if (objectId == null)

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

@ -255,7 +255,7 @@ public class MergeCommand extends GitCommand<MergeResult> {
refLogMessage.append(ref.getName());
// handle annotated tags
ref = repo.peel(ref);
ref = repo.getRefDatabase().peel(ref);
ObjectId objectId = ref.getPeeledObjectId();
if (objectId == null)
objectId = ref.getObjectId();

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

@ -360,7 +360,7 @@ public class ResetCommand extends GitCommand<Ref> {
private void resetIndexForPaths(ObjectId commitTree) {
DirCache dc = null;
try (final TreeWalk tw = new TreeWalk(repo)) {
try (TreeWalk tw = new TreeWalk(repo)) {
dc = repo.lockDirCache();
DirCacheBuilder builder = dc.builder();

2
org.eclipse.jgit/src/org/eclipse/jgit/api/RmCommand.java

@ -154,7 +154,7 @@ public class RmCommand extends GitCommand<DirCache> {
DirCache dc = null;
List<String> actuallyDeletedFiles = new ArrayList<>();
try (final TreeWalk tw = new TreeWalk(repo)) {
try (TreeWalk tw = new TreeWalk(repo)) {
dc = repo.lockDirCache();
DirCacheBuilder builder = dc.builder();
tw.reset(); // drop the first empty tree, which we do not need here

2
org.eclipse.jgit/src/org/eclipse/jgit/api/StashCreateCommand.java

@ -195,7 +195,7 @@ public class StashCreateCommand extends GitCommand<RevCommit> {
private RevCommit parseCommit(final ObjectReader reader,
final ObjectId headId) throws IOException {
try (final RevWalk walk = new RevWalk(reader)) {
try (RevWalk walk = new RevWalk(reader)) {
return walk.parseCommit(headId);
}
}

2
org.eclipse.jgit/src/org/eclipse/jgit/blame/ReverseWalk.java

@ -108,7 +108,7 @@ final class ReverseWalk extends RevWalk {
return children.length;
}
ReverseCommit getChild(final int nth) {
ReverseCommit getChild(int nth) {
return children[nth];
}
}

18
org.eclipse.jgit/src/org/eclipse/jgit/diff/MyersDiff.java

@ -359,7 +359,7 @@ if (k < beginK || k > endK)
abstract int getLeft(int x);
abstract int getRight(int x);
abstract boolean isBetter(int left, int right);
abstract void adjustMinMaxK(final int k, final int x);
abstract void adjustMinMaxK(int k, int x);
abstract boolean meets(int d, int k, int x, long snake);
final long newSnake(int k, int x) {
@ -469,22 +469,22 @@ if (k < beginK || k > endK)
}
@Override
final int getLeft(final int x) {
final int getLeft(int x) {
return x;
}
@Override
final int getRight(final int x) {
final int getRight(int x) {
return x + 1;
}
@Override
final boolean isBetter(final int left, final int right) {
final boolean isBetter(int left, int right) {
return left > right;
}
@Override
final void adjustMinMaxK(final int k, final int x) {
final void adjustMinMaxK(int k, int x) {
if (x >= endA || k + x >= endB) {
if (k > backward.middleK)
maxK = k;
@ -517,22 +517,22 @@ if (k < beginK || k > endK)
}
@Override
final int getLeft(final int x) {
final int getLeft(int x) {
return x - 1;
}
@Override
final int getRight(final int x) {
final int getRight(int x) {
return x;
}
@Override
final boolean isBetter(final int left, final int right) {
final boolean isBetter(int left, int right) {
return left < right;
}
@Override
final void adjustMinMaxK(final int k, final int x) {
final void adjustMinMaxK(int k, int x) {
if (x <= beginA || k + x <= beginB) {
if (k > forward.middleK)
maxK = k;

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

@ -157,7 +157,7 @@ public class SimilarityIndex {
}
}
void hash(byte[] raw, int ptr, final int end) throws TableFullException {
void hash(byte[] raw, int ptr, int end) throws TableFullException {
final boolean text = !RawText.isBinary(raw);
hashedCnt = 0;
while (ptr < end) {

10
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java vendored

@ -121,11 +121,11 @@ public class DirCache {
}
};
static int cmp(final DirCacheEntry a, final DirCacheEntry b) {
static int cmp(DirCacheEntry a, DirCacheEntry b) {
return cmp(a.path, a.path.length, b);
}
static int cmp(final byte[] aPath, final int aLen, final DirCacheEntry b) {
static int cmp(byte[] aPath, int aLen, DirCacheEntry b) {
return cmp(aPath, aLen, b.path, b.path.length);
}
@ -404,7 +404,7 @@ public class DirCache {
return new DirCacheEditor(this, entryCnt + 16);
}
void replace(final DirCacheEntry[] e, final int cnt) {
void replace(DirCacheEntry[] e, int cnt) {
sortedEntries = e;
entryCnt = cnt;
tree = null;
@ -648,7 +648,7 @@ public class DirCache {
}
}
void writeTo(File dir, final OutputStream os) throws IOException {
void writeTo(File dir, OutputStream os) throws IOException {
final MessageDigest foot = Constants.newMessageDigest();
final DigestOutputStream dos = new DigestOutputStream(os, foot);
@ -848,7 +848,7 @@ public class DirCache {
return nextIdx;
}
int nextEntry(final byte[] p, final int pLen, int nextIdx) {
int nextEntry(byte[] p, int pLen, int nextIdx) {
while (nextIdx < entryCnt) {
final DirCacheEntry next = sortedEntries[nextIdx];
if (!DirCacheTree.peq(p, next.path, pLen))

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

@ -312,7 +312,7 @@ public class DirCacheEntry {
System.arraycopy(src.info, src.infoOffset, info, 0, INFO_LEN);
}
void write(final OutputStream os) throws IOException {
void write(OutputStream os) throws IOException {
final int len = isExtended() ? INFO_LEN_EXTENDED : INFO_LEN;
final int pathLen = path.length;
os.write(info, infoOffset, len);
@ -719,7 +719,7 @@ public class DirCacheEntry {
* @param keepStage
* if true, the stage attribute will not be copied
*/
void copyMetaData(final DirCacheEntry src, boolean keepStage) {
void copyMetaData(DirCacheEntry src, boolean keepStage) {
int origflags = NB.decodeUInt16(info, infoOffset + P_FLAGS);
int newflags = NB.decodeUInt16(src.info, src.infoOffset + P_FLAGS);
System.arraycopy(src.info, src.infoOffset, info, infoOffset, INFO_LEN);
@ -771,7 +771,7 @@ public class DirCacheEntry {
}
}
static String toString(final byte[] path) {
static String toString(byte[] path) {
return Constants.CHARSET.decode(ByteBuffer.wrap(path)).toString();
}

2
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheIterator.java vendored

@ -124,7 +124,7 @@ public class DirCacheIterator extends AbstractTreeIterator {
parseEntry();
}
DirCacheIterator(final DirCacheIterator p, final DirCacheTree dct) {
DirCacheIterator(DirCacheIterator p, DirCacheTree dct) {
super(p, p.path, p.pathLen + 1);
cache = p.cache;
tree = dct;

6
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheTree.java vendored

@ -185,7 +185,7 @@ public class DirCacheTree {
childCnt = subcnt;
}
void write(final byte[] tmp, final OutputStream os) throws IOException {
void write(byte[] tmp, OutputStream os) throws IOException {
int ptr = tmp.length;
tmp[--ptr] = '\n';
ptr = RawParseUtils.formatBase10(tmp, ptr, childCnt);
@ -404,7 +404,7 @@ public class DirCacheTree {
return encodedName.length;
}
final boolean contains(final byte[] a, int aOff, final int aLen) {
final boolean contains(byte[] a, int aOff, int aLen) {
final byte[] e = encodedName;
final int eLen = e.length;
for (int eOff = 0; eOff < eLen && aOff < aLen; eOff++, aOff++)
@ -531,7 +531,7 @@ public class DirCacheTree {
children[n] = null;
}
static boolean peq(final byte[] a, final byte[] b, int aLen) {
static boolean peq(byte[] a, byte[] b, int aLen) {
if (b.length < aLen)
return false;
for (aLen--; aLen >= 0; aLen--)

2
org.eclipse.jgit/src/org/eclipse/jgit/errors/CompoundException.java

@ -59,7 +59,7 @@ public class CompoundException extends Exception {
private static String format(Collection<Throwable> causes) {
final StringBuilder msg = new StringBuilder();
msg.append(JGitText.get().failureDueToOneOfTheFollowing);
for (final Throwable c : causes) {
for (Throwable c : causes) {
msg.append(" "); //$NON-NLS-1$
msg.append(c.getMessage());
msg.append("\n"); //$NON-NLS-1$

2
org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingBundlePrerequisiteException.java

@ -59,7 +59,7 @@ public class MissingBundlePrerequisiteException extends TransportException {
private static String format(Map<ObjectId, String> missingCommits) {
final StringBuilder r = new StringBuilder();
r.append(JGitText.get().missingPrerequisiteCommits);
for (final Map.Entry<ObjectId, String> e : missingCommits.entrySet()) {
for (Map.Entry<ObjectId, String> e : missingCommits.entrySet()) {
r.append("\n "); //$NON-NLS-1$
r.append(e.getKey().name());
if (e.getValue() != null)

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

@ -61,7 +61,7 @@ final class GroupHead extends AbstractHead {
private final boolean inverse;
GroupHead(String pattern, final String wholePattern)
GroupHead(String pattern, String wholePattern)
throws InvalidPatternException {
super(false);
this.characterClasses = new ArrayList<>();
@ -214,7 +214,7 @@ final class GroupHead extends AbstractHead {
private static final class OneCharacterPattern implements CharacterPattern {
private char expectedCharacter;
OneCharacterPattern(final char c) {
OneCharacterPattern(char c) {
this.expectedCharacter = c;
}

2
org.eclipse.jgit/src/org/eclipse/jgit/fnmatch/RestrictedWildCardHead.java

@ -47,7 +47,7 @@ package org.eclipse.jgit.fnmatch;
final class RestrictedWildCardHead extends AbstractHead {
private final char excludedCharacter;
RestrictedWildCardHead(final char excludedCharacter, final boolean star) {
RestrictedWildCardHead(char excludedCharacter, boolean star) {
super(star);
this.excludedCharacter = excludedCharacter;
}

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java

@ -497,7 +497,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
} while (!packList.compareAndSet(o, n));
}
PackList scanPacks(final PackList original) throws IOException {
PackList scanPacks(PackList original) throws IOException {
PackList o, n;
synchronized (packList) {
do {

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjectToPack.java

@ -60,7 +60,7 @@ class DfsObjectToPack extends ObjectToPack {
/** Length of the data section of the object. */
long length;
DfsObjectToPack(AnyObjectId src, final int type) {
DfsObjectToPack(AnyObjectId src, int type) {
super(src, type);
}

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteArrayWindow.java

@ -58,7 +58,7 @@ import org.eclipse.jgit.internal.storage.pack.PackOutputStream;
final class ByteArrayWindow extends ByteWindow {
private final byte[] array;
ByteArrayWindow(final PackFile pack, final long o, final byte[] b) {
ByteArrayWindow(PackFile pack, long o, byte[] b) {
super(pack, o, b.length);
array = b;
}

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteBufferWindow.java

@ -60,7 +60,7 @@ import org.eclipse.jgit.internal.storage.pack.PackOutputStream;
final class ByteBufferWindow extends ByteWindow {
private final ByteBuffer buffer;
ByteBufferWindow(final PackFile pack, final long o, final ByteBuffer b) {
ByteBufferWindow(PackFile pack, long o, ByteBuffer b) {
super(pack, o, b.capacity());
buffer = b;
}

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ByteWindow.java

@ -86,7 +86,7 @@ abstract class ByteWindow {
return (int) (end - start);
}
final boolean contains(final PackFile neededFile, final long neededPos) {
final boolean contains(PackFile neededFile, long neededPos) {
return pack == neededFile && start <= neededPos && neededPos < end;
}

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/CachedObjectDirectory.java

@ -205,7 +205,7 @@ class CachedObjectDirectory extends FileObjectDatabase {
}
@Override
ObjectLoader openObject(final WindowCursor curs, final AnyObjectId objectId)
ObjectLoader openObject(WindowCursor curs, AnyObjectId objectId)
throws IOException {
return openObject(curs, objectId, null);
}

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

@ -82,7 +82,7 @@ class DeltaBaseCache {
cache = new Slot[CACHE_SZ];
}
Entry get(final PackFile pack, final long position) {
Entry get(PackFile pack, long position) {
Slot e = cache[hash(position)];
if (e == null)
return null;
@ -168,7 +168,7 @@ class DeltaBaseCache {
final int type;
Entry(final byte[] aData, final int aType) {
Entry(byte[] aData, int aType) {
data = aData;
type = aType;
}

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

Loading…
Cancel
Save