diff options
35 files changed, 317 insertions, 68 deletions
diff --git a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF index d6eac232e1..771e113d3b 100644 --- a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF @@ -7,6 +7,7 @@ Bundle-Vendor: %provider_name Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: J2SE-1.5 Import-Package: org.eclipse.jgit.api;version="[0.9.0,0.10.0)", + org.eclipse.jgit.api.errors;version="[0.9.0,0.10.0)", org.eclipse.jgit.awtui;version="[0.9.0,0.10.0)", org.eclipse.jgit.diff;version="[0.9.0,0.10.0)", org.eclipse.jgit.dircache;version="[0.9.0,0.10.0)", 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 5cf598917e..2737422dc2 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 @@ -38,11 +38,11 @@ package org.eclipse.jgit.pgm; import org.eclipse.jgit.api.CommitCommand; -import org.eclipse.jgit.api.ConcurrentRefUpdateException; import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.JGitInternalException; -import org.eclipse.jgit.api.NoHeadException; -import org.eclipse.jgit.api.NoMessageException; +import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +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.revwalk.RevCommit; diff --git a/org.eclipse.jgit.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.test/META-INF/MANIFEST.MF index f25358b429..c1ef787b15 100644 --- a/org.eclipse.jgit.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.test/META-INF/MANIFEST.MF @@ -11,6 +11,7 @@ Import-Package: junit.framework;version="[4.0.0,5.0.0)", junit.textui;version="[3.8.2,4.0.0)", org.eclipse.jgit;version="[0.9.0,0.10.0)", org.eclipse.jgit.api;version="[0.9.0,0.10.0)", + org.eclipse.jgit.api.errors;version="[0.9.0,0.10.0)", org.eclipse.jgit.awtui;version="[0.9.0,0.10.0)", org.eclipse.jgit.console;version="[0.9.0,0.10.0)", org.eclipse.jgit.diff;version="[0.9.0,0.10.0)", 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 2dbf929983..68007b6cff 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 @@ -48,6 +48,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; +import org.eclipse.jgit.api.errors.NoFilepatternException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheBuilder; import org.eclipse.jgit.dircache.DirCacheEntry; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java index cf30039ab7..9106cc2c04 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTests.java @@ -47,6 +47,12 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; +import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.api.errors.NoFilepatternException; +import org.eclipse.jgit.api.errors.NoHeadException; +import org.eclipse.jgit.api.errors.NoMessageException; +import org.eclipse.jgit.api.errors.WrongRepositoryStateException; import org.eclipse.jgit.errors.UnmergedPathException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; 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 2def86cf1c..02d4b0e15b 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 @@ -48,6 +48,7 @@ import java.io.IOException; import java.util.Iterator; import org.eclipse.jgit.api.MergeResult.MergeStatus; +import org.eclipse.jgit.api.errors.InvalidMergeHeadsException; import org.eclipse.jgit.dircache.DirCacheCheckout; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java index 79054fba61..47b49af1ba 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java @@ -42,6 +42,12 @@ */ package org.eclipse.jgit.api; +import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +import org.eclipse.jgit.api.errors.InvalidTagNameException; +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.api.errors.WrongRepositoryStateException; import org.eclipse.jgit.errors.UnmergedPathException; import org.eclipse.jgit.lib.RepositoryTestCase; import org.eclipse.jgit.revwalk.RevCommit; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java index 860d0d67f3..e12e869ec5 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java @@ -4,6 +4,7 @@ * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com> * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com> * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> + * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com> * and other copyright owners as documented in the project's IP log. * * This program and the accompanying materials are made available @@ -47,6 +48,7 @@ package org.eclipse.jgit.lib; +import java.text.MessageFormat; import java.util.Arrays; import java.util.LinkedList; import java.util.Set; @@ -61,7 +63,7 @@ import org.eclipse.jgit.util.SystemReader; /** * Test reading of git config */ -public class RepositoryConfigTest extends TestCase { +public class ConfigTest extends TestCase { public void test001_ReadBareKey() throws ConfigInvalidException { final Config c = parse("[foo]\nbar\n"); assertEquals(true, c.getBoolean("foo", null, "bar", false)); @@ -351,6 +353,28 @@ public class RepositoryConfigTest extends TestCase { assertTrue("Subsection should contain \"b\"", names.contains("b")); } + public void testQuotingForSubSectionNames() { + String resultPattern = "[testsection \"{0}\"]\n\ttestname = testvalue\n"; + String result; + + Config config = new Config(); + config.setString("testsection", "testsubsection", "testname", + "testvalue"); + + result = MessageFormat.format(resultPattern, "testsubsection"); + assertEquals(result, config.toText()); + config.clear(); + + config.setString("testsection", "#quotable", "testname", "testvalue"); + result = MessageFormat.format(resultPattern, "#quotable"); + assertEquals(result, config.toText()); + config.clear(); + + config.setString("testsection", "with\"quote", "testname", "testvalue"); + result = MessageFormat.format(resultPattern, "with\\\"quote"); + assertEquals(result, config.toText()); + } + private void assertReadLong(long exp) throws ConfigInvalidException { assertReadLong(exp, String.valueOf(exp)); } diff --git a/org.eclipse.jgit/META-INF/MANIFEST.MF b/org.eclipse.jgit/META-INF/MANIFEST.MF index a8f39d93bf..0c4d102e7f 100644 --- a/org.eclipse.jgit/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit/META-INF/MANIFEST.MF @@ -7,10 +7,11 @@ Bundle-Localization: plugin Bundle-Vendor: %provider_name Export-Package: org.eclipse.jgit;version="0.9.0", org.eclipse.jgit.api;version="0.9.0", + org.eclipse.jgit.api.errors;version="0.9.0", org.eclipse.jgit.diff;version="0.9.0", org.eclipse.jgit.dircache;version="0.9.0", - org.eclipse.jgit.events;version="0.9.0", org.eclipse.jgit.errors;version="0.9.0", + org.eclipse.jgit.events;version="0.9.0", org.eclipse.jgit.fnmatch;version="0.9.0", org.eclipse.jgit.ignore;version="0.9.0", org.eclipse.jgit.lib;version="0.9.0", diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java index 29c520c172..7a01e74b06 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java @@ -49,6 +49,8 @@ import java.util.Collection; import java.util.LinkedList; import org.eclipse.jgit.JGitText; +import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.api.errors.NoFilepatternException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheBuildIterator; import org.eclipse.jgit.dircache.DirCacheBuilder; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java index e385e7cb81..1f59dfdbdb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java @@ -48,6 +48,12 @@ import java.util.LinkedList; import java.util.List; import org.eclipse.jgit.JGitText; +import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.api.errors.NoFilepatternException; +import org.eclipse.jgit.api.errors.NoHeadException; +import org.eclipse.jgit.api.errors.NoMessageException; +import org.eclipse.jgit.api.errors.WrongRepositoryStateException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.errors.UnmergedPathException; import org.eclipse.jgit.lib.CommitBuilder; @@ -57,9 +63,9 @@ import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.RefUpdate; +import org.eclipse.jgit.lib.RefUpdate.Result; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RepositoryState; -import org.eclipse.jgit.lib.RefUpdate.Result; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevWalk; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java index 61a87b416a..aa1cdea7d4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java @@ -46,6 +46,8 @@ import java.io.IOException; import java.text.MessageFormat; import org.eclipse.jgit.JGitText; +import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.api.errors.NoHeadException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; import org.eclipse.jgit.lib.AnyObjectId; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java index 48920fe42e..b2e0175e36 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java @@ -52,16 +52,23 @@ import java.util.Map; import org.eclipse.jgit.JGitText; import org.eclipse.jgit.api.MergeResult.MergeStatus; +import org.eclipse.jgit.api.errors.CheckoutConflictException; +import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +import org.eclipse.jgit.api.errors.InvalidMergeHeadsException; +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.api.errors.WrongRepositoryStateException; import org.eclipse.jgit.dircache.DirCacheCheckout; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectIdRef; import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.lib.RefUpdate; -import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Ref.Storage; +import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.RefUpdate.Result; +import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.merge.MergeStrategy; import org.eclipse.jgit.merge.ResolveMerger; import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java index 77a8825d0c..27248529f4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java @@ -46,6 +46,10 @@ import java.io.IOException; import java.text.MessageFormat; import org.eclipse.jgit.JGitText; +import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; +import org.eclipse.jgit.api.errors.InvalidTagNameException; +import org.eclipse.jgit.api.errors.JGitInternalException; +import org.eclipse.jgit.api.errors.NoHeadException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectInserter; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutConflictException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java index 09dda6f61d..de45c1d8e2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutConflictException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/CheckoutConflictException.java @@ -35,7 +35,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package org.eclipse.jgit.api; +package org.eclipse.jgit.api.errors; import java.util.LinkedList; import java.util.List; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ConcurrentRefUpdateException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/ConcurrentRefUpdateException.java index 2a5f7f9225..0321ae4224 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ConcurrentRefUpdateException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/ConcurrentRefUpdateException.java @@ -35,7 +35,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package org.eclipse.jgit.api; +package org.eclipse.jgit.api.errors; import java.text.MessageFormat; @@ -54,7 +54,13 @@ public class ConcurrentRefUpdateException extends GitAPIException { private RefUpdate.Result rc; private Ref ref; - ConcurrentRefUpdateException(String message, Ref ref, + /** + * @param message + * @param ref + * @param rc + * @param cause + */ + public ConcurrentRefUpdateException(String message, Ref ref, RefUpdate.Result rc, Throwable cause) { super((rc == null) ? message : message + ". " + MessageFormat.format(JGitText.get().refUpdateReturnCodeWas, rc), cause); @@ -62,7 +68,12 @@ public class ConcurrentRefUpdateException extends GitAPIException { this.ref = ref; } - ConcurrentRefUpdateException(String message, Ref ref, + /** + * @param message + * @param ref + * @param rc + */ + public ConcurrentRefUpdateException(String message, Ref ref, RefUpdate.Result rc) { super((rc == null) ? message : message + ". " + MessageFormat.format(JGitText.get().refUpdateReturnCodeWas, rc)); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/GitAPIException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/GitAPIException.java index 9991502aaa..ba38529ab3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/GitAPIException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/GitAPIException.java @@ -35,7 +35,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package org.eclipse.jgit.api; +package org.eclipse.jgit.api.errors; /** * Superclass of all exceptions thrown by the API classes in diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/InvalidMergeHeadsException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidMergeHeadsException.java index 7748853910..e56cbc438e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/InvalidMergeHeadsException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidMergeHeadsException.java @@ -35,7 +35,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package org.eclipse.jgit.api; +package org.eclipse.jgit.api.errors; /** @@ -47,7 +47,10 @@ package org.eclipse.jgit.api; public class InvalidMergeHeadsException extends GitAPIException { private static final long serialVersionUID = 1L; - InvalidMergeHeadsException(String msg) { + /** + * @param msg + */ + public InvalidMergeHeadsException(String msg) { super(msg); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/InvalidTagNameException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidTagNameException.java index ceff637845..1779c45e2c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/InvalidTagNameException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/InvalidTagNameException.java @@ -35,7 +35,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package org.eclipse.jgit.api; +package org.eclipse.jgit.api.errors; /** * Exception thrown when a tag command was called with an invalid tag name (or @@ -44,7 +44,10 @@ package org.eclipse.jgit.api; public class InvalidTagNameException extends GitAPIException { private static final long serialVersionUID = 1L; - InvalidTagNameException(String msg) { + /** + * @param msg + */ + public InvalidTagNameException(String msg) { super(msg); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/JGitInternalException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/JGitInternalException.java index a0475da135..9042daddcc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/JGitInternalException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/JGitInternalException.java @@ -35,7 +35,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package org.eclipse.jgit.api; +package org.eclipse.jgit.api.errors; /** * Exception thrown when during command execution a low-level exception from the @@ -59,11 +59,18 @@ package org.eclipse.jgit.api; public class JGitInternalException extends RuntimeException { private static final long serialVersionUID = 1L; - JGitInternalException(String message, Throwable cause) { + /** + * @param message + * @param cause + */ + public JGitInternalException(String message, Throwable cause) { super(message, cause); } - JGitInternalException(String message) { + /** + * @param message + */ + public JGitInternalException(String message) { super(message); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/NoFilepatternException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoFilepatternException.java index 8a845d5153..1130c256f5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/NoFilepatternException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoFilepatternException.java @@ -37,7 +37,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -package org.eclipse.jgit.api; +package org.eclipse.jgit.api.errors; /** * Exception thrown when the options given to a command don't include a @@ -47,11 +47,18 @@ public class NoFilepatternException extends GitAPIException { private static final long serialVersionUID = 1L; - NoFilepatternException(String message, Throwable cause) { + /** + * @param message + * @param cause + */ + public NoFilepatternException(String message, Throwable cause) { super(message, cause); } - NoFilepatternException(String message) { + /** + * @param message + */ + public NoFilepatternException(String message) { super(message); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/NoHeadException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoHeadException.java index 5d79233cf5..50c4dc96b3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/NoHeadException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoHeadException.java @@ -35,7 +35,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package org.eclipse.jgit.api; +package org.eclipse.jgit.api.errors; /** * Exception thrown when a command expected the {@code HEAD} reference to exist @@ -44,11 +44,18 @@ package org.eclipse.jgit.api; public class NoHeadException extends GitAPIException { private static final long serialVersionUID = 1L; - NoHeadException(String message, Throwable cause) { + /** + * @param message + * @param cause + */ + public NoHeadException(String message, Throwable cause) { super(message, cause); } - NoHeadException(String message) { + /** + * @param message + */ + public NoHeadException(String message) { super(message); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/NoMessageException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoMessageException.java index ab5652e24c..b7d8dc8db3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/NoMessageException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/NoMessageException.java @@ -35,7 +35,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package org.eclipse.jgit.api; +package org.eclipse.jgit.api.errors; /** * Exception thrown when the options given to a command don't include a @@ -46,11 +46,18 @@ package org.eclipse.jgit.api; public class NoMessageException extends GitAPIException { private static final long serialVersionUID = 1L; - NoMessageException(String message, Throwable cause) { + /** + * @param message + * @param cause + */ + public NoMessageException(String message, Throwable cause) { super(message, cause); } - NoMessageException(String message) { + /** + * @param message + */ + public NoMessageException(String message) { super(message); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/WrongRepositoryStateException.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/WrongRepositoryStateException.java index 833cf8d6ed..dd2b3998ea 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/WrongRepositoryStateException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/errors/WrongRepositoryStateException.java @@ -35,7 +35,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -package org.eclipse.jgit.api; +package org.eclipse.jgit.api.errors; /** * Exception thrown when the state of the repository doesn't allow the execution @@ -45,11 +45,18 @@ package org.eclipse.jgit.api; public class WrongRepositoryStateException extends GitAPIException { private static final long serialVersionUID = 1L; - WrongRepositoryStateException(String message, Throwable cause) { + /** + * @param message + * @param cause + */ + public WrongRepositoryStateException(String message, Throwable cause) { super(message, cause); } - WrongRepositoryStateException(String message) { + /** + * @param message + */ + public WrongRepositoryStateException(String message) { super(message); } } 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 4befe586c3..ad81de58c9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java @@ -95,7 +95,7 @@ public class RawText implements Sequence { protected final IntList lines; /** Hash code for each line, for fast equality elimination. */ - protected final IntList hashes; + protected final int[] hashes; /** * Create a new sequence from an existing content byte array. @@ -140,7 +140,7 @@ public class RawText implements Sequence { private static boolean equals(final RawText a, final int ai, final RawText b, final int bi) { - if (a.hashes.get(ai) != b.hashes.get(bi)) + if (a.hashes[ai] != b.hashes[bi]) return false; int as = a.lines.get(ai); @@ -197,15 +197,13 @@ public class RawText implements Sequence { return content[end - 1] != '\n'; } - private IntList computeHashes() { - final IntList r = new IntList(lines.size()); - r.add(0); + private int[] computeHashes() { + final int[] r = new int[lines.size()]; for (int lno = 1; lno < lines.size() - 1; lno++) { final int ptr = lines.get(lno); final int end = lines.get(lno + 1); - r.add(hashLine(content, ptr, end)); + r[lno] = hashLine(content, ptr, end); } - r.add(0); return r; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreAllWhitespace.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreAllWhitespace.java index 211618a3fb..855a872428 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreAllWhitespace.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreAllWhitespace.java @@ -79,7 +79,7 @@ public class RawTextIgnoreAllWhitespace extends RawText { private static boolean equals(final RawText a, final int ai, final RawText b, final int bi) { - if (a.hashes.get(ai) != b.hashes.get(bi)) + if (a.hashes[ai] != b.hashes[bi]) return false; int as = a.lines.get(ai); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreLeadingWhitespace.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreLeadingWhitespace.java index 23778973b7..df4805a4c8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreLeadingWhitespace.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreLeadingWhitespace.java @@ -78,7 +78,7 @@ public class RawTextIgnoreLeadingWhitespace extends RawText { private static boolean equals(final RawText a, final int ai, final RawText b, final int bi) { - if (a.hashes.get(ai) != b.hashes.get(bi)) + if (a.hashes[ai] != b.hashes[bi]) return false; int as = a.lines.get(ai); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreTrailingWhitespace.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreTrailingWhitespace.java index 3feb2e783a..5e69eaabd7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreTrailingWhitespace.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreTrailingWhitespace.java @@ -78,7 +78,7 @@ public class RawTextIgnoreTrailingWhitespace extends RawText { private static boolean equals(final RawText a, final int ai, final RawText b, final int bi) { - if (a.hashes.get(ai) != b.hashes.get(bi)) + if (a.hashes[ai] != b.hashes[bi]) return false; int as = a.lines.get(ai); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChange.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChange.java index e6bd8e98b7..2d1b9772fe 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChange.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawTextIgnoreWhitespaceChange.java @@ -81,7 +81,7 @@ public class RawTextIgnoreWhitespaceChange extends RawText { private static boolean equals(final RawText a, final int ai, final RawText b, final int bi) { - if (a.hashes.get(ai) != b.hashes.get(bi)) + if (a.hashes[ai] != b.hashes[bi]) return false; int as = a.lines.get(ai); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java index 335cada7a3..884f49845c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Config.java @@ -834,9 +834,15 @@ public class Config { out.append(e.section); if (e.subsection != null) { out.append(' '); - out.append('"'); - out.append(escapeValue(e.subsection)); - out.append('"'); + String escaped = escapeValue(e.subsection); + // make sure to avoid double quotes here + boolean quoted = escaped.startsWith("\"") + && escaped.endsWith("\""); + if (!quoted) + out.append('"'); + out.append(escaped); + if (!quoted) + out.append('"'); } out.append(']'); } else if (e.section != null && e.name != null) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java index 59d10f68c7..eccaa55146 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java @@ -58,6 +58,7 @@ import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.WorkingTreeIterator; import org.eclipse.jgit.treewalk.filter.AndTreeFilter; import org.eclipse.jgit.treewalk.filter.NotIgnoredFilter; +import org.eclipse.jgit.treewalk.filter.SkipWorkTreeFilter; import org.eclipse.jgit.treewalk.filter.TreeFilter; /** @@ -160,8 +161,9 @@ public class IndexDiff { treeWalk.addTree(new DirCacheIterator(dirCache)); treeWalk.addTree(initialWorkingTreeIterator); treeWalk.setFilter(TreeFilter.ANY_DIFF); - treeWalk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, - new NotIgnoredFilter(WORKDIR))); + treeWalk.setFilter(AndTreeFilter.create(new TreeFilter[] { + new NotIgnoredFilter(WORKDIR), new SkipWorkTreeFilter(INDEX), + TreeFilter.ANY_DIFF })); while (treeWalk.next()) { AbstractTreeIterator treeIterator = treeWalk.getTree(TREE, AbstractTreeIterator.class); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/NotIgnoredFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/NotIgnoredFilter.java index 122ce40344..2e96d2ffa4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/NotIgnoredFilter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/NotIgnoredFilter.java @@ -50,32 +50,26 @@ import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.WorkingTreeIterator; /** - * This filter includes workdir entries that are not ignored. This class is - * immutable. + * Skip {@link WorkingTreeIterator} entries that appear in gitignore files. */ public class NotIgnoredFilter extends TreeFilter { - - private final int workdirTreeIndex; + private final int index; /** - * constructor + * Construct a filter to ignore paths known to a particular iterator. * * @param workdirTreeIndex * index of the workdir tree in the tree walk */ public NotIgnoredFilter(final int workdirTreeIndex) { - this.workdirTreeIndex = workdirTreeIndex; + this.index = workdirTreeIndex; } @Override - public boolean include(TreeWalk walker) throws MissingObjectException, + public boolean include(TreeWalk tw) throws MissingObjectException, IncorrectObjectTypeException, IOException { - WorkingTreeIterator workingTreeIterator = walker.getTree( - workdirTreeIndex, WorkingTreeIterator.class); - if (workingTreeIterator != null) - // do not include ignored entries - return !workingTreeIterator.isEntryIgnored(); - return true; + WorkingTreeIterator i = tw.getTree(index, WorkingTreeIterator.class); + return i == null || !i.isEntryIgnored(); } @Override @@ -89,4 +83,8 @@ public class NotIgnoredFilter extends TreeFilter { return this; } + @Override + public String toString() { + return "NotIgnored(" + index + ")"; + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/SkipWorkTreeFilter.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/SkipWorkTreeFilter.java new file mode 100644 index 0000000000..d06a13ed89 --- /dev/null +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/filter/SkipWorkTreeFilter.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2010, Google Inc. + * Copyright (C) 2010, Marc Strapetz <marc.strapetz@syntevo.com> + * 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.treewalk.filter; + +import org.eclipse.jgit.dircache.DirCacheEntry; +import org.eclipse.jgit.dircache.DirCacheIterator; +import org.eclipse.jgit.treewalk.TreeWalk; + +/** + * To be used in combination with a DirCacheIterator: includes only tree entries + * for which 'skipWorkTree' flag is not set. + */ +public class SkipWorkTreeFilter extends TreeFilter { + + /** Index of DirCacheIterator to work on. */ + private final int treeIdx; + + /** + * Create a filter to work on the specified DirCacheIterator. + * + * @param treeIdx + * index of DirCacheIterator to work on. If the index does not + * refer to a DirCacheIterator, the filter will include all + * entries. + */ + public SkipWorkTreeFilter(int treeIdx) { + this.treeIdx = treeIdx; + } + + @Override + public boolean include(TreeWalk walker) { + DirCacheIterator i = walker.getTree(treeIdx, DirCacheIterator.class); + if (i == null) + return true; + + DirCacheEntry e = i.getDirCacheEntry(); + return e == null || !e.isSkipWorkTree(); + } + + @Override + public boolean shouldBeRecursive() { + return false; + } + + @Override + public TreeFilter clone() { + return this; + } + + @Override + public String toString() { + return "SkipWorkTree(" + treeIdx + ")"; + } +} diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index cb5c8bda54..9e817ca770 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -52,16 +52,44 @@ public abstract class FS { /** The auto-detected implementation selected for this operating system and JRE. */ public static final FS DETECTED; - static { + /** + * Auto-detect the appropriate file system abstraction, taking into account + * the presence of a Cygwin installation on the system. Using jgit in + * combination with Cygwin requires a more elaborate (and possibly slower) + * resolution of file system paths. + * + * @param cygwinUsed + * <ul> + * <li><code>Boolean.TRUE</code> to assume that Cygwin is used in + * combination with jgit</li> + * <li><code>Boolean.FALSE</code> to assume that Cygwin is + * <b>not</b> used with jgit</li> + * <li><code>null</code> to auto-detect whether a Cygwin + * installation is present on the system and in this case assume + * that Cygwin is used</li> + * </ul> + * + * Note: this parameter is only relevant on Windows. + * + * @return detected file system abstraction + */ + public static FS detect(Boolean cygwinUsed) { if (FS_Win32.detect()) { - if (FS_Win32_Cygwin.detect()) - DETECTED = new FS_Win32_Cygwin(); + boolean useCygwin = (cygwinUsed == null && FS_Win32_Cygwin.detect()) + || Boolean.TRUE.equals(cygwinUsed); + + if (useCygwin) + return new FS_Win32_Cygwin(); else - DETECTED = new FS_Win32(); + return new FS_Win32(); } else if (FS_POSIX_Java6.detect()) - DETECTED = new FS_POSIX_Java6(); + return new FS_POSIX_Java6(); else - DETECTED = new FS_POSIX_Java5(); + return new FS_POSIX_Java5(); + } + + static { + DETECTED = detect(null); } private final File userHome; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/LongList.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/LongList.java index 96b311dfbf..e3aeb83a7e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/LongList.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/LongList.java @@ -44,6 +44,8 @@ package org.eclipse.jgit.util; +import java.util.Arrays; + /** A more efficient List<Long> using a primitive long array. */ public class LongList { private long[] entries; @@ -146,6 +148,11 @@ public class LongList { add(val); } + /** Sort the list of longs according to their natural ordering. */ + public void sort() { + Arrays.sort(entries, 0, count); + } + private void grow() { final long[] n = new long[(entries.length + 16) * 3 / 2]; System.arraycopy(entries, 0, n, 0, count); |