Merge branch 'master' into stable-5.3
* master:
Update Orbit to R20190226160451
Upgrade maven-javadoc-plugin to 3.1.0
diff: add option metaVar for --src-prefix and --dst-prefix
ResolveMerger: Destroy TemporaryBuffer on unchecked exceptions
Expose the filter blob limit in UploadPack
Upgrade error_prone_core to 2.3.3
On Windows use %APPDATA%\gnupg as GPG directory if it exists
Remove duplicate externalized message
RebaseCommand: tighten check for --preserve-merges on --continue
RebaseCommand: fix ONTO_NAME, and --preserve-merges is interactive
RebaseCommand: use orig-head to abort
Fix core.autocrlf for non-normalized index
RebaseCommand: use orig-head in addition to head
SHA1: Use externalized message in log
JGitText: Remove unnecessary suffix from externalized message identifier
FS_POSIX: Externalize log message
Strongly reference indices in DfsPackFile
Update Orbit to S20190219190953
Update README
Update README
Add missing @since tag for new API method getUpdateIndex
Fix NPE in PlotCommitList
CommitBuilder: Deprecate setEncoding(String)
CommitBuilder: Add missing periods on methods' Javadoc
Upgrade wagon-ssh to 3.3.2
Fix bug in copyPackBypassCache's skip 'PACK' header logic
Upgrade spotbugs to 3.1.11
Atomic file creation: hard-linking may not be allowed
Update Orbit to S20190129210011
Fix GC.deleteEmptyRefsFolders
Enable cloning only specific tags
Delete jgit-4.5 target platform
Add 4.11-staging target platform and update Orbit to I20190123233226
Upgrade jacoco-maven-plugin to 0.8.3
Bazel: Format BUILD file with buildifier
RenameBranchCommand: more consistent handling of short ref names
SshdSessionFactory: generalize providing default keys
Allow to check for signing key
Handle premature EOF in BundleFetchConnection
pgm: Fix missing braces in Version.run()
pgm: Handle IOException in Version command
pgm: Fix missing braces in UploadPack.run()
pgm: Handle IOException in UploadPack command
pgm: Handle exceptions in Tag command
pgm: Fix missing braces in Status.run()
pgm: Handle exceptions in Status command
pgm: Fix missing braces in ShowRef.run()
pgm: Handle IOException in ShowRef command
pgm: Fix missing braces in Show.run()
pgm: Handle exceptions in Show command
pgm: Fix missing braces in Rm command
pgm: Handle GitAPIException in Rm command
pgm: Handle exceptions in RevParse command
pgm: Externalize error message
pgm: Fix missing braces in Reset.run()
pgm: Handle GitAPIException in Reset command
pgm: Handle GitAPIException in Repo command
pgm: Handle exceptions in Remote command
pgm: Handle exceptions in Reflog command
pgm: Handle IOException in ReceivePack command
SmartClientSmartServerTest: Open Repository in try-with-resource
SmartClientSmartServerTest: Open ObjectInserter.Formatter in try-with-resource
SmartClientSmartServerTest#addBrokenContext: Remove unused TestRepository
IO: Open TemporaryBuffer.Heap in try-with-resource
GitSmartHttpTools: Open SideBandOutputStream in try-with-resource
TemporaryBufferTest: Open TemporaryBuffer in try-with-resource
Scanner: Open RevWalk in try-with-resource
SubmoduleWalkTest: Open Repository in try-with-resource
SideBandOutputStreamTest: Open SideBandOutputStream in try-with-resource
UnionInputStreamTest: Open UnionInputStream in try-with-resource
Merge: Avoid non-localised literal string warning for "recursive"
pgm: Fix missing braces in Push.run()
pgm: Handle exceptions in Push command
pgm: Fix missing braces in MergeBase.run()
pgm: Handle IOException in MergeBase command
pgm: Fix missing braces in Merge command
pgm: Handle exceptions in Merge command
pgm: Fix missing braces in LsTree.run()
pgm: Handle exceptions in LsTree command
pgm: Fix missing braces in LsRemote.run()
pgm: Handle exceptions in LsRemote command
pgm: Handle exceptions in LsFiles command
pgm: Fix missing braces in Log.run()
pgm: Handle exceptions in Log command
pgm: Handle exceptions in Init command
pgm: Handle IOException in IndexPack command
pgm: Fix missing braces in Fetch.run()
pgm: Handle IOException in Fetch command
pgm: Handle GitAPIException in Gc command
pgm: Fix missing braces in DiffTree.run()
pgm: Handle exceptions in DiffTree command
pgm: Fix missing braces in Diff.run()
pgm: Handle exceptions in Diff command
RawParseUtils: Avoid import of java.nio.charset.StandardCharsets
Consistently import constants from StandardCharsets as static
LocalDiskRepositoryTestCase#createRepository: Default auto-close to false
UploadPack: Suppress false-positive resource leak warning
PushConnectionTest: Open TestRepository in try-with-resource
MergerTest: Open TestRepository in try-with-resource
MergeCommandTest: Open TestRepository in try-with-resource
PackWriterTest: Open TestRepository in try-with-resource
ReceivePackAdvertiseRefsHookTest: Open TestRepository in try-with-resource
SubmoduleStatusTest: Open TestRepository in try-with-resource
UploadPackTest: Open TestRepository in try-with-resource
PackParserTest: Open TestRepository in try-with-resource
SmartClientSmartServerTest: Open TestRepository in try-with-resource
Stop using deprecated methods of RemoteSetUrlCommand/RemoteRemoveCommand
SmartClientSmartServerTest: Stop using deprecated Repository#hasObject
DumbClientSmartServerTest: Open TestRepository in try-with-resource
DumbClientDumbServerTest: Open TestRepository in try-with-resource
DirCacheCheckoutTest: Open TestRepository in try-with-resource
HttpTestCase#fsck: Open TestRepository in try-with-resource
CheckoutCommandTest: Add comment to document intentionally empty catch block
pgm: Fix missing braces in Describe.run()
pgm: Handle exceptions in Describe command
pgm: Handle exceptions in Config command
pgm: Fix too wide lines in Commit.run()
pgm: Fix missing braces in Commit.run()
pgm: Handle exceptions in Commit command
pgm: Handle exceptions in Clean command
pgm: Handle GitAPIException in Fetch command
Fix missing braces in Branch.run()
pgm: Handle exceptions in Branch command
Fix missing braces in Blame.run()
pgm: Handle NoWorkTreeException and IOException in Blame command
Use try-with-resource for reader in Blame.run()
pgm: Handle GitAPIException in Add command
Change-Id: I6d546885beb9596120e201973995a7c6bfe115e0
diff --git a/README.md b/README.md
index 54133e1..091accd 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,16 @@
-Java Git
-========
+# Java Git
An implementation of the Git version control system in pure Java.
-This package is licensed under the EDL (Eclipse Distribution
+This project is licensed under the __EDL__ (Eclipse Distribution
License).
-JGit can be imported straight into Eclipse, built and tested from
-there, but the automated builds use Maven.
+JGit can be imported straight into Eclipse and built and tested from
+there. It can be built from the command line using
+[Maven](https://maven.apache.org/) or [Bazel](https://bazel.build/).
+The CI builds use Maven and run on [Jenkins](https://ci.eclipse.org/jgit/).
-- org.eclipse.jgit
+- __org.eclipse.jgit__
A pure Java library capable of being run standalone, with no
additional support libraries. It provides classes to read and
@@ -18,63 +19,73 @@
All portions of JGit are covered by the EDL. Absolutely no GPL,
LGPL or EPL contributions are accepted within this package.
-- org.eclipse.jgit.ant
+- __org.eclipse.jgit.ant__
Ant tasks based on JGit.
-- org.eclipse.jgit.archive
+- __org.eclipse.jgit.archive__
Support for exporting to various archive formats (zip etc).
-- org.eclipse.jgit.http.apache
+- __org.eclipse.jgit.http.apache__
- Apache httpclient support
+ [Apache httpclient](https://hc.apache.org/httpcomponents-client-ga/) support.
-- org.eclipse.jgit.http.server
+- __org.eclipse.jgit.http.server__
- Server for the smart and dumb Git HTTP protocol.
+ Server for the smart and dumb
+ [Git HTTP protocol](https://github.com/git/git/blob/master/Documentation/technical/http-protocol.txt).
-- org.eclipse.jgit.pgm
+- __org.eclipse.jgit.lfs__
- Command-line interface Git commands implemented using JGit
- ("pgm" stands for program).
+ Support for [LFS](https://git-lfs.github.com/) (Large File Storage).
-- org.eclipse.jgit.packaging
+- __org.eclipse.jgit.lfs.server__
+
+ Basic LFS server support.
+
+- __org.eclipse.jgit.packaging__
Production of Eclipse features and p2 repository for JGit. See the JGit
Wiki on why and how to use this module.
-Tests
------
+- __org.eclipse.jgit.pgm__
-- org.eclipse.jgit.junit
+ Command-line interface Git commands implemented using JGit
+ ("pgm" stands for program).
- Helpers for unit testing
+- __org.eclipse.jgit.ssh.apache__
-- org.eclipse.jgit.test
+ Client support for the ssh protocol based on
+ [Apache Mina sshd](https://mina.apache.org/sshd-project/).
- Unit tests for org.eclipse.jgit
+- __org.eclipse.jgit.ui__
-- org.eclipse.jgit.ant.test
-- org.eclipse.jgit.pgm.test
-- org.eclipse.jgit.http.test
-- org.eclipse.jgit.junit.test
+ Simple UI for displaying git log.
- No further description needed
+## Tests
-Warnings/Caveats
-----------------
+- __org.eclipse.jgit.junit__, __org.eclipse.jgit.junit.http__,
+__org.eclipse.jgit.junit.ssh__: Helpers for unit testing
+- __org.eclipse.jgit.ant.test__: Unit tests for org.eclipse.jgit.ant
+- __org.eclipse.jgit.http.test__: Unit tests for org.eclipse.jgit.http.server
+- __org.eclipse.jgit.lfs.server.test__: Unit tests for org.eclipse.jgit.lfs.server
+- __org.eclipse.jgit.lfs.test__: Unit tests for org.eclipse.jgit.lfs
+- __org.eclipse.jgit.pgm.test__: Unit tests for org.eclipse.jgit.pgm
+- __org.eclipse.jgit.ssh.apache.test__: Unit tests for org.eclipse.jgit.ssh.apache
+- __org.eclipse.jgit.test__: Unit tests for org.eclipse.jgit
-- Native smbolic links are supported, provided the file system supports
- them. For Windows you must have Windows Vista/Windows 2008 or newer,
- use a non-administrator account and have the SeCreateSymbolicLinkPrivilege.
+## Warnings/Caveats
-- Only the timestamp of the index is used by jgit if the index is
+- Native symbolic links are supported, provided the file system supports
+ them. For Windows you must use a non-administrator account and have the SeCreateSymbolicLinkPrivilege.
+
+- Only the timestamp of the index is used by JGit if the index is
dirty.
- JGit requires at least a Java 8 JDK.
-- CRLF conversion is performed depending on the core.autocrlf setting,
+- CRLF conversion is performed depending on the `core.autocrlf` setting,
however Git for Windows by default stores that setting during
installation in the "system wide" configuration file. If Git is not
installed, use the global or repository configuration for the
@@ -88,102 +99,69 @@
is installed. Modifying PATH is the recommended option if C Git is
installed.
-- We try to use the same notation of $HOME as C Git does. On Windows
- this is often not the same value as the user.home system property.
+- We try to use the same notation of `$HOME` as C Git does. On Windows
+ this is often not the same value as the `user.home` system property.
+## Features
-Package Features
-----------------
-
-- org.eclipse.jgit/
-
- * Read loose and packed commits, trees, blobs, including
- deltafied objects.
-
- * Read objects from shared repositories
-
- * Write loose commits, trees, blobs.
-
- * Write blobs from local files or Java InputStreams.
-
- * Read blobs as Java InputStreams.
-
- * Copy trees to local directory, or local directory to a tree.
-
- * Lazily loads objects as necessary.
-
- * Read and write .git/config files.
-
- * Create a new repository.
-
- * Read and write refs, including walking through symrefs.
-
- * Read, update and write the Git index.
-
- * Checkout in dirty working directory if trivial.
-
- * Walk the history from a given set of commits looking for commits
+- __org.eclipse.jgit__
+ - Read loose and packed commits, trees, blobs, including
+ deltafied objects.
+ - Read objects from shared repositories
+ - Write loose commits, trees, blobs.
+ - Write blobs from local files or Java InputStreams.
+ - Read blobs as Java InputStreams.
+ - Copy trees to local directory, or local directory to a tree.
+ - Lazily loads objects as necessary.
+ - Read and write .git/config files.
+ - Create a new repository.
+ - Read and write refs, including walking through symrefs.
+ - Read, update and write the Git index.
+ - Checkout in dirty working directory if trivial.
+ - Walk the history from a given set of commits looking for commits
introducing changes in files under a specified path.
+ - Object transport
- * Object transport
Fetch via ssh, git, http, Amazon S3 and bundles.
Push via ssh, git and Amazon S3. JGit does not yet deltify
the pushed packs so they may be a lot larger than C Git packs.
- * Garbage collection
+ - Garbage collection
+ - Merge
+ - Rebase
+ - And much more
- * Merge
-
- * Rebase
-
- * And much more
-
-- org.eclipse.jgit.pgm/
-
- * Assorted set of command line utilities. Mostly for ad-hoc testing of jgit
+- __org.eclipse.jgit.pgm__
+ - Assorted set of command line utilities. Mostly for ad-hoc testing of jgit
log, glog, fetch etc.
+- __org.eclipse.jgit.ant__
+ - Ant tasks
+- __org.eclipse.jgit.archive__
+ - Support for Zip/Tar and other formats
+- __org.eclipse.http__
+ - HTTP client and server support
-- org.eclipse.jgit.ant/
-
- * Ant tasks
-
-- org.eclipse.jgit.archive/
-
- * Support for Zip/Tar and other formats
-
-- org.eclipse.http.*/
-
- * HTTP client and server support
-
-Missing Features
-----------------
+## Missing Features
There are some missing features:
-- gitattributes support
+- verifying signed commits
+- signing tags
+- signing push
+## Support
-Support
--------
+Post questions, comments or discussions to the jgit-dev@eclipse.org mailing list.
+You need to be [subscribed](https://dev.eclipse.org/mailman/listinfo/jgit-dev)
+to post. File bugs and enhancement requests in
+[Bugzilla](https://wiki.eclipse.org/EGit/Contributor_Guide#Filing_Bugs).
-Post question, comments or patches to the jgit-dev@eclipse.org mailing list.
-You need to be subscribed to post, see here:
+## Contributing
-https://dev.eclipse.org/mailman/listinfo/jgit-dev
+See the [EGit Contributor Guide](http://wiki.eclipse.org/EGit/Contributor_Guide).
-
-Contributing
-------------
-
-See the EGit Contributor Guide:
-
-http://wiki.eclipse.org/EGit/Contributor_Guide
-
-
-About Git
----------
+## About Git
More information about Git, its repository format, and the canonical
-C based implementation can be obtained from the Git website:
-
-http://git-scm.com/
+C based implementation can be obtained from the
+[Git website](http://git-scm.com/).
diff --git a/WORKSPACE b/WORKSPACE
index 31820fc..c9ffb73 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -48,14 +48,14 @@
maven_jar(
name = "httpclient",
- artifact = "org.apache.httpcomponents:httpclient:4.5.5",
- sha1 = "1603dfd56ebcd583ccdf337b6c3984ac55d89e58",
+ artifact = "org.apache.httpcomponents:httpclient:4.5.6",
+ sha1 = "1afe5621985efe90a92d0fbc9be86271efbe796f",
)
maven_jar(
name = "httpcore",
- artifact = "org.apache.httpcomponents:httpcore:4.4.9",
- sha1 = "a86ce739e5a7175b4b234c290a00a5fdb80957a0",
+ artifact = "org.apache.httpcomponents:httpcore:4.4.10",
+ sha1 = "acc54d9b28bdffe4bbde89ed2e4a1e86b5285e2b",
)
maven_jar(
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java
index 8961d1b..5e09d01 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java
@@ -299,10 +299,11 @@ private static boolean isReceivePackSideBand(HttpServletRequest req) {
private static void writeSideBand(OutputStream out, String textForGit)
throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- OutputStream msg = new SideBandOutputStream(CH_ERROR, SMALL_BUF, out);
- msg.write(Constants.encode("error: " + textForGit));
- msg.flush();
+ try (OutputStream msg = new SideBandOutputStream(CH_ERROR, SMALL_BUF,
+ out)) {
+ msg.write(Constants.encode("error: " + textForGit));
+ msg.flush();
+ }
}
private static void writePacket(PacketLineOut pckOut, String textForGit)
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
index 422be56..c1e55cb 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
@@ -213,7 +213,10 @@ public void testInitialClone_Loose() throws Exception {
@Test
public void testInitialClone_Packed() throws Exception {
- new TestRepository<>(remoteRepository).packAndPrune();
+ try (TestRepository<Repository> tr = new TestRepository<>(
+ remoteRepository)) {
+ tr.packAndPrune();
+ }
Repository dst = createBareRepository();
assertFalse(dst.getObjectDatabase().has(A_txt));
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
index 5fdc10e..2d22baf 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
@@ -215,7 +215,10 @@ public void testInitialClone_Small() throws Exception {
@Test
public void testInitialClone_Packed() throws Exception {
- new TestRepository<>(remoteRepository).packAndPrune();
+ try (TestRepository<Repository> tr = new TestRepository<>(
+ remoteRepository)) {
+ tr.packAndPrune();
+ }
Repository dst = createBareRepository();
assertFalse(dst.getObjectDatabase().has(A_txt));
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
index ecab61e..aad029c 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
@@ -208,7 +208,7 @@ public UploadPack create(HttpServletRequest req, Repository db)
ServletContextHandler app = addNormalContext(gs, src, srcName);
- ServletContextHandler broken = addBrokenContext(gs, src, srcName);
+ ServletContextHandler broken = addBrokenContext(gs, srcName);
ServletContextHandler redirect = addRedirectContext(gs);
@@ -287,8 +287,8 @@ public void destroy() {
return app;
}
- @SuppressWarnings("unused")
- private ServletContextHandler addBrokenContext(GitServlet gs, TestRepository<Repository> src, String srcName) {
+ private ServletContextHandler addBrokenContext(GitServlet gs,
+ String srcName) {
ServletContextHandler broken = server.addContext("/bad");
broken.addFilter(new FilterHolder(new Filter() {
@@ -416,12 +416,11 @@ public void destroy() {
@Test
public void testListRemote() throws IOException {
- Repository dst = createBareRepository();
-
assertEquals("http", remoteURI.getScheme());
Map<String, Ref> map;
- try (Transport t = Transport.open(dst, remoteURI)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, remoteURI)) {
// I didn't make up these public interface names, I just
// approved them for inclusion into the code base. Sorry.
// --spearce
@@ -459,9 +458,9 @@ public void testListRemote() throws IOException {
@Test
public void testListRemote_BadName() throws IOException, URISyntaxException {
- Repository dst = createBareRepository();
URIish uri = new URIish(this.remoteURI.toString() + ".invalid");
- try (Transport t = Transport.open(dst, uri)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, uri)) {
try {
t.openFetch();
fail("fetch connection opened");
@@ -486,23 +485,20 @@ public void testListRemote_BadName() throws IOException, URISyntaxException {
@Test
public void testFetchBySHA1() throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.hasObject(A_txt));
-
- try (Transport t = Transport.open(dst, remoteURI)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, remoteURI)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.fetch(NullProgressMonitor.INSTANCE,
Collections.singletonList(new RefSpec(B.name())));
+ assertTrue(dst.getObjectDatabase().has(A_txt));
}
-
- assertTrue(dst.hasObject(A_txt));
}
@Test
public void testFetchBySHA1Unreachable() throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.hasObject(A_txt));
-
- try (Transport t = Transport.open(dst, remoteURI)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, remoteURI)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
thrown.expect(TransportException.class);
thrown.expectMessage(Matchers.containsString(
"want " + unreachableCommit.name() + " not valid"));
@@ -514,9 +510,6 @@ public void testFetchBySHA1Unreachable() throws Exception {
@Test
public void testFetchBySHA1UnreachableByAdvertiseRefsHook()
throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.hasObject(A_txt));
-
advertiseRefsHook = new AbstractAdvertiseRefsHook() {
@Override
protected Map<String, Ref> getAdvertisedRefs(Repository repository,
@@ -525,7 +518,9 @@ protected Map<String, Ref> getAdvertisedRefs(Repository repository,
}
};
- try (Transport t = Transport.open(dst, remoteURI)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, remoteURI)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
thrown.expect(TransportException.class);
thrown.expectMessage(Matchers.containsString(
"want " + A.name() + " not valid"));
@@ -536,17 +531,15 @@ protected Map<String, Ref> getAdvertisedRefs(Repository repository,
@Test
public void testInitialClone_Small() throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
-
- try (Transport t = Transport.open(dst, remoteURI)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, remoteURI)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
+ assertTrue(dst.getObjectDatabase().has(A_txt));
+ assertEquals(B, dst.exactRef(master).getObjectId());
+ fsck(dst, B);
}
- assertTrue(dst.getObjectDatabase().has(A_txt));
- assertEquals(B, dst.exactRef(master).getObjectId());
- fsck(dst, B);
-
List<AccessEvent> requests = getRequests();
assertEquals(2, requests.size());
@@ -576,21 +569,20 @@ public void testInitialClone_Small() throws Exception {
private void initialClone_Redirect(int nofRedirects, int code)
throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
-
URIish cloneFrom = redirectURI;
if (code != 301 || nofRedirects > 1) {
cloneFrom = extendPath(cloneFrom,
"/response/" + nofRedirects + "/" + code);
}
- try (Transport t = Transport.open(dst, cloneFrom)) {
- t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
- }
- assertTrue(dst.getObjectDatabase().has(A_txt));
- assertEquals(B, dst.exactRef(master).getObjectId());
- fsck(dst, B);
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, cloneFrom)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
+ t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
+ assertTrue(dst.getObjectDatabase().has(A_txt));
+ assertEquals(B, dst.exactRef(master).getObjectId());
+ fsck(dst, B);
+ }
List<AccessEvent> requests = getRequests();
assertEquals(2 + nofRedirects, requests.size());
@@ -665,12 +657,12 @@ public void testInitialClone_RedirectTooOften() throws Exception {
.openUserConfig(null, FS.DETECTED);
userConfig.setInt("http", null, "maxRedirects", 3);
userConfig.save();
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
URIish cloneFrom = extendPath(redirectURI, "/response/4/302");
String remoteUri = cloneFrom.toString();
- try (Transport t = Transport.open(dst, cloneFrom)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, cloneFrom)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
fail("Should have failed (too many redirects)");
} catch (TransportException e) {
@@ -687,11 +679,10 @@ public void testInitialClone_RedirectTooOften() throws Exception {
@Test
public void testInitialClone_RedirectLoop() throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
-
URIish cloneFrom = extendPath(redirectURI, "/loop");
- try (Transport t = Transport.open(dst, cloneFrom)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, cloneFrom)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
fail("Should have failed (redirect loop)");
} catch (TransportException e) {
@@ -705,18 +696,17 @@ public void testInitialClone_RedirectOnPostAllowed() throws Exception {
.openUserConfig(null, FS.DETECTED);
userConfig.setString("http", null, "followRedirects", "true");
userConfig.save();
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
URIish cloneFrom = extendPath(remoteURI, "/post");
- try (Transport t = Transport.open(dst, cloneFrom)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, cloneFrom)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
+ assertTrue(dst.getObjectDatabase().has(A_txt));
+ assertEquals(B, dst.exactRef(master).getObjectId());
+ fsck(dst, B);
}
- assertTrue(dst.getObjectDatabase().has(A_txt));
- assertEquals(B, dst.exactRef(master).getObjectId());
- fsck(dst, B);
-
List<AccessEvent> requests = getRequests();
assertEquals(3, requests.size());
@@ -750,11 +740,10 @@ public void testInitialClone_RedirectOnPostAllowed() throws Exception {
@Test
public void testInitialClone_RedirectOnPostForbidden() throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
-
URIish cloneFrom = extendPath(remoteURI, "/post");
- try (Transport t = Transport.open(dst, cloneFrom)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, cloneFrom)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
fail("Should have failed (redirect on POST)");
} catch (TransportException e) {
@@ -769,10 +758,9 @@ public void testInitialClone_RedirectForbidden() throws Exception {
userConfig.setString("http", null, "followRedirects", "false");
userConfig.save();
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
-
- try (Transport t = Transport.open(dst, redirectURI)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, redirectURI)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
fail("Should have failed (redirects forbidden)");
} catch (TransportException e) {
@@ -783,18 +771,16 @@ public void testInitialClone_RedirectForbidden() throws Exception {
@Test
public void testInitialClone_WithAuthentication() throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
-
- try (Transport t = Transport.open(dst, authURI)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, authURI)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.setCredentialsProvider(testCredentials);
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
+ assertTrue(dst.getObjectDatabase().has(A_txt));
+ assertEquals(B, dst.exactRef(master).getObjectId());
+ fsck(dst, B);
}
- assertTrue(dst.getObjectDatabase().has(A_txt));
- assertEquals(B, dst.exactRef(master).getObjectId());
- fsck(dst, B);
-
List<AccessEvent> requests = getRequests();
assertEquals(3, requests.size());
@@ -829,10 +815,9 @@ public void testInitialClone_WithAuthentication() throws Exception {
@Test
public void testInitialClone_WithAuthenticationNoCredentials()
throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
-
- try (Transport t = Transport.open(dst, authURI)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, authURI)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
fail("Should not have succeeded -- no authentication");
} catch (TransportException e) {
@@ -851,10 +836,9 @@ public void testInitialClone_WithAuthenticationNoCredentials()
@Test
public void testInitialClone_WithAuthenticationWrongCredentials()
throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
-
- try (Transport t = Transport.open(dst, authURI)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, authURI)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.setCredentialsProvider(new UsernamePasswordCredentialsProvider(
AppServer.username, "wrongpassword"));
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
@@ -877,9 +861,6 @@ public void testInitialClone_WithAuthenticationWrongCredentials()
@Test
public void testInitialClone_WithAuthenticationAfterRedirect()
throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
-
URIish cloneFrom = extendPath(redirectURI, "/target/auth");
CredentialsProvider uriSpecificCredentialsProvider = new UsernamePasswordCredentialsProvider(
"unknown", "none") {
@@ -897,15 +878,16 @@ public boolean get(URIish uri, CredentialItem... items)
return super.get(uri, items);
}
};
- try (Transport t = Transport.open(dst, cloneFrom)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, cloneFrom)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.setCredentialsProvider(uriSpecificCredentialsProvider);
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
+ assertTrue(dst.getObjectDatabase().has(A_txt));
+ assertEquals(B, dst.exactRef(master).getObjectId());
+ fsck(dst, B);
}
- assertTrue(dst.getObjectDatabase().has(A_txt));
- assertEquals(B, dst.exactRef(master).getObjectId());
- fsck(dst, B);
-
List<AccessEvent> requests = getRequests();
assertEquals(4, requests.size());
@@ -946,18 +928,16 @@ public boolean get(URIish uri, CredentialItem... items)
@Test
public void testInitialClone_WithAuthenticationOnPostOnly()
throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
-
- try (Transport t = Transport.open(dst, authOnPostURI)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, authOnPostURI)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
t.setCredentialsProvider(testCredentials);
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
+ assertTrue(dst.getObjectDatabase().has(A_txt));
+ assertEquals(B, dst.exactRef(master).getObjectId());
+ fsck(dst, B);
}
- assertTrue(dst.getObjectDatabase().has(A_txt));
- assertEquals(B, dst.exactRef(master).getObjectId());
- fsck(dst, B);
-
List<AccessEvent> requests = getRequests();
assertEquals(3, requests.size());
@@ -1008,8 +988,12 @@ public void testFetch_FewLocalCommits() throws Exception {
// Create a new commit on the remote.
//
- b = new TestRepository<>(remoteRepository).branch(master);
- RevCommit Z = b.commit().message("Z").create();
+ RevCommit Z;
+ try (TestRepository<Repository> tr = new TestRepository<>(
+ remoteRepository)) {
+ b = tr.branch(master);
+ Z = b.commit().message("Z").create();
+ }
// Now incrementally update.
//
@@ -1068,8 +1052,12 @@ public void testFetch_TooManyLocalCommits() throws Exception {
// Create a new commit on the remote.
//
- b = new TestRepository<>(remoteRepository).branch(master);
- RevCommit Z = b.commit().message("Z").create();
+ RevCommit Z;
+ try (TestRepository<Repository> tr = new TestRepository<>(
+ remoteRepository)) {
+ b = tr.branch(master);
+ Z = b.commit().message("Z").create();
+ }
// Now incrementally update.
//
@@ -1123,10 +1111,9 @@ public void testFetch_TooManyLocalCommits() throws Exception {
@Test
public void testInitialClone_BrokenServer() throws Exception {
- Repository dst = createBareRepository();
- assertFalse(dst.getObjectDatabase().has(A_txt));
-
- try (Transport t = Transport.open(dst, brokenURI)) {
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, brokenURI)) {
+ assertFalse(dst.getObjectDatabase().has(A_txt));
try {
t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
fail("fetch completed despite upload-pack being broken");
@@ -1161,12 +1148,14 @@ public void testInitialClone_BrokenServer() throws Exception {
@Test
public void testInvalidWant() throws Exception {
- @SuppressWarnings("resource")
- ObjectId id = new ObjectInserter.Formatter().idFor(Constants.OBJ_BLOB,
- "testInvalidWant".getBytes(UTF_8));
+ ObjectId id;
+ try (ObjectInserter.Formatter formatter = new ObjectInserter.Formatter()) {
+ id = formatter.idFor(Constants.OBJ_BLOB,
+ "testInvalidWant".getBytes(UTF_8));
+ }
- Repository dst = createBareRepository();
- try (Transport t = Transport.open(dst, remoteURI);
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, remoteURI);
FetchConnection c = t.openFetch()) {
Ref want = new ObjectIdRef.Unpeeled(Ref.Storage.NETWORK, id.name(),
id);
@@ -1203,8 +1192,8 @@ public void testFetch_RefsUnreadableOnUpload() throws Exception {
URIish badRefsURI = new URIish(noRefServer.getURI()
.resolve(app.getContextPath() + "/" + repoName).toString());
- Repository dst = createBareRepository();
- try (Transport t = Transport.open(dst, badRefsURI);
+ try (Repository dst = createBareRepository();
+ Transport t = Transport.open(dst, badRefsURI);
FetchConnection c = t.openFetch()) {
// We start failing here to exercise the post-advertisement
// upload pack handler.
diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/HttpTestCase.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/HttpTestCase.java
index a133ca6..41bc97d 100644
--- a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/HttpTestCase.java
+++ b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/HttpTestCase.java
@@ -186,9 +186,10 @@ protected List<AccessEvent> getRequests(String path) {
*/
protected static void fsck(Repository db, RevObject... tips)
throws Exception {
- TestRepository<? extends Repository> tr =
- new TestRepository<>(db);
- tr.fsck(tips);
+ try (TestRepository<? extends Repository> tr =
+ new TestRepository<>(db)) {
+ tr.fsck(tips);
+ }
}
/**
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
index 12b2169..4b2eadf 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
@@ -394,10 +394,11 @@ protected FileRepository createWorkRepository() throws IOException {
* @return the newly created repository, opened for access
* @throws IOException
* the repository could not be created in the temporary area
+ * @since 5.3
*/
- private FileRepository createRepository(boolean bare)
+ protected FileRepository createRepository(boolean bare)
throws IOException {
- return createRepository(bare, true /* auto close */);
+ return createRepository(bare, false /* auto close */);
}
/**
@@ -407,11 +408,13 @@ private FileRepository createRepository(boolean bare)
* true to create a bare repository; false to make a repository
* within its working directory
* @param autoClose
- * auto close the repository in #tearDown
+ * auto close the repository in {@link #tearDown()}
* @return the newly created repository, opened for access
* @throws IOException
* the repository could not be created in the temporary area
+ * @deprecated use {@link #createRepository(boolean)} instead
*/
+ @Deprecated
public FileRepository createRepository(boolean bare, boolean autoClose)
throws IOException {
File gitdir = createUniqueTestGitDir(bare);
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/.project b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/.project
index 18caf2c..48c2bd1 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/.project
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/.project
@@ -6,6 +6,11 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
@@ -13,5 +18,6 @@
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.tpd
deleted file mode 100644
index 2cdb59a..0000000
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.tpd
+++ /dev/null
@@ -1,8 +0,0 @@
-target "jgit-4.10-staging" with source configurePhase
-
-include "projects/jetty-9.4.14.tpd"
-include "orbit/R20181128170323-2018-12.tpd"
-
-location "http://download.eclipse.org/staging/2018-12/" {
- org.eclipse.osgi lazy
-}
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.target
similarity index 84%
rename from org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target
rename to org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.target
index 0295526..1a6a0fc 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.target
@@ -1,9 +1,6 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde?>
-<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="jgit-4.5" sequenceNumber="1547541100">
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><?pde?><!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl --><target name="jgit-4.10" sequenceNumber="1551829107">
<locations>
- <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
+ <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
<unit id="org.eclipse.jetty.client.source" version="9.4.14.v20181114"/>
<unit id="org.eclipse.jetty.continuation" version="9.4.14.v20181114"/>
@@ -22,7 +19,7 @@
<unit id="org.eclipse.jetty.util.source" version="9.4.14.v20181114"/>
<repository id="jetty-9.4.14" location="http://download.eclipse.org/jetty/updates/jetty-bundles-9.x/9.4.14.v20181114"/>
</location>
- <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
+ <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<unit id="org.apache.ant" version="1.10.5.v20180808-0324"/>
<unit id="org.apache.ant.source" version="1.10.5.v20180808-0324"/>
<unit id="org.apache.commons.codec" version="1.10.0.v20180409-1845"/>
@@ -31,18 +28,18 @@
<unit id="org.apache.commons.compress.source" version="1.18.0.v20181121-2221"/>
<unit id="org.apache.commons.logging" version="1.2.0.v20180409-1502"/>
<unit id="org.apache.commons.logging.source" version="1.2.0.v20180409-1502"/>
- <unit id="org.apache.httpcomponents.httpclient" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore" version="4.4.9.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.9.v20180409-1525"/>
+ <unit id="org.apache.httpcomponents.httpclient" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpcore" version="4.4.10.v20190123-2214"/>
+ <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181107-1520"/>
+ <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -82,11 +79,11 @@
<unit id="org.apache.sshd.core.source" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp.source" version="2.0.0.v20181102-1323"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20181128170323/repository"/>
+ <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20190226160451/repository"/>
</location>
- <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
+ <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.osgi" version="0.0.0"/>
- <repository location="http://download.eclipse.org/releases/mars/"/>
+ <repository location="http://download.eclipse.org/releases/2018-12/"/>
</location>
</locations>
-</target>
+</target>
\ No newline at end of file
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.tpd
new file mode 100644
index 0000000..31981f2
--- /dev/null
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.tpd
@@ -0,0 +1,8 @@
+target "jgit-4.10" with source configurePhase
+
+include "projects/jetty-9.4.14.tpd"
+include "orbit/R20190226160451-2019-03.tpd"
+
+location "http://download.eclipse.org/releases/2018-12/" {
+ org.eclipse.osgi lazy
+}
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11-staging.target
similarity index 92%
rename from org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.target
rename to org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11-staging.target
index 83ca7c4..14cd0d7 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.target
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11-staging.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="jgit-4.10-staging" sequenceNumber="1547541125">
+<target name="jgit-4.11-staging" sequenceNumber="1551829209">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -31,18 +31,18 @@
<unit id="org.apache.commons.compress.source" version="1.18.0.v20181121-2221"/>
<unit id="org.apache.commons.logging" version="1.2.0.v20180409-1502"/>
<unit id="org.apache.commons.logging.source" version="1.2.0.v20180409-1502"/>
- <unit id="org.apache.httpcomponents.httpclient" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore" version="4.4.9.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.9.v20180409-1525"/>
+ <unit id="org.apache.httpcomponents.httpclient" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpcore" version="4.4.10.v20190123-2214"/>
+ <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181107-1520"/>
+ <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -82,11 +82,11 @@
<unit id="org.apache.sshd.core.source" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp.source" version="2.0.0.v20181102-1323"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20181128170323/repository"/>
+ <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20190226160451/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.osgi" version="0.0.0"/>
- <repository location="http://download.eclipse.org/staging/2018-12/"/>
+ <repository location="http://download.eclipse.org/staging/2019-03/"/>
</location>
</locations>
</target>
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11-staging.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11-staging.tpd
new file mode 100644
index 0000000..05002f2
--- /dev/null
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11-staging.tpd
@@ -0,0 +1,8 @@
+target "jgit-4.11-staging" with source configurePhase
+
+include "projects/jetty-9.4.14.tpd"
+include "orbit/R20190226160451-2019-03.tpd"
+
+location "http://download.eclipse.org/staging/2019-03/" {
+ org.eclipse.osgi lazy
+}
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.tpd
deleted file mode 100644
index dd72392..0000000
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.tpd
+++ /dev/null
@@ -1,8 +0,0 @@
-target "jgit-4.5" with source configurePhase
-
-include "projects/jetty-9.4.14.tpd"
-include "orbit/R20181128170323-2018-12.tpd"
-
-location "http://download.eclipse.org/releases/mars/" {
- org.eclipse.osgi lazy
-}
\ No newline at end of file
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target
index dfbb452..f8641ca 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="jgit-4.6" sequenceNumber="1547541085">
+<target name="jgit-4.6" sequenceNumber="1551829238">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -31,18 +31,18 @@
<unit id="org.apache.commons.compress.source" version="1.18.0.v20181121-2221"/>
<unit id="org.apache.commons.logging" version="1.2.0.v20180409-1502"/>
<unit id="org.apache.commons.logging.source" version="1.2.0.v20180409-1502"/>
- <unit id="org.apache.httpcomponents.httpclient" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore" version="4.4.9.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.9.v20180409-1525"/>
+ <unit id="org.apache.httpcomponents.httpclient" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpcore" version="4.4.10.v20190123-2214"/>
+ <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181107-1520"/>
+ <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -82,7 +82,7 @@
<unit id="org.apache.sshd.core.source" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp.source" version="2.0.0.v20181102-1323"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20181128170323/repository"/>
+ <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20190226160451/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.osgi" version="0.0.0"/>
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd
index 4c977d8..81eb219 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd
@@ -1,7 +1,7 @@
target "jgit-4.6" with source configurePhase
include "projects/jetty-9.4.14.tpd"
-include "orbit/R20181128170323-2018-12.tpd"
+include "orbit/R20190226160451-2019-03.tpd"
location "http://download.eclipse.org/releases/neon/" {
org.eclipse.osgi lazy
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target
index 89a2014..427f9dc 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="jgit-4.7" sequenceNumber="1547541067">
+<target name="jgit-4.7" sequenceNumber="1551829255">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -31,18 +31,18 @@
<unit id="org.apache.commons.compress.source" version="1.18.0.v20181121-2221"/>
<unit id="org.apache.commons.logging" version="1.2.0.v20180409-1502"/>
<unit id="org.apache.commons.logging.source" version="1.2.0.v20180409-1502"/>
- <unit id="org.apache.httpcomponents.httpclient" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore" version="4.4.9.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.9.v20180409-1525"/>
+ <unit id="org.apache.httpcomponents.httpclient" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpcore" version="4.4.10.v20190123-2214"/>
+ <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181107-1520"/>
+ <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -82,7 +82,7 @@
<unit id="org.apache.sshd.core.source" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp.source" version="2.0.0.v20181102-1323"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20181128170323/repository"/>
+ <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20190226160451/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.osgi" version="0.0.0"/>
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd
index 51a59e4..10a4eb7 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd
@@ -1,7 +1,7 @@
target "jgit-4.7" with source configurePhase
include "projects/jetty-9.4.14.tpd"
-include "orbit/R20181128170323-2018-12.tpd"
+include "orbit/R20190226160451-2019-03.tpd"
location "http://download.eclipse.org/releases/oxygen/" {
org.eclipse.osgi lazy
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target
index 45321ee..fe641ef 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="jgit-4.8" sequenceNumber="1547541051">
+<target name="jgit-4.8" sequenceNumber="1551829263">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -31,18 +31,18 @@
<unit id="org.apache.commons.compress.source" version="1.18.0.v20181121-2221"/>
<unit id="org.apache.commons.logging" version="1.2.0.v20180409-1502"/>
<unit id="org.apache.commons.logging.source" version="1.2.0.v20180409-1502"/>
- <unit id="org.apache.httpcomponents.httpclient" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore" version="4.4.9.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.9.v20180409-1525"/>
+ <unit id="org.apache.httpcomponents.httpclient" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpcore" version="4.4.10.v20190123-2214"/>
+ <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181107-1520"/>
+ <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -82,7 +82,7 @@
<unit id="org.apache.sshd.core.source" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp.source" version="2.0.0.v20181102-1323"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20181128170323/repository"/>
+ <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20190226160451/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.osgi" version="0.0.0"/>
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd
index a29ce1b..daa24dd 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd
@@ -1,7 +1,7 @@
target "jgit-4.8" with source configurePhase
include "projects/jetty-9.4.14.tpd"
-include "orbit/R20181128170323-2018-12.tpd"
+include "orbit/R20190226160451-2019-03.tpd"
location "http://download.eclipse.org/releases/photon/" {
org.eclipse.osgi lazy
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target
index baf845a..4f63f66 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="jgit-4.9" sequenceNumber="1547541040">
+<target name="jgit-4.9" sequenceNumber="1551829271">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.14.v20181114"/>
@@ -31,18 +31,18 @@
<unit id="org.apache.commons.compress.source" version="1.18.0.v20181121-2221"/>
<unit id="org.apache.commons.logging" version="1.2.0.v20180409-1502"/>
<unit id="org.apache.commons.logging.source" version="1.2.0.v20180409-1502"/>
- <unit id="org.apache.httpcomponents.httpclient" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.5.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore" version="4.4.9.v20180409-1525"/>
- <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.9.v20180409-1525"/>
+ <unit id="org.apache.httpcomponents.httpclient" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.6.v20190213-1430"/>
+ <unit id="org.apache.httpcomponents.httpcore" version="4.4.10.v20190123-2214"/>
+ <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.10.v20190123-2214"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
- <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181107-1520"/>
- <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181107-1520"/>
+ <unit id="org.bouncycastle.bcpg" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpg.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcpkix.source" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov" version="1.60.0.v20181210-2057"/>
+ <unit id="org.bouncycastle.bcprov.source" version="1.60.0.v20181210-2057"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
<unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/>
<unit id="org.hamcrest" version="1.1.0.v20090501071000"/>
@@ -82,7 +82,7 @@
<unit id="org.apache.sshd.core.source" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp" version="2.0.0.v20181102-1323"/>
<unit id="org.apache.sshd.sftp.source" version="2.0.0.v20181102-1323"/>
- <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20181128170323/repository"/>
+ <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20190226160451/repository"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.osgi" version="0.0.0"/>
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd
index 0cfd6c4..d024dca 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd
@@ -1,7 +1,7 @@
target "jgit-4.9" with source configurePhase
include "projects/jetty-9.4.14.tpd"
-include "orbit/R20181128170323-2018-12.tpd"
+include "orbit/R20190226160451-2019-03.tpd"
location "http://download.eclipse.org/releases/2018-09/" {
org.eclipse.osgi lazy
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20190226160451-2019-03.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20190226160451-2019-03.tpd
new file mode 100644
index 0000000..32aba68
--- /dev/null
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20190226160451-2019-03.tpd
@@ -0,0 +1,64 @@
+target "R20190226160451-2019-03" with source configurePhase
+// see http://download.eclipse.org/tools/orbit/downloads/
+
+location "http://download.eclipse.org/tools/orbit/downloads/drops/R20190226160451/repository" {
+ org.apache.ant [1.10.5.v20180808-0324,1.10.5.v20180808-0324]
+ org.apache.ant.source [1.10.5.v20180808-0324,1.10.5.v20180808-0324]
+ org.apache.commons.codec [1.10.0.v20180409-1845,1.10.0.v20180409-1845]
+ org.apache.commons.codec.source [1.10.0.v20180409-1845,1.10.0.v20180409-1845]
+ org.apache.commons.compress [1.18.0.v20181121-2221,1.18.0.v20181121-2221]
+ org.apache.commons.compress.source [1.18.0.v20181121-2221,1.18.0.v20181121-2221]
+ org.apache.commons.logging [1.2.0.v20180409-1502,1.2.0.v20180409-1502]
+ org.apache.commons.logging.source [1.2.0.v20180409-1502,1.2.0.v20180409-1502]
+ org.apache.httpcomponents.httpclient [4.5.6.v20190213-1430,4.5.6.v20190213-1430]
+ org.apache.httpcomponents.httpclient.source [4.5.6.v20190213-1430,4.5.6.v20190213-1430]
+ org.apache.httpcomponents.httpcore [4.4.10.v20190123-2214,4.4.10.v20190123-2214]
+ org.apache.httpcomponents.httpcore.source [4.4.10.v20190123-2214,4.4.10.v20190123-2214]
+ org.apache.log4j [1.2.15.v201012070815,1.2.15.v201012070815]
+ org.apache.log4j.source [1.2.15.v201012070815,1.2.15.v201012070815]
+ org.bouncycastle.bcpg [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
+ org.bouncycastle.bcpg.source [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
+ org.bouncycastle.bcpkix [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
+ org.bouncycastle.bcpkix.source [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
+ org.bouncycastle.bcprov [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
+ org.bouncycastle.bcprov.source [1.60.0.v20181210-2057,1.60.0.v20181210-2057]
+ org.kohsuke.args4j [2.33.0.v20160323-2218,2.33.0.v20160323-2218]
+ org.kohsuke.args4j.source [2.33.0.v20160323-2218,2.33.0.v20160323-2218]
+ org.hamcrest [1.1.0.v20090501071000,1.1.0.v20090501071000]
+ org.hamcrest.core [1.3.0.v20180420-1519,1.3.0.v20180420-1519]
+ org.hamcrest.core.source [1.3.0.v20180420-1519,1.3.0.v20180420-1519]
+ org.hamcrest.library [1.3.0.v20180524-2246,1.3.0.v20180524-2246]
+ org.hamcrest.library.source [1.3.0.v20180524-2246,1.3.0.v20180524-2246]
+ javaewah [1.1.6.v20160919-1400,1.1.6.v20160919-1400]
+ javaewah.source [1.1.6.v20160919-1400,1.1.6.v20160919-1400]
+ org.objenesis [2.6.0.v20180420-1519,2.6.0.v20180420-1519]
+ org.objenesis.source [2.6.0.v20180420-1519,2.6.0.v20180420-1519]
+ org.mockito [2.13.0.v20180426-1843,2.13.0.v20180426-1843]
+ org.mockito.source [2.13.0.v20180426-1843,2.13.0.v20180426-1843]
+ net.bytebuddy.byte-buddy [1.7.9.v20180420-1519,1.7.9.v20180420-1519]
+ net.bytebuddy.byte-buddy.source [1.7.9.v20180420-1519,1.7.9.v20180420-1519]
+ net.bytebuddy.byte-buddy-agent [1.7.9.v20180420-1519,1.7.9.v20180420-1519]
+ net.bytebuddy.byte-buddy-agent.source [1.7.9.v20180420-1519,1.7.9.v20180420-1519]
+ com.google.gson [2.8.2.v20180104-1110,2.8.2.v20180104-1110]
+ com.google.gson.source [2.8.2.v20180104-1110,2.8.2.v20180104-1110]
+ com.jcraft.jsch [0.1.54.v20170116-1932,0.1.54.v20170116-1932]
+ com.jcraft.jsch.source [0.1.54.v20170116-1932,0.1.54.v20170116-1932]
+ org.junit [4.12.0.v201504281640,4.12.0.v201504281640]
+ org.junit.source [4.12.0.v201504281640,4.12.0.v201504281640]
+ javax.servlet [3.1.0.v201410161800,3.1.0.v201410161800]
+ javax.servlet.source [3.1.0.v201410161800,3.1.0.v201410161800]
+ org.tukaani.xz [1.8.0.v20180207-1613,1.8.0.v20180207-1613]
+ org.tukaani.xz.source [1.8.0.v20180207-1613,1.8.0.v20180207-1613]
+ org.slf4j.api [1.7.2.v20121108-1250,1.7.2.v20121108-1250]
+ org.slf4j.api.source [1.7.2.v20121108-1250,1.7.2.v20121108-1250]
+ org.slf4j.impl.log4j12 [1.7.2.v20131105-2200,1.7.2.v20131105-2200]
+ org.slf4j.impl.log4j12.source [1.7.2.v20131105-2200,1.7.2.v20131105-2200]
+ com.jcraft.jzlib [1.1.1.v201205102305,1.1.1.v201205102305]
+ com.jcraft.jzlib.source [1.1.1.v201205102305,1.1.1.v201205102305]
+ net.i2p.crypto.eddsa [0.3.0.v20181102-1323,0.3.0.v20181102-1323]
+ net.i2p.crypto.eddsa.source [0.3.0.v20181102-1323,0.3.0.v20181102-1323]
+ org.apache.sshd.core [2.0.0.v20181102-1323,2.0.0.v20181102-1323]
+ org.apache.sshd.core.source [2.0.0.v20181102-1323,2.0.0.v20181102-1323]
+ org.apache.sshd.sftp [2.0.0.v20181102-1323,2.0.0.v20181102-1323]
+ org.apache.sshd.sftp.source [2.0.0.v20181102-1323,2.0.0.v20181102-1323]
+}
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
index 538c876..a482ce3 100644
--- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
+++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
@@ -51,6 +51,7 @@
clonedEmptyRepository=warning: You appear to have cloned an empty repository.
cloningInto=Cloning into ''{0}''...
commitLabel=commit
+configOnlyListOptionSupported=only the --list option is currently supported
configFileNotFound=configuration file {0} not found
conflictingUsageOf_git_dir_andArguments=conflicting usage of --git-dir and arguments
couldNotCreateBranch=Could not create branch {0}: {1}
@@ -132,6 +133,7 @@
metaVar_paths=path ...
metaVar_pattern=pattern
metaVar_port=PORT
+metaVar_prefix=PREFIX
metaVar_ref=REF
metaVar_refs=REFS
metaVar_refspec=refspec
@@ -175,7 +177,7 @@
onBranch=On branch {0}
onBranchToBeBorn=You are on a branch yet to be born
onlyOneMetaVarExpectedIn=Only one {0} expected in {1}.
-onlyOneOfIncludeOnlyAllInteractiveCanBeUsed=Only one of --include/--only/--all/--interactive can be used.
+onlyOneCommitOptionAllowed=Only one of --include/--only/--all/--interactive can be used.
password=Password:
pathspecDidNotMatch=error: pathspec ''{0}'' did not match any file(s) known to git.
pushTo=To {0}
@@ -186,6 +188,7 @@
remoteSideDoesNotSupportDeletingRefs=remote side does not support deleting refs
removing=Removing {0}
repaint=Repaint
+resetNoMode=no reset mode set
s3InvalidBucket=Invalid S3 bucket ''{0}''
serviceNotSupported=Service ''{0}'' not supported
skippingObject=skipping {0} {1}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Add.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Add.java
index 08a9f48..9ecbbf1 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Add.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Add.java
@@ -48,6 +48,7 @@
import org.eclipse.jgit.api.AddCommand;
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@@ -69,6 +70,8 @@ protected void run() throws Exception {
for (String p : filepatterns)
addCmd.addFilepattern(p);
addCmd.call();
+ } catch (GitAPIException e) {
+ throw die(e.getMessage(), e);
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java
index 13a38dd..3858b3d 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java
@@ -65,6 +65,7 @@
import org.eclipse.jgit.diff.RawText;
import org.eclipse.jgit.diff.RawTextComparator;
import org.eclipse.jgit.dircache.DirCache;
+import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.PersonIdent;
@@ -122,8 +123,6 @@ void ignoreAllSpace(@SuppressWarnings("unused") boolean on) {
@Argument(index = 1, required = false, metaVar = "metaVar_file")
private String file;
- private ObjectReader reader;
-
private final Map<RevCommit, String> abbreviatedCommits = new HashMap<>();
private SimpleDateFormat dateFmt;
@@ -136,29 +135,34 @@ void ignoreAllSpace(@SuppressWarnings("unused") boolean on) {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
if (file == null) {
- if (revision == null)
+ if (revision == null) {
throw die(CLIText.get().fileIsRequired);
+ }
file = revision;
revision = null;
}
boolean autoAbbrev = abbrev == 0;
- if (abbrev == 0)
+ if (abbrev == 0) {
abbrev = db.getConfig().getInt("core", "abbrev", 7); //$NON-NLS-1$ //$NON-NLS-2$
- if (!showBlankBoundary)
+ }
+ if (!showBlankBoundary) {
root = db.getConfig().getBoolean("blame", "blankboundary", false); //$NON-NLS-1$ //$NON-NLS-2$
- if (!root)
+ }
+ if (!root) {
root = db.getConfig().getBoolean("blame", "showroot", false); //$NON-NLS-1$ //$NON-NLS-2$
+ }
- if (showRawTimestamp)
+ if (showRawTimestamp) {
dateFmt = new SimpleDateFormat("ZZZZ"); //$NON-NLS-1$
- else
+ } else {
dateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZZ"); //$NON-NLS-1$
+ }
- reader = db.newObjectReader();
- try (BlameGenerator generator = new BlameGenerator(db, file)) {
+ try (ObjectReader reader = db.newObjectReader();
+ BlameGenerator generator = new BlameGenerator(db, file)) {
RevFlag scanned = generator.newFlag("SCANNED"); //$NON-NLS-1$
generator.setTextComparator(comparator);
@@ -166,10 +170,11 @@ protected void run() throws Exception {
RevCommit rangeStart = null;
List<RevCommit> rangeEnd = new ArrayList<>(2);
for (RevCommit c : reverseRange) {
- if (c.has(RevFlag.UNINTERESTING))
+ if (c.has(RevFlag.UNINTERESTING)) {
rangeStart = c;
- else
+ } else {
rangeEnd.add(c);
+ }
}
generator.reverse(rangeStart, rangeEnd);
} else if (revision != null) {
@@ -179,20 +184,23 @@ protected void run() throws Exception {
if (!db.isBare()) {
DirCache dc = db.readDirCache();
int entry = dc.findEntry(file);
- if (0 <= entry)
+ if (0 <= entry) {
generator.push(null, dc.getEntry(entry).getObjectId());
+ }
File inTree = new File(db.getWorkTree(), file);
- if (db.getFS().isFile(inTree))
+ if (db.getFS().isFile(inTree)) {
generator.push(null, new RawText(inTree));
+ }
}
}
blame = BlameResult.create(generator);
begin = 0;
end = blame.getResultContents().size();
- if (rangeString != null)
+ if (rangeString != null) {
parseLineRangeOption();
+ }
blame.computeRange(begin, end);
int authorWidth = 8;
@@ -203,14 +211,16 @@ protected void run() throws Exception {
RevCommit c = blame.getSourceCommit(line);
if (c != null && !c.has(scanned)) {
c.add(scanned);
- if (autoAbbrev)
- abbrev = Math.max(abbrev, uniqueAbbrevLen(c));
+ if (autoAbbrev) {
+ abbrev = Math.max(abbrev, uniqueAbbrevLen(reader, c));
+ }
authorWidth = Math.max(authorWidth, author(line).length());
dateWidth = Math.max(dateWidth, date(line).length());
pathWidth = Math.max(pathWidth, path(line).length());
}
- while (line + 1 < end && blame.getSourceCommit(line + 1) == c)
+ while (line + 1 < end && blame.getSourceCommit(line + 1) == c) {
line++;
+ }
maxSourceLine = Math.max(maxSourceLine, blame.getSourceLine(line));
}
@@ -224,7 +234,7 @@ protected void run() throws Exception {
for (int line = begin; line < end;) {
RevCommit c = blame.getSourceCommit(line);
- String commit = abbreviate(c);
+ String commit = abbreviate(reader, c);
String author = null;
String date = null;
if (!noAuthor) {
@@ -233,12 +243,15 @@ protected void run() throws Exception {
}
do {
outw.print(commit);
- if (showSourcePath)
+ if (showSourcePath) {
outw.format(pathFmt, path(line));
- if (showSourceLine)
+ }
+ if (showSourceLine) {
outw.format(numFmt, valueOf(blame.getSourceLine(line) + 1));
- if (!noAuthor)
+ }
+ if (!noAuthor) {
outw.format(authorFmt, author, date);
+ }
outw.format(lineFmt, valueOf(line + 1));
outw.flush();
blame.getResultContents().writeLine(outs, line);
@@ -246,12 +259,13 @@ protected void run() throws Exception {
outw.print('\n');
} while (++line < end && blame.getSourceCommit(line) == c);
}
- } finally {
- reader.close();
+ } catch (NoWorkTreeException | IOException e) {
+ throw die(e.getMessage(), e);
}
}
- private int uniqueAbbrevLen(RevCommit commit) throws IOException {
+ private int uniqueAbbrevLen(ObjectReader reader, RevCommit commit)
+ throws IOException {
return reader.abbreviate(commit, abbrev).length();
}
@@ -345,7 +359,8 @@ private String date(int line) {
dateFmt.format(author.getWhen()));
}
- private String abbreviate(RevCommit commit) throws IOException {
+ private String abbreviate(ObjectReader reader, RevCommit commit)
+ throws IOException {
String r = abbreviatedCommits.get(commit);
if (r != null)
return r;
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java
index a88354d..bac697f 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java
@@ -54,6 +54,7 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ListBranchCommand;
import org.eclipse.jgit.api.ListBranchCommand.ListMode;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
@@ -182,15 +183,17 @@ public void moveRename(List<String> currentAndNew) {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
- if (delete != null || deleteForce != null) {
- if (delete != null) {
- delete(delete, false);
+ protected void run() {
+ try {
+ if (delete != null || deleteForce != null) {
+ if (delete != null) {
+ delete(delete, false);
+ }
+ if (deleteForce != null) {
+ delete(deleteForce, true);
+ }
+ return;
}
- if (deleteForce != null) {
- delete(deleteForce, true);
- }
- } else {
if (rename) {
String src, dst;
if (otherBranch == null) {
@@ -204,22 +207,27 @@ protected void run() throws Exception {
} else {
src = branch;
final Ref old = db.findRef(src);
- if (old == null)
+ if (old == null) {
throw die(MessageFormat.format(CLIText.get().doesNotExist, src));
- if (!old.getName().startsWith(Constants.R_HEADS))
+ }
+ if (!old.getName().startsWith(Constants.R_HEADS)) {
throw die(MessageFormat.format(CLIText.get().notABranch, src));
+ }
src = old.getName();
dst = otherBranch;
}
- if (!dst.startsWith(Constants.R_HEADS))
+ if (!dst.startsWith(Constants.R_HEADS)) {
dst = Constants.R_HEADS + dst;
- if (!Repository.isValidRefName(dst))
+ }
+ if (!Repository.isValidRefName(dst)) {
throw die(MessageFormat.format(CLIText.get().notAValidRefName, dst));
+ }
RefRename r = db.renameRef(src, dst);
- if (r.rename() != Result.RENAMED)
+ if (r.rename() != Result.RENAMED) {
throw die(MessageFormat.format(CLIText.get().cannotBeRenamed, src));
+ }
} else if (createForce || branch != null) {
String newHead = branch;
@@ -264,10 +272,12 @@ protected void run() throws Exception {
}
list();
}
+ } catch (IOException | GitAPIException e) {
+ throw die(e.getMessage(), e);
}
}
- private void list() throws Exception {
+ private void list() throws IOException, GitAPIException {
Ref head = db.exactRef(Constants.HEAD);
// This can happen if HEAD is stillborn
if (head != null) {
@@ -316,7 +326,7 @@ private void addRef(String name, Ref ref) {
}
private void printHead(final ObjectReader reader, final String ref,
- final boolean isCurrent, final Ref refObj) throws Exception {
+ final boolean isCurrent, final Ref refObj) throws IOException {
outw.print(isCurrent ? '*' : ' ');
outw.print(' ');
outw.print(ref);
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clean.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clean.java
index 6ae078c..db9e959 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clean.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clean.java
@@ -43,10 +43,13 @@
package org.eclipse.jgit.pgm;
+import java.io.IOException;
import java.text.MessageFormat;
import java.util.Set;
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.pgm.internal.CLIText;
import org.kohsuke.args4j.Option;
@@ -64,7 +67,7 @@ class Clean extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
boolean requireForce = git.getRepository().getConfig()
.getBoolean("clean", "requireForce", true); //$NON-NLS-1$ //$NON-NLS-2$
@@ -82,6 +85,8 @@ protected void run() throws Exception {
outw.println(MessageFormat.format(CLIText.get().removing,
removedFile));
}
+ } catch (NoWorkTreeException | GitAPIException | IOException e) {
+ throw die(e.getMessage(), e);
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
index 00d2d10..b0713f7 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
@@ -37,15 +37,14 @@
*/
package org.eclipse.jgit.pgm;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jgit.api.CommitCommand;
import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
-import org.eclipse.jgit.api.errors.NoHeadException;
-import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.pgm.internal.CLIText;
@@ -87,14 +86,15 @@ class Commit extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws NoHeadException, NoMessageException,
- ConcurrentRefUpdateException, JGitInternalException, Exception {
+ protected void run() {
try (Git git = new Git(db)) {
CommitCommand commitCmd = git.commit();
- if (author != null)
+ if (author != null) {
commitCmd.setAuthor(RawParseUtils.parsePersonIdent(author));
- if (message != null)
+ }
+ if (message != null) {
commitCmd.setMessage(message);
+ }
if (noGpgSign) {
commitCmd.setSign(Boolean.FALSE);
} else if (gpgSigningKey != null) {
@@ -103,13 +103,17 @@ protected void run() throws NoHeadException, NoMessageException,
commitCmd.setSigningKey(gpgSigningKey);
}
}
- if (only && paths.isEmpty())
+ if (only && paths.isEmpty()) {
throw die(CLIText.get().pathsRequired);
- if (only && all)
- throw die(CLIText.get().onlyOneOfIncludeOnlyAllInteractiveCanBeUsed);
- if (!paths.isEmpty())
- for (String p : paths)
+ }
+ if (only && all) {
+ throw die(CLIText.get().onlyOneCommitOptionAllowed);
+ }
+ if (!paths.isEmpty()) {
+ for (String p : paths) {
commitCmd.setOnly(p);
+ }
+ }
commitCmd.setAmend(amend);
commitCmd.setAll(all);
Ref head = db.exactRef(Constants.HEAD);
@@ -119,20 +123,24 @@ protected void run() throws NoHeadException, NoMessageException,
RevCommit commit;
try {
commit = commitCmd.call();
- } catch (JGitInternalException e) {
+ } catch (JGitInternalException | GitAPIException e) {
throw die(e.getMessage(), e);
}
String branchName;
- if (!head.isSymbolic())
+ if (!head.isSymbolic()) {
branchName = CLIText.get().branchDetachedHEAD;
- else {
+ } else {
branchName = head.getTarget().getName();
- if (branchName.startsWith(Constants.R_HEADS))
- branchName = branchName.substring(Constants.R_HEADS.length());
+ if (branchName.startsWith(Constants.R_HEADS)) {
+ branchName = branchName
+ .substring(Constants.R_HEADS.length());
+ }
}
- outw.println("[" + branchName + " " + commit.name() + "] " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ outw.println('[' + branchName + ' ' + commit.name() + "] " //$NON-NLS-1$
+ commit.getShortMessage());
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java
index f762c0d..979c6fa 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java
@@ -42,9 +42,9 @@
import java.util.Set;
import org.eclipse.jgit.errors.ConfigInvalidException;
-import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.pgm.internal.CLIText;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.StringUtils;
@@ -70,12 +70,15 @@ class Config extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
- if (list)
+ protected void run() {
+ if (!list) {
+ throw die(CLIText.get().configOnlyListOptionSupported);
+ }
+ try {
list();
- else
- throw new NotSupportedException(
- "only --list option is currently supported"); //$NON-NLS-1$
+ } catch (IOException | ConfigInvalidException e) {
+ throw die(e.getMessage(), e);
+ }
}
private void list() throws IOException, ConfigInvalidException {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java
index f914748..d89fee6 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java
@@ -42,12 +42,15 @@
*/
package org.eclipse.jgit.pgm;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jgit.api.DescribeCommand;
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.RefNotFoundException;
+import org.eclipse.jgit.errors.InvalidPatternException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.pgm.internal.CLIText;
import org.kohsuke.args4j.Argument;
@@ -67,11 +70,12 @@ class Describe extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
DescribeCommand cmd = git.describe();
- if (tree != null)
+ if (tree != null) {
cmd.setTarget(tree);
+ }
cmd.setLong(longDesc);
cmd.setMatch(patterns.toArray(new String[0]));
String result = null;
@@ -80,10 +84,13 @@ protected void run() throws Exception {
} catch (RefNotFoundException e) {
throw die(CLIText.get().noNamesFound, e);
}
- if (result == null)
+ if (result == null) {
throw die(CLIText.get().noNamesFound);
+ }
outw.println(result);
+ } catch (IOException | InvalidPatternException | GitAPIException e) {
+ throw die(e.getMessage(), e);
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java
index 97e3df3..7747dc7 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java
@@ -62,6 +62,7 @@
import org.eclipse.jgit.diff.RawTextComparator;
import org.eclipse.jgit.diff.RenameDetector;
import org.eclipse.jgit.dircache.DirCacheIterator;
+import org.eclipse.jgit.errors.RevisionSyntaxException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.Repository;
@@ -150,12 +151,12 @@ void abbrev(@SuppressWarnings("unused") boolean on) {
diffFmt.setAbbreviationLength(OBJECT_ID_STRING_LENGTH);
}
- @Option(name = "--src-prefix", usage = "usage_srcPrefix")
+ @Option(name = "--src-prefix", metaVar = "metaVar_prefix", usage = "usage_srcPrefix")
void sourcePrefix(String path) {
diffFmt.setOldPrefix(path);
}
- @Option(name = "--dst-prefix", usage = "usage_dstPrefix")
+ @Option(name = "--dst-prefix", metaVar = "metaVar_prefix", usage = "usage_dstPrefix")
void dstPrefix(String path) {
diffFmt.setNewPrefix(path);
}
@@ -177,14 +178,15 @@ protected void init(Repository repository, String gitDir) {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
diffFmt.setRepository(db);
try {
if (cached) {
if (oldTree == null) {
ObjectId head = db.resolve(HEAD + "^{tree}"); //$NON-NLS-1$
- if (head == null)
+ if (head == null) {
die(MessageFormat.format(CLIText.get().notATree, HEAD));
+ }
CanonicalTreeParser p = new CanonicalTreeParser();
try (ObjectReader reader = db.newObjectReader()) {
p.reset(reader, head);
@@ -195,15 +197,17 @@ protected void run() throws Exception {
} else if (oldTree == null) {
oldTree = new DirCacheIterator(db.readDirCache());
newTree = new FileTreeIterator(db);
- } else if (newTree == null)
+ } else if (newTree == null) {
newTree = new FileTreeIterator(db);
+ }
TextProgressMonitor pm = new TextProgressMonitor(errw);
pm.setDelayStart(2, TimeUnit.SECONDS);
diffFmt.setProgressMonitor(pm);
diffFmt.setPathFilter(pathFilter);
- if (detectRenames != null)
+ if (detectRenames != null) {
diffFmt.setDetectRenames(detectRenames.booleanValue());
+ }
if (renameLimit != null && diffFmt.isDetectRenames()) {
RenameDetector rd = diffFmt.getRenameDetector();
rd.setRenameLimit(renameLimit.intValue());
@@ -212,11 +216,12 @@ protected void run() throws Exception {
if (showNameAndStatusOnly) {
nameStatus(outw, diffFmt.scan(oldTree, newTree));
outw.flush();
-
} else {
diffFmt.format(oldTree, newTree);
diffFmt.flush();
}
+ } catch (RevisionSyntaxException | IOException e) {
+ throw die(e.getMessage(), e);
} finally {
diffFmt.close();
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java
index 42aabc2..371395b 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/DiffTree.java
@@ -44,6 +44,7 @@
package org.eclipse.jgit.pgm;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -74,7 +75,7 @@ void tree_0(final AbstractTreeIterator c) {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (TreeWalk walk = new TreeWalk(db)) {
walk.setRecursive(recursive);
for (AbstractTreeIterator i : trees)
@@ -83,13 +84,15 @@ protected void run() throws Exception {
final int nTree = walk.getTreeCount();
while (walk.next()) {
- for (int i = 1; i < nTree; i++)
+ for (int i = 1; i < nTree; i++) {
outw.print(':');
+ }
for (int i = 0; i < nTree; i++) {
final FileMode m = walk.getFileMode(i);
final String s = m.toString();
- for (int pad = 6 - s.length(); pad > 0; pad--)
+ for (int pad = 6 - s.length(); pad > 0; pad--) {
outw.print('0');
+ }
outw.print(s);
outw.print(' ');
}
@@ -103,12 +106,13 @@ protected void run() throws Exception {
if (nTree == 2) {
final int m0 = walk.getRawMode(0);
final int m1 = walk.getRawMode(1);
- if (m0 == 0 && m1 != 0)
+ if (m0 == 0 && m1 != 0) {
chg = 'A';
- else if (m0 != 0 && m1 == 0)
+ } else if (m0 != 0 && m1 == 0) {
chg = 'D';
- else if (m0 != m1 && walk.idEqual(0, 1))
+ } else if (m0 != m1 && walk.idEqual(0, 1)) {
chg = 'T';
+ }
}
outw.print(chg);
@@ -116,6 +120,8 @@ else if (m0 != m1 && walk.idEqual(0, 1))
outw.print(walk.getPathString());
outw.println();
}
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
index 61fd521..da3c498 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
@@ -51,6 +51,7 @@
import org.eclipse.jgit.api.FetchCommand;
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.SubmoduleConfig.FetchRecurseSubmodulesMode;
import org.eclipse.jgit.lib.TextProgressMonitor;
@@ -136,27 +137,33 @@ void noRecurseSubmodules(@SuppressWarnings("unused")
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
FetchCommand fetch = git.fetch();
- if (fsck != null)
+ if (fsck != null) {
fetch.setCheckFetchedObjects(fsck.booleanValue());
- if (prune != null)
+ }
+ if (prune != null) {
fetch.setRemoveDeletedRefs(prune.booleanValue());
- if (toget != null)
+ }
+ if (toget != null) {
fetch.setRefSpecs(toget);
+ }
if (tags != null) {
fetch.setTagOpt(tags.booleanValue() ? TagOpt.FETCH_TAGS
: TagOpt.NO_TAGS);
}
- if (0 <= timeout)
+ if (0 <= timeout) {
fetch.setTimeout(timeout);
+ }
fetch.setDryRun(dryRun);
fetch.setRemote(remote);
- if (thin != null)
+ if (thin != null) {
fetch.setThin(thin.booleanValue());
- if (quiet == null || !quiet.booleanValue())
+ }
+ if (quiet == null || !quiet.booleanValue()) {
fetch.setProgressMonitor(new TextProgressMonitor(errw));
+ }
fetch.setRecurseSubmodules(recurseSubmodules).setCallback(this);
if (force != null) {
fetch.setForceUpdate(force.booleanValue());
@@ -164,10 +171,12 @@ protected void run() throws Exception {
FetchResult result = fetch.call();
if (result.getTrackingRefUpdates().isEmpty()
- && result.submoduleResults().isEmpty())
+ && result.submoduleResults().isEmpty()) {
return;
-
+ }
showFetchResult(result);
+ } catch (GitAPIException | IOException e) {
+ throw die(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java
index 56172f5..e65f0ec 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java
@@ -44,6 +44,7 @@
package org.eclipse.jgit.pgm;
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.TextProgressMonitor;
import org.kohsuke.args4j.Option;
@@ -60,11 +61,15 @@ class Gc extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
Git git = Git.wrap(db);
- git.gc().setAggressive(aggressive)
- .setPreserveOldPacks(preserveOldPacks)
- .setPrunePreserved(prunePreserved)
- .setProgressMonitor(new TextProgressMonitor(errw)).call();
+ try {
+ git.gc().setAggressive(aggressive)
+ .setPreserveOldPacks(preserveOldPacks)
+ .setPrunePreserved(prunePreserved)
+ .setProgressMonitor(new TextProgressMonitor(errw)).call();
+ } catch (GitAPIException e) {
+ throw die(e.getMessage(), e);
+ }
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java
index 2627671..394083c 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/IndexPack.java
@@ -45,6 +45,7 @@
package org.eclipse.jgit.pgm;
import java.io.BufferedInputStream;
+import java.io.IOException;
import org.eclipse.jgit.internal.storage.file.ObjectDirectoryPackParser;
import org.eclipse.jgit.lib.ObjectInserter;
@@ -62,7 +63,7 @@ class IndexPack extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
BufferedInputStream in = new BufferedInputStream(ins);
try (ObjectInserter inserter = db.newObjectInserter()) {
PackParser p = inserter.newPackParser(in);
@@ -73,6 +74,8 @@ protected void run() throws Exception {
}
p.parse(new TextProgressMonitor(errw));
inserter.flush();
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
index f880fc2..d24733d 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Init.java
@@ -49,10 +49,12 @@
package org.eclipse.jgit.pgm;
import java.io.File;
+import java.io.IOException;
import java.text.MessageFormat;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.InitCommand;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.pgm.internal.CLIText;
import org.kohsuke.args4j.Argument;
@@ -74,7 +76,7 @@ protected final boolean requiresRepository() {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
InitCommand command = Git.init();
command.setBare(bare);
if (gitdir != null) {
@@ -83,9 +85,14 @@ protected void run() throws Exception {
if (directory != null) {
command.setDirectory(new File(directory));
}
- Repository repository = command.call().getRepository();
- outw.println(MessageFormat.format(
- CLIText.get().initializedEmptyGitRepositoryIn, repository
- .getDirectory().getAbsolutePath()));
+ Repository repository;
+ try {
+ repository = command.call().getRepository();
+ outw.println(MessageFormat.format(
+ CLIText.get().initializedEmptyGitRepositoryIn,
+ repository.getDirectory().getAbsolutePath()));
+ } catch (GitAPIException | IOException e) {
+ throw die(e.getMessage(), e);
+ }
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java
index ad92a78..05b7980 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java
@@ -193,12 +193,13 @@ protected void init(Repository repository, String gitDir) {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
diffFmt.setRepository(db);
try {
diffFmt.setPathFilter(pathFilter);
- if (detectRenames != null)
+ if (detectRenames != null) {
diffFmt.setDetectRenames(detectRenames.booleanValue());
+ }
if (renameLimit != null && diffFmt.isDetectRenames()) {
RenameDetector rd = diffFmt.getRenameDetector();
rd.setRenameLimit(renameLimit.intValue());
@@ -220,11 +221,13 @@ protected void run() throws Exception {
}
}
- if (decorate)
+ if (decorate) {
allRefsByPeeledObjectId = getRepository()
.getAllRefsByPeeledObjectId();
-
+ }
super.run();
+ } catch (Exception e) {
+ throw die(e.getMessage(), e);
} finally {
diffFmt.close();
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsFiles.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsFiles.java
index dc13000..ef25844 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsFiles.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsFiles.java
@@ -48,11 +48,13 @@
import static org.eclipse.jgit.lib.FileMode.REGULAR_FILE;
import static org.eclipse.jgit.lib.FileMode.SYMLINK;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.jgit.dircache.DirCacheIterator;
+import org.eclipse.jgit.errors.RevisionSyntaxException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
@@ -72,7 +74,7 @@ class LsFiles extends TextBuiltin {
private List<String> paths = new ArrayList<>();
@Override
- protected void run() throws Exception {
+ protected void run() {
try (RevWalk rw = new RevWalk(db);
TreeWalk tw = new TreeWalk(db)) {
final ObjectId head = db.resolve(Constants.HEAD);
@@ -96,6 +98,8 @@ protected void run() throws Exception {
QuotedString.GIT_PATH.quote(tw.getPathString()));
}
}
+ } catch (RevisionSyntaxException | IOException e) {
+ throw die(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
index 2711c15..1c2564d 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
@@ -51,6 +51,7 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.LsRemoteCommand;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Ref;
import org.kohsuke.args4j.Argument;
@@ -72,7 +73,7 @@ class LsRemote extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
LsRemoteCommand command = Git.lsRemoteRepository().setRemote(remote)
.setTimeout(timeout).setHeads(heads).setTags(tags);
TreeSet<Ref> refs = new TreeSet<>(new Comparator<Ref>() {
@@ -82,11 +83,16 @@ public int compare(Ref r1, Ref r2) {
return r1.getName().compareTo(r2.getName());
}
});
- refs.addAll(command.call());
- for (Ref r : refs) {
- show(r.getObjectId(), r.getName());
- if (r.getPeeledObjectId() != null)
- show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
+ try {
+ refs.addAll(command.call());
+ for (Ref r : refs) {
+ show(r.getObjectId(), r.getName());
+ if (r.getPeeledObjectId() != null) {
+ show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
+ }
+ }
+ } catch (GitAPIException | IOException e) {
+ throw die(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java
index 01fa7ee..2a2bb7c 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsTree.java
@@ -45,6 +45,7 @@
package org.eclipse.jgit.pgm;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -72,18 +73,20 @@ class LsTree extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (TreeWalk walk = new TreeWalk(db)) {
walk.reset(); // drop the first empty tree, which we do not need here
- if (paths.size() > 0)
+ if (paths.size() > 0) {
walk.setFilter(PathFilterGroup.createFromStrings(paths));
+ }
walk.setRecursive(recursive);
walk.addTree(tree);
while (walk.next()) {
final FileMode mode = walk.getFileMode(0);
- if (mode == FileMode.TREE)
+ if (mode == FileMode.TREE) {
outw.print('0');
+ }
outw.print(mode);
outw.print(' ');
outw.print(Constants.typeString(mode.getObjectType()));
@@ -95,6 +98,8 @@ protected void run() throws Exception {
outw.print(QuotedString.GIT_PATH.quote(walk.getPathString()));
outw.println();
}
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
index de059e9..0b362a4 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
@@ -52,6 +52,7 @@
import org.eclipse.jgit.api.MergeCommand.FastForwardMode;
import org.eclipse.jgit.api.MergeResult;
import org.eclipse.jgit.api.errors.CheckoutConflictException;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
@@ -103,110 +104,124 @@ void ffonly(@SuppressWarnings("unused") final boolean ignored) {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
- if (squash && ff == FastForwardMode.NO_FF)
+ protected void run() {
+ if (squash && ff == FastForwardMode.NO_FF) {
throw die(CLIText.get().cannotCombineSquashWithNoff);
+ }
// determine the merge strategy
if (strategyName != null) {
mergeStrategy = MergeStrategy.get(strategyName);
- if (mergeStrategy == null)
+ if (mergeStrategy == null) {
throw die(MessageFormat.format(
CLIText.get().unknownMergeStrategy, strategyName));
- }
-
- // determine the other revision we want to merge with HEAD
- final Ref srcRef = db.findRef(ref);
- final ObjectId src = db.resolve(ref + "^{commit}"); //$NON-NLS-1$
- if (src == null)
- throw die(MessageFormat.format(
- CLIText.get().refDoesNotExistOrNoCommit, ref));
-
- Ref oldHead = getOldHead();
- MergeResult result;
- try (Git git = new Git(db)) {
- MergeCommand mergeCmd = git.merge().setStrategy(mergeStrategy)
- .setSquash(squash).setFastForward(ff).setCommit(!noCommit);
- if (srcRef != null)
- mergeCmd.include(srcRef);
- else
- mergeCmd.include(src);
-
- if (message != null)
- mergeCmd.setMessage(message);
-
- try {
- result = mergeCmd.call();
- } catch (CheckoutConflictException e) {
- result = new MergeResult(e.getConflictingPaths()); // CHECKOUT_CONFLICT
}
}
- switch (result.getMergeStatus()) {
- case ALREADY_UP_TO_DATE:
- if (squash)
- outw.print(CLIText.get().nothingToSquash);
- outw.println(CLIText.get().alreadyUpToDate);
- break;
- case FAST_FORWARD:
- ObjectId oldHeadId = oldHead.getObjectId();
- if (oldHeadId != null) {
- String oldId = oldHeadId.abbreviate(7).name();
- String newId = result.getNewHead().abbreviate(7).name();
- outw.println(MessageFormat.format(CLIText.get().updating, oldId,
- newId));
+ try {
+ // determine the other revision we want to merge with HEAD
+ final Ref srcRef = db.findRef(ref);
+ final ObjectId src = db.resolve(ref + "^{commit}"); //$NON-NLS-1$
+ if (src == null) {
+ throw die(MessageFormat
+ .format(CLIText.get().refDoesNotExistOrNoCommit, ref));
}
- outw.println(result.getMergeStatus().toString());
- break;
- case CHECKOUT_CONFLICT:
- outw.println(CLIText.get().mergeCheckoutConflict);
- for (String collidingPath : result.getCheckoutConflicts())
- outw.println("\t" + collidingPath); //$NON-NLS-1$
- outw.println(CLIText.get().mergeCheckoutFailed);
- break;
- case CONFLICTING:
- for (String collidingPath : result.getConflicts().keySet())
- outw.println(MessageFormat.format(CLIText.get().mergeConflict,
- collidingPath));
- outw.println(CLIText.get().mergeFailed);
- break;
- case FAILED:
- for (Map.Entry<String, MergeFailureReason> entry : result
- .getFailingPaths().entrySet())
- switch (entry.getValue()) {
- case DIRTY_WORKTREE:
- case DIRTY_INDEX:
- outw.println(CLIText.get().dontOverwriteLocalChanges);
- outw.println(" " + entry.getKey()); //$NON-NLS-1$
- break;
- case COULD_NOT_DELETE:
- outw.println(CLIText.get().cannotDeleteFile);
- outw.println(" " + entry.getKey()); //$NON-NLS-1$
- break;
+
+ Ref oldHead = getOldHead();
+ MergeResult result;
+ try (Git git = new Git(db)) {
+ MergeCommand mergeCmd = git.merge().setStrategy(mergeStrategy)
+ .setSquash(squash).setFastForward(ff)
+ .setCommit(!noCommit);
+ if (srcRef != null) {
+ mergeCmd.include(srcRef);
+ } else {
+ mergeCmd.include(src);
}
- break;
- case MERGED:
- String name;
- if (!isMergedInto(oldHead, src))
- name = mergeStrategy.getName();
- else
- name = "recursive"; //$NON-NLS-1$
- outw.println(MessageFormat.format(CLIText.get().mergeMadeBy, name));
- break;
- case MERGED_NOT_COMMITTED:
- outw.println(CLIText.get().mergeWentWellStoppedBeforeCommitting);
- break;
- case MERGED_SQUASHED:
- case FAST_FORWARD_SQUASHED:
- case MERGED_SQUASHED_NOT_COMMITTED:
- outw.println(CLIText.get().mergedSquashed);
- outw.println(CLIText.get().mergeWentWellStoppedBeforeCommitting);
- break;
- case ABORTED:
- throw die(CLIText.get().ffNotPossibleAborting);
- case NOT_SUPPORTED:
- outw.println(MessageFormat.format(
- CLIText.get().unsupportedOperation, result.toString()));
+
+ if (message != null) {
+ mergeCmd.setMessage(message);
+ }
+
+ try {
+ result = mergeCmd.call();
+ } catch (CheckoutConflictException e) {
+ result = new MergeResult(e.getConflictingPaths()); // CHECKOUT_CONFLICT
+ }
+ }
+
+ switch (result.getMergeStatus()) {
+ case ALREADY_UP_TO_DATE:
+ if (squash) {
+ outw.print(CLIText.get().nothingToSquash);
+ }
+ outw.println(CLIText.get().alreadyUpToDate);
+ break;
+ case FAST_FORWARD:
+ ObjectId oldHeadId = oldHead.getObjectId();
+ if (oldHeadId != null) {
+ String oldId = oldHeadId.abbreviate(7).name();
+ String newId = result.getNewHead().abbreviate(7).name();
+ outw.println(MessageFormat.format(CLIText.get().updating,
+ oldId, newId));
+ }
+ outw.println(result.getMergeStatus().toString());
+ break;
+ case CHECKOUT_CONFLICT:
+ outw.println(CLIText.get().mergeCheckoutConflict);
+ for (String collidingPath : result.getCheckoutConflicts()) {
+ outw.println("\t" + collidingPath); //$NON-NLS-1$
+ }
+ outw.println(CLIText.get().mergeCheckoutFailed);
+ break;
+ case CONFLICTING:
+ for (String collidingPath : result.getConflicts().keySet())
+ outw.println(MessageFormat.format(
+ CLIText.get().mergeConflict, collidingPath));
+ outw.println(CLIText.get().mergeFailed);
+ break;
+ case FAILED:
+ for (Map.Entry<String, MergeFailureReason> entry : result
+ .getFailingPaths().entrySet())
+ switch (entry.getValue()) {
+ case DIRTY_WORKTREE:
+ case DIRTY_INDEX:
+ outw.println(CLIText.get().dontOverwriteLocalChanges);
+ outw.println(" " + entry.getKey()); //$NON-NLS-1$
+ break;
+ case COULD_NOT_DELETE:
+ outw.println(CLIText.get().cannotDeleteFile);
+ outw.println(" " + entry.getKey()); //$NON-NLS-1$
+ break;
+ }
+ break;
+ case MERGED:
+ MergeStrategy strategy = isMergedInto(oldHead, src)
+ ? MergeStrategy.RECURSIVE
+ : mergeStrategy;
+ outw.println(MessageFormat.format(CLIText.get().mergeMadeBy,
+ strategy.getName()));
+ break;
+ case MERGED_NOT_COMMITTED:
+ outw.println(
+ CLIText.get().mergeWentWellStoppedBeforeCommitting);
+ break;
+ case MERGED_SQUASHED:
+ case FAST_FORWARD_SQUASHED:
+ case MERGED_SQUASHED_NOT_COMMITTED:
+ outw.println(CLIText.get().mergedSquashed);
+ outw.println(
+ CLIText.get().mergeWentWellStoppedBeforeCommitting);
+ break;
+ case ABORTED:
+ throw die(CLIText.get().ffNotPossibleAborting);
+ case NOT_SUPPORTED:
+ outw.println(MessageFormat.format(
+ CLIText.get().unsupportedOperation, result.toString()));
+ }
+ } catch (GitAPIException | IOException e) {
+ throw die(e.getMessage(), e);
}
+
}
private Ref getOldHead() throws IOException {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java
index 6842d8d..60b1743 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java
@@ -44,6 +44,7 @@
package org.eclipse.jgit.pgm;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -67,16 +68,22 @@ void commit_0(final RevCommit c) {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
- for (RevCommit c : commits)
- argWalk.markStart(c);
- argWalk.setRevFilter(RevFilter.MERGE_BASE);
- int max = all ? Integer.MAX_VALUE : 1;
- while (max-- > 0) {
- final RevCommit b = argWalk.next();
- if (b == null)
- break;
- outw.println(b.getId().name());
+ protected void run() {
+ try {
+ for (RevCommit c : commits) {
+ argWalk.markStart(c);
+ }
+ argWalk.setRevFilter(RevFilter.MERGE_BASE);
+ int max = all ? Integer.MAX_VALUE : 1;
+ while (max-- > 0) {
+ final RevCommit b = argWalk.next();
+ if (b == null) {
+ break;
+ }
+ outw.println(b.getId().name());
+ }
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
index be8ad37..e65e5d1 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java
@@ -53,6 +53,7 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.PushCommand;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
@@ -115,7 +116,7 @@ void nothin(@SuppressWarnings("unused") final boolean ignored) {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
PushCommand push = git.push();
push.setDryRun(dryRun);
@@ -123,10 +124,12 @@ protected void run() throws Exception {
push.setProgressMonitor(new TextProgressMonitor(errw));
push.setReceivePack(receivePack);
push.setRefSpecs(refSpecs);
- if (all)
+ if (all) {
push.setPushAll();
- if (tags)
+ }
+ if (tags) {
push.setPushTags();
+ }
push.setRemote(remote);
push.setThin(thin);
push.setAtomic(atomic);
@@ -140,6 +143,8 @@ protected void run() throws Exception {
printPushResult(reader, result.getURI(), result);
}
}
+ } catch (GitAPIException | IOException e) {
+ throw die(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java
index f3baafb..b601d80 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ReceivePack.java
@@ -45,6 +45,7 @@
package org.eclipse.jgit.pgm;
import java.io.File;
+import java.io.IOException;
import java.text.MessageFormat;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
@@ -66,7 +67,7 @@ protected final boolean requiresRepository() {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
final org.eclipse.jgit.transport.ReceivePack rp;
try {
@@ -75,9 +76,15 @@ protected void run() throws Exception {
} catch (RepositoryNotFoundException notFound) {
throw die(MessageFormat.format(CLIText.get().notAGitRepository,
dstGitdir.getPath()));
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
}
rp = new org.eclipse.jgit.transport.ReceivePack(db);
- rp.receive(ins, outs, errs);
+ try {
+ rp.receive(ins, outs, errs);
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
+ }
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java
index 6f4fcc2..410e88f 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java
@@ -42,10 +42,12 @@
*/
package org.eclipse.jgit.pgm;
+import java.io.IOException;
import java.util.Collection;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ReflogCommand;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ReflogEntry;
import org.eclipse.jgit.lib.Repository;
@@ -59,7 +61,7 @@ class Reflog extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
ReflogCommand cmd = git.reflog();
if (ref != null)
@@ -69,6 +71,8 @@ protected void run() throws Exception {
for (ReflogEntry entry : entries) {
outw.println(toString(entry, i++));
}
+ } catch (GitAPIException | IOException e) {
+ throw die(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java
index 63eba15..58138fa 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Remote.java
@@ -53,6 +53,7 @@
import org.eclipse.jgit.api.RemoteListCommand;
import org.eclipse.jgit.api.RemoteRemoveCommand;
import org.eclipse.jgit.api.RemoteSetUrlCommand;
+import org.eclipse.jgit.api.RemoteSetUrlCommand.UriType;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.pgm.internal.CLIText;
import org.eclipse.jgit.pgm.opt.CmdLineParser;
@@ -86,7 +87,7 @@ class Remote extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
if (command == null) {
RemoteListCommand cmd = git.remoteList();
@@ -99,13 +100,13 @@ protected void run() throws Exception {
cmd.call();
} else if ("remove".equals(command) || "rm".equals(command)) { //$NON-NLS-1$ //$NON-NLS-2$
RemoteRemoveCommand cmd = git.remoteRemove();
- cmd.setName(name);
+ cmd.setRemoteName(name);
cmd.call();
} else if ("set-url".equals(command)) { //$NON-NLS-1$
RemoteSetUrlCommand cmd = git.remoteSetUrl();
- cmd.setName(name);
- cmd.setUri(new URIish(uri));
- cmd.setPush(push);
+ cmd.setRemoteName(name);
+ cmd.setRemoteUri(new URIish(uri));
+ cmd.setUriType(push ? UriType.PUSH : UriType.FETCH);
cmd.call();
} else if ("update".equals(command)) { //$NON-NLS-1$
// reuse fetch command for basic implementation of remote update
@@ -141,6 +142,8 @@ protected void run() throws Exception {
throw new JGitInternalException(MessageFormat
.format(CLIText.get().unknownSubcommand, command));
}
+ } catch (Exception e) {
+ throw die(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Repo.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Repo.java
index f557211..eec562d 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Repo.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Repo.java
@@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.pgm;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.gitrepo.RepoCommand;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@@ -60,11 +61,15 @@ class Repo extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
- new RepoCommand(db)
- .setURI(uri)
- .setPath(path)
- .setGroups(groups)
- .call();
+ protected void run() {
+ try {
+ new RepoCommand(db)
+ .setURI(uri)
+ .setPath(path)
+ .setGroups(groups)
+ .call();
+ } catch (GitAPIException e) {
+ throw die(e.getMessage(), e);
+ }
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java
index f84c848..b3e81c6 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java
@@ -49,6 +49,8 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ResetCommand;
import org.eclipse.jgit.api.ResetCommand.ResetType;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.pgm.internal.CLIText;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.spi.RestOfArgumentsHandler;
@@ -74,26 +76,33 @@ class Reset extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
ResetCommand command = git.reset();
command.setRef(commit);
if (paths.size() > 0) {
- for (String path : paths)
+ for (String path : paths) {
command.addPath(path);
+ }
} else {
ResetType mode = null;
- if (soft)
+ if (soft) {
mode = selectMode(mode, ResetType.SOFT);
- if (mixed)
+ }
+ if (mixed) {
mode = selectMode(mode, ResetType.MIXED);
- if (hard)
+ }
+ if (hard) {
mode = selectMode(mode, ResetType.HARD);
- if (mode == null)
- throw die("no reset mode set"); //$NON-NLS-1$
+ }
+ if (mode == null) {
+ throw die(CLIText.get().resetNoMode);
+ }
command.setMode(mode);
}
command.call();
+ } catch (GitAPIException e) {
+ throw die(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
index ac08cd6..9ff12d8 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
@@ -45,6 +45,7 @@
package org.eclipse.jgit.pgm;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -69,27 +70,31 @@ class RevParse extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
- if (all) {
- for (Ref r : db.getRefDatabase().getRefs()) {
- ObjectId objectId = r.getObjectId();
- // getRefs skips dangling symrefs, so objectId should never be
- // null.
- if (objectId == null) {
- throw new NullPointerException();
+ protected void run() {
+ try {
+ if (all) {
+ for (Ref r : db.getRefDatabase().getRefs()) {
+ ObjectId objectId = r.getObjectId();
+ // getRefs skips dangling symrefs, so objectId should never
+ // be null.
+ if (objectId == null) {
+ throw new NullPointerException();
+ }
+ outw.println(objectId.name());
}
- outw.println(objectId.name());
- }
- } else {
- if (verify && commits.size() > 1) {
- final CmdLineParser clp = new CmdLineParser(this);
- throw new CmdLineException(clp,
- CLIText.format(CLIText.get().needSingleRevision));
- }
+ } else {
+ if (verify && commits.size() > 1) {
+ final CmdLineParser clp = new CmdLineParser(this);
+ throw new CmdLineException(clp,
+ CLIText.format(CLIText.get().needSingleRevision));
+ }
- for (ObjectId o : commits) {
- outw.println(o.name());
+ for (ObjectId o : commits) {
+ outw.println(o.name());
+ }
}
+ } catch (IOException | CmdLineException e) {
+ throw die(e.getMessage(), e);
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java
index f591610..4b66462 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java
@@ -49,6 +49,7 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.RmCommand;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.spi.StopOptionHandler;
@@ -61,12 +62,15 @@ class Rm extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
RmCommand command = git.rm();
- for (String p : paths)
+ for (String p : paths) {
command.addFilepattern(p);
+ }
command.call();
+ } catch (GitAPIException e) {
+ throw die(e.getMessage(), e);
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java
index 89a15fe..ff3d003 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java
@@ -59,6 +59,7 @@
import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
+import org.eclipse.jgit.errors.RevisionSyntaxException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
@@ -175,22 +176,24 @@ protected void init(Repository repository, String gitDir) {
/** {@inheritDoc} */
@SuppressWarnings("boxing")
@Override
- protected void run() throws Exception {
+ protected void run() {
diffFmt.setRepository(db);
try {
diffFmt.setPathFilter(pathFilter);
- if (detectRenames != null)
+ if (detectRenames != null) {
diffFmt.setDetectRenames(detectRenames.booleanValue());
+ }
if (renameLimit != null && diffFmt.isDetectRenames()) {
RenameDetector rd = diffFmt.getRenameDetector();
rd.setRenameLimit(renameLimit.intValue());
}
ObjectId objectId;
- if (objectName == null)
+ if (objectName == null) {
objectId = db.resolve(Constants.HEAD);
- else
+ } else {
objectId = db.resolve(objectName);
+ }
try (RevWalk rw = new RevWalk(db)) {
RevObject obj = rw.parseAny(objectId);
@@ -224,6 +227,8 @@ protected void run() throws Exception {
obj.getType()));
}
}
+ } catch (RevisionSyntaxException | IOException e) {
+ throw die(e.getMessage(), e);
} finally {
diffFmt.close();
}
@@ -273,7 +278,7 @@ private void show(RevTree obj) throws MissingObjectException,
}
}
- private void show(RevWalk rw, RevCommit c) throws Exception {
+ private void show(RevWalk rw, RevCommit c) throws IOException {
char[] outbuffer = new char[Constants.OBJECT_ID_LENGTH * 2];
outw.print(CLIText.get().commitLabel);
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java
index 6318a63..b8442c5 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java
@@ -56,15 +56,20 @@
class ShowRef extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
- for (Ref r : getSortedRefs()) {
- show(r.getObjectId(), r.getName());
- if (r.getPeeledObjectId() != null)
- show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
+ protected void run() {
+ try {
+ for (Ref r : getSortedRefs()) {
+ show(r.getObjectId(), r.getName());
+ if (r.getPeeledObjectId() != null) {
+ show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
+ }
+ }
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
}
}
- private Iterable<Ref> getSortedRefs() throws Exception {
+ private Iterable<Ref> getSortedRefs() throws IOException {
List<Ref> all = db.getRefDatabase().getRefs();
// TODO(jrn) check if we can reintroduce fast-path by e.g. implementing
// SortedList
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
index fb2fd7e..dfc8a94 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
@@ -54,6 +54,8 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.StatusCommand;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.IndexDiff.StageState;
import org.eclipse.jgit.lib.Ref;
@@ -88,14 +90,18 @@ class Status extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
StatusCommand statusCommand = git.status();
- if (filterPaths != null && filterPaths.size() > 0)
- for (String path : filterPaths)
+ if (filterPaths != null && filterPaths.size() > 0) {
+ for (String path : filterPaths) {
statusCommand.addPath(path);
+ }
+ }
org.eclipse.jgit.api.Status status = statusCommand.call();
printStatus(status);
+ } catch (GitAPIException | NoWorkTreeException | IOException e) {
+ throw die(e.getMessage(), e);
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java
index 43c1f54..1da4b1d 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java
@@ -48,12 +48,14 @@
package org.eclipse.jgit.pgm;
+import java.io.IOException;
import java.text.MessageFormat;
import java.util.List;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ListTagCommand;
import org.eclipse.jgit.api.TagCommand;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.RefAlreadyExistsException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
@@ -82,7 +84,7 @@ class Tag extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
if (tagName != null) {
if (delete) {
@@ -115,6 +117,8 @@ protected void run() throws Exception {
outw.println(Repository.shortenRefName(ref.getName()));
}
}
+ } catch (GitAPIException | IOException e) {
+ throw die(e.getMessage(), e);
}
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
index 5d032d2..c138302 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
@@ -45,6 +45,7 @@
package org.eclipse.jgit.pgm;
import java.io.File;
+import java.io.IOException;
import java.text.MessageFormat;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
@@ -70,20 +71,21 @@ protected final boolean requiresRepository() {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
- final org.eclipse.jgit.transport.UploadPack up;
-
+ protected void run() {
try {
FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED);
db = key.open(true /* must exist */);
+ org.eclipse.jgit.transport.UploadPack up = new org.eclipse.jgit.transport.UploadPack(
+ db);
+ if (0 <= timeout) {
+ up.setTimeout(timeout);
+ }
+ up.upload(ins, outs, errs);
} catch (RepositoryNotFoundException notFound) {
throw die(MessageFormat.format(CLIText.get().notAGitRepository,
srcGitdir.getPath()));
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
}
-
- up = new org.eclipse.jgit.transport.UploadPack(db);
- if (0 <= timeout)
- up.setTimeout(timeout);
- up.upload(ins, outs, errs);
}
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java
index 58acc5c..cb447e4 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Version.java
@@ -57,21 +57,28 @@
class Version extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
// read the Implementation-Version from Manifest
String version = getImplementationVersion();
// if Implementation-Version is not available then try reading
// Bundle-Version
- if (version == null)
+ if (version == null) {
version = getBundleVersion();
+ }
// if both Implementation-Version and Bundle-Version are not available
// then throw an exception
- if (version == null)
+ if (version == null) {
throw die(CLIText.get().cannotReadPackageInformation);
+ }
- outw.println(MessageFormat.format(CLIText.get().jgitVersion, version));
+ try {
+ outw.println(
+ MessageFormat.format(CLIText.get().jgitVersion, version));
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
+ }
}
/** {@inheritDoc} */
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
index b3ad8bf..d0288a8 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
@@ -165,6 +165,7 @@ public static String fatalError(String message) {
/***/ public String clonedEmptyRepository;
/***/ public String cloningInto;
/***/ public String commitLabel;
+ /***/ public String configOnlyListOptionSupported;
/***/ public String conflictingUsageOf_git_dir_andArguments;
/***/ public String couldNotCreateBranch;
/***/ public String dateInfo;
@@ -278,7 +279,7 @@ public static String fatalError(String message) {
/***/ public String onBranchToBeBorn;
/***/ public String onBranch;
/***/ public String onlyOneMetaVarExpectedIn;
- /***/ public String onlyOneOfIncludeOnlyAllInteractiveCanBeUsed;
+ /***/ public String onlyOneCommitOptionAllowed;
/***/ public String password;
/***/ public String pathspecDidNotMatch;
/***/ public String pushTo;
@@ -289,6 +290,7 @@ public static String fatalError(String message) {
/***/ public String remoteSideDoesNotSupportDeletingRefs;
/***/ public String removing;
/***/ public String repaint;
+ /***/ public String resetNoMode;
/***/ public String s3InvalidBucket;
/***/ public String serviceNotSupported;
/***/ public String skippingObject;
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/CachingKeyPairProvider.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/CachingKeyPairProvider.java
index 06a0a5f..1072f32 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/CachingKeyPairProvider.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/CachingKeyPairProvider.java
@@ -63,7 +63,8 @@
* A {@link EncryptedFileKeyPairProvider} that uses an external
* {@link KeyCache}.
*/
-public class CachingKeyPairProvider extends EncryptedFileKeyPairProvider {
+public class CachingKeyPairProvider extends EncryptedFileKeyPairProvider
+ implements Iterable<KeyPair> {
private final KeyCache cache;
@@ -83,11 +84,17 @@ public CachingKeyPairProvider(List<Path> paths, KeyCache cache) {
}
@Override
- protected Iterable<KeyPair> loadKeys(Collection<? extends Path> resources) {
+ public Iterator<KeyPair> iterator() {
+ Collection<? extends Path> resources = getPaths();
if (resources.isEmpty()) {
- return Collections.emptyList();
+ return Collections.emptyListIterator();
}
- return () -> new CancellingKeyPairIterator(resources);
+ return new CancellingKeyPairIterator(resources);
+ }
+
+ @Override
+ public Iterable<KeyPair> loadKeys() {
+ return this;
}
@Override
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/EncryptedFileKeyPairProvider.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/EncryptedFileKeyPairProvider.java
index ff81989..ef8e611 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/EncryptedFileKeyPairProvider.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/EncryptedFileKeyPairProvider.java
@@ -70,7 +70,7 @@
* encrypted private key if the {@link FilePasswordProvider} is a
* {@link RepeatingFilePasswordProvider}.
*/
-public class EncryptedFileKeyPairProvider extends FileKeyPairProvider {
+public abstract class EncryptedFileKeyPairProvider extends FileKeyPairProvider {
// TODO: remove this class once we're based on sshd > 2.1.0. See upstream
// issue SSHD-850 https://issues.apache.org/jira/browse/SSHD-850 and commit
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java
index 212b67f..b9ff5e5 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/JGitSshClient.java
@@ -70,7 +70,7 @@
import org.apache.sshd.common.future.SshFutureListener;
import org.apache.sshd.common.io.IoConnectFuture;
import org.apache.sshd.common.io.IoSession;
-import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
+import org.apache.sshd.common.keyprovider.AbstractResourceKeyPairProvider;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
import org.apache.sshd.common.session.helpers.AbstractSession;
import org.apache.sshd.common.util.ValidateUtils;
@@ -243,12 +243,11 @@ private JGitClientSession createSession(IoSession ioSession,
int numberOfPasswordPrompts = getNumberOfPasswordPrompts(hostConfig);
session.getProperties().put(PASSWORD_PROMPTS,
Integer.valueOf(numberOfPasswordPrompts));
- FilePasswordProvider provider = getFilePasswordProvider();
- if (provider instanceof RepeatingFilePasswordProvider) {
- ((RepeatingFilePasswordProvider) provider)
+ FilePasswordProvider passwordProvider = getFilePasswordProvider();
+ if (passwordProvider instanceof RepeatingFilePasswordProvider) {
+ ((RepeatingFilePasswordProvider) passwordProvider)
.setAttempts(numberOfPasswordPrompts);
}
- FileKeyPairProvider ourConfiguredKeysProvider = null;
List<Path> identities = hostConfig.getIdentities().stream()
.map(s -> {
try {
@@ -260,16 +259,16 @@ private JGitClientSession createSession(IoSession ioSession,
}
}).filter(p -> p != null && Files.exists(p))
.collect(Collectors.toList());
- ourConfiguredKeysProvider = new CachingKeyPairProvider(identities,
- keyCache);
- ourConfiguredKeysProvider.setPasswordFinder(getFilePasswordProvider());
+ CachingKeyPairProvider ourConfiguredKeysProvider = new CachingKeyPairProvider(
+ identities, keyCache);
+ ourConfiguredKeysProvider.setPasswordFinder(passwordProvider);
if (hostConfig.isIdentitiesOnly()) {
session.setKeyPairProvider(ourConfiguredKeysProvider);
} else {
KeyPairProvider defaultKeysProvider = getKeyPairProvider();
- if (defaultKeysProvider instanceof FileKeyPairProvider) {
- ((FileKeyPairProvider) defaultKeysProvider)
- .setPasswordFinder(getFilePasswordProvider());
+ if (defaultKeysProvider instanceof AbstractResourceKeyPairProvider<?>) {
+ ((AbstractResourceKeyPairProvider<?>) defaultKeysProvider)
+ .setPasswordFinder(passwordProvider);
}
KeyPairProvider combinedProvider = new CombinedKeyPairProvider(
ourConfiguredKeysProvider, defaultKeysProvider);
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/KnownHostEntryReader.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/KnownHostEntryReader.java
index 4db24a1..659ffae 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/KnownHostEntryReader.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/KnownHostEntryReader.java
@@ -42,13 +42,13 @@
*/
package org.eclipse.jgit.internal.transport.sshd;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static java.text.MessageFormat.format;
import static org.apache.sshd.client.config.hosts.HostPatternsHolder.NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM;
import static org.apache.sshd.client.config.hosts.HostPatternsHolder.NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM;
import java.io.BufferedReader;
import java.io.IOException;
-import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
@@ -99,8 +99,7 @@ private KnownHostEntryReader() {
public static List<KnownHostEntry> readFromFile(Path path)
throws IOException {
List<KnownHostEntry> result = new LinkedList<>();
- try (BufferedReader r = Files.newBufferedReader(path,
- StandardCharsets.UTF_8)) {
+ try (BufferedReader r = Files.newBufferedReader(path, UTF_8)) {
r.lines().forEachOrdered(l -> {
if (l == null) {
return;
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyVerifier.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyVerifier.java
index cfd3d19..7d8f3fd 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyVerifier.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/OpenSshServerKeyVerifier.java
@@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.internal.transport.sshd;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static java.text.MessageFormat.format;
import java.io.BufferedReader;
@@ -52,7 +53,6 @@
import java.io.OutputStreamWriter;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
-import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
@@ -386,7 +386,7 @@ private void updateKnownHostsFile(ClientSession clientSession,
try {
try (BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(lock.getOutputStream(),
- StandardCharsets.UTF_8))) {
+ UTF_8))) {
writer.newLine();
writer.write(entry.getConfigLine());
writer.newLine();
@@ -422,10 +422,9 @@ private void updateModifiedServerKey(ClientSession clientSession,
if (lock.lock()) {
try {
try (BufferedWriter writer = new BufferedWriter(
- new OutputStreamWriter(lock.getOutputStream(),
- StandardCharsets.UTF_8));
+ new OutputStreamWriter(lock.getOutputStream(), UTF_8));
BufferedReader reader = Files.newBufferedReader(path,
- StandardCharsets.UTF_8)) {
+ UTF_8)) {
boolean done = false;
String line;
while ((line = reader.readLine()) != null) {
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/auth/BasicAuthentication.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/auth/BasicAuthentication.java
index efb1f55..a257a5e 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/auth/BasicAuthentication.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/auth/BasicAuthentication.java
@@ -42,13 +42,14 @@
*/
package org.eclipse.jgit.internal.transport.sshd.auth;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.net.Authenticator;
import java.net.Authenticator.RequestorType;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
-import java.nio.charset.StandardCharsets;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
@@ -99,7 +100,7 @@ public BasicAuthentication(InetSocketAddress proxy, String initialUser,
if (pass == null) {
return new byte[0];
}
- ByteBuffer bytes = StandardCharsets.UTF_8.encode(CharBuffer.wrap(pass));
+ ByteBuffer bytes = UTF_8.encode(CharBuffer.wrap(pass));
byte[] pwd = new byte[bytes.remaining()];
bytes.get(pwd);
if (bytes.hasArray()) {
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpClientConnector.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpClientConnector.java
index 46cdd52..c66ee38 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpClientConnector.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/HttpClientConnector.java
@@ -42,12 +42,13 @@
*/
package org.eclipse.jgit.internal.transport.sshd.proxy;
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static java.text.MessageFormat.format;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
-import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -164,7 +165,7 @@ public void sendClientProxyMetadata(ClientSession sshSession)
}
private void send(StringBuilder msg, IoSession session) throws Exception {
- byte[] data = eol(msg).toString().getBytes(StandardCharsets.US_ASCII);
+ byte[] data = eol(msg).toString().getBytes(US_ASCII);
Buffer buffer = new ByteArrayBuffer(data.length, false);
buffer.putRawBytes(data);
session.writePacket(buffer).verify(getTimeout());
@@ -196,7 +197,7 @@ public void messageReceived(IoSession session, Readable buffer)
int length = buffer.available();
byte[] data = new byte[length];
buffer.getRawBytes(data, 0, length);
- String[] reply = new String(data, StandardCharsets.US_ASCII)
+ String[] reply = new String(data, US_ASCII)
.split("\r\n"); //$NON-NLS-1$
handleMessage(session, Arrays.asList(reply));
} catch (Exception e) {
@@ -348,7 +349,7 @@ public String getToken() throws Exception {
throw new IOException(format(
SshdText.get().proxyHttpInvalidUserName, proxy, user));
}
- byte[] rawUser = user.getBytes(StandardCharsets.UTF_8);
+ byte[] rawUser = user.getBytes(UTF_8);
byte[] toEncode = new byte[rawUser.length + 1 + password.length];
System.arraycopy(rawUser, 0, toEncode, 0, rawUser.length);
toEncode[rawUser.length] = ':';
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/Socks5ClientConnector.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/Socks5ClientConnector.java
index 1844fdc..27d6f41 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/Socks5ClientConnector.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/proxy/Socks5ClientConnector.java
@@ -42,12 +42,13 @@
*/
package org.eclipse.jgit.internal.transport.sshd.proxy;
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static java.text.MessageFormat.format;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
-import java.nio.charset.StandardCharsets;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.io.IoSession;
@@ -295,8 +296,7 @@ private void sendConnectInfo(IoSession session) throws Exception {
byte type;
int length = 0;
if (rawAddress == null) {
- remoteName = remoteAddress.getHostString()
- .getBytes(StandardCharsets.US_ASCII);
+ remoteName = remoteAddress.getHostString().getBytes(US_ASCII);
if (remoteName == null || remoteName.length == 0) {
throw new IOException(
format(SshdText.get().proxySocksNoRemoteHostName,
@@ -542,7 +542,7 @@ public Buffer getToken() throws IOException {
return null;
}
try {
- byte[] rawUser = user.getBytes(StandardCharsets.UTF_8);
+ byte[] rawUser = user.getBytes(UTF_8);
if (rawUser.length > 255) {
throw new IOException(format(
SshdText.get().proxySocksUsernameTooLong, proxy,
diff --git a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSessionFactory.java b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSessionFactory.java
index 275cf58..cdd47bf 100644
--- a/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSessionFactory.java
+++ b/org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSessionFactory.java
@@ -47,6 +47,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.security.KeyPair;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
@@ -68,7 +69,6 @@
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.compression.BuiltinCompressions;
import org.apache.sshd.common.config.keys.FilePasswordProvider;
-import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.errors.TransportException;
@@ -89,7 +89,9 @@
import org.eclipse.jgit.util.FS;
/**
- * A {@link SshSessionFactory} that uses Apache MINA sshd.
+ * A {@link SshSessionFactory} that uses Apache MINA sshd. Classes from Apache
+ * MINA sshd are kept private to avoid API evolution problems when Apache MINA
+ * sshd interfaces change.
*
* @since 5.2
*/
@@ -103,7 +105,7 @@ public class SshdSessionFactory extends SshSessionFactory implements Closeable {
private final Map<Tuple, ServerKeyVerifier> defaultServerKeyVerifier = new ConcurrentHashMap<>();
- private final Map<Tuple, FileKeyPairProvider> defaultKeys = new ConcurrentHashMap<>();
+ private final Map<Tuple, Iterable<KeyPair>> defaultKeys = new ConcurrentHashMap<>();
private final KeyCache keyCache;
@@ -209,8 +211,8 @@ public SshdSession getSession(URIish uri,
}
HostConfigEntryResolver configFile = getHostConfigEntryResolver(
home, sshDir);
- KeyPairProvider defaultKeysProvider = getDefaultKeysProvider(
- sshDir);
+ KeyPairProvider defaultKeysProvider = toKeyPairProvider(
+ getDefaultKeys(sshDir));
KeyPasswordProvider passphrases = createKeyPasswordProvider(
credentialsProvider);
SshClient client = ClientBuilder.builder()
@@ -395,14 +397,38 @@ protected List<Path> getDefaultKnownHostsFiles(@NonNull File sshDir) {
}
/**
- * Determines a {@link KeyPairProvider} to use to load the default keys.
+ * Determines the default keys. The default implementation will lazy load
+ * the {@link #getDefaultIdentities(File) default identity files}.
+ * <p>
+ * Subclasses may override and return an {@link Iterable} of whatever keys
+ * are appropriate. If the returned iterable lazily loads keys, it should be
+ * an instance of
+ * {@link org.apache.sshd.common.keyprovider.AbstractResourceKeyPairProvider
+ * AbstractResourceKeyPairProvider} so that the session can later pass it
+ * the {@link #createKeyPasswordProvider(CredentialsProvider) password
+ * provider} wrapped as a {@link FilePasswordProvider} via
+ * {@link org.apache.sshd.common.keyprovider.AbstractResourceKeyPairProvider#setPasswordFinder(FilePasswordProvider)
+ * AbstractResourceKeyPairProvider#setPasswordFinder(FilePasswordProvider)}
+ * so that encrypted, password-protected keys can be loaded.
+ * </p>
+ * <p>
+ * The default implementation uses exactly this mechanism; class
+ * {@link CachingKeyPairProvider} may serve as a model for a customized
+ * lazy-loading {@link Iterable} implementation
+ * </p>
+ * <p>
+ * If the {@link Iterable} returned has the keys already pre-loaded or
+ * otherwise doesn't need to decrypt encrypted keys, it can be any
+ * {@link Iterable}, for instance a simple {@link java.util.List List}.
+ * </p>
*
* @param sshDir
* to look in for keys
- * @return the {@link KeyPairProvider}
+ * @return an {@link Iterable} over the default keys
+ * @since 5.3
*/
@NonNull
- private KeyPairProvider getDefaultKeysProvider(@NonNull File sshDir) {
+ protected Iterable<KeyPair> getDefaultKeys(@NonNull File sshDir) {
List<Path> defaultIdentities = getDefaultIdentities(sshDir);
return defaultKeys.computeIfAbsent(
new Tuple(defaultIdentities.toArray(new Path[0])),
@@ -411,6 +437,21 @@ private KeyPairProvider getDefaultKeysProvider(@NonNull File sshDir) {
}
/**
+ * Converts an {@link Iterable} of {link KeyPair}s into a
+ * {@link KeyPairProvider}.
+ *
+ * @param keys
+ * to provide via the returned {@link KeyPairProvider}
+ * @return a {@link KeyPairProvider} that provides the given {@code keys}
+ */
+ private KeyPairProvider toKeyPairProvider(Iterable<KeyPair> keys) {
+ if (keys instanceof KeyPairProvider) {
+ return (KeyPairProvider) keys;
+ }
+ return () -> keys;
+ }
+
+ /**
* Gets a list of default identities, i.e., private key files that shall
* always be tried for public key authentication. Typically those are
* ~/.ssh/id_dsa, ~/.ssh/id_rsa, and so on. The default implementation
diff --git a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java
index dde55b6..2f367ba 100644
--- a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java
+++ b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java
@@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.transport.ssh;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -51,7 +52,6 @@
import java.io.File;
import java.io.IOException;
-import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import java.util.Locale;
@@ -409,8 +409,7 @@ public void testSshModifiedHostKeyWithProviderDeny() throws Exception {
private void checkKnownHostsModifiedHostKey(File backup, File newFile,
String wrongKey) throws IOException {
- List<String> oldLines = Files.readAllLines(backup.toPath(),
- StandardCharsets.UTF_8);
+ List<String> oldLines = Files.readAllLines(backup.toPath(), UTF_8);
// Find the original entry. We should have that again in known_hosts.
String oldKeyPart = null;
for (String oldLine : oldLines) {
@@ -424,8 +423,7 @@ private void checkKnownHostsModifiedHostKey(File backup, File newFile,
}
}
assertNotNull("Old key not found", oldKeyPart);
- List<String> newLines = Files.readAllLines(newFile.toPath(),
- StandardCharsets.UTF_8);
+ List<String> newLines = Files.readAllLines(newFile.toPath(), UTF_8);
assertFalse("Old host key still found in known_hosts file" + newFile,
hasHostKey("localhost", testPort, wrongKey, newLines));
assertTrue("New host key not found in known_hosts file" + newFile,
@@ -448,10 +446,10 @@ public void testSshModifiedHostKeyAllow() throws Exception {
"IdentityFile " + privateKey1.getAbsolutePath());
// File should not have been updated!
String[] oldLines = Files
- .readAllLines(backup.toPath(), StandardCharsets.UTF_8)
+ .readAllLines(backup.toPath(), UTF_8)
.toArray(new String[0]);
String[] newLines = Files
- .readAllLines(knownHosts.toPath(), StandardCharsets.UTF_8)
+ .readAllLines(knownHosts.toPath(), UTF_8)
.toArray(new String[0]);
assertArrayEquals("Known hosts file should not be modified", oldLines,
newLines);
diff --git a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestHarness.java b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestHarness.java
index 59925a5..ada16b7 100644
--- a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestHarness.java
+++ b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestHarness.java
@@ -42,6 +42,8 @@
*/
package org.eclipse.jgit.transport.ssh;
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@@ -54,7 +56,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
@@ -150,7 +151,7 @@ public void setUp() throws Exception {
knownHosts = new File(sshDir, "known_hosts");
Files.write(knownHosts.toPath(), Collections.singleton("[localhost]:"
+ testPort + ' '
- + publicHostKey.toString(StandardCharsets.US_ASCII.name())));
+ + publicHostKey.toString(US_ASCII.name())));
factory = createSessionFactory();
SshSessionFactory.setInstance(factory);
}
@@ -200,8 +201,7 @@ private static File createKeyPair(File privateKeyFile) throws Exception {
*/
protected static String createKnownHostsFile(File file, String host,
int port, File publicKey) throws IOException {
- List<String> lines = Files.readAllLines(publicKey.toPath(),
- StandardCharsets.UTF_8);
+ List<String> lines = Files.readAllLines(publicKey.toPath(), UTF_8);
assertEquals("Public key has too many lines", 1, lines.size());
String pubKey = lines.get(0);
// Strip off the comment.
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
index 1a5793c..3fee51a 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
@@ -501,11 +501,11 @@ public void testAddExistingSingleSmallFileWithNewLine() throws IOException,
indexState(CONTENT));
db.getConfig().setString("core", null, "autocrlf", "true");
git.add().addFilepattern("a.txt").call();
- assertEquals("[a.txt, mode:100644, content:row1\nrow2]",
+ assertEquals("[a.txt, mode:100644, content:row1\r\nrow2]",
indexState(CONTENT));
db.getConfig().setString("core", null, "autocrlf", "input");
git.add().addFilepattern("a.txt").call();
- assertEquals("[a.txt, mode:100644, content:row1\nrow2]",
+ assertEquals("[a.txt, mode:100644, content:row1\r\nrow2]",
indexState(CONTENT));
}
}
@@ -523,19 +523,18 @@ public void testAddExistingSingleMediumSizeFileWithNewLine()
try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) {
writer.print(crData);
}
- String lfData = data.toString().replaceAll("\r", "");
try (Git git = new Git(db)) {
db.getConfig().setString("core", null, "autocrlf", "false");
git.add().addFilepattern("a.txt").call();
- assertEquals("[a.txt, mode:100644, content:" + data + "]",
+ assertEquals("[a.txt, mode:100644, content:" + crData + "]",
indexState(CONTENT));
db.getConfig().setString("core", null, "autocrlf", "true");
git.add().addFilepattern("a.txt").call();
- assertEquals("[a.txt, mode:100644, content:" + lfData + "]",
+ assertEquals("[a.txt, mode:100644, content:" + crData + "]",
indexState(CONTENT));
db.getConfig().setString("core", null, "autocrlf", "input");
git.add().addFilepattern("a.txt").call();
- assertEquals("[a.txt, mode:100644, content:" + lfData + "]",
+ assertEquals("[a.txt, mode:100644, content:" + crData + "]",
indexState(CONTENT));
}
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
index 749c344..98a8adc 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java
@@ -145,6 +145,7 @@ public void testCheckoutForced() throws Exception {
git.checkout().setName("master").call().getObjectId();
fail("Expected CheckoutConflictException didn't occur");
} catch (CheckoutConflictException e) {
+ // Expected
}
assertEquals(initialCommit.getId(), git.checkout().setName("master")
.setForced(true).call().getObjectId());
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
index 6b5fe50..1523b49 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
@@ -424,6 +424,32 @@ public void testBareCloneRepositoryOnlyOneBranch() throws Exception {
specs.get(0));
}
+ @Test
+ public void testCloneRepositoryOnlyOneTag() throws Exception {
+ File directory = createTempDirectory("testCloneRepositoryWithBranch");
+ CloneCommand command = Git.cloneRepository();
+ command.setBranch("tag-initial");
+ command.setBranchesToClone(
+ Collections.singletonList("refs/tags/tag-initial"));
+ command.setDirectory(directory);
+ command.setURI(fileUri());
+ Git git2 = command.call();
+ addRepoToClose(git2.getRepository());
+ assertNotNull(git2);
+ assertNull(git2.getRepository().resolve("tag-for-blob"));
+ assertNull(git2.getRepository().resolve("refs/heads/master"));
+ assertNotNull(git2.getRepository().resolve("tag-initial"));
+ ObjectId taggedCommit = db.resolve("tag-initial^{commit}");
+ assertEquals(taggedCommit.name(), git2.getRepository().getFullBranch());
+ RemoteConfig cfg = new RemoteConfig(git2.getRepository().getConfig(),
+ Constants.DEFAULT_REMOTE_NAME);
+ List<RefSpec> specs = cfg.getFetchRefSpecs();
+ assertEquals(1, specs.size());
+ assertEquals(
+ new RefSpec("+refs/tags/tag-initial:refs/tags/tag-initial"),
+ specs.get(0));
+ }
+
public static String allRefNames(List<Ref> refs) {
StringBuilder sb = new StringBuilder();
for (Ref f : refs) {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java
index 5f1992c..cd96f41 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java
@@ -56,6 +56,8 @@
import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicInteger;
+import org.eclipse.jgit.api.CherryPickResult.CherryPickStatus;
+import org.eclipse.jgit.api.errors.CanceledException;
import org.eclipse.jgit.api.errors.EmptyCommitException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.diff.DiffEntry;
@@ -76,6 +78,7 @@
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.submodule.SubmoduleWalk;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.treewalk.TreeWalk;
@@ -619,9 +622,100 @@ public void commitOnlyShouldHandleIgnored() throws Exception {
writeTrashFile(".gitignore", "bar");
git.add().addFilepattern("subdir").call();
git.commit().setOnly("subdir").setMessage("first commit").call();
+ assertEquals("[subdir/foo, mode:100644, content:Hello World]",
+ indexState(CONTENT));
}
}
+ @Test
+ public void commitWithAutoCrlfAndNonNormalizedIndex() throws Exception {
+ try (Git git = new Git(db)) {
+ // Commit a file with CR/LF into the index
+ FileBasedConfig config = db.getConfig();
+ config.setString("core", null, "autocrlf", "false");
+ config.save();
+ writeTrashFile("file.txt", "line 1\r\nline 2\r\n");
+ git.add().addFilepattern("file.txt").call();
+ git.commit().setMessage("Initial").call();
+ assertEquals(
+ "[file.txt, mode:100644, content:line 1\r\nline 2\r\n]",
+ indexState(CONTENT));
+ config.setString("core", null, "autocrlf", "true");
+ config.save();
+ writeTrashFile("file.txt", "line 1\r\nline 1.5\r\nline 2\r\n");
+ writeTrashFile("file2.txt", "new\r\nfile\r\n");
+ git.add().addFilepattern("file.txt").addFilepattern("file2.txt")
+ .call();
+ git.commit().setMessage("Second").call();
+ assertEquals(
+ "[file.txt, mode:100644, content:line 1\r\nline 1.5\r\nline 2\r\n]"
+ + "[file2.txt, mode:100644, content:new\nfile\n]",
+ indexState(CONTENT));
+ writeTrashFile("file2.txt", "new\r\nfile\r\ncontent\r\n");
+ git.add().addFilepattern("file2.txt").call();
+ git.commit().setMessage("Third").call();
+ assertEquals(
+ "[file.txt, mode:100644, content:line 1\r\nline 1.5\r\nline 2\r\n]"
+ + "[file2.txt, mode:100644, content:new\nfile\ncontent\n]",
+ indexState(CONTENT));
+ }
+ }
+
+ private void testConflictWithAutoCrlf(String baseLf, String lf)
+ throws Exception {
+ try (Git git = new Git(db)) {
+ // Commit a file with CR/LF into the index
+ FileBasedConfig config = db.getConfig();
+ config.setString("core", null, "autocrlf", "false");
+ config.save();
+ writeTrashFile("file.txt", "foo" + baseLf);
+ git.add().addFilepattern("file.txt").call();
+ git.commit().setMessage("Initial").call();
+ // Switch to side branch
+ git.checkout().setCreateBranch(true).setName("side").call();
+ writeTrashFile("file.txt", "bar\r\n");
+ git.add().addFilepattern("file.txt").call();
+ RevCommit side = git.commit().setMessage("Side").call();
+ // Switch back to master and commit a conflict with the given lf
+ git.checkout().setName("master");
+ writeTrashFile("file.txt", "foob" + lf);
+ git.add().addFilepattern("file.txt").call();
+ git.commit().setMessage("Second").call();
+ // Switch on autocrlf=true
+ config.setString("core", null, "autocrlf", "true");
+ config.save();
+ // Cherry pick side: conflict. Resolve with CR-LF and commit.
+ CherryPickResult pick = git.cherryPick().include(side).call();
+ assertEquals("Expected a cherry-pick conflict",
+ CherryPickStatus.CONFLICTING, pick.getStatus());
+ writeTrashFile("file.txt", "foobar\r\n");
+ git.add().addFilepattern("file.txt").call();
+ git.commit().setMessage("Second").call();
+ assertEquals("[file.txt, mode:100644, content:foobar" + lf + "]",
+ indexState(CONTENT));
+ }
+ }
+
+ @Test
+ public void commitConflictWithAutoCrlfBaseCrLfOursLf() throws Exception {
+ testConflictWithAutoCrlf("\r\n", "\n");
+ }
+
+ @Test
+ public void commitConflictWithAutoCrlfBaseLfOursLf() throws Exception {
+ testConflictWithAutoCrlf("\n", "\n");
+ }
+
+ @Test
+ public void commitConflictWithAutoCrlfBasCrLfOursCrLf() throws Exception {
+ testConflictWithAutoCrlf("\r\n", "\r\n");
+ }
+
+ @Test
+ public void commitConflictWithAutoCrlfBaseLfOursCrLf() throws Exception {
+ testConflictWithAutoCrlf("\n", "\r\n");
+ }
+
private static void addUnmergedEntry(String file, DirCacheBuilder builder) {
DirCacheEntry stage1 = new DirCacheEntry(file, DirCacheEntry.STAGE_1);
DirCacheEntry stage2 = new DirCacheEntry(file, DirCacheEntry.STAGE_2);
@@ -651,6 +745,14 @@ public void sign(CommitBuilder commit, String gpgSigningKey,
signingCommitters[0] = signingCommitter;
callCount.incrementAndGet();
}
+
+ @Override
+ public boolean canLocateSigningKey(String gpgSigningKey,
+ PersonIdent signingCommitter,
+ CredentialsProvider credentialsProvider)
+ throws CanceledException {
+ return false;
+ }
});
// first call should use config, which is expected to be null at
@@ -706,6 +808,14 @@ public void sign(CommitBuilder commit, String gpgSigningKey,
PersonIdent signingCommitter, CredentialsProvider credentialsProvider) {
callCount.incrementAndGet();
}
+
+ @Override
+ public boolean canLocateSigningKey(String gpgSigningKey,
+ PersonIdent signingCommitter,
+ CredentialsProvider credentialsProvider)
+ throws CanceledException {
+ return false;
+ }
});
// first call should use config, which is expected to be null at
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
index 9af003d..5a15838 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
@@ -1557,32 +1557,37 @@ public void testFastForwardOnlyNotPossible() throws Exception {
@Test
public void testRecursiveMergeWithConflict() throws Exception {
- TestRepository<Repository> db_t = new TestRepository<>(db);
- BranchBuilder master = db_t.branch("master");
- RevCommit m0 = master.commit().add("f", "1\n2\n3\n4\n5\n6\n7\n8\n9\n")
- .message("m0").create();
- RevCommit m1 = master.commit()
- .add("f", "1-master\n2\n3\n4\n5\n6\n7\n8\n9\n").message("m1")
- .create();
- db_t.getRevWalk().parseCommit(m1);
+ try (TestRepository<Repository> db_t = new TestRepository<>(db)) {
+ BranchBuilder master = db_t.branch("master");
+ RevCommit m0 = master.commit()
+ .add("f", "1\n2\n3\n4\n5\n6\n7\n8\n9\n").message("m0")
+ .create();
+ RevCommit m1 = master.commit()
+ .add("f", "1-master\n2\n3\n4\n5\n6\n7\n8\n9\n")
+ .message("m1").create();
+ db_t.getRevWalk().parseCommit(m1);
- BranchBuilder side = db_t.branch("side");
- RevCommit s1 = side.commit().parent(m0)
- .add("f", "1\n2\n3\n4\n5\n6\n7\n8\n9-side\n").message("s1")
- .create();
- RevCommit s2 = side.commit().parent(m1)
- .add("f", "1-master\n2\n3\n4\n5\n6\n7-res(side)\n8\n9-side\n")
- .message("s2(merge)").create();
- master.commit().parent(s1)
- .add("f", "1-master\n2\n3\n4\n5\n6\n7-conflict\n8\n9-side\n")
- .message("m2(merge)").create();
+ BranchBuilder side = db_t.branch("side");
+ RevCommit s1 = side.commit().parent(m0)
+ .add("f", "1\n2\n3\n4\n5\n6\n7\n8\n9-side\n").message("s1")
+ .create();
+ RevCommit s2 = side.commit().parent(m1)
+ .add("f",
+ "1-master\n2\n3\n4\n5\n6\n7-res(side)\n8\n9-side\n")
+ .message("s2(merge)").create();
+ master.commit().parent(s1)
+ .add("f",
+ "1-master\n2\n3\n4\n5\n6\n7-conflict\n8\n9-side\n")
+ .message("m2(merge)").create();
- Git git = Git.wrap(db);
- git.checkout().setName("master").call();
+ Git git = Git.wrap(db);
+ git.checkout().setName("master").call();
- MergeResult result = git.merge().setStrategy(MergeStrategy.RECURSIVE)
- .include("side", s2).call();
- assertEquals(MergeStatus.CONFLICTING, result.getMergeStatus());
+ MergeResult result = git.merge()
+ .setStrategy(MergeStrategy.RECURSIVE).include("side", s2)
+ .call();
+ assertEquals(MergeStatus.CONFLICTING, result.getMergeStatus());
+ }
}
private Ref prepareSuccessfulMerge(Git git) throws Exception {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteDeleteCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteDeleteCommandTest.java
index 7055daf..50e7095 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteDeleteCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteDeleteCommandTest.java
@@ -56,7 +56,7 @@ public void testDelete() throws Exception {
// execute the command to remove the remote
RemoteRemoveCommand cmd = Git.wrap(db).remoteRemove();
- cmd.setName(REMOTE_NAME);
+ cmd.setRemoteName(REMOTE_NAME);
RemoteConfig remote = cmd.call();
// assert that the removed remote is the initial remote
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteSetUrlCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteSetUrlCommandTest.java
index 6969c3d..d3265fe 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteSetUrlCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RemoteSetUrlCommandTest.java
@@ -45,6 +45,7 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import org.eclipse.jgit.api.RemoteSetUrlCommand.UriType;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.URIish;
import org.junit.Test;
@@ -58,9 +59,9 @@ public void testSetUrl() throws Exception {
// execute the command to change the fetch url
RemoteSetUrlCommand cmd = Git.wrap(db).remoteSetUrl();
- cmd.setName(REMOTE_NAME);
+ cmd.setRemoteName(REMOTE_NAME);
URIish newUri = new URIish("git://test.com/test");
- cmd.setUri(newUri);
+ cmd.setRemoteUri(newUri);
RemoteConfig remote = cmd.call();
// assert that the changed remote has the new fetch url
@@ -79,10 +80,10 @@ public void testSetPushUrl() throws Exception {
// execute the command to change the push url
RemoteSetUrlCommand cmd = Git.wrap(db).remoteSetUrl();
- cmd.setName(REMOTE_NAME);
+ cmd.setRemoteName(REMOTE_NAME);
URIish newUri = new URIish("git://test.com/test");
- cmd.setUri(newUri);
- cmd.setPush(true);
+ cmd.setRemoteUri(newUri);
+ cmd.setUriType(UriType.PUSH);
RemoteConfig remote = cmd.call();
// assert that the changed remote has the old fetch url and the new push
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java
index 5c437ac..9facce9 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RenameBranchCommandTest.java
@@ -49,14 +49,18 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import org.eclipse.jgit.api.errors.RefAlreadyExistsException;
import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.lib.BranchConfig.BranchRebaseMode;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
/**
* Unit tests of {@link RenameBranchCommand}
@@ -69,6 +73,9 @@ public class RenameBranchCommandTest extends RepositoryTestCase {
private Git git;
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
@Override
@Before
public void setUp() throws Exception {
@@ -81,6 +88,45 @@ public void setUp() throws Exception {
}
@Test
+ public void renameToExisting() throws Exception {
+ assertNotNull(git.branchCreate().setName("foo").call());
+ thrown.expect(RefAlreadyExistsException.class);
+ git.branchRename().setOldName("master").setNewName("foo").call();
+ }
+
+ @Test
+ public void renameToTag() throws Exception {
+ Ref ref = git.tag().setName("foo").call();
+ assertNotNull(ref);
+ assertEquals("Unexpected tag name", Constants.R_TAGS + "foo",
+ ref.getName());
+ ref = git.branchRename().setNewName("foo").call();
+ assertNotNull(ref);
+ assertEquals("Unexpected ref name", Constants.R_HEADS + "foo",
+ ref.getName());
+ // Check that we can rename it back
+ ref = git.branchRename().setOldName("foo").setNewName(Constants.MASTER)
+ .call();
+ assertNotNull(ref);
+ assertEquals("Unexpected ref name",
+ Constants.R_HEADS + Constants.MASTER, ref.getName());
+ }
+
+ @Test
+ public void renameToStupidName() throws Exception {
+ Ref ref = git.branchRename().setNewName(Constants.R_HEADS + "foo")
+ .call();
+ assertEquals("Unexpected ref name",
+ Constants.R_HEADS + Constants.R_HEADS + "foo",
+ ref.getName());
+ // And check that we can rename it back to a sane name
+ ref = git.branchRename().setNewName("foo").call();
+ assertNotNull(ref);
+ assertEquals("Unexpected ref name", Constants.R_HEADS + "foo",
+ ref.getName());
+ }
+
+ @Test
public void renameBranchNoConfigValues() throws Exception {
StoredConfig config = git.getRepository().getConfig();
config.unsetSection(ConfigConstants.CONFIG_BRANCH_SECTION,
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java
index 178d620..5333451 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java
@@ -79,6 +79,36 @@ public void testNul() {
}
@Test
+ public void testCrLfTextYes() {
+ assertTrue(RawText
+ .isCrLfText(Constants.encodeASCII("line 1\r\nline 2\r\n")));
+ }
+
+ @Test
+ public void testCrLfTextNo() {
+ assertFalse(
+ RawText.isCrLfText(Constants.encodeASCII("line 1\nline 2\n")));
+ }
+
+ @Test
+ public void testCrLfTextBinary() {
+ assertFalse(RawText
+ .isCrLfText(Constants.encodeASCII("line 1\r\nline\0 2\r\n")));
+ }
+
+ @Test
+ public void testCrLfTextMixed() {
+ assertTrue(RawText
+ .isCrLfText(Constants.encodeASCII("line 1\nline 2\r\n")));
+ }
+
+ @Test
+ public void testCrLfTextCutShort() {
+ assertFalse(
+ RawText.isCrLfText(Constants.encodeASCII("line 1\nline 2\r")));
+ }
+
+ @Test
public void testEquals() {
final RawText a = new RawText(Constants.encodeASCII("foo-a\nfoo-b\n"));
final RawText b = new RawText(Constants.encodeASCII("foo-b\nfoo-c\n"));
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsPackFileTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsPackFileTest.java
new file mode 100644
index 0000000..dd41b6f
--- /dev/null
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsPackFileTest.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2019, Google LLC.
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.eclipse.jgit.internal.storage.dfs;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.zip.Deflater;
+
+import org.eclipse.jgit.internal.storage.pack.PackExt;
+import org.eclipse.jgit.internal.storage.pack.PackOutputStream;
+import org.eclipse.jgit.internal.storage.pack.PackWriter;
+import org.eclipse.jgit.junit.JGitTestUtil;
+import org.eclipse.jgit.junit.TestRng;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.NullProgressMonitor;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DfsPackFileTest {
+ InMemoryRepository db;
+ boolean bypassCache;
+ boolean clearCache;
+
+ @Before
+ public void setUp() {
+ db = new InMemoryRepository(new DfsRepositoryDescription("test"));
+ }
+
+ @Test
+ public void testCopyPackBypassCachesSmallCached() throws IOException {
+ bypassCache = true;
+ clearCache = false;
+ setupPack(512, 256);
+ assertPackSize();
+ }
+
+ @Test
+ public void testCopyPackBypassCacheSmallNoCache() throws IOException {
+ bypassCache = true;
+ clearCache = true;
+ setupPack(512, 256);
+ assertPackSize();
+ }
+
+ @Test
+ public void testCopyPackBypassCacheLargeCached() throws IOException {
+ bypassCache = true;
+ clearCache = false;
+ setupPack(512, 8000);
+ assertPackSize();
+ }
+
+ @Test
+ public void testCopyPackBypassCacheLargeNoCache() throws IOException {
+ bypassCache = true;
+ clearCache = true;
+ setupPack(512, 8000);
+ assertPackSize();
+ }
+
+ @Test
+ public void testCopyPackThroughCacheSmallCached() throws IOException {
+ bypassCache = false;
+ clearCache = false;
+ setupPack(512, 256);
+ assertPackSize();
+ }
+
+ @Test
+ public void testCopyPackThroughCacheSmallNoCache() throws IOException {
+ bypassCache = false;
+ clearCache = true;
+ setupPack(512, 256);
+ assertPackSize();
+ }
+
+ @Test
+ public void testCopyPackThroughCacheLargeCached() throws IOException {
+ bypassCache = false;
+ clearCache = false;
+ setupPack(512, 8000);
+ assertPackSize();
+ }
+
+ @Test
+ public void testCopyPackThroughCacheLargeNoCache() throws IOException {
+ bypassCache = false;
+ clearCache = true;
+ setupPack(512, 8000);
+ assertPackSize();
+ }
+
+ private void setupPack(int bs, int ps) throws IOException {
+ DfsBlockCacheConfig cfg = new DfsBlockCacheConfig().setBlockSize(bs)
+ .setBlockLimit(bs * 100).setStreamRatio(bypassCache ? 0F : 1F);
+ DfsBlockCache.reconfigure(cfg);
+
+ byte[] data = new TestRng(JGitTestUtil.getName()).nextBytes(ps);
+ DfsInserter ins = (DfsInserter) db.newObjectInserter();
+ ins.setCompressionLevel(Deflater.NO_COMPRESSION);
+ ins.insert(Constants.OBJ_BLOB, data);
+ ins.flush();
+
+ if (clearCache) {
+ DfsBlockCache.reconfigure(cfg);
+ db.getObjectDatabase().clearCache();
+ }
+ }
+
+ private void assertPackSize() throws IOException {
+ try (DfsReader ctx = db.getObjectDatabase().newReader();
+ PackWriter pw = new PackWriter(ctx);
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ PackOutputStream out = new PackOutputStream(
+ NullProgressMonitor.INSTANCE, os, pw)) {
+ DfsPackFile pack = db.getObjectDatabase().getPacks()[0];
+ long packSize = pack.getPackDescription().getFileSize(PackExt.PACK);
+ pack.copyPackAsIs(out, ctx);
+ assertEquals(packSize - (12 + 20), os.size());
+ }
+ }
+}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcDeleteEmptyRefsFoldersTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcDeleteEmptyRefsFoldersTest.java
index 3caae72..d450f94 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcDeleteEmptyRefsFoldersTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcDeleteEmptyRefsFoldersTest.java
@@ -91,6 +91,20 @@ public void emptyRefFoldersAreDeleted() throws Exception {
assertFalse(refDir02.getParent().getParent().toFile().exists());
}
+ @Test
+ public void emptyRefFoldersSkipFiles() throws Exception {
+ FileTime fileTime = FileTime.from(Instant.now().minusSeconds(31));
+ Path refFile = Files.createFile(refsDir.resolve(".DS_Store"));
+ Path refDir01 = Files.createDirectories(heads.resolve(REF_FOLDER_01));
+ Path refDir02 = Files.createDirectories(heads.resolve(REF_FOLDER_02));
+ setLastModifiedTime(fileTime, heads, REF_FOLDER_01);
+ setLastModifiedTime(fileTime, heads, REF_FOLDER_02);
+ assertTrue(refDir01.toFile().exists());
+ assertTrue(refDir02.toFile().exists());
+ gc.gc();
+ assertTrue(Files.exists(refFile));
+ }
+
private void setLastModifiedTime(FileTime fileTime, Path path, String folder) throws IOException {
long numParents = folder.chars().filter(c -> c == '/').count();
Path folderPath = path.resolve(folder);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java
index 04bed09..ca44862 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/PackWriterTest.java
@@ -469,10 +469,12 @@ public void testWritePack4SizeThinVsNoThin() throws Exception {
public void testDeltaStatistics() throws Exception {
config.setDeltaCompress(true);
FileRepository repo = createBareRepository();
- TestRepository<FileRepository> testRepo = new TestRepository<>(repo);
ArrayList<RevObject> blobs = new ArrayList<>();
- blobs.add(testRepo.blob(genDeltableData(1000)));
- blobs.add(testRepo.blob(genDeltableData(1005)));
+ try (TestRepository<FileRepository> testRepo = new TestRepository<>(
+ repo)) {
+ blobs.add(testRepo.blob(genDeltableData(1000)));
+ blobs.add(testRepo.blob(genDeltableData(1005)));
+ }
try (PackWriter pw = new PackWriter(repo)) {
NullProgressMonitor m = NullProgressMonitor.INSTANCE;
@@ -535,25 +537,23 @@ public void testWriteIndex() throws Exception {
public void testExclude() throws Exception {
FileRepository repo = createBareRepository();
- TestRepository<FileRepository> testRepo = new TestRepository<>(
- repo);
- BranchBuilder bb = testRepo.branch("refs/heads/master");
- contentA = testRepo.blob("A");
- c1 = bb.commit().add("f", contentA).create();
- testRepo.getRevWalk().parseHeaders(c1);
- PackIndex pf1 = writePack(repo, wants(c1), EMPTY_ID_SET);
- assertContent(
- pf1,
- Arrays.asList(c1.getId(), c1.getTree().getId(),
- contentA.getId()));
- contentB = testRepo.blob("B");
- c2 = bb.commit().add("f", contentB).create();
- testRepo.getRevWalk().parseHeaders(c2);
- PackIndex pf2 = writePack(repo, wants(c2), Sets.of((ObjectIdSet) pf1));
- assertContent(
- pf2,
- Arrays.asList(c2.getId(), c2.getTree().getId(),
- contentB.getId()));
+ try (TestRepository<FileRepository> testRepo = new TestRepository<>(
+ repo)) {
+ BranchBuilder bb = testRepo.branch("refs/heads/master");
+ contentA = testRepo.blob("A");
+ c1 = bb.commit().add("f", contentA).create();
+ testRepo.getRevWalk().parseHeaders(c1);
+ PackIndex pf1 = writePack(repo, wants(c1), EMPTY_ID_SET);
+ assertContent(pf1, Arrays.asList(c1.getId(), c1.getTree().getId(),
+ contentA.getId()));
+ contentB = testRepo.blob("B");
+ c2 = bb.commit().add("f", contentB).create();
+ testRepo.getRevWalk().parseHeaders(c2);
+ PackIndex pf2 = writePack(repo, wants(c2),
+ Sets.of((ObjectIdSet) pf1));
+ assertContent(pf2, Arrays.asList(c2.getId(), c2.getTree().getId(),
+ contentB.getId()));
+ }
}
private static void assertContent(PackIndex pi, List<ObjectId> expected) {
@@ -660,20 +660,21 @@ public void testShallowFetchShallowAncestorDepth2() throws Exception {
private FileRepository setupRepoForShallowFetch() throws Exception {
FileRepository repo = createBareRepository();
- TestRepository<Repository> r = new TestRepository<>(repo);
- BranchBuilder bb = r.branch("refs/heads/master");
- contentA = r.blob("A");
- contentB = r.blob("B");
- contentC = r.blob("C");
- contentD = r.blob("D");
- contentE = r.blob("E");
- c1 = bb.commit().add("a", contentA).create();
- c2 = bb.commit().add("b", contentB).create();
- c3 = bb.commit().add("c", contentC).create();
- c4 = bb.commit().add("d", contentD).create();
- c5 = bb.commit().add("e", contentE).create();
- r.getRevWalk().parseHeaders(c5); // fully initialize the tip RevCommit
- return repo;
+ try (TestRepository<Repository> r = new TestRepository<>(repo)) {
+ BranchBuilder bb = r.branch("refs/heads/master");
+ contentA = r.blob("A");
+ contentB = r.blob("B");
+ contentC = r.blob("C");
+ contentD = r.blob("D");
+ contentE = r.blob("E");
+ c1 = bb.commit().add("a", contentA).create();
+ c2 = bb.commit().add("b", contentB).create();
+ c3 = bb.commit().add("c", contentC).create();
+ c4 = bb.commit().add("d", contentD).create();
+ c5 = bb.commit().add("e", contentE).create();
+ r.getRevWalk().parseHeaders(c5); // fully initialize the tip RevCommit
+ return repo;
+ }
}
private static PackIndex writePack(FileRepository repo,
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java
index 96caa01..c613849 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java
@@ -538,7 +538,7 @@ public void test024_createCommitNonAscii() throws IOException {
4294967295000L, 60));
commit.setCommitter(new PersonIdent("Joe Hacker", "joe2@example.com",
4294967295000L, 60));
- commit.setEncoding("ISO-8859-1");
+ commit.setEncoding(ISO_8859_1);
commit.setMessage("\u00dcbergeeks");
ObjectId cid = insertCommit(commit);
assertEquals("2979b39d385014b33287054b87f77bcb3ecb5ebf", cid.name());
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java
index 534b323..483051c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java
@@ -267,10 +267,10 @@ public void testResetHardFromIndexEntryWithoutFileToTreeWithoutFile()
public void testInitialCheckout() throws Exception {
ChangeRecorder recorder = new ChangeRecorder();
ListenerHandle handle = null;
- try (Git git = new Git(db)) {
+ try (Git git = new Git(db);
+ TestRepository<Repository> db_t = new TestRepository<>(db)) {
handle = db.getListenerList()
.addWorkingTreeModifiedListener(recorder);
- TestRepository<Repository> db_t = new TestRepository<>(db);
BranchBuilder master = db_t.branch("master");
master.commit().add("f", "1").message("m0").create();
assertFalse(new File(db.getWorkTree(), "f").exists());
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java
index 58b005c..15c4e4a 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java
@@ -110,7 +110,7 @@ public void testFileKeyOpenExisting() throws IOException {
@Test
public void testFileKeyOpenNew() throws IOException {
File gitdir;
- try (Repository n = createRepository(true, false)) {
+ try (Repository n = createRepository(true)) {
gitdir = n.getDirectory();
}
recursiveDelete(gitdir);
@@ -192,7 +192,7 @@ public void testRepositoryUsageCount() throws Exception {
@Test
public void testRepositoryUsageCountWithRegisteredRepository()
throws IOException {
- @SuppressWarnings("resource") // We are testing the close() method
+ @SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method
Repository repo = createRepository(false, false);
assertEquals(1, repo.useCnt.get());
RepositoryCache.register(repo);
@@ -240,9 +240,9 @@ public void testRepositoryUnregisteringWhenExpiredAndUsageCountNegative()
@Test
public void testRepositoryUnregisteringWhenExpired() throws Exception {
- @SuppressWarnings("resource") // We are testing the close() method
+ @SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method
Repository repoA = createRepository(true, false);
- @SuppressWarnings("resource") // We are testing the close() method
+ @SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method
Repository repoB = createRepository(true, false);
Repository repoC = createBareRepository();
RepositoryCache.register(repoA);
@@ -276,7 +276,7 @@ public void testRepositoryUnregisteringWhenExpired() throws Exception {
@Test
public void testReconfigure() throws InterruptedException, IOException {
- @SuppressWarnings("resource") // We are testing the close() method
+ @SuppressWarnings({"resource", "deprecation"}) // We are testing the close() method
Repository repo = createRepository(false, false);
RepositoryCache.register(repo);
assertTrue(RepositoryCache.isCached(repo));
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java
index 335a8ca..f6fc00c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergerTest.java
@@ -1360,14 +1360,15 @@ private void checkModificationTimeStampOrder(String... pathes)
}
private String readBlob(ObjectId treeish, String path) throws Exception {
- TestRepository<?> tr = new TestRepository<>(db);
- RevWalk rw = tr.getRevWalk();
- RevTree tree = rw.parseTree(treeish);
- RevObject obj = tr.get(tree, path);
- if (obj == null) {
- return null;
+ try (TestRepository<?> tr = new TestRepository<>(db)) {
+ RevWalk rw = tr.getRevWalk();
+ RevTree tree = rw.parseTree(treeish);
+ RevObject obj = tr.get(tree, path);
+ if (obj == null) {
+ return null;
+ }
+ return new String(
+ rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), UTF_8);
}
- return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(),
- UTF_8);
}
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleStatusTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleStatusTest.java
index 5832518..9151b04 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleStatusTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleStatusTest.java
@@ -263,8 +263,10 @@ public void repositoryWithInitializedSubmodule() throws Exception {
.getRepository();
assertNotNull(subRepo);
- TestRepository<?> subTr = new TestRepository<>(subRepo);
- ObjectId id = subTr.branch(Constants.HEAD).commit().create().copy();
+ ObjectId id;
+ try (TestRepository<?> subTr = new TestRepository<>(subRepo)) {
+ id = subTr.branch(Constants.HEAD).commit().create().copy();
+ }
DirCache cache = db.lockDirCache();
DirCacheEditor editor = cache.editor();
@@ -315,50 +317,52 @@ public void repositoryWithDifferentRevCheckedOutSubmodule() throws Exception {
.getRepository();
assertNotNull(subRepo);
- TestRepository<?> subTr = new TestRepository<>(subRepo);
- ObjectId id = subTr.branch(Constants.HEAD).commit().create().copy();
+ try (TestRepository<?> subTr = new TestRepository<>(subRepo)) {
+ ObjectId id = subTr.branch(Constants.HEAD).commit().create().copy();
+ DirCache cache = db.lockDirCache();
+ DirCacheEditor editor = cache.editor();
+ editor.add(new PathEdit(path) {
- DirCache cache = db.lockDirCache();
- DirCacheEditor editor = cache.editor();
- editor.add(new PathEdit(path) {
+ @Override
+ public void apply(DirCacheEntry ent) {
+ ent.setFileMode(FileMode.GITLINK);
+ ent.setObjectId(id);
+ }
+ });
+ editor.commit();
- @Override
- public void apply(DirCacheEntry ent) {
- ent.setFileMode(FileMode.GITLINK);
- ent.setObjectId(id);
- }
- });
- editor.commit();
+ String url = "git://server/repo.git";
+ StoredConfig config = db.getConfig();
+ config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
+ ConfigConstants.CONFIG_KEY_URL, url);
+ config.save();
- String url = "git://server/repo.git";
- StoredConfig config = db.getConfig();
- config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
- ConfigConstants.CONFIG_KEY_URL, url);
- config.save();
+ FileBasedConfig modulesConfig = new FileBasedConfig(
+ new File(db.getWorkTree(), Constants.DOT_GIT_MODULES),
+ db.getFS());
+ modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
+ path, ConfigConstants.CONFIG_KEY_PATH, path);
+ modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
+ path, ConfigConstants.CONFIG_KEY_URL, url);
+ modulesConfig.save();
- FileBasedConfig modulesConfig = new FileBasedConfig(new File(
- db.getWorkTree(), Constants.DOT_GIT_MODULES), db.getFS());
- modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
- ConfigConstants.CONFIG_KEY_PATH, path);
- modulesConfig.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
- ConfigConstants.CONFIG_KEY_URL, url);
- modulesConfig.save();
+ ObjectId newId = subTr.branch(Constants.HEAD).commit().create()
+ .copy();
- ObjectId newId = subTr.branch(Constants.HEAD).commit().create().copy();
-
- SubmoduleStatusCommand command = new SubmoduleStatusCommand(db);
- Map<String, SubmoduleStatus> statuses = command.call();
- assertNotNull(statuses);
- assertEquals(1, statuses.size());
- Entry<String, SubmoduleStatus> module = statuses.entrySet().iterator()
- .next();
- assertNotNull(module);
- assertEquals(path, module.getKey());
- SubmoduleStatus status = module.getValue();
- assertNotNull(status);
- assertEquals(path, status.getPath());
- assertEquals(id, status.getIndexId());
- assertEquals(newId, status.getHeadId());
- assertEquals(SubmoduleStatusType.REV_CHECKED_OUT, status.getType());
+ SubmoduleStatusCommand command = new SubmoduleStatusCommand(db);
+ Map<String, SubmoduleStatus> statuses = command.call();
+ assertNotNull(statuses);
+ assertEquals(1, statuses.size());
+ Entry<String, SubmoduleStatus> module = statuses.entrySet()
+ .iterator().next();
+ assertNotNull(module);
+ assertEquals(path, module.getKey());
+ SubmoduleStatus status = module.getValue();
+ assertNotNull(status);
+ assertEquals(path, status.getPath());
+ assertEquals(id, status.getIndexId());
+ assertEquals(newId, status.getHeadId());
+ assertEquals(SubmoduleStatusType.REV_CHECKED_OUT, status.getType());
+ }
}
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java
index a0cd37e..ea1ace3 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java
@@ -145,7 +145,6 @@ public void apply(DirCacheEntry ent) {
assertFalse(gen.next());
}
- @SuppressWarnings("resource" /* java 7 */)
@Test
public void repositoryWithRootLevelSubmoduleAbsoluteRef()
throws IOException, ConfigInvalidException {
@@ -189,17 +188,16 @@ public void apply(DirCacheEntry ent) {
assertNull(gen.getModulesPath());
assertNull(gen.getModulesUpdate());
assertNull(gen.getModulesUrl());
- Repository subRepo = gen.getRepository();
- assertNotNull(subRepo);
- assertEquals(modulesGitDir.getAbsolutePath(),
- subRepo.getDirectory().getAbsolutePath());
- assertEquals(new File(db.getWorkTree(), path).getAbsolutePath(),
- subRepo.getWorkTree().getAbsolutePath());
- subRepo.close();
+ try (Repository subRepo = gen.getRepository()) {
+ assertNotNull(subRepo);
+ assertEquals(modulesGitDir.getAbsolutePath(),
+ subRepo.getDirectory().getAbsolutePath());
+ assertEquals(new File(db.getWorkTree(), path).getAbsolutePath(),
+ subRepo.getWorkTree().getAbsolutePath());
+ }
assertFalse(gen.next());
}
- @SuppressWarnings("resource" /* java 7 */)
@Test
public void repositoryWithRootLevelSubmoduleRelativeRef()
throws IOException, ConfigInvalidException {
@@ -244,13 +242,14 @@ public void apply(DirCacheEntry ent) {
assertNull(gen.getModulesPath());
assertNull(gen.getModulesUpdate());
assertNull(gen.getModulesUrl());
- Repository subRepo = gen.getRepository();
- assertNotNull(subRepo);
- assertEqualsFile(modulesGitDir, subRepo.getDirectory());
- assertEqualsFile(new File(db.getWorkTree(), path),
- subRepo.getWorkTree());
- subRepo.close();
- assertFalse(gen.next());
+ try (Repository subRepo = gen.getRepository()) {
+ assertNotNull(subRepo);
+ assertEqualsFile(modulesGitDir, subRepo.getDirectory());
+ assertEqualsFile(new File(db.getWorkTree(), path),
+ subRepo.getWorkTree());
+ subRepo.close();
+ assertFalse(gen.next());
+ }
}
@Test
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java
index 7b31bfa..dce9db5 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java
@@ -77,10 +77,38 @@
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.test.resources.SampleDataRepositoryTestCase;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
public class BundleWriterTest extends SampleDataRepositoryTestCase {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void testEmptyBundleFails() throws Exception {
+ Repository newRepo = createBareRepository();
+ thrown.expect(TransportException.class);
+ fetchFromBundle(newRepo, new byte[0]);
+ }
+
+ @Test
+ public void testNonBundleFails() throws Exception {
+ Repository newRepo = createBareRepository();
+ thrown.expect(TransportException.class);
+ fetchFromBundle(newRepo, "Not a bundle file".getBytes(UTF_8));
+ }
+
+ @Test
+ public void testGarbageBundleFails() throws Exception {
+ Repository newRepo = createBareRepository();
+ thrown.expect(TransportException.class);
+ fetchFromBundle(newRepo,
+ (TransportBundle.V2_BUNDLE_SIGNATURE + '\n' + "Garbage")
+ .getBytes(UTF_8));
+ }
+
@Test
public void testWriteSingleRef() throws Exception {
// Create a tiny bundle, (well one of) the first commits only
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java
index 0f98fac..fd952f3 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java
@@ -141,8 +141,10 @@ public void test2() throws IOException {
@Test
public void testTinyThinPack() throws Exception {
- TestRepository d = new TestRepository<Repository>(db);
- RevBlob a = d.blob("a");
+ RevBlob a;
+ try (TestRepository d = new TestRepository<Repository>(db)) {
+ a = d.blob("a");
+ }
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
@@ -162,8 +164,9 @@ public void testTinyThinPack() throws Exception {
@Test
public void testPackWithDuplicateBlob() throws Exception {
final byte[] data = Constants.encode("0123456789abcdefg");
- TestRepository<Repository> d = new TestRepository<>(db);
- assertTrue(db.getObjectDatabase().has(d.blob(data)));
+ try (TestRepository<Repository> d = new TestRepository<>(db)) {
+ assertTrue(db.getObjectDatabase().has(d.blob(data)));
+ }
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
packHeader(pack, 1);
@@ -179,8 +182,10 @@ public void testPackWithDuplicateBlob() throws Exception {
@Test
public void testPackWithTrailingGarbage() throws Exception {
- TestRepository d = new TestRepository<Repository>(db);
- RevBlob a = d.blob("a");
+ RevBlob a;
+ try (TestRepository d = new TestRepository<Repository>(db)) {
+ a = d.blob("a");
+ }
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
packHeader(pack, 1);
@@ -206,9 +211,10 @@ public void testPackWithTrailingGarbage() throws Exception {
@Test
public void testMaxObjectSizeFullBlob() throws Exception {
- TestRepository d = new TestRepository<Repository>(db);
final byte[] data = Constants.encode("0123456789");
- d.blob(data);
+ try (TestRepository d = new TestRepository<Repository>(db)) {
+ d.blob(data);
+ }
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
@@ -238,8 +244,10 @@ public void testMaxObjectSizeFullBlob() throws Exception {
@Test
public void testMaxObjectSizeDeltaBlock() throws Exception {
- TestRepository d = new TestRepository<Repository>(db);
- RevBlob a = d.blob("a");
+ RevBlob a;
+ try (TestRepository d = new TestRepository<Repository>(db)) {
+ a = d.blob("a");
+ }
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
@@ -269,8 +277,10 @@ public void testMaxObjectSizeDeltaBlock() throws Exception {
@Test
public void testMaxObjectSizeDeltaResultSize() throws Exception {
- TestRepository d = new TestRepository<Repository>(db);
- RevBlob a = d.blob("0123456789");
+ RevBlob a;
+ try (TestRepository d = new TestRepository<Repository>(db)) {
+ a = d.blob("0123456789");
+ }
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
@@ -299,8 +309,10 @@ public void testMaxObjectSizeDeltaResultSize() throws Exception {
@Test
public void testNonMarkingInputStream() throws Exception {
- TestRepository d = new TestRepository<Repository>(db);
- RevBlob a = d.blob("a");
+ RevBlob a;
+ try (TestRepository d = new TestRepository<Repository>(db)) {
+ a = d.blob("a");
+ }
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
packHeader(pack, 1);
@@ -337,8 +349,10 @@ public void mark(int maxlength) {
@Test
public void testDataAfterPackFooterSingleRead() throws Exception {
- TestRepository d = new TestRepository<Repository>(db);
- RevBlob a = d.blob("a");
+ RevBlob a;
+ try (TestRepository d = new TestRepository<Repository>(db)) {
+ a = d.blob("a");
+ }
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(32*1024);
packHeader(pack, 1);
@@ -395,9 +409,11 @@ public void testDataAfterPackFooterSplitObjectRead() throws Exception {
@Test
public void testDataAfterPackFooterSplitHeaderRead() throws Exception {
- TestRepository d = new TestRepository<Repository>(db);
final byte[] data = Constants.encode("a");
- RevBlob b = d.blob(data);
+ RevBlob b;
+ try (TestRepository d = new TestRepository<Repository>(db)) {
+ b = d.blob(data);
+ }
int objects = 248;
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(32 * 1024);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java
index 63478f6..cea432e 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushConnectionTest.java
@@ -216,15 +216,16 @@ public void limitCommandBytes() throws IOException {
@Test
public void commandOrder() throws Exception {
- TestRepository<?> tr = new TestRepository<>(client);
List<RemoteRefUpdate> updates = new ArrayList<>();
- // Arbitrary non-sorted order.
- for (int i = 9; i >= 0; i--) {
- String name = "refs/heads/b" + i;
- tr.branch(name).commit().create();
- RemoteRefUpdate rru = new RemoteRefUpdate(client, name, name, false, null,
- ObjectId.zeroId());
- updates.add(rru);
+ try (TestRepository<?> tr = new TestRepository<>(client)) {
+ // Arbitrary non-sorted order.
+ for (int i = 9; i >= 0; i--) {
+ String name = "refs/heads/b" + i;
+ tr.branch(name).commit().create();
+ RemoteRefUpdate rru = new RemoteRefUpdate(client, name, name,
+ false, null, ObjectId.zeroId());
+ updates.add(rru);
+ }
}
PushResult result;
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java
index fa8856d..50c8a29 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java
@@ -110,24 +110,26 @@ public void setUp() throws Exception {
// Fill dst with a some common history.
//
- TestRepository<Repository> d = new TestRepository<>(dst);
- a = d.blob("a");
- A = d.commit(d.tree(d.file("a", a)));
- B = d.commit().parent(A).create();
- d.update(R_MASTER, B);
+ try (TestRepository<Repository> d = new TestRepository<>(dst)) {
+ a = d.blob("a");
+ A = d.commit(d.tree(d.file("a", a)));
+ B = d.commit().parent(A).create();
+ d.update(R_MASTER, B);
- // Clone from dst into src
- //
- try (Transport t = Transport.open(src, uriOf(dst))) {
- t.fetch(PM, Collections.singleton(new RefSpec("+refs/*:refs/*")));
- assertEquals(B, src.resolve(R_MASTER));
+ // Clone from dst into src
+ //
+ try (Transport t = Transport.open(src, uriOf(dst))) {
+ t.fetch(PM,
+ Collections.singleton(new RefSpec("+refs/*:refs/*")));
+ assertEquals(B, src.resolve(R_MASTER));
+ }
+
+ // Now put private stuff into dst.
+ //
+ b = d.blob("b");
+ P = d.commit(d.tree(d.file("b", b)), A);
+ d.update(R_PRIVATE, P);
}
-
- // Now put private stuff into dst.
- //
- b = d.blob("b");
- P = d.commit(d.tree(d.file("b", b)), A);
- d.update(R_PRIVATE, P);
}
@Test
@@ -241,31 +243,33 @@ public void testSuccess() throws Exception {
// Now use b but in a different commit than what is hidden.
//
- TestRepository<Repository> s = new TestRepository<>(src);
- RevCommit N = s.commit().parent(B).add("q", b).create();
- s.update(R_MASTER, N);
+ try (TestRepository<Repository> s = new TestRepository<>(src)) {
+ RevCommit N = s.commit().parent(B).add("q", b).create();
+ s.update(R_MASTER, N);
- // Push this new content to the remote, doing strict validation.
- //
- PushResult r;
- RemoteRefUpdate u = new RemoteRefUpdate( //
- src, //
- R_MASTER, // src name
- R_MASTER, // dst name
- false, // do not force update
- null, // local tracking branch
- null // expected id
- );
- try (TransportLocal t = newTransportLocalWithStrictValidation()) {
- t.setPushThin(true);
- r = t.push(PM, Collections.singleton(u));
- dst.close();
+ // Push this new content to the remote, doing strict validation.
+ //
+ PushResult r;
+ RemoteRefUpdate u = new RemoteRefUpdate( //
+ src, //
+ R_MASTER, // src name
+ R_MASTER, // dst name
+ false, // do not force update
+ null, // local tracking branch
+ null // expected id
+ );
+ try (TransportLocal t = newTransportLocalWithStrictValidation()) {
+ t.setPushThin(true);
+ r = t.push(PM, Collections.singleton(u));
+ dst.close();
+ }
+
+ assertNotNull("have result", r);
+ assertNull("private not advertised", r.getAdvertisedRef(R_PRIVATE));
+ assertSame("master updated", RemoteRefUpdate.Status.OK,
+ u.getStatus());
+ assertEquals(N, dst.resolve(R_MASTER));
}
-
- assertNotNull("have result", r);
- assertNull("private not advertised", r.getAdvertisedRef(R_PRIVATE));
- assertSame("master updated", RemoteRefUpdate.Status.OK, u.getStatus());
- assertEquals(N, dst.resolve(R_MASTER));
}
@Test
@@ -318,154 +322,165 @@ private static void receive(final ReceivePack rp,
@Test
public void testUsingHiddenDeltaBaseFails() throws Exception {
byte[] delta = { 0x1, 0x1, 0x1, 'c' };
- TestRepository<Repository> s = new TestRepository<>(src);
- RevCommit N = s.commit().parent(B).add("q",
- s.blob(BinaryDelta.apply(dst.open(b).getCachedBytes(), delta)))
- .create();
+ try (TestRepository<Repository> s = new TestRepository<>(src)) {
+ RevCommit N = s.commit().parent(B)
+ .add("q",
+ s.blob(BinaryDelta.apply(
+ dst.open(b).getCachedBytes(), delta)))
+ .create();
- final TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
- packHeader(pack, 3);
- copy(pack, src.open(N));
- copy(pack, src.open(s.parseBody(N).getTree()));
- pack.write((Constants.OBJ_REF_DELTA) << 4 | 4);
- b.copyRawTo(pack);
- deflate(pack, delta);
- digest(pack);
+ final TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
+ packHeader(pack, 3);
+ copy(pack, src.open(N));
+ copy(pack, src.open(s.parseBody(N).getTree()));
+ pack.write((Constants.OBJ_REF_DELTA) << 4 | 4);
+ b.copyRawTo(pack);
+ deflate(pack, delta);
+ digest(pack);
- final TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
- final PacketLineOut inPckLine = new PacketLineOut(inBuf);
- inPckLine.writeString(ObjectId.zeroId().name() + ' ' + N.name() + ' '
- + "refs/heads/s" + '\0'
- + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
- inPckLine.end();
- pack.writeTo(inBuf, PM);
+ final TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
+ final PacketLineOut inPckLine = new PacketLineOut(inBuf);
+ inPckLine.writeString(ObjectId.zeroId().name() + ' ' + N.name()
+ + ' ' + "refs/heads/s" + '\0'
+ + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
+ inPckLine.end();
+ pack.writeTo(inBuf, PM);
- final TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
- final ReceivePack rp = new ReceivePack(dst);
- rp.setCheckReceivedObjects(true);
- rp.setCheckReferencedObjectsAreReachable(true);
- rp.setAdvertiseRefsHook(new HidePrivateHook());
- try {
- receive(rp, inBuf, outBuf);
- fail("Expected UnpackException");
- } catch (UnpackException failed) {
- Throwable err = failed.getCause();
- assertTrue(err instanceof MissingObjectException);
- MissingObjectException moe = (MissingObjectException) err;
- assertEquals(b, moe.getObjectId());
+ final TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
+ final ReceivePack rp = new ReceivePack(dst);
+ rp.setCheckReceivedObjects(true);
+ rp.setCheckReferencedObjectsAreReachable(true);
+ rp.setAdvertiseRefsHook(new HidePrivateHook());
+ try {
+ receive(rp, inBuf, outBuf);
+ fail("Expected UnpackException");
+ } catch (UnpackException failed) {
+ Throwable err = failed.getCause();
+ assertTrue(err instanceof MissingObjectException);
+ MissingObjectException moe = (MissingObjectException) err;
+ assertEquals(b, moe.getObjectId());
+ }
+
+ final PacketLineIn r = asPacketLineIn(outBuf);
+ String master = r.readString();
+ int nul = master.indexOf('\0');
+ assertTrue("has capability list", nul > 0);
+ assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
+ assertSame(PacketLineIn.END, r.readString());
+
+ assertEquals("unpack error Missing blob " + b.name(),
+ r.readString());
+ assertEquals("ng refs/heads/s n/a (unpacker error)",
+ r.readString());
+ assertSame(PacketLineIn.END, r.readString());
}
-
- final PacketLineIn r = asPacketLineIn(outBuf);
- String master = r.readString();
- int nul = master.indexOf('\0');
- assertTrue("has capability list", nul > 0);
- assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
- assertSame(PacketLineIn.END, r.readString());
-
- assertEquals("unpack error Missing blob " + b.name(), r.readString());
- assertEquals("ng refs/heads/s n/a (unpacker error)", r.readString());
- assertSame(PacketLineIn.END, r.readString());
}
@Test
public void testUsingHiddenCommonBlobFails() throws Exception {
// Try to use the 'b' blob that is hidden.
//
- TestRepository<Repository> s = new TestRepository<>(src);
- RevCommit N = s.commit().parent(B).add("q", s.blob("b")).create();
+ try (TestRepository<Repository> s = new TestRepository<>(src)) {
+ RevCommit N = s.commit().parent(B).add("q", s.blob("b")).create();
- // But don't include it in the pack.
- //
- final TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
- packHeader(pack, 2);
- copy(pack, src.open(N));
- copy(pack,src.open(s.parseBody(N).getTree()));
- digest(pack);
+ // But don't include it in the pack.
+ //
+ final TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
+ packHeader(pack, 2);
+ copy(pack, src.open(N));
+ copy(pack, src.open(s.parseBody(N).getTree()));
+ digest(pack);
- final TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
- final PacketLineOut inPckLine = new PacketLineOut(inBuf);
- inPckLine.writeString(ObjectId.zeroId().name() + ' ' + N.name() + ' '
- + "refs/heads/s" + '\0'
- + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
- inPckLine.end();
- pack.writeTo(inBuf, PM);
+ final TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
+ final PacketLineOut inPckLine = new PacketLineOut(inBuf);
+ inPckLine.writeString(ObjectId.zeroId().name() + ' ' + N.name()
+ + ' ' + "refs/heads/s" + '\0'
+ + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
+ inPckLine.end();
+ pack.writeTo(inBuf, PM);
- final TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
- final ReceivePack rp = new ReceivePack(dst);
- rp.setCheckReceivedObjects(true);
- rp.setCheckReferencedObjectsAreReachable(true);
- rp.setAdvertiseRefsHook(new HidePrivateHook());
- try {
- receive(rp, inBuf, outBuf);
- fail("Expected UnpackException");
- } catch (UnpackException failed) {
- Throwable err = failed.getCause();
- assertTrue(err instanceof MissingObjectException);
- MissingObjectException moe = (MissingObjectException) err;
- assertEquals(b, moe.getObjectId());
+ final TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
+ final ReceivePack rp = new ReceivePack(dst);
+ rp.setCheckReceivedObjects(true);
+ rp.setCheckReferencedObjectsAreReachable(true);
+ rp.setAdvertiseRefsHook(new HidePrivateHook());
+ try {
+ receive(rp, inBuf, outBuf);
+ fail("Expected UnpackException");
+ } catch (UnpackException failed) {
+ Throwable err = failed.getCause();
+ assertTrue(err instanceof MissingObjectException);
+ MissingObjectException moe = (MissingObjectException) err;
+ assertEquals(b, moe.getObjectId());
+ }
+
+ final PacketLineIn r = asPacketLineIn(outBuf);
+ String master = r.readString();
+ int nul = master.indexOf('\0');
+ assertTrue("has capability list", nul > 0);
+ assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
+ assertSame(PacketLineIn.END, r.readString());
+
+ assertEquals("unpack error Missing blob " + b.name(),
+ r.readString());
+ assertEquals("ng refs/heads/s n/a (unpacker error)",
+ r.readString());
+ assertSame(PacketLineIn.END, r.readString());
}
-
- final PacketLineIn r = asPacketLineIn(outBuf);
- String master = r.readString();
- int nul = master.indexOf('\0');
- assertTrue("has capability list", nul > 0);
- assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
- assertSame(PacketLineIn.END, r.readString());
-
- assertEquals("unpack error Missing blob " + b.name(), r.readString());
- assertEquals("ng refs/heads/s n/a (unpacker error)", r.readString());
- assertSame(PacketLineIn.END, r.readString());
}
@Test
public void testUsingUnknownBlobFails() throws Exception {
// Try to use the 'n' blob that is not on the server.
//
- TestRepository<Repository> s = new TestRepository<>(src);
- RevBlob n = s.blob("n");
- RevCommit N = s.commit().parent(B).add("q", n).create();
+ try (TestRepository<Repository> s = new TestRepository<>(src)) {
+ RevBlob n = s.blob("n");
+ RevCommit N = s.commit().parent(B).add("q", n).create();
- // But don't include it in the pack.
- //
- final TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
- packHeader(pack, 2);
- copy(pack, src.open(N));
- copy(pack,src.open(s.parseBody(N).getTree()));
- digest(pack);
+ // But don't include it in the pack.
+ //
+ final TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
+ packHeader(pack, 2);
+ copy(pack, src.open(N));
+ copy(pack, src.open(s.parseBody(N).getTree()));
+ digest(pack);
- final TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
- final PacketLineOut inPckLine = new PacketLineOut(inBuf);
- inPckLine.writeString(ObjectId.zeroId().name() + ' ' + N.name() + ' '
- + "refs/heads/s" + '\0'
- + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
- inPckLine.end();
- pack.writeTo(inBuf, PM);
+ final TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
+ final PacketLineOut inPckLine = new PacketLineOut(inBuf);
+ inPckLine.writeString(ObjectId.zeroId().name() + ' ' + N.name()
+ + ' ' + "refs/heads/s" + '\0'
+ + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
+ inPckLine.end();
+ pack.writeTo(inBuf, PM);
- final TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
- final ReceivePack rp = new ReceivePack(dst);
- rp.setCheckReceivedObjects(true);
- rp.setCheckReferencedObjectsAreReachable(true);
- rp.setAdvertiseRefsHook(new HidePrivateHook());
- try {
- receive(rp, inBuf, outBuf);
- fail("Expected UnpackException");
- } catch (UnpackException failed) {
- Throwable err = failed.getCause();
- assertTrue(err instanceof MissingObjectException);
- MissingObjectException moe = (MissingObjectException) err;
- assertEquals(n, moe.getObjectId());
+ final TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
+ final ReceivePack rp = new ReceivePack(dst);
+ rp.setCheckReceivedObjects(true);
+ rp.setCheckReferencedObjectsAreReachable(true);
+ rp.setAdvertiseRefsHook(new HidePrivateHook());
+ try {
+ receive(rp, inBuf, outBuf);
+ fail("Expected UnpackException");
+ } catch (UnpackException failed) {
+ Throwable err = failed.getCause();
+ assertTrue(err instanceof MissingObjectException);
+ MissingObjectException moe = (MissingObjectException) err;
+ assertEquals(n, moe.getObjectId());
+ }
+
+ final PacketLineIn r = asPacketLineIn(outBuf);
+ String master = r.readString();
+ int nul = master.indexOf('\0');
+ assertTrue("has capability list", nul > 0);
+ assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
+ assertSame(PacketLineIn.END, r.readString());
+
+ assertEquals("unpack error Missing blob " + n.name(),
+ r.readString());
+ assertEquals("ng refs/heads/s n/a (unpacker error)",
+ r.readString());
+ assertSame(PacketLineIn.END, r.readString());
}
-
- final PacketLineIn r = asPacketLineIn(outBuf);
- String master = r.readString();
- int nul = master.indexOf('\0');
- assertTrue("has capability list", nul > 0);
- assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
- assertSame(PacketLineIn.END, r.readString());
-
- assertEquals("unpack error Missing blob " + n.name(), r.readString());
- assertEquals("ng refs/heads/s n/a (unpacker error)", r.readString());
- assertSame(PacketLineIn.END, r.readString());
}
@Test
@@ -509,75 +524,79 @@ private TemporaryBuffer.Heap setupSourceRepoInvalidGitmodules()
.append(" url = -upayload.sh\n")
.toString();
- TestRepository<Repository> s = new TestRepository<>(src);
- RevBlob blob = s.blob(fakeGitmodules);
- RevCommit N = s.commit().parent(B)
- .add(".gitmodules", blob).create();
- RevTree t = s.parseBody(N).getTree();
+ try (TestRepository<Repository> s = new TestRepository<>(src)) {
+ RevBlob blob = s.blob(fakeGitmodules);
+ RevCommit N = s.commit().parent(B).add(".gitmodules", blob)
+ .create();
+ RevTree t = s.parseBody(N).getTree();
- final TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
- packHeader(pack, 3);
- copy(pack, src.open(N));
- copy(pack, src.open(t));
- copy(pack, src.open(blob));
- digest(pack);
+ final TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
+ packHeader(pack, 3);
+ copy(pack, src.open(N));
+ copy(pack, src.open(t));
+ copy(pack, src.open(blob));
+ digest(pack);
- final TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
- final PacketLineOut inPckLine = new PacketLineOut(inBuf);
- inPckLine.writeString(ObjectId.zeroId().name() + ' ' + N.name() + ' '
- + "refs/heads/s" + '\0'
- + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
- inPckLine.end();
- pack.writeTo(inBuf, PM);
- return inBuf;
+ final TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
+ final PacketLineOut inPckLine = new PacketLineOut(inBuf);
+ inPckLine.writeString(ObjectId.zeroId().name() + ' ' + N.name()
+ + ' ' + "refs/heads/s" + '\0'
+ + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
+ inPckLine.end();
+ pack.writeTo(inBuf, PM);
+ return inBuf;
+ }
}
@Test
public void testUsingUnknownTreeFails() throws Exception {
- TestRepository<Repository> s = new TestRepository<>(src);
- RevCommit N = s.commit().parent(B).add("q", s.blob("a")).create();
- RevTree t = s.parseBody(N).getTree();
+ try (TestRepository<Repository> s = new TestRepository<>(src)) {
+ RevCommit N = s.commit().parent(B).add("q", s.blob("a")).create();
+ RevTree t = s.parseBody(N).getTree();
- // Don't include the tree in the pack.
- //
- final TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
- packHeader(pack, 1);
- copy(pack, src.open(N));
- digest(pack);
+ // Don't include the tree in the pack.
+ //
+ final TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
+ packHeader(pack, 1);
+ copy(pack, src.open(N));
+ digest(pack);
- final TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
- final PacketLineOut inPckLine = new PacketLineOut(inBuf);
- inPckLine.writeString(ObjectId.zeroId().name() + ' ' + N.name() + ' '
- + "refs/heads/s" + '\0'
- + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
- inPckLine.end();
- pack.writeTo(inBuf, PM);
+ final TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
+ final PacketLineOut inPckLine = new PacketLineOut(inBuf);
+ inPckLine.writeString(ObjectId.zeroId().name() + ' ' + N.name()
+ + ' ' + "refs/heads/s" + '\0'
+ + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
+ inPckLine.end();
+ pack.writeTo(inBuf, PM);
- final TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
- final ReceivePack rp = new ReceivePack(dst);
- rp.setCheckReceivedObjects(true);
- rp.setCheckReferencedObjectsAreReachable(true);
- rp.setAdvertiseRefsHook(new HidePrivateHook());
- try {
- receive(rp, inBuf, outBuf);
- fail("Expected UnpackException");
- } catch (UnpackException failed) {
- Throwable err = failed.getCause();
- assertTrue(err instanceof MissingObjectException);
- MissingObjectException moe = (MissingObjectException) err;
- assertEquals(t, moe.getObjectId());
+ final TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
+ final ReceivePack rp = new ReceivePack(dst);
+ rp.setCheckReceivedObjects(true);
+ rp.setCheckReferencedObjectsAreReachable(true);
+ rp.setAdvertiseRefsHook(new HidePrivateHook());
+ try {
+ receive(rp, inBuf, outBuf);
+ fail("Expected UnpackException");
+ } catch (UnpackException failed) {
+ Throwable err = failed.getCause();
+ assertTrue(err instanceof MissingObjectException);
+ MissingObjectException moe = (MissingObjectException) err;
+ assertEquals(t, moe.getObjectId());
+ }
+
+ final PacketLineIn r = asPacketLineIn(outBuf);
+ String master = r.readString();
+ int nul = master.indexOf('\0');
+ assertTrue("has capability list", nul > 0);
+ assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
+ assertSame(PacketLineIn.END, r.readString());
+
+ assertEquals("unpack error Missing tree " + t.name(),
+ r.readString());
+ assertEquals("ng refs/heads/s n/a (unpacker error)",
+ r.readString());
+ assertSame(PacketLineIn.END, r.readString());
}
-
- final PacketLineIn r = asPacketLineIn(outBuf);
- String master = r.readString();
- int nul = master.indexOf('\0');
- assertTrue("has capability list", nul > 0);
- assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
- assertSame(PacketLineIn.END, r.readString());
-
- assertEquals("unpack error Missing tree " + t.name(), r.readString());
- assertEquals("ng refs/heads/s n/a (unpacker error)", r.readString());
- assertSame(PacketLineIn.END, r.readString());
}
private static void packHeader(TemporaryBuffer.Heap tinyPack, int cnt)
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java
index b6cf356..0bf9a80 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/SideBandOutputStreamTest.java
@@ -77,76 +77,76 @@ public void setUp() throws Exception {
@Test
public void testWrite_CH_DATA() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final SideBandOutputStream out = new SideBandOutputStream(CH_DATA,
- SMALL_BUF, rawOut);
- out.write(new byte[] { 'a', 'b', 'c' });
- out.flush();
+ try (SideBandOutputStream out = new SideBandOutputStream(CH_DATA,
+ SMALL_BUF, rawOut)) {
+ out.write(new byte[] { 'a', 'b', 'c' });
+ out.flush();
+ }
assertBuffer("0008\001abc");
}
@Test
public void testWrite_CH_PROGRESS() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final SideBandOutputStream out = new SideBandOutputStream(CH_PROGRESS,
- SMALL_BUF, rawOut);
- out.write(new byte[] { 'a', 'b', 'c' });
- out.flush();
+ try (SideBandOutputStream out = new SideBandOutputStream(CH_PROGRESS,
+ SMALL_BUF, rawOut)) {
+ out.write(new byte[] { 'a', 'b', 'c' });
+ out.flush();
+ }
assertBuffer("0008\002abc");
}
@Test
public void testWrite_CH_ERROR() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final SideBandOutputStream out = new SideBandOutputStream(CH_ERROR,
- SMALL_BUF, rawOut);
- out.write(new byte[] { 'a', 'b', 'c' });
- out.flush();
+ try (SideBandOutputStream out = new SideBandOutputStream(CH_ERROR,
+ SMALL_BUF, rawOut)) {
+ out.write(new byte[] { 'a', 'b', 'c' });
+ out.flush();
+ }
assertBuffer("0008\003abc");
}
@Test
public void testWrite_Small() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final SideBandOutputStream out = new SideBandOutputStream(CH_DATA,
- SMALL_BUF, rawOut);
- out.write('a');
- out.write('b');
- out.write('c');
- out.flush();
+ try (SideBandOutputStream out = new SideBandOutputStream(CH_DATA,
+ SMALL_BUF, rawOut)) {
+ out.write('a');
+ out.write('b');
+ out.write('c');
+ out.flush();
+ }
assertBuffer("0008\001abc");
}
@Test
public void testWrite_SmallBlocks1() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final SideBandOutputStream out = new SideBandOutputStream(CH_DATA, 6,
- rawOut);
- out.write('a');
- out.write('b');
- out.write('c');
- out.flush();
+ try (SideBandOutputStream out = new SideBandOutputStream(CH_DATA, 6,
+ rawOut)) {
+ out.write('a');
+ out.write('b');
+ out.write('c');
+ out.flush();
+ }
assertBuffer("0006\001a0006\001b0006\001c");
}
@Test
public void testWrite_SmallBlocks2() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final SideBandOutputStream out = new SideBandOutputStream(CH_DATA, 6,
- rawOut);
- out.write(new byte[] { 'a', 'b', 'c' });
- out.flush();
+ try (SideBandOutputStream out = new SideBandOutputStream(CH_DATA, 6,
+ rawOut)) {
+ out.write(new byte[] { 'a', 'b', 'c' });
+ out.flush();
+ }
assertBuffer("0006\001a0006\001b0006\001c");
}
@Test
public void testWrite_SmallBlocks3() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final SideBandOutputStream out = new SideBandOutputStream(CH_DATA, 7,
- rawOut);
- out.write('a');
- out.write(new byte[] { 'b', 'c' });
- out.flush();
+ try (SideBandOutputStream out = new SideBandOutputStream(CH_DATA, 7,
+ rawOut)) {
+ out.write('a');
+ out.write(new byte[] { 'b', 'c' });
+ out.flush();
+ }
assertBuffer("0007\001ab0006\001c");
}
@@ -158,11 +158,11 @@ public void testWrite_Large() throws IOException {
buf[i] = (byte) i;
}
- @SuppressWarnings("resource" /* java 7 */)
- final SideBandOutputStream out = new SideBandOutputStream(CH_DATA,
- MAX_BUF, rawOut);
- out.write(buf);
- out.flush();
+ try (SideBandOutputStream out = new SideBandOutputStream(CH_DATA,
+ MAX_BUF, rawOut)) {
+ out.write(buf);
+ out.flush();
+ }
final byte[] act = rawOut.toByteArray();
final String explen = Integer.toString(buf.length + HDR_SIZE, 16);
@@ -174,7 +174,6 @@ public void testWrite_Large() throws IOException {
}
}
- @SuppressWarnings("resource" /* java 7 */)
@Test
public void testFlush() throws IOException {
final int[] flushCnt = new int[1];
@@ -190,7 +189,10 @@ public void flush() throws IOException {
}
};
- new SideBandOutputStream(CH_DATA, SMALL_BUF, mockout).flush();
+ try (SideBandOutputStream out = new SideBandOutputStream(CH_DATA,
+ SMALL_BUF, mockout)) {
+ out.flush();
+ }
assertEquals(1, flushCnt[0]);
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
index a0635b7..1cbe8a4 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
@@ -200,224 +200,233 @@ public void testFetchReachableBlobWithoutBitmap() throws Exception {
@Test
public void testFetchWithBlobNoneFilter() throws Exception {
InMemoryRepository server2 = newRepo("server2");
- TestRepository<InMemoryRepository> remote2 =
- new TestRepository<>(server2);
- RevBlob blob1 = remote2.blob("foobar");
- RevBlob blob2 = remote2.blob("fooba");
- RevTree tree = remote2.tree(remote2.file("1", blob1),
- remote2.file("2", blob2));
- RevCommit commit = remote2.commit(tree);
- remote2.update("master", commit);
+ try (TestRepository<InMemoryRepository> remote2 = new TestRepository<>(
+ server2)) {
+ RevBlob blob1 = remote2.blob("foobar");
+ RevBlob blob2 = remote2.blob("fooba");
+ RevTree tree = remote2.tree(remote2.file("1", blob1),
+ remote2.file("2", blob2));
+ RevCommit commit = remote2.commit(tree);
+ remote2.update("master", commit);
- server2.getConfig().setBoolean("uploadpack", null, "allowfilter", true);
+ server2.getConfig().setBoolean("uploadpack", null, "allowfilter",
+ true);
- testProtocol = new TestProtocol<>(
- new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
- }, null);
- uri = testProtocol.register(ctx, server2);
+ testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
+ @Override
+ public UploadPack create(Object req, Repository db)
+ throws ServiceNotEnabledException,
+ ServiceNotAuthorizedException {
+ UploadPack up = new UploadPack(db);
+ return up;
+ }
+ }, null);
+ uri = testProtocol.register(ctx, server2);
- try (Transport tn = testProtocol.open(uri, client, "server2")) {
- tn.setFilterBlobLimit(0);
- tn.fetch(NullProgressMonitor.INSTANCE,
- Collections.singletonList(new RefSpec(commit.name())));
- assertTrue(client.getObjectDatabase().has(tree.toObjectId()));
- assertFalse(client.getObjectDatabase().has(blob1.toObjectId()));
- assertFalse(client.getObjectDatabase().has(blob2.toObjectId()));
+ try (Transport tn = testProtocol.open(uri, client, "server2")) {
+ tn.setFilterBlobLimit(0);
+ tn.fetch(NullProgressMonitor.INSTANCE,
+ Collections.singletonList(new RefSpec(commit.name())));
+ assertTrue(client.getObjectDatabase().has(tree.toObjectId()));
+ assertFalse(client.getObjectDatabase().has(blob1.toObjectId()));
+ assertFalse(client.getObjectDatabase().has(blob2.toObjectId()));
+ }
}
}
@Test
public void testFetchExplicitBlobWithFilter() throws Exception {
InMemoryRepository server2 = newRepo("server2");
- TestRepository<InMemoryRepository> remote2 =
- new TestRepository<>(server2);
- RevBlob blob1 = remote2.blob("foobar");
- RevBlob blob2 = remote2.blob("fooba");
- RevTree tree = remote2.tree(remote2.file("1", blob1),
- remote2.file("2", blob2));
- RevCommit commit = remote2.commit(tree);
- remote2.update("master", commit);
- remote2.update("a_blob", blob1);
+ try (TestRepository<InMemoryRepository> remote2 = new TestRepository<>(
+ server2)) {
+ RevBlob blob1 = remote2.blob("foobar");
+ RevBlob blob2 = remote2.blob("fooba");
+ RevTree tree = remote2.tree(remote2.file("1", blob1),
+ remote2.file("2", blob2));
+ RevCommit commit = remote2.commit(tree);
+ remote2.update("master", commit);
+ remote2.update("a_blob", blob1);
- server2.getConfig().setBoolean("uploadpack", null, "allowfilter", true);
+ server2.getConfig().setBoolean("uploadpack", null, "allowfilter",
+ true);
- testProtocol = new TestProtocol<>(
- new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
- }, null);
- uri = testProtocol.register(ctx, server2);
+ testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
+ @Override
+ public UploadPack create(Object req, Repository db)
+ throws ServiceNotEnabledException,
+ ServiceNotAuthorizedException {
+ UploadPack up = new UploadPack(db);
+ return up;
+ }
+ }, null);
+ uri = testProtocol.register(ctx, server2);
- try (Transport tn = testProtocol.open(uri, client, "server2")) {
- tn.setFilterBlobLimit(0);
- tn.fetch(NullProgressMonitor.INSTANCE, Arrays.asList(
- new RefSpec(commit.name()),
- new RefSpec(blob1.name())));
- assertTrue(client.getObjectDatabase().has(tree.toObjectId()));
- assertTrue(client.getObjectDatabase().has(blob1.toObjectId()));
- assertFalse(client.getObjectDatabase().has(blob2.toObjectId()));
+ try (Transport tn = testProtocol.open(uri, client, "server2")) {
+ tn.setFilterBlobLimit(0);
+ tn.fetch(NullProgressMonitor.INSTANCE, Arrays.asList(
+ new RefSpec(commit.name()), new RefSpec(blob1.name())));
+ assertTrue(client.getObjectDatabase().has(tree.toObjectId()));
+ assertTrue(client.getObjectDatabase().has(blob1.toObjectId()));
+ assertFalse(client.getObjectDatabase().has(blob2.toObjectId()));
+ }
}
}
@Test
public void testFetchWithBlobLimitFilter() throws Exception {
InMemoryRepository server2 = newRepo("server2");
- TestRepository<InMemoryRepository> remote2 =
- new TestRepository<>(server2);
- RevBlob longBlob = remote2.blob("foobar");
- RevBlob shortBlob = remote2.blob("fooba");
- RevTree tree = remote2.tree(remote2.file("1", longBlob),
- remote2.file("2", shortBlob));
- RevCommit commit = remote2.commit(tree);
- remote2.update("master", commit);
+ try (TestRepository<InMemoryRepository> remote2 = new TestRepository<>(
+ server2)) {
+ RevBlob longBlob = remote2.blob("foobar");
+ RevBlob shortBlob = remote2.blob("fooba");
+ RevTree tree = remote2.tree(remote2.file("1", longBlob),
+ remote2.file("2", shortBlob));
+ RevCommit commit = remote2.commit(tree);
+ remote2.update("master", commit);
- server2.getConfig().setBoolean("uploadpack", null, "allowfilter", true);
+ server2.getConfig().setBoolean("uploadpack", null, "allowfilter",
+ true);
- testProtocol = new TestProtocol<>(
- new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
- }, null);
- uri = testProtocol.register(ctx, server2);
+ testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
+ @Override
+ public UploadPack create(Object req, Repository db)
+ throws ServiceNotEnabledException,
+ ServiceNotAuthorizedException {
+ UploadPack up = new UploadPack(db);
+ return up;
+ }
+ }, null);
+ uri = testProtocol.register(ctx, server2);
- try (Transport tn = testProtocol.open(uri, client, "server2")) {
- tn.setFilterBlobLimit(5);
- tn.fetch(NullProgressMonitor.INSTANCE,
- Collections.singletonList(new RefSpec(commit.name())));
- assertFalse(client.getObjectDatabase().has(longBlob.toObjectId()));
- assertTrue(client.getObjectDatabase().has(shortBlob.toObjectId()));
+ try (Transport tn = testProtocol.open(uri, client, "server2")) {
+ tn.setFilterBlobLimit(5);
+ tn.fetch(NullProgressMonitor.INSTANCE,
+ Collections.singletonList(new RefSpec(commit.name())));
+ assertFalse(
+ client.getObjectDatabase().has(longBlob.toObjectId()));
+ assertTrue(
+ client.getObjectDatabase().has(shortBlob.toObjectId()));
+ }
}
}
@Test
public void testFetchExplicitBlobWithFilterAndBitmaps() throws Exception {
InMemoryRepository server2 = newRepo("server2");
- TestRepository<InMemoryRepository> remote2 =
- new TestRepository<>(server2);
- RevBlob blob1 = remote2.blob("foobar");
- RevBlob blob2 = remote2.blob("fooba");
- RevTree tree = remote2.tree(remote2.file("1", blob1),
- remote2.file("2", blob2));
- RevCommit commit = remote2.commit(tree);
- remote2.update("master", commit);
- remote2.update("a_blob", blob1);
+ try (TestRepository<InMemoryRepository> remote2 = new TestRepository<>(
+ server2)) {
+ RevBlob blob1 = remote2.blob("foobar");
+ RevBlob blob2 = remote2.blob("fooba");
+ RevTree tree = remote2.tree(remote2.file("1", blob1),
+ remote2.file("2", blob2));
+ RevCommit commit = remote2.commit(tree);
+ remote2.update("master", commit);
+ remote2.update("a_blob", blob1);
- server2.getConfig().setBoolean("uploadpack", null, "allowfilter", true);
+ server2.getConfig().setBoolean("uploadpack", null, "allowfilter",
+ true);
- // generate bitmaps
- new DfsGarbageCollector(server2).pack(null);
- server2.scanForRepoChanges();
+ // generate bitmaps
+ new DfsGarbageCollector(server2).pack(null);
+ server2.scanForRepoChanges();
- testProtocol = new TestProtocol<>(
- new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
- }, null);
- uri = testProtocol.register(ctx, server2);
+ testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
+ @Override
+ public UploadPack create(Object req, Repository db)
+ throws ServiceNotEnabledException,
+ ServiceNotAuthorizedException {
+ UploadPack up = new UploadPack(db);
+ return up;
+ }
+ }, null);
+ uri = testProtocol.register(ctx, server2);
- try (Transport tn = testProtocol.open(uri, client, "server2")) {
- tn.setFilterBlobLimit(0);
- tn.fetch(NullProgressMonitor.INSTANCE, Arrays.asList(
- new RefSpec(commit.name()),
- new RefSpec(blob1.name())));
- assertTrue(client.getObjectDatabase().has(blob1.toObjectId()));
- assertFalse(client.getObjectDatabase().has(blob2.toObjectId()));
+ try (Transport tn = testProtocol.open(uri, client, "server2")) {
+ tn.setFilterBlobLimit(0);
+ tn.fetch(NullProgressMonitor.INSTANCE, Arrays.asList(
+ new RefSpec(commit.name()), new RefSpec(blob1.name())));
+ assertTrue(client.getObjectDatabase().has(blob1.toObjectId()));
+ assertFalse(client.getObjectDatabase().has(blob2.toObjectId()));
+ }
}
}
@Test
public void testFetchWithBlobLimitFilterAndBitmaps() throws Exception {
InMemoryRepository server2 = newRepo("server2");
- TestRepository<InMemoryRepository> remote2 =
- new TestRepository<>(server2);
- RevBlob longBlob = remote2.blob("foobar");
- RevBlob shortBlob = remote2.blob("fooba");
- RevTree tree = remote2.tree(remote2.file("1", longBlob),
- remote2.file("2", shortBlob));
- RevCommit commit = remote2.commit(tree);
- remote2.update("master", commit);
+ try (TestRepository<InMemoryRepository> remote2 = new TestRepository<>(
+ server2)) {
+ RevBlob longBlob = remote2.blob("foobar");
+ RevBlob shortBlob = remote2.blob("fooba");
+ RevTree tree = remote2.tree(remote2.file("1", longBlob),
+ remote2.file("2", shortBlob));
+ RevCommit commit = remote2.commit(tree);
+ remote2.update("master", commit);
- server2.getConfig().setBoolean("uploadpack", null, "allowfilter", true);
+ server2.getConfig().setBoolean("uploadpack", null, "allowfilter",
+ true);
- // generate bitmaps
- new DfsGarbageCollector(server2).pack(null);
- server2.scanForRepoChanges();
+ // generate bitmaps
+ new DfsGarbageCollector(server2).pack(null);
+ server2.scanForRepoChanges();
- testProtocol = new TestProtocol<>(
- new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
- }, null);
- uri = testProtocol.register(ctx, server2);
+ testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
+ @Override
+ public UploadPack create(Object req, Repository db)
+ throws ServiceNotEnabledException,
+ ServiceNotAuthorizedException {
+ UploadPack up = new UploadPack(db);
+ return up;
+ }
+ }, null);
+ uri = testProtocol.register(ctx, server2);
- try (Transport tn = testProtocol.open(uri, client, "server2")) {
- tn.setFilterBlobLimit(5);
- tn.fetch(NullProgressMonitor.INSTANCE,
- Collections.singletonList(new RefSpec(commit.name())));
- assertFalse(client.getObjectDatabase().has(longBlob.toObjectId()));
- assertTrue(client.getObjectDatabase().has(shortBlob.toObjectId()));
+ try (Transport tn = testProtocol.open(uri, client, "server2")) {
+ tn.setFilterBlobLimit(5);
+ tn.fetch(NullProgressMonitor.INSTANCE,
+ Collections.singletonList(new RefSpec(commit.name())));
+ assertFalse(
+ client.getObjectDatabase().has(longBlob.toObjectId()));
+ assertTrue(
+ client.getObjectDatabase().has(shortBlob.toObjectId()));
+ }
}
}
@Test
public void testFetchWithNonSupportingServer() throws Exception {
InMemoryRepository server2 = newRepo("server2");
- TestRepository<InMemoryRepository> remote2 =
- new TestRepository<>(server2);
- RevBlob blob = remote2.blob("foo");
- RevTree tree = remote2.tree(remote2.file("1", blob));
- RevCommit commit = remote2.commit(tree);
- remote2.update("master", commit);
+ try (TestRepository<InMemoryRepository> remote2 = new TestRepository<>(
+ server2)) {
+ RevBlob blob = remote2.blob("foo");
+ RevTree tree = remote2.tree(remote2.file("1", blob));
+ RevCommit commit = remote2.commit(tree);
+ remote2.update("master", commit);
- server2.getConfig().setBoolean("uploadpack", null, "allowfilter", false);
+ server2.getConfig().setBoolean("uploadpack", null, "allowfilter",
+ false);
- testProtocol = new TestProtocol<>(
- new UploadPackFactory<Object>() {
- @Override
- public UploadPack create(Object req, Repository db)
- throws ServiceNotEnabledException,
- ServiceNotAuthorizedException {
- UploadPack up = new UploadPack(db);
- return up;
- }
- }, null);
- uri = testProtocol.register(ctx, server2);
+ testProtocol = new TestProtocol<>(new UploadPackFactory<Object>() {
+ @Override
+ public UploadPack create(Object req, Repository db)
+ throws ServiceNotEnabledException,
+ ServiceNotAuthorizedException {
+ UploadPack up = new UploadPack(db);
+ return up;
+ }
+ }, null);
+ uri = testProtocol.register(ctx, server2);
- try (Transport tn = testProtocol.open(uri, client, "server2")) {
- tn.setFilterBlobLimit(0);
+ try (Transport tn = testProtocol.open(uri, client, "server2")) {
+ tn.setFilterBlobLimit(0);
- thrown.expect(TransportException.class);
- thrown.expectMessage("filter requires server to advertise that capability");
+ thrown.expect(TransportException.class);
+ thrown.expectMessage(
+ "filter requires server to advertise that capability");
- tn.fetch(NullProgressMonitor.INSTANCE,
- Collections.singletonList(new RefSpec(commit.name())));
+ tn.fetch(NullProgressMonitor.INSTANCE,
+ Collections.singletonList(new RefSpec(commit.name())));
+ }
}
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java
index edcce12..9f1395b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java
@@ -404,16 +404,16 @@ public void testRandomWrites() throws IOException {
@Test
public void testHeap() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final TemporaryBuffer b = new TemporaryBuffer.Heap(2 * 8 * 1024);
- final byte[] r = new byte[8 * 1024];
- b.write(r);
- b.write(r);
- try {
- b.write(1);
- fail("accepted too many bytes of data");
- } catch (IOException e) {
- assertEquals("In-memory buffer limit exceeded", e.getMessage());
+ try (TemporaryBuffer b = new TemporaryBuffer.Heap(2 * 8 * 1024)) {
+ final byte[] r = new byte[8 * 1024];
+ b.write(r);
+ b.write(r);
+ try {
+ b.write(1);
+ fail("accepted too many bytes of data");
+ } catch (IOException e) {
+ assertEquals("In-memory buffer limit exceeded", e.getMessage());
+ }
}
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java
index a6e0eed..e38bbfe 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/UnionInputStreamTest.java
@@ -69,53 +69,52 @@ public void testEmptyStream() throws IOException {
@Test
public void testReadSingleBytes() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final UnionInputStream u = new UnionInputStream();
+ try (UnionInputStream u = new UnionInputStream()) {
+ assertTrue(u.isEmpty());
+ u.add(new ByteArrayInputStream(new byte[] { 1, 0, 2 }));
+ u.add(new ByteArrayInputStream(new byte[] { 3 }));
+ u.add(new ByteArrayInputStream(new byte[] { 4, 5 }));
- assertTrue(u.isEmpty());
- u.add(new ByteArrayInputStream(new byte[] { 1, 0, 2 }));
- u.add(new ByteArrayInputStream(new byte[] { 3 }));
- u.add(new ByteArrayInputStream(new byte[] { 4, 5 }));
+ assertFalse(u.isEmpty());
+ assertEquals(3, u.available());
+ assertEquals(1, u.read());
+ assertEquals(0, u.read());
+ assertEquals(2, u.read());
+ assertEquals(0, u.available());
- assertFalse(u.isEmpty());
- assertEquals(3, u.available());
- assertEquals(1, u.read());
- assertEquals(0, u.read());
- assertEquals(2, u.read());
- assertEquals(0, u.available());
+ assertEquals(3, u.read());
+ assertEquals(0, u.available());
- assertEquals(3, u.read());
- assertEquals(0, u.available());
+ assertEquals(4, u.read());
+ assertEquals(1, u.available());
+ assertEquals(5, u.read());
+ assertEquals(0, u.available());
+ assertEquals(-1, u.read());
- assertEquals(4, u.read());
- assertEquals(1, u.available());
- assertEquals(5, u.read());
- assertEquals(0, u.available());
- assertEquals(-1, u.read());
-
- assertTrue(u.isEmpty());
- u.add(new ByteArrayInputStream(new byte[] { (byte) 255 }));
- assertEquals(255, u.read());
- assertEquals(-1, u.read());
- assertTrue(u.isEmpty());
+ assertTrue(u.isEmpty());
+ u.add(new ByteArrayInputStream(new byte[] { (byte) 255 }));
+ assertEquals(255, u.read());
+ assertEquals(-1, u.read());
+ assertTrue(u.isEmpty());
+ }
}
@Test
public void testReadByteBlocks() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final UnionInputStream u = new UnionInputStream();
- u.add(new ByteArrayInputStream(new byte[] { 1, 0, 2 }));
- u.add(new ByteArrayInputStream(new byte[] { 3 }));
- u.add(new ByteArrayInputStream(new byte[] { 4, 5 }));
+ try (UnionInputStream u = new UnionInputStream()) {
+ u.add(new ByteArrayInputStream(new byte[] { 1, 0, 2 }));
+ u.add(new ByteArrayInputStream(new byte[] { 3 }));
+ u.add(new ByteArrayInputStream(new byte[] { 4, 5 }));
- final byte[] r = new byte[5];
- assertEquals(3, u.read(r, 0, 5));
- assertTrue(Arrays.equals(new byte[] { 1, 0, 2, }, slice(r, 3)));
- assertEquals(1, u.read(r, 0, 5));
- assertEquals(3, r[0]);
- assertEquals(2, u.read(r, 0, 5));
- assertTrue(Arrays.equals(new byte[] { 4, 5, }, slice(r, 2)));
- assertEquals(-1, u.read(r, 0, 5));
+ final byte[] r = new byte[5];
+ assertEquals(3, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 1, 0, 2, }, slice(r, 3)));
+ assertEquals(1, u.read(r, 0, 5));
+ assertEquals(3, r[0]);
+ assertEquals(2, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 4, 5, }, slice(r, 2)));
+ assertEquals(-1, u.read(r, 0, 5));
+ }
}
private static byte[] slice(byte[] in, int len) {
@@ -126,89 +125,88 @@ public void testReadByteBlocks() throws IOException {
@Test
public void testArrayConstructor() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final UnionInputStream u = new UnionInputStream(
+ try (UnionInputStream u = new UnionInputStream(
new ByteArrayInputStream(new byte[] { 1, 0, 2 }),
new ByteArrayInputStream(new byte[] { 3 }),
- new ByteArrayInputStream(new byte[] { 4, 5 }));
-
- final byte[] r = new byte[5];
- assertEquals(3, u.read(r, 0, 5));
- assertTrue(Arrays.equals(new byte[] { 1, 0, 2, }, slice(r, 3)));
- assertEquals(1, u.read(r, 0, 5));
- assertEquals(3, r[0]);
- assertEquals(2, u.read(r, 0, 5));
- assertTrue(Arrays.equals(new byte[] { 4, 5, }, slice(r, 2)));
- assertEquals(-1, u.read(r, 0, 5));
+ new ByteArrayInputStream(new byte[] { 4, 5 }))) {
+ final byte[] r = new byte[5];
+ assertEquals(3, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 1, 0, 2, }, slice(r, 3)));
+ assertEquals(1, u.read(r, 0, 5));
+ assertEquals(3, r[0]);
+ assertEquals(2, u.read(r, 0, 5));
+ assertTrue(Arrays.equals(new byte[] { 4, 5, }, slice(r, 2)));
+ assertEquals(-1, u.read(r, 0, 5));
+ }
}
@Test
- public void testMarkSupported() {
- @SuppressWarnings("resource" /* java 7 */)
- final UnionInputStream u = new UnionInputStream();
- assertFalse(u.markSupported());
- u.add(new ByteArrayInputStream(new byte[] { 1, 0, 2 }));
- assertFalse(u.markSupported());
+ public void testMarkSupported() throws IOException {
+ try (UnionInputStream u = new UnionInputStream()) {
+ assertFalse(u.markSupported());
+ u.add(new ByteArrayInputStream(new byte[] { 1, 0, 2 }));
+ assertFalse(u.markSupported());
+ }
}
@Test
public void testSkip() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final UnionInputStream u = new UnionInputStream();
- u.add(new ByteArrayInputStream(new byte[] { 1, 0, 2 }));
- u.add(new ByteArrayInputStream(new byte[] { 3 }));
- u.add(new ByteArrayInputStream(new byte[] { 4, 5 }));
- assertEquals(0, u.skip(0));
- assertEquals(3, u.skip(3));
- assertEquals(3, u.read());
- assertEquals(2, u.skip(5));
- assertEquals(0, u.skip(5));
- assertEquals(-1, u.read());
+ try (UnionInputStream u = new UnionInputStream()) {
+ u.add(new ByteArrayInputStream(new byte[] { 1, 0, 2 }));
+ u.add(new ByteArrayInputStream(new byte[] { 3 }));
+ u.add(new ByteArrayInputStream(new byte[] { 4, 5 }));
+ assertEquals(0, u.skip(0));
+ assertEquals(3, u.skip(3));
+ assertEquals(3, u.read());
+ assertEquals(2, u.skip(5));
+ assertEquals(0, u.skip(5));
+ assertEquals(-1, u.read());
- u.add(new ByteArrayInputStream(new byte[] { 20, 30 }) {
- @Override
- @SuppressWarnings("UnsynchronizedOverridesSynchronized")
- // This is only used in tests and is thread-safe
- public long skip(long n) {
- return 0;
- }
- });
- assertEquals(2, u.skip(8));
- assertEquals(-1, u.read());
+ u.add(new ByteArrayInputStream(new byte[] { 20, 30 }) {
+ @Override
+ @SuppressWarnings("UnsynchronizedOverridesSynchronized")
+ // This is only used in tests and is thread-safe
+ public long skip(long n) {
+ return 0;
+ }
+ });
+ assertEquals(2, u.skip(8));
+ assertEquals(-1, u.read());
+ }
}
@Test
public void testAutoCloseDuringRead() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
- final UnionInputStream u = new UnionInputStream();
- final boolean closed[] = new boolean[2];
- u.add(new ByteArrayInputStream(new byte[] { 1 }) {
- @Override
- public void close() {
- closed[0] = true;
- }
- });
- u.add(new ByteArrayInputStream(new byte[] { 2 }) {
- @Override
- public void close() {
- closed[1] = true;
- }
- });
+ try (UnionInputStream u = new UnionInputStream()) {
+ final boolean closed[] = new boolean[2];
+ u.add(new ByteArrayInputStream(new byte[] { 1 }) {
+ @Override
+ public void close() {
+ closed[0] = true;
+ }
+ });
+ u.add(new ByteArrayInputStream(new byte[] { 2 }) {
+ @Override
+ public void close() {
+ closed[1] = true;
+ }
+ });
- assertFalse(closed[0]);
- assertFalse(closed[1]);
+ assertFalse(closed[0]);
+ assertFalse(closed[1]);
- assertEquals(1, u.read());
- assertFalse(closed[0]);
- assertFalse(closed[1]);
+ assertEquals(1, u.read());
+ assertFalse(closed[0]);
+ assertFalse(closed[1]);
- assertEquals(2, u.read());
- assertTrue(closed[0]);
- assertFalse(closed[1]);
+ assertEquals(2, u.read());
+ assertTrue(closed[0]);
+ assertFalse(closed[1]);
- assertEquals(-1, u.read());
- assertTrue(closed[0]);
- assertTrue(closed[1]);
+ assertEquals(-1, u.read());
+ assertTrue(closed[0]);
+ assertTrue(closed[1]);
+ }
}
@Test
@@ -267,18 +265,18 @@ public int read(byte b[], int off, int len) throws IOException {
throw new IOException("Expected");
}
};
- @SuppressWarnings("resource" /* java 7 */)
- final UnionInputStream u = new UnionInputStream(
- new ByteArrayInputStream(new byte[]{1,2,3}),
- errorReadStream);
- byte buf[] = new byte[10];
- assertEquals(3, u.read(buf, 0, 10));
- assertTrue(Arrays.equals(new byte[] {1,2,3}, slice(buf, 3)));
- try {
- u.read(buf, 0, 1);
- fail("Expected exception from errorReadStream");
- } catch (IOException e) {
- assertEquals("Expected", e.getMessage());
+ try (UnionInputStream u = new UnionInputStream(
+ new ByteArrayInputStream(new byte[] { 1, 2, 3 }),
+ errorReadStream)) {
+ byte buf[] = new byte[10];
+ assertEquals(3, u.read(buf, 0, 10));
+ assertTrue(Arrays.equals(new byte[] { 1, 2, 3 }, slice(buf, 3)));
+ try {
+ u.read(buf, 0, 1);
+ fail("Expected exception from errorReadStream");
+ } catch (IOException e) {
+ assertEquals("Expected", e.getMessage());
+ }
}
}
}
diff --git a/org.eclipse.jgit/BUILD b/org.eclipse.jgit/BUILD
index 9ddcb9d..b67bfac 100644
--- a/org.eclipse.jgit/BUILD
+++ b/org.eclipse.jgit/BUILD
@@ -22,13 +22,13 @@
resources = RESOURCES,
deps = [
":insecure_cipher_factory",
+ "//lib:bcpg",
+ "//lib:bcpkix",
+ "//lib:bcprov",
"//lib:javaewah",
"//lib:jsch",
"//lib:jzlib",
"//lib:slf4j-api",
- "//lib:bcpg",
- "//lib:bcprov",
- "//lib:bcpkix"
],
)
diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
index 38901f9..51910f8 100644
--- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
+++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
@@ -302,7 +302,7 @@
expectedPktLineWithService=expected pkt-line with ''# service=-'', got ''{0}''
expectedReceivedContentType=expected Content-Type {0}; received Content-Type {1}
expectedReportForRefNotReceived={0}: expected report for ref {1} not received
-failedAtomicFileCreation=Atomic file creation failed, number of hard links to file {0} was not 2 but {1}"
+failedAtomicFileCreation=Atomic file creation failed, number of hard links to file {0} was not 2 but {1}
failedToDetermineFilterDefinition=An exception occurred while determining filter definitions
failedUpdatingRefs=failed updating refs
failureDueToOneOfTheFollowing=Failure due to one of the following:
@@ -590,8 +590,9 @@
remoteDoesNotHaveSpec=Remote does not have {0} available for fetch.
remoteDoesNotSupportSmartHTTPPush=remote does not support smart HTTP push
remoteHungUpUnexpectedly=remote hung up unexpectedly
-remoteNameCantBeNull=Remote name can't be null.
-renameBranchFailedBecauseTag=Can not rename as Ref {0} is a tag
+remoteNameCannotBeNull=Remote name cannot be null.
+renameBranchFailedAmbiguous=Cannot rename branch {0}; name is ambiguous: {1} or {2}
+renameBranchFailedNotABranch=Cannot rename {0}: this is not a branch
renameBranchFailedUnknownReason=Rename failed with unknown reason
renameBranchUnexpectedResult=Unexpected rename result {0}
renameCancelled=Rename detection was cancelled
@@ -630,7 +631,7 @@
sequenceTooLargeForDiffAlgorithm=Sequence too large for difference algorithm.
serviceNotEnabledNoName=Service not enabled
serviceNotPermitted={1} not permitted on ''{0}''
-sha1CollisionDetected1=SHA-1 collision detected on {0}
+sha1CollisionDetected=SHA-1 collision detected on {0}
shallowCommitsAlreadyInitialized=Shallow commits have already been initialized
shallowPacksRequireDepthWalk=Shallow packs require a DepthWalk
shortCompressedStreamAt=Short compressed stream at {0}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
index 73af8ba..0248ba2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
@@ -303,18 +303,25 @@ private FetchResult fetch(Repository clonedRepo, URIish u)
}
private List<RefSpec> calculateRefSpecs(boolean fetchAll, String dst) {
- RefSpec wcrs = new RefSpec();
- wcrs = wcrs.setForceUpdate(true);
- wcrs = wcrs.setSourceDestination(Constants.R_HEADS + '*', dst);
+ RefSpec heads = new RefSpec();
+ heads = heads.setForceUpdate(true);
+ heads = heads.setSourceDestination(Constants.R_HEADS + '*', dst);
List<RefSpec> specs = new ArrayList<>();
if (!fetchAll) {
+ RefSpec tags = new RefSpec();
+ tags = tags.setForceUpdate(true);
+ tags = tags.setSourceDestination(Constants.R_TAGS + '*',
+ Constants.R_TAGS + '*');
for (String selectedRef : branchesToClone) {
- if (wcrs.matchSource(selectedRef)) {
- specs.add(wcrs.expandFromSource(selectedRef));
+ if (heads.matchSource(selectedRef)) {
+ specs.add(heads.expandFromSource(selectedRef));
+ } else if (tags.matchSource(selectedRef)) {
+ specs.add(tags.expandFromSource(selectedRef));
}
}
} else {
- specs.add(wcrs);
+ // We'll fetch the tags anyway.
+ specs.add(heads);
}
return specs;
}
@@ -590,11 +597,15 @@ public CloneCommand setProgressMonitor(ProgressMonitor monitor) {
}
/**
- * Set whether all branches have to be fetched
+ * Set whether all branches have to be fetched.
+ * <p>
+ * If {@code false}, use {@link #setBranchesToClone(Collection)} to define
+ * what will be cloned. If neither are set, all branches will be cloned.
+ * </p>
*
* @param cloneAllBranches
- * true when all branches have to be fetched (indicates wildcard
- * in created fetch refspec), false otherwise.
+ * {@code true} when all branches have to be fetched (indicates
+ * wildcard in created fetch refspec), {@code false} otherwise.
* @return {@code this}
*/
public CloneCommand setCloneAllBranches(boolean cloneAllBranches) {
@@ -616,12 +627,17 @@ public CloneCommand setCloneSubmodules(boolean cloneSubmodules) {
}
/**
- * Set branches to clone
+ * Set the branches or tags to clone.
+ * <p>
+ * This is ignored if {@link #setCloneAllBranches(boolean)
+ * setCloneAllBranches(true)} is used. If {@code branchesToClone} is
+ * {@code null} or empty, it's also ignored and all branches will be cloned.
+ * </p>
*
* @param branchesToClone
- * collection of branches to clone. Ignored when allSelected is
- * true. Must be specified as full ref names (e.g.
- * <code>refs/heads/master</code>).
+ * collection of branches to clone. Must be specified as full ref
+ * names (e.g. {@code refs/heads/master} or
+ * {@code refs/tags/v1.0.0}).
* @return {@code this}
*/
public CloneCommand setBranchesToClone(Collection<String> branchesToClone) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
index 9653c36..0e3d000 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
@@ -158,11 +158,14 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
private static final String ONTO = "onto"; //$NON-NLS-1$
- private static final String ONTO_NAME = "onto-name"; //$NON-NLS-1$
+ private static final String ONTO_NAME = "onto_name"; //$NON-NLS-1$
private static final String PATCH = "patch"; //$NON-NLS-1$
- private static final String REBASE_HEAD = "head"; //$NON-NLS-1$
+ private static final String REBASE_HEAD = "orig-head"; //$NON-NLS-1$
+
+ /** Pre git 1.7.6 file name for {@link #REBASE_HEAD}. */
+ private static final String REBASE_HEAD_LEGACY = "head"; //$NON-NLS-1$
private static final String AMEND = "amend"; //$NON-NLS-1$
@@ -177,6 +180,10 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
/**
* The folder containing the hashes of (potentially) rewritten commits when
* --preserve-merges is used.
+ * <p>
+ * Native git rebase --merge uses a <em>file</em> of that name to record
+ * commits to copy notes at the end of the whole rebase.
+ * </p>
*/
private static final String REWRITTEN = "rewritten"; //$NON-NLS-1$
@@ -289,7 +296,7 @@ public RebaseResult call() throws GitAPIException, NoHeadException,
}
this.upstreamCommit = walk.parseCommit(repo
.resolve(upstreamCommitId));
- preserveMerges = rebaseState.getRewrittenDir().exists();
+ preserveMerges = rebaseState.getRewrittenDir().isDirectory();
break;
case BEGIN:
autoStash();
@@ -1120,10 +1127,14 @@ else if (!isInteractive() && walk.isMergedInto(headCommit, upstream)) {
repo.writeOrigHead(headId);
rebaseState.createFile(REBASE_HEAD, headId.name());
+ rebaseState.createFile(REBASE_HEAD_LEGACY, headId.name());
rebaseState.createFile(HEAD_NAME, headName);
rebaseState.createFile(ONTO, upstreamCommit.name());
rebaseState.createFile(ONTO_NAME, upstreamCommitName);
- if (isInteractive()) {
+ if (isInteractive() || preserveMerges) {
+ // --preserve-merges is an interactive mode for native git. Without
+ // this, native git rebase --continue after a conflict would fall
+ // into merge mode.
rebaseState.createFile(INTERACTIVE, ""); //$NON-NLS-1$
}
rebaseState.createFile(QUIET, ""); //$NON-NLS-1$
@@ -1333,8 +1344,8 @@ private void checkParameters() throws WrongRepositoryStateException {
private RebaseResult abort(RebaseResult result) throws IOException,
GitAPIException {
+ ObjectId origHead = getOriginalHead();
try {
- ObjectId origHead = repo.readOrigHead();
String commitId = origHead != null ? origHead.name() : null;
monitor.beginTask(MessageFormat.format(
JGitText.get().abortingRebase, commitId),
@@ -1373,7 +1384,7 @@ private RebaseResult abort(RebaseResult result) throws IOException,
// update the HEAD
res = refUpdate.link(headName);
} else {
- refUpdate.setNewObjectId(repo.readOrigHead());
+ refUpdate.setNewObjectId(origHead);
res = refUpdate.forceUpdate();
}
@@ -1400,6 +1411,19 @@ private RebaseResult abort(RebaseResult result) throws IOException,
}
}
+ private ObjectId getOriginalHead() throws IOException {
+ try {
+ return ObjectId.fromString(rebaseState.readFile(REBASE_HEAD));
+ } catch (FileNotFoundException e) {
+ try {
+ return ObjectId
+ .fromString(rebaseState.readFile(REBASE_HEAD_LEGACY));
+ } catch (FileNotFoundException ex) {
+ return repo.readOrigHead();
+ }
+ }
+ }
+
private boolean checkoutCommit(String headName, RevCommit commit)
throws IOException,
CheckoutConflictException {
@@ -1706,7 +1730,20 @@ public File getRewrittenDir() {
}
public String readFile(String name) throws IOException {
- return readFile(getDir(), name);
+ try {
+ return readFile(getDir(), name);
+ } catch (FileNotFoundException e) {
+ if (ONTO_NAME.equals(name)) {
+ // Older JGit mistakenly wrote a file "onto-name" instead of
+ // "onto_name". Try that wrong name just in case somebody
+ // upgraded while a rebase started by JGit was in progress.
+ File oldFile = getFile(ONTO_NAME.replace('_', '-'));
+ if (oldFile.exists()) {
+ return readFile(oldFile);
+ }
+ }
+ throw e;
+ }
}
public void createFile(String name, String content) throws IOException {
@@ -1721,14 +1758,18 @@ public String getPath(String name) {
return (getDir().getName() + "/" + name); //$NON-NLS-1$
}
- private static String readFile(File directory, String fileName)
- throws IOException {
- byte[] content = IO.readFully(new File(directory, fileName));
+ private static String readFile(File file) throws IOException {
+ byte[] content = IO.readFully(file);
// strip off the last LF
int end = RawParseUtils.prevLF(content, content.length);
return RawParseUtils.decode(content, 0, end + 1);
}
+ private static String readFile(File directory, String fileName)
+ throws IOException {
+ return readFile(new File(directory, fileName));
+ }
+
private static void createFile(File parentDir, String name,
String content)
throws IOException {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RenameBranchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RenameBranchCommand.java
index 24d9dd4..7e8c33c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RenameBranchCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RenameBranchCommand.java
@@ -94,25 +94,38 @@ public Ref call() throws GitAPIException, RefNotFoundException, InvalidRefNameEx
RefAlreadyExistsException, DetachedHeadException {
checkCallable();
- if (newName == null)
+ if (newName == null) {
throw new InvalidRefNameException(MessageFormat.format(JGitText
.get().branchNameInvalid, "<null>")); //$NON-NLS-1$
-
+ }
try {
String fullOldName;
String fullNewName;
- if (repo.findRef(newName) != null)
- throw new RefAlreadyExistsException(MessageFormat.format(
- JGitText.get().refAlreadyExists1, newName));
if (oldName != null) {
- Ref ref = repo.findRef(oldName);
- if (ref == null)
- throw new RefNotFoundException(MessageFormat.format(
- JGitText.get().refNotResolved, oldName));
- if (ref.getName().startsWith(Constants.R_TAGS))
- throw new RefNotFoundException(MessageFormat.format(
- JGitText.get().renameBranchFailedBecauseTag,
- oldName));
+ // Don't just rely on findRef -- if there are local and remote
+ // branches with the same name, and oldName is a short name, it
+ // does not uniquely identify the ref and we might end up
+ // renaming the wrong branch or finding a tag instead even
+ // if a unique branch for the name exists!
+ //
+ // OldName may be a either a short or a full name.
+ Ref ref = repo.exactRef(oldName);
+ if (ref == null) {
+ ref = repo.exactRef(Constants.R_HEADS + oldName);
+ Ref ref2 = repo.exactRef(Constants.R_REMOTES + oldName);
+ if (ref != null && ref2 != null) {
+ throw new RefNotFoundException(MessageFormat.format(
+ JGitText.get().renameBranchFailedAmbiguous,
+ oldName, ref.getName(), ref2.getName()));
+ } else if (ref == null) {
+ if (ref2 != null) {
+ ref = ref2;
+ } else {
+ throw new RefNotFoundException(MessageFormat.format(
+ JGitText.get().refNotResolved, oldName));
+ }
+ }
+ }
fullOldName = ref.getName();
} else {
fullOldName = repo.getFullBranch();
@@ -124,26 +137,34 @@ public Ref call() throws GitAPIException, RefNotFoundException, InvalidRefNameEx
throw new DetachedHeadException();
}
- if (fullOldName.startsWith(Constants.R_REMOTES))
+ if (fullOldName.startsWith(Constants.R_REMOTES)) {
fullNewName = Constants.R_REMOTES + newName;
- else {
+ } else if (fullOldName.startsWith(Constants.R_HEADS)) {
fullNewName = Constants.R_HEADS + newName;
+ } else {
+ throw new RefNotFoundException(MessageFormat.format(
+ JGitText.get().renameBranchFailedNotABranch,
+ fullOldName));
}
- if (!Repository.isValidRefName(fullNewName))
+ if (!Repository.isValidRefName(fullNewName)) {
throw new InvalidRefNameException(MessageFormat.format(JGitText
.get().branchNameInvalid, fullNewName));
-
+ }
+ if (repo.exactRef(fullNewName) != null) {
+ throw new RefAlreadyExistsException(MessageFormat
+ .format(JGitText.get().refAlreadyExists1, fullNewName));
+ }
RefRename rename = repo.renameRef(fullOldName, fullNewName);
Result renameResult = rename.rename();
setCallable(false);
- if (Result.RENAMED != renameResult)
+ if (Result.RENAMED != renameResult) {
throw new JGitInternalException(MessageFormat.format(JGitText
.get().renameBranchUnexpectedResult, renameResult
.name()));
-
+ }
if (fullNewName.startsWith(Constants.R_HEADS)) {
String shortOldName = fullOldName.substring(Constants.R_HEADS
.length());
@@ -154,8 +175,9 @@ public Ref call() throws GitAPIException, RefNotFoundException, InvalidRefNameEx
String[] values = repoConfig.getStringList(
ConfigConstants.CONFIG_BRANCH_SECTION,
shortOldName, name);
- if (values.length == 0)
+ if (values.length == 0) {
continue;
+ }
// Keep any existing values already configured for the
// new branch name
String[] existing = repoConfig.getStringList(
@@ -180,10 +202,11 @@ public Ref call() throws GitAPIException, RefNotFoundException, InvalidRefNameEx
repoConfig.save();
}
- Ref resultRef = repo.findRef(newName);
- if (resultRef == null)
+ Ref resultRef = repo.exactRef(fullNewName);
+ if (resultRef == null) {
throw new JGitInternalException(
JGitText.get().renameBranchFailedUnknownReason);
+ }
return resultRef;
} catch (IOException ioe) {
throw new JGitInternalException(ioe.getMessage(), ioe);
@@ -191,7 +214,13 @@ public Ref call() throws GitAPIException, RefNotFoundException, InvalidRefNameEx
}
/**
- * Set the new name of the branch
+ * Sets the new short name of the branch.
+ * <p>
+ * The full name is constructed using the prefix of the branch to be renamed
+ * defined by either {@link #setOldName(String)} or HEAD. If that old branch
+ * is a local branch, the renamed branch also will be, and if the old branch
+ * is a remote branch, so will be the renamed branch.
+ * </p>
*
* @param newName
* the new name
@@ -204,7 +233,11 @@ public RenameBranchCommand setNewName(String newName) {
}
/**
- * Set the old name of the branch
+ * Sets the old name of the branch.
+ * <p>
+ * {@code oldName} may be a short or a full name. Using a full name is
+ * recommended to unambiguously identify the branch to be renamed.
+ * </p>
*
* @param oldName
* the name of the branch to rename; if not set, the currently
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
index bd41d90..6c0d90e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
@@ -309,6 +309,74 @@ public static boolean isBinary(byte[] raw, int length) {
}
/**
+ * Determine heuristically whether a byte array represents text content
+ * using CR-LF as line separator.
+ *
+ * @param raw
+ * the raw file content.
+ * @return {@code true} if raw is likely to be CR-LF delimited text,
+ * {@code false} otherwise
+ * @since 5.3
+ */
+ public static boolean isCrLfText(byte[] raw) {
+ return isCrLfText(raw, raw.length);
+ }
+
+ /**
+ * Determine heuristically whether the bytes contained in a stream represent
+ * text content using CR-LF as line separator.
+ *
+ * Note: Do not further use this stream after having called this method! The
+ * stream may not be fully read and will be left at an unknown position
+ * after consuming an unknown number of bytes. The caller is responsible for
+ * closing the stream.
+ *
+ * @param raw
+ * input stream containing the raw file content.
+ * @return {@code true} if raw is likely to be CR-LF delimited text,
+ * {@code false} otherwise
+ * @throws java.io.IOException
+ * if input stream could not be read
+ * @since 5.3
+ */
+ public static boolean isCrLfText(InputStream raw) throws IOException {
+ byte[] buffer = new byte[FIRST_FEW_BYTES];
+ int cnt = 0;
+ while (cnt < buffer.length) {
+ int n = raw.read(buffer, cnt, buffer.length - cnt);
+ if (n == -1) {
+ break;
+ }
+ cnt += n;
+ }
+ return isCrLfText(buffer, cnt);
+ }
+
+ /**
+ * Determine heuristically whether a byte array represents text content
+ * using CR-LF as line separator.
+ *
+ * @param raw
+ * the raw file content.
+ * @param length
+ * number of bytes in {@code raw} to evaluate.
+ * @return {@code true} if raw is likely to be CR-LF delimited text,
+ * {@code false} otherwise
+ * @since 5.3
+ */
+ public static boolean isCrLfText(byte[] raw, int length) {
+ boolean has_crlf = false;
+ for (int ptr = 0; ptr < length - 1; ptr++) {
+ if (raw[ptr] == '\0') {
+ return false; // binary
+ } else if (raw[ptr] == '\r' && raw[ptr + 1] == '\n') {
+ has_crlf = true;
+ }
+ }
+ return has_crlf;
+ }
+
+ /**
* Get the line delimiter for the first line.
*
* @since 2.0
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
index ac9a637..018b643 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -651,8 +651,9 @@ public static JGitText get() {
/***/ public String remoteDoesNotHaveSpec;
/***/ public String remoteDoesNotSupportSmartHTTPPush;
/***/ public String remoteHungUpUnexpectedly;
- /***/ public String remoteNameCantBeNull;
- /***/ public String renameBranchFailedBecauseTag;
+ /***/ public String remoteNameCannotBeNull;
+ /***/ public String renameBranchFailedAmbiguous;
+ /***/ public String renameBranchFailedNotABranch;
/***/ public String renameBranchFailedUnknownReason;
/***/ public String renameBranchUnexpectedResult;
/***/ public String renameCancelled;
@@ -691,7 +692,7 @@ public static JGitText get() {
/***/ public String sequenceTooLargeForDiffAlgorithm;
/***/ public String serviceNotEnabledNoName;
/***/ public String serviceNotPermitted;
- /***/ public String sha1CollisionDetected1;
+ /***/ public String sha1CollisionDetected;
/***/ public String shallowCommitsAlreadyInitialized;
/***/ public String shallowPacksRequireDepthWalk;
/***/ public String shortCompressedStreamAt;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
index 7d891b5..451986e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
@@ -98,13 +98,13 @@ public final class DfsPackFile extends BlockBasedFile {
private final Object initLock = new Object();
/** Index mapping {@link ObjectId} to position within the pack stream. */
- private volatile DfsBlockCache.Ref<PackIndex> index;
+ private volatile PackIndex index;
/** Reverse version of {@link #index} mapping position to {@link ObjectId}. */
- private volatile DfsBlockCache.Ref<PackReverseIndex> reverseIndex;
+ private volatile PackReverseIndex reverseIndex;
/** Index of compressed bitmap mapping entire object graph. */
- private volatile DfsBlockCache.Ref<PackBitmapIndex> bitmapIndex;
+ private volatile PackBitmapIndex bitmapIndex;
/**
* Objects we have tried to read, and discovered to be corrupt.
@@ -150,15 +150,15 @@ public DfsPackDescription getPackDescription() {
* @return whether the pack index file is loaded and cached in memory.
*/
public boolean isIndexLoaded() {
- DfsBlockCache.Ref<PackIndex> idxref = index;
- return idxref != null && idxref.has();
+ return index != null;
}
void setPackIndex(PackIndex idx) {
long objCnt = idx.getObjectCount();
int recSize = Constants.OBJECT_ID_LENGTH + 8;
long sz = objCnt * recSize;
- index = cache.putRef(desc.getStreamKey(INDEX), sz, idx);
+ cache.putRef(desc.getStreamKey(INDEX), sz, idx);
+ index = idx;
}
/**
@@ -176,12 +176,8 @@ public PackIndex getPackIndex(DfsReader ctx) throws IOException {
}
private PackIndex idx(DfsReader ctx) throws IOException {
- DfsBlockCache.Ref<PackIndex> idxref = index;
- if (idxref != null) {
- PackIndex idx = idxref.get();
- if (idx != null) {
- return idx;
- }
+ if (index != null) {
+ return index;
}
if (invalid) {
@@ -192,59 +188,60 @@ private PackIndex idx(DfsReader ctx) throws IOException {
.dispatch(new BeforeDfsPackIndexLoadedEvent(this));
synchronized (initLock) {
- idxref = index;
- if (idxref != null) {
- PackIndex idx = idxref.get();
- if (idx != null) {
- return idx;
- }
+ if (index != null) {
+ return index;
}
- DfsStreamKey idxKey = desc.getStreamKey(INDEX);
try {
- idxref = cache.getOrLoadRef(idxKey, () -> {
- try {
- ctx.stats.readIdx++;
- long start = System.nanoTime();
- try (ReadableChannel rc = ctx.db.openFile(desc,
- INDEX)) {
- InputStream in = Channels.newInputStream(rc);
- int wantSize = 8192;
- int bs = rc.blockSize();
- if (0 < bs && bs < wantSize) {
- bs = (wantSize / bs) * bs;
- } else if (bs <= 0) {
- bs = wantSize;
+ DfsStreamKey idxKey = desc.getStreamKey(INDEX);
+ DfsBlockCache.Ref<PackIndex> idxref = cache.getOrLoadRef(idxKey,
+ () -> {
+ try {
+ ctx.stats.readIdx++;
+ long start = System.nanoTime();
+ try (ReadableChannel rc = ctx.db.openFile(desc,
+ INDEX)) {
+ InputStream in = Channels
+ .newInputStream(rc);
+ int wantSize = 8192;
+ int bs = rc.blockSize();
+ if (0 < bs && bs < wantSize) {
+ bs = (wantSize / bs) * bs;
+ } else if (bs <= 0) {
+ bs = wantSize;
+ }
+ PackIndex idx = PackIndex.read(
+ new BufferedInputStream(in, bs));
+ int sz = (int) Math.min(
+ idx.getObjectCount() * REC_SIZE,
+ Integer.MAX_VALUE);
+ ctx.stats.readIdxBytes += rc.position();
+ index = idx;
+ return new DfsBlockCache.Ref<>(idxKey, 0,
+ sz, idx);
+ } finally {
+ ctx.stats.readIdxMicros += elapsedMicros(
+ start);
+ }
+ } catch (EOFException e) {
+ throw new IOException(MessageFormat.format(
+ DfsText.get().shortReadOfIndex,
+ desc.getFileName(INDEX)), e);
+ } catch (IOException e) {
+ throw new IOException(MessageFormat.format(
+ DfsText.get().cannotReadIndex,
+ desc.getFileName(INDEX)), e);
}
- PackIndex idx = PackIndex
- .read(new BufferedInputStream(in, bs));
- int sz = (int) Math.min(
- idx.getObjectCount() * REC_SIZE,
- Integer.MAX_VALUE);
- ctx.stats.readIdxBytes += rc.position();
- return new DfsBlockCache.Ref<>(idxKey, 0, sz, idx);
- } finally {
- ctx.stats.readIdxMicros += elapsedMicros(start);
- }
- } catch (EOFException e) {
- throw new IOException(MessageFormat.format(
- DfsText.get().shortReadOfIndex,
- desc.getFileName(INDEX)), e);
- } catch (IOException e) {
- throw new IOException(MessageFormat.format(
- DfsText.get().cannotReadIndex,
- desc.getFileName(INDEX)), e);
- }
- });
+ });
+ PackIndex idx = idxref.get();
+ if (index == null && idx != null) {
+ index = idx;
+ }
+ return index;
} catch (IOException e) {
invalid = true;
throw e;
}
- PackIndex idx = idxref.get();
- if (idx != null) {
- index = idxref;
- }
- return idx;
}
}
@@ -257,102 +254,90 @@ PackBitmapIndex getBitmapIndex(DfsReader ctx) throws IOException {
return null;
}
- DfsBlockCache.Ref<PackBitmapIndex> idxref = bitmapIndex;
- if (idxref != null) {
- PackBitmapIndex bmidx = idxref.get();
- if (bmidx != null) {
- return bmidx;
- }
+ if (bitmapIndex != null) {
+ return bitmapIndex;
}
synchronized (initLock) {
- idxref = bitmapIndex;
- if (idxref != null) {
- PackBitmapIndex bmidx = idxref.get();
- if (bmidx != null) {
- return bmidx;
- }
+ if (bitmapIndex != null) {
+ return bitmapIndex;
}
PackIndex idx = idx(ctx);
PackReverseIndex revidx = getReverseIdx(ctx);
DfsStreamKey bitmapKey = desc.getStreamKey(BITMAP_INDEX);
- idxref = cache.getOrLoadRef(bitmapKey, () -> {
- ctx.stats.readBitmap++;
- long start = System.nanoTime();
- try (ReadableChannel rc = ctx.db.openFile(desc, BITMAP_INDEX)) {
- long size;
- PackBitmapIndex bmidx;
- try {
- InputStream in = Channels.newInputStream(rc);
- int wantSize = 8192;
- int bs = rc.blockSize();
- if (0 < bs && bs < wantSize) {
- bs = (wantSize / bs) * bs;
- } else if (bs <= 0) {
- bs = wantSize;
+ DfsBlockCache.Ref<PackBitmapIndex> idxref = cache
+ .getOrLoadRef(bitmapKey, () -> {
+ ctx.stats.readBitmap++;
+ long start = System.nanoTime();
+ try (ReadableChannel rc = ctx.db.openFile(desc,
+ BITMAP_INDEX)) {
+ long size;
+ PackBitmapIndex bmidx;
+ try {
+ InputStream in = Channels.newInputStream(rc);
+ int wantSize = 8192;
+ int bs = rc.blockSize();
+ if (0 < bs && bs < wantSize) {
+ bs = (wantSize / bs) * bs;
+ } else if (bs <= 0) {
+ bs = wantSize;
+ }
+ in = new BufferedInputStream(in, bs);
+ bmidx = PackBitmapIndex.read(in, idx, revidx);
+ } finally {
+ size = rc.position();
+ ctx.stats.readIdxBytes += size;
+ ctx.stats.readIdxMicros += elapsedMicros(start);
+ }
+ int sz = (int) Math.min(size, Integer.MAX_VALUE);
+ bitmapIndex = bmidx;
+ return new DfsBlockCache.Ref<>(bitmapKey, 0, sz,
+ bmidx);
+ } catch (EOFException e) {
+ throw new IOException(MessageFormat.format(
+ DfsText.get().shortReadOfIndex,
+ desc.getFileName(BITMAP_INDEX)), e);
+ } catch (IOException e) {
+ throw new IOException(MessageFormat.format(
+ DfsText.get().cannotReadIndex,
+ desc.getFileName(BITMAP_INDEX)), e);
}
- in = new BufferedInputStream(in, bs);
- bmidx = PackBitmapIndex.read(in, idx, revidx);
- } finally {
- size = rc.position();
- ctx.stats.readIdxBytes += size;
- ctx.stats.readIdxMicros += elapsedMicros(start);
- }
- int sz = (int) Math.min(size, Integer.MAX_VALUE);
- return new DfsBlockCache.Ref<>(bitmapKey, 0, sz, bmidx);
- } catch (EOFException e) {
- throw new IOException(
- MessageFormat.format(DfsText.get().shortReadOfIndex,
- desc.getFileName(BITMAP_INDEX)),
- e);
- } catch (IOException e) {
- throw new IOException(
- MessageFormat.format(DfsText.get().cannotReadIndex,
- desc.getFileName(BITMAP_INDEX)),
- e);
- }
- });
+ });
PackBitmapIndex bmidx = idxref.get();
- if (bmidx != null) {
- bitmapIndex = idxref;
+ if (bitmapIndex == null && bmidx != null) {
+ bitmapIndex = bmidx;
}
- return bmidx;
+ return bitmapIndex;
}
}
PackReverseIndex getReverseIdx(DfsReader ctx) throws IOException {
- DfsBlockCache.Ref<PackReverseIndex> revref = reverseIndex;
- if (revref != null) {
- PackReverseIndex revidx = revref.get();
- if (revidx != null) {
- return revidx;
- }
+ if (reverseIndex != null) {
+ return reverseIndex;
}
synchronized (initLock) {
- revref = reverseIndex;
- if (revref != null) {
- PackReverseIndex revidx = revref.get();
- if (revidx != null) {
- return revidx;
- }
+ if (reverseIndex != null) {
+ return reverseIndex;
}
PackIndex idx = idx(ctx);
DfsStreamKey revKey = new DfsStreamKey.ForReverseIndex(
desc.getStreamKey(INDEX));
- revref = cache.getOrLoadRef(revKey, () -> {
- PackReverseIndex revidx = new PackReverseIndex(idx);
- int sz = (int) Math.min(idx.getObjectCount() * 8,
- Integer.MAX_VALUE);
- return new DfsBlockCache.Ref<>(revKey, 0, sz, revidx);
- });
+ DfsBlockCache.Ref<PackReverseIndex> revref = cache
+ .getOrLoadRef(revKey, () -> {
+ PackReverseIndex revidx = new PackReverseIndex(idx);
+ int sz = (int) Math.min(idx.getObjectCount() * 8,
+ Integer.MAX_VALUE);
+ reverseIndex = revidx;
+ return new DfsBlockCache.Ref<>(revKey, 0, sz, revidx);
+ });
PackReverseIndex revidx = revref.get();
- if (revidx != null) {
- reverseIndex = revref;
+ if (reverseIndex == null && revidx != null) {
+ reverseIndex = revidx;
}
- return revidx;
+ return reverseIndex;
}
}
@@ -464,6 +449,9 @@ private void copyPackThroughCache(PackOutputStream out, DfsReader ctx,
while (0 < remaining) {
DfsBlock b = cache.getOrLoad(this, position, ctx, () -> rc);
int ptr = (int) (position - b.start);
+ if (b.size() <= ptr) {
+ throw packfileIsTruncated();
+ }
int n = (int) Math.min(b.size() - ptr, remaining);
b.write(out, position, n);
position += n;
@@ -481,6 +469,9 @@ private long copyPackBypassCache(PackOutputStream out, ReadableChannel rc)
DfsBlock b = cache.get(key, alignToBlock(position));
if (b != null) {
int ptr = (int) (position - b.start);
+ if (b.size() <= ptr) {
+ throw packfileIsTruncated();
+ }
int n = (int) Math.min(b.size() - ptr, remaining);
b.write(out, position, n);
position += n;
@@ -490,23 +481,18 @@ private long copyPackBypassCache(PackOutputStream out, ReadableChannel rc)
continue;
}
+ // Need to skip the 'PACK' header for the first read
+ int ptr = packHeadSkipped ? 0 : 12;
buf.position(0);
- int n = read(rc, buf);
- if (n <= 0) {
+ int bufLen = read(rc, buf);
+ if (bufLen <= ptr) {
throw packfileIsTruncated();
- } else if (n > remaining) {
- n = (int) remaining;
}
-
- if (!packHeadSkipped) {
- // Need skip the 'PACK' header for the first read
- out.write(buf.array(), 12, n - 12);
- packHeadSkipped = true;
- } else {
- out.write(buf.array(), 0, n);
- }
+ int n = (int) Math.min(bufLen - ptr, remaining);
+ out.write(buf.array(), ptr, n);
position += n;
remaining -= n;
+ packHeadSkipped = true;
}
return position;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
index 8040548..76ef1cf 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
@@ -910,7 +910,8 @@ private void deleteEmptyRefsFolders() throws IOException {
// Avoid deleting a folder that was created after the threshold so that concurrent
// operations trying to create a reference are not impacted
Instant threshold = Instant.now().minus(30, ChronoUnit.SECONDS);
- try (Stream<Path> entries = Files.list(refs)) {
+ try (Stream<Path> entries = Files.list(refs)
+ .filter(Files::isDirectory)) {
Iterator<Path> iterator = entries.iterator();
while (iterator.hasNext()) {
try (Stream<Path> s = Files.list(iterator.next())) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Scanner.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Scanner.java
index 2ef0f20..2fa59f3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Scanner.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftree/Scanner.java
@@ -221,10 +221,11 @@ private static Ref resolve(Ref ref, int depth, RefList<Ref> refs)
return new SymbolicRef(ref.getName(), dst);
}
- @SuppressWarnings("resource")
private static RevTree toTree(ObjectReader reader, AnyObjectId id)
throws IOException {
- return new RevWalk(reader).parseTree(id);
+ try (RevWalk rw = new RevWalk(reader)) {
+ return rw.parseTree(id);
+ }
}
private static boolean curElementHasPeelSuffix(AbstractTreeIterator itr) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java
index a30f042..6cbddec 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CommitBuilder.java
@@ -116,7 +116,7 @@ public ObjectId getTreeId() {
}
/**
- * Set the tree id for this commit object
+ * Set the tree id for this commit object.
*
* @param id
* the tree identity.
@@ -154,7 +154,7 @@ public PersonIdent getCommitter() {
}
/**
- * Set the committer and commit time for this object
+ * Set the committer and commit time for this object.
*
* @param newCommitter
* the committer information. Should not be null.
@@ -164,7 +164,7 @@ public void setCommitter(PersonIdent newCommitter) {
}
/**
- * Set the GPG signature of this commit
+ * Set the GPG signature of this commit.
* <p>
* Note, the signature set here will change the payload of the commit, i.e.
* the output of {@link #build()} will include the signature. Thus, the
@@ -290,18 +290,20 @@ public void setMessage(String newMessage) {
}
/**
- * Set the encoding for the commit information
+ * Set the encoding for the commit information.
*
* @param encodingName
* the encoding name. See
* {@link java.nio.charset.Charset#forName(String)}.
+ * @deprecated use {@link #setEncoding(Charset)} instead.
*/
+ @Deprecated
public void setEncoding(String encodingName) {
encoding = Charset.forName(encodingName);
}
/**
- * Set the encoding for the commit information
+ * Set the encoding for the commit information.
*
* @param enc
* the encoding to use.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgSigner.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgSigner.java
index 7796c20..99a23c6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgSigner.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/GpgSigner.java
@@ -43,6 +43,7 @@
package org.eclipse.jgit.lib;
import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.api.errors.CanceledException;
import org.eclipse.jgit.lib.internal.BouncyCastleGpgSigner;
import org.eclipse.jgit.transport.CredentialsProvider;
@@ -95,9 +96,11 @@ public static void setDefault(GpgSigner signer) {
* the commit to sign (must not be <code>null</code> and must be
* complete to allow proper calculation of payload)
* @param gpgSigningKey
- * the signing key (passed as is to the GPG signing tool)
+ * the signing key to locate (passed as is to the GPG signing
+ * tool as is; eg., value of <code>user.signingkey</code>)
* @param committer
- * the signing identity (to help with key lookup)
+ * the signing identity (to help with key lookup in case signing
+ * key is not specified)
* @param credentialsProvider
* provider to use when querying for signing key credentials (eg.
* passphrase)
@@ -106,7 +109,30 @@ public static void setDefault(GpgSigner signer) {
* passphrase)
*/
public abstract void sign(@NonNull CommitBuilder commit,
- String gpgSigningKey, @NonNull PersonIdent committer,
+ @Nullable String gpgSigningKey, @NonNull PersonIdent committer,
+ CredentialsProvider credentialsProvider) throws CanceledException;
+
+ /**
+ * Indicates if a signing key is available for the specified committer
+ * and/or signing key.
+ *
+ * @param gpgSigningKey
+ * the signing key to locate (passed as is to the GPG signing
+ * tool as is; eg., value of <code>user.signingkey</code>)
+ * @param committer
+ * the signing identity (to help with key lookup in case signing
+ * key is not specified)
+ * @param credentialsProvider
+ * provider to use when querying for signing key credentials (eg.
+ * passphrase)
+ * @return <code>true</code> if a signing key is available,
+ * <code>false</code> otherwise
+ * @throws CanceledException
+ * when signing was canceled (eg., user aborted when entering
+ * passphrase)
+ */
+ public abstract boolean canLocateSigningKey(@Nullable String gpgSigningKey,
+ @NonNull PersonIdent committer,
CredentialsProvider credentialsProvider) throws CanceledException;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdRef.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdRef.java
index bcda538..b791c64 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdRef.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdRef.java
@@ -278,7 +278,10 @@ public Storage getStorage() {
return storage;
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ * @since 5.3
+ */
@Override
public long getUpdateIndex() {
if (updateIndex == -1) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/SymbolicRef.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/SymbolicRef.java
index ee0eb2f..00fcf52 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/SymbolicRef.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/SymbolicRef.java
@@ -149,7 +149,10 @@ public boolean isPeeled() {
return getLeaf().isPeeled();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ * @since 5.3
+ */
@Override
public long getUpdateIndex() {
if (updateIndex == -1) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java
index c7cbe36..091667d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocator.java
@@ -46,10 +46,12 @@
import static java.nio.file.Files.newInputStream;
import java.io.BufferedInputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.MessageFormat;
@@ -81,6 +83,8 @@
import org.eclipse.jgit.api.errors.CanceledException;
import org.eclipse.jgit.errors.UnsupportedCredentialItem;
import org.eclipse.jgit.internal.JGitText;
+import org.eclipse.jgit.util.FS;
+import org.eclipse.jgit.util.SystemReader;
/**
* Locates GPG keys from either <code>~/.gnupg/private-keys-v1.d</code> or
@@ -88,19 +92,48 @@
*/
class BouncyCastleGpgKeyLocator {
- private static final Path USER_KEYBOX_PATH = Paths
- .get(System.getProperty("user.home"), ".gnupg", "pubring.kbx"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final Path GPG_DIRECTORY = findGpgDirectory();
- private static final Path USER_SECRET_KEY_DIR = Paths.get(
- System.getProperty("user.home"), ".gnupg", "private-keys-v1.d"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final Path USER_KEYBOX_PATH = GPG_DIRECTORY
+ .resolve("pubring.kbx"); //$NON-NLS-1$
- private static final Path USER_PGP_LEGACY_SECRING_FILE = Paths
- .get(System.getProperty("user.home"), ".gnupg", "secring.gpg"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final Path USER_SECRET_KEY_DIR = GPG_DIRECTORY
+ .resolve("private-keys-v1.d"); //$NON-NLS-1$
+
+ private static final Path USER_PGP_LEGACY_SECRING_FILE = GPG_DIRECTORY
+ .resolve("secring.gpg"); //$NON-NLS-1$
private final String signingKey;
private BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt;
+ private static Path findGpgDirectory() {
+ SystemReader system = SystemReader.getInstance();
+ if (system.isWindows()) {
+ // On Windows prefer %APPDATA%\gnupg if it exists, even if Cygwin is
+ // used.
+ String appData = system.getenv("APPDATA"); //$NON-NLS-1$
+ if (appData != null && !appData.isEmpty()) {
+ try {
+ Path directory = Paths.get(appData).resolve("gnupg"); //$NON-NLS-1$
+ if (Files.isDirectory(directory)) {
+ return directory;
+ }
+ } catch (SecurityException | InvalidPathException e) {
+ // Ignore and return the default location below.
+ }
+ }
+ }
+ // All systems, including Cygwin and even Windows if
+ // %APPDATA%\gnupg doesn't exist: ~/.gnupg
+ File home = FS.DETECTED.userHome();
+ if (home == null) {
+ // Oops. What now?
+ home = new File(".").getAbsoluteFile(); //$NON-NLS-1$
+ }
+ return home.toPath().resolve(".gnupg"); //$NON-NLS-1$
+ }
+
/**
* Create a new key locator for the specified signing key.
* <p>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgSigner.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgSigner.java
index f447912..4d696dd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgSigner.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/internal/BouncyCastleGpgSigner.java
@@ -59,8 +59,10 @@
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.api.errors.CanceledException;
import org.eclipse.jgit.api.errors.JGitInternalException;
+import org.eclipse.jgit.errors.UnsupportedCredentialItem;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.CommitBuilder;
import org.eclipse.jgit.lib.GpgSignature;
@@ -90,27 +92,50 @@ public BouncyCastleGpgSigner() {
}
@Override
- public void sign(@NonNull CommitBuilder commit, String gpgSigningKey,
- @NonNull PersonIdent committer,
- CredentialsProvider credentialsProvider) throws CanceledException {
+ public boolean canLocateSigningKey(@Nullable String gpgSigningKey,
+ PersonIdent committer, CredentialsProvider credentialsProvider)
+ throws CanceledException {
+ try (BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt = new BouncyCastleGpgKeyPassphrasePrompt(
+ credentialsProvider)) {
+ BouncyCastleGpgKey gpgKey = locateSigningKey(gpgSigningKey,
+ committer, passphrasePrompt);
+ return gpgKey != null;
+ } catch (PGPException | IOException | URISyntaxException e) {
+ return false;
+ }
+ }
+
+ private BouncyCastleGpgKey locateSigningKey(@Nullable String gpgSigningKey,
+ PersonIdent committer,
+ BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt)
+ throws CanceledException, UnsupportedCredentialItem, IOException,
+ PGPException, URISyntaxException {
if (gpgSigningKey == null || gpgSigningKey.isEmpty()) {
gpgSigningKey = committer.getEmailAddress();
}
+ BouncyCastleGpgKeyLocator keyHelper = new BouncyCastleGpgKeyLocator(
+ gpgSigningKey, passphrasePrompt);
+
+ return keyHelper.findSecretKey();
+ }
+
+ @Override
+ public void sign(@NonNull CommitBuilder commit,
+ @Nullable String gpgSigningKey, @NonNull PersonIdent committer,
+ CredentialsProvider credentialsProvider) throws CanceledException {
try (BouncyCastleGpgKeyPassphrasePrompt passphrasePrompt = new BouncyCastleGpgKeyPassphrasePrompt(
credentialsProvider)) {
- BouncyCastleGpgKeyLocator keyHelper = new BouncyCastleGpgKeyLocator(
- gpgSigningKey, passphrasePrompt);
-
- BouncyCastleGpgKey gpgKey = keyHelper.findSecretKey();
+ BouncyCastleGpgKey gpgKey = locateSigningKey(gpgSigningKey,
+ committer, passphrasePrompt);
PGPSecretKey secretKey = gpgKey.getSecretKey();
if (secretKey == null) {
throw new JGitInternalException(
JGitText.get().unableToSignCommitNoSecretKey);
}
- char[] passphrase = passphrasePrompt
- .getPassphrase(secretKey.getPublicKey().getFingerprint(),
- gpgKey.getOrigin());
+ char[] passphrase = passphrasePrompt.getPassphrase(
+ secretKey.getPublicKey().getFingerprint(),
+ gpgKey.getOrigin());
PGPPrivateKey privateKey = secretKey
.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder()
.setProvider(BouncyCastleProvider.PROVIDER_NAME)
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
index 412d9bb..9ea1868 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
@@ -1024,13 +1024,16 @@ private TemporaryBuffer doMerge(MergeResult<RawText> result)
throws IOException {
TemporaryBuffer.LocalFile buf = new TemporaryBuffer.LocalFile(
db != null ? nonNullRepo().getDirectory() : null, inCoreLimit);
+ boolean success = false;
try {
new MergeFormatter().formatMerge(buf, result,
Arrays.asList(commitNames), UTF_8);
buf.close();
- } catch (IOException e) {
- buf.destroy();
- throw e;
+ success = true;
+ } finally {
+ if (!success) {
+ buf.destroy();
+ }
}
return buf;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
index 5e15316..45508ce 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotCommitList.java
@@ -141,7 +141,8 @@ protected void enter(int index, PlotCommit<L> currCommit) {
final PlotCommit<L> c = currCommit.children[0];
currCommit.lane = c.lane;
Integer len = laneLength.get(currCommit.lane);
- len = Integer.valueOf(len.intValue() + 1);
+ len = len != null ? Integer.valueOf(len.intValue() + 1)
+ : Integer.valueOf(0);
laneLength.put(currCommit.lane, len);
} else {
// More than one child, or our child is a merge.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
index 4b20f6c..84a0972 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
@@ -50,6 +50,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.BufferedInputStream;
+import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.text.MessageFormat;
@@ -165,9 +166,13 @@ private String readLine(byte[] hdrbuf) throws IOException {
while (!done) {
bin.mark(hdrbuf.length);
final int cnt = bin.read(hdrbuf);
+ if (cnt < 0) {
+ throw new EOFException(JGitText.get().shortReadOfBlock);
+ }
int lf = 0;
- while (lf < cnt && hdrbuf[lf] != '\n')
+ while (lf < cnt && hdrbuf[lf] != '\n') {
lf++;
+ }
bin.reset();
IO.skipFully(bin, lf);
if (lf < cnt && hdrbuf[lf] == '\n') {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java
index 9a67f0f..c34e3b8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/RemoteRefUpdate.java
@@ -293,7 +293,7 @@ public RemoteRefUpdate(final Repository localDb, final String srcRef,
final boolean forceUpdate, final String localName,
final ObjectId expectedOldObjectId) throws IOException {
if (remoteName == null)
- throw new IllegalArgumentException(JGitText.get().remoteNameCantBeNull);
+ throw new IllegalArgumentException(JGitText.get().remoteNameCannotBeNull);
if (srcId == null && srcRef != null)
throw new IOException(MessageFormat.format(
JGitText.get().sourceRefDoesntResolveToAnyObject, srcRef));
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index 19c5e53..1d0f836 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -1526,6 +1526,20 @@ public int getDepth() {
}
/**
+ * Returns the filter blob limit for the current request. Valid only after
+ * calling recvWants(). A limit -1 means no limit.
+ *
+ * @return filter blob limit requested by the client, or -1 if no limit
+ * @since 5.3
+ */
+ public long getFilterBlobLimit() {
+ if (currentRequest == null) {
+ throw new RequestNotYetReadException();
+ }
+ return currentRequest.getFilterBlobLimit();
+ }
+
+ /**
* Get the user agent of the client.
* <p>
* If the client is new enough to use {@code agent=} capability that value
@@ -2120,6 +2134,7 @@ else if (ref.getName().startsWith(Constants.R_HEADS))
: req.getDepth() - 1;
pw.setShallowPack(req.getDepth(), unshallowCommits);
+ @SuppressWarnings("resource") // Ownership is transferred below
DepthWalk.RevWalk dw = new DepthWalk.RevWalk(
walk.getObjectReader(), walkDepth);
dw.setDeepenSince(req.getDeepenSince());
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
index 1fa1db5..b768acd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
@@ -74,6 +74,7 @@
import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.dircache.DirCacheIterator;
import org.eclipse.jgit.errors.CorruptObjectException;
+import org.eclipse.jgit.errors.LargeObjectException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.ignore.FastIgnoreRule;
@@ -1471,9 +1472,18 @@ public EolStreamType getEolStreamType() throws IOException {
private EolStreamType getEolStreamType(OperationType opType)
throws IOException {
if (eolStreamTypeHolder == null) {
- EolStreamType type=null;
+ EolStreamType type = null;
if (state.walk != null) {
type = state.walk.getEolStreamType(opType);
+ OperationType operationType = opType != null ? opType
+ : state.walk.getOperationType();
+ if (OperationType.CHECKIN_OP.equals(operationType)
+ && EolStreamType.AUTO_LF.equals(type)
+ && hasCrLfInIndex(getDirCacheIterator())) {
+ // If text=auto (or core.autocrlf=true) and the file has
+ // already been committed with CR/LF, then don't convert.
+ type = EolStreamType.DIRECT;
+ }
} else {
switch (getOptions().getAutoCRLF()) {
case FALSE:
@@ -1490,6 +1500,59 @@ private EolStreamType getEolStreamType(OperationType opType)
return eolStreamTypeHolder.get();
}
+ /**
+ * Determines whether the file was committed un-normalized. If the iterator
+ * points to a conflict entry, checks the "ours" version.
+ *
+ * @param dirCache
+ * iterator pointing to the current entry for the file in the
+ * index
+ * @return {@code true} if the file in the index is not binary and has CR/LF
+ * line endings, {@code false} otherwise
+ */
+ private boolean hasCrLfInIndex(DirCacheIterator dirCache) {
+ if (dirCache == null) {
+ return false;
+ }
+ // Read blob from index and check for CR/LF-delimited text.
+ DirCacheEntry entry = dirCache.getDirCacheEntry();
+ if (FileMode.REGULAR_FILE.equals(entry.getFileMode())) {
+ ObjectId blobId = entry.getObjectId();
+ if (entry.getStage() > 0
+ && entry.getStage() != DirCacheEntry.STAGE_2) {
+ // Merge conflict: check ours (stage 2)
+ byte[] name = entry.getRawPath();
+ int i = 0;
+ while (!dirCache.eof()) {
+ dirCache.next(1);
+ i++;
+ entry = dirCache.getDirCacheEntry();
+ if (!Arrays.equals(name, entry.getRawPath())) {
+ break;
+ }
+ if (entry.getStage() == DirCacheEntry.STAGE_2) {
+ blobId = entry.getObjectId();
+ break;
+ }
+ }
+ dirCache.back(i);
+ }
+ try (ObjectReader reader = repository.newObjectReader()) {
+ ObjectLoader loader = reader.open(blobId, Constants.OBJ_BLOB);
+ try {
+ return RawText.isCrLfText(loader.getCachedBytes());
+ } catch (LargeObjectException e) {
+ try (InputStream in = loader.openStream()) {
+ return RawText.isCrLfText(in);
+ }
+ }
+ } catch (IOException e) {
+ // Ignore and return false below
+ }
+ }
+ return false;
+ }
+
private boolean isDirectoryIgnored(String pathRel) throws IOException {
final int pOff = 0 < pathOffset ? pathOffset - 1 : pathOffset;
final String base = TreeWalk.pathOf(this.path, 0, pOff);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
index 8795329..716711e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
@@ -48,6 +48,7 @@
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.nio.charset.Charset;
+import java.nio.file.AccessDeniedException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -399,8 +400,9 @@ public boolean createNewFile(File lock) throws IOException {
Integer nlink = (Integer) (Files.getAttribute(lockPath,
"unix:nlink")); //$NON-NLS-1$
if (nlink > 2) {
- LOG.warn("nlink of link to lock file {} was not 2 but {}", //$NON-NLS-1$
- lock.getPath(), nlink);
+ LOG.warn(MessageFormat.format(
+ JGitText.get().failedAtomicFileCreation, lockPath,
+ nlink));
return false;
} else if (nlink < 2) {
supportsUnixNLink = false;
@@ -463,7 +465,8 @@ public LockToken createNewFileAtomic(File file) throws IOException {
supportsUnixNLink = false;
}
return token(true, link);
- } catch (UnsupportedOperationException | IllegalArgumentException e) {
+ } catch (UnsupportedOperationException | IllegalArgumentException
+ | AccessDeniedException | SecurityException e) {
supportsUnixNLink = false;
return token(true, link);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java
index e88e7a3..a07a4fd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java
@@ -203,12 +203,13 @@ public static ByteBuffer readWholeStream(InputStream in, int sizeHint)
if (last < 0)
return ByteBuffer.wrap(out, 0, pos);
- @SuppressWarnings("resource" /* java 7 */)
- TemporaryBuffer.Heap tmp = new TemporaryBuffer.Heap(Integer.MAX_VALUE);
- tmp.write(out);
- tmp.write(last);
- tmp.copy(in);
- return ByteBuffer.wrap(tmp.toByteArray());
+ try (TemporaryBuffer.Heap tmp = new TemporaryBuffer.Heap(
+ Integer.MAX_VALUE)) {
+ tmp.write(out);
+ tmp.write(last);
+ tmp.copy(in);
+ return ByteBuffer.wrap(tmp.toByteArray());
+ }
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.java
index 9feb20a..2081bac 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.java
@@ -57,7 +57,6 @@
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Arrays;
import java.util.HashMap;
@@ -76,7 +75,7 @@ public final class RawParseUtils {
* UTF-8 charset constant.
*
* @since 2.2
- * @deprecated use {@link StandardCharsets#UTF_8} instead
+ * @deprecated use {@link java.nio.charset.StandardCharsets#UTF_8} instead
*/
@Deprecated
public static final Charset UTF8_CHARSET = UTF_8;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFInputStream.java
index 08377e6..4c60862 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFInputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFInputStream.java
@@ -144,9 +144,18 @@ public void close() throws IOException {
}
private boolean fillBuffer() throws IOException {
- cnt = in.read(buf, 0, buf.length);
- if (cnt < 1)
+ cnt = 0;
+ while (cnt < buf.length) {
+ int n = in.read(buf, cnt, buf.length - cnt);
+ if (n < 0) {
+ break;
+ }
+ cnt += n;
+ }
+ if (cnt < 1) {
+ cnt = -1;
return false;
+ }
if (detectBinary) {
isBinary = RawText.isBinary(buf, cnt);
detectBinary = false;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoLFInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoLFInputStream.java
index ff28161..280cf7e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoLFInputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoLFInputStream.java
@@ -189,9 +189,18 @@ public void close() throws IOException {
}
private boolean fillBuffer() throws IOException {
- cnt = in.read(buf, 0, buf.length);
- if (cnt < 1)
+ cnt = 0;
+ while (cnt < buf.length) {
+ int n = in.read(buf, cnt, buf.length - cnt);
+ if (n < 0) {
+ break;
+ }
+ cnt += n;
+ }
+ if (cnt < 1) {
+ cnt = -1;
return false;
+ }
if (detectBinary) {
isBinary = RawText.isBinary(buf, cnt);
detectBinary = false;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/SHA1.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/SHA1.java
index 9fe01f1..1ad6602 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/SHA1.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/SHA1.java
@@ -48,8 +48,10 @@
import static java.lang.Integer.rotateLeft;
import static java.lang.Integer.rotateRight;
+import java.text.MessageFormat;
import java.util.Arrays;
+import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.MutableObjectId;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.util.NB;
@@ -497,7 +499,8 @@ private void finish() {
if (foundCollision) {
ObjectId id = h.toObjectId();
- LOG.warn("possible SHA-1 collision " + id.name()); //$NON-NLS-1$
+ LOG.warn(MessageFormat.format(JGitText.get().sha1CollisionDetected,
+ id.name()));
throw new Sha1CollisionException(id);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/Sha1CollisionException.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/Sha1CollisionException.java
index dcefe95..0e5c919 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/Sha1CollisionException.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/sha1/Sha1CollisionException.java
@@ -65,7 +65,7 @@ public class Sha1CollisionException extends RuntimeException {
*/
public Sha1CollisionException(ObjectId id) {
super(MessageFormat.format(
- JGitText.get().sha1CollisionDetected1,
+ JGitText.get().sha1CollisionDetected,
id.name()));
}
}
diff --git a/pom.xml b/pom.xml
index 779e85a..5967214 100644
--- a/pom.xml
+++ b/pom.xml
@@ -195,15 +195,15 @@
<servlet-api-version>3.1.0</servlet-api-version>
<jetty-version>9.4.14.v20181114</jetty-version>
<japicmp-version>0.13.0</japicmp-version>
- <httpclient-version>4.5.5</httpclient-version>
- <httpcore-version>4.4.9</httpcore-version>
+ <httpclient-version>4.5.6</httpclient-version>
+ <httpcore-version>4.4.10</httpcore-version>
<slf4j-version>1.7.2</slf4j-version>
<log4j-version>1.2.15</log4j-version>
- <maven-javadoc-plugin-version>3.0.1</maven-javadoc-plugin-version>
+ <maven-javadoc-plugin-version>3.1.0</maven-javadoc-plugin-version>
<tycho-extras-version>1.3.0</tycho-extras-version>
<gson-version>2.8.2</gson-version>
<bouncycastle-version>1.60</bouncycastle-version>
- <spotbugs-maven-plugin-version>3.1.10</spotbugs-maven-plugin-version>
+ <spotbugs-maven-plugin-version>3.1.11</spotbugs-maven-plugin-version>
<maven-surefire-version>2.22.1</maven-surefire-version>
<maven-compiler-plugin-version>3.8.0</maven-compiler-plugin-version>
<maven-project-info-reports-plugin-version>3.0.0</maven-project-info-reports-plugin-version>
@@ -366,7 +366,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
- <version>0.8.2</version>
+ <version>0.8.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -376,7 +376,7 @@
<dependency><!-- add support for ssh/scp -->
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
- <version>3.3.1</version>
+ <version>3.3.2</version>
</dependency>
</dependencies>
</plugin>
@@ -868,7 +868,7 @@
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
- <version>2.3.2</version>
+ <version>2.3.3</version>
</dependency>
</dependencies>
</plugin>