Browse Source

Merge branch 'stable-2.0'

By Robin Rosenberg (6) and others
via Gerrit Code Review @ Eclipse.org (2) and Matthias Sohn (1)
* stable-2.0:
  Prepare next 2.0.0-SNAPSHOT builds
  JGit v2.0.0.201206060730-rc3
  Remove Jetty p2 repository from Maven build
  Get rid of warnings about empty statments
  Removed unused parameters from private methods
  cleanup: Remove unused declarations
  Make FS OS X detection work for OpenJDK
  Use working tree iterator to compare file modes
  Further cleanup of exceptions in Git API
  Update build to use Tycho 0.15.0
  Throw formal CheckoutConflictException on hard reset
  Configure maven-source-plugin execution in parent POM
  Support gitdir: refs in BaseRepositoryBuilder.findGitDir
  Relax RevisionSyntaxException to an IllegalArgumentException

Change-Id: I05727693e0c9e762d4fc220ceadcd5a5bfb11d0d
stable-2.1
Shawn O. Pearce 12 years ago
parent
commit
65f6e06b8d
  1. 1
      org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitInitTask.java
  2. 1
      org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java
  3. 6
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
  4. 14
      org.eclipse.jgit.packaging/org.eclipse.jgit.repository/assembly.xml
  5. 0
      org.eclipse.jgit.packaging/org.eclipse.jgit.repository/category.xml
  6. 28
      org.eclipse.jgit.packaging/org.eclipse.jgit.repository/pom.xml
  7. 2
      org.eclipse.jgit.packaging/pom.xml
  8. 1
      org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/ChunkIndex.java
  9. 40
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java
  10. 57
      org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java
  11. 6
      org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java
  12. 14
      org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java
  13. 5
      org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java
  14. 15
      org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
  15. 3
      org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
  16. 5
      org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java
  17. 61
      org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java
  18. 14
      org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java
  19. 6
      org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
  20. 9
      org.eclipse.jgit/src/org/eclipse/jgit/api/ReflogCommand.java
  21. 14
      org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
  22. 13
      org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java
  23. 5
      org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java
  24. 1
      org.eclipse.jgit/src/org/eclipse/jgit/api/StashCreateCommand.java
  25. 1
      org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java
  26. 3
      org.eclipse.jgit/src/org/eclipse/jgit/api/StashListCommand.java
  27. 32
      org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java
  28. 4
      org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
  29. 7
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
  30. 3
      org.eclipse.jgit/src/org/eclipse/jgit/errors/RevisionSyntaxException.java
  31. 57
      org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
  32. 1
      org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
  33. 19
      org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
  34. 1
      org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsInserter.java
  35. 12
      org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java
  36. 11
      org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
  37. 46
      org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
  38. 2
      org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
  39. 19
      pom.xml

1
org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitInitTask.java

@ -48,7 +48,6 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.InitCommand;
import org.eclipse.jgit.api.errors.JGitInternalException;
/**
* Create an empty git repository.

1
org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java

@ -184,7 +184,6 @@ public class RecordingLogger implements Logger {
// Ignore (not relevant to test failures)
}
@SuppressWarnings("unused")
public void ignore(Throwable arg0) {
// Ignore (not relevant to test failures)
}

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

@ -459,9 +459,13 @@ public class TestRepository<R extends Repository> {
*/
public <T extends AnyObjectId> T update(String ref, T obj) throws Exception {
if (Constants.HEAD.equals(ref)) {
// nothing
} else if ("FETCH_HEAD".equals(ref)) {
// nothing
} else if ("MERGE_HEAD".equals(ref)) {
// nothing
} else if (ref.startsWith(Constants.R_REFS)) {
// nothing
} else
ref = Constants.R_HEADS + ref;
@ -537,7 +541,9 @@ public class TestRepository<R extends Repository> {
*/
public BranchBuilder branch(String ref) {
if (Constants.HEAD.equals(ref)) {
// nothing
} else if (ref.startsWith(Constants.R_REFS)) {
// nothing
} else
ref = Constants.R_HEADS + ref;
return new BranchBuilder(ref);

14
org.eclipse.jgit.packaging/org.eclipse.jgit.repository/assembly.xml

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<id>site</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}/site</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>

0
org.eclipse.jgit.packaging/org.eclipse.jgit.repository/site.xml → org.eclipse.jgit.packaging/org.eclipse.jgit.repository/category.xml

28
org.eclipse.jgit.packaging/org.eclipse.jgit.repository/pom.xml

@ -54,9 +54,7 @@
</parent>
<artifactId>org.eclipse.jgit.repository</artifactId>
<!-- TODO as soon as Tycho bug 368596 is fixed we should use packaging type
eclipse-repository -->
<packaging>eclipse-update-site</packaging>
<packaging>eclipse-repository</packaging>
<name>JGit P2 Repository</name>
@ -82,28 +80,4 @@
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

2
org.eclipse.jgit.packaging/pom.xml

@ -59,7 +59,7 @@
<name>JGit Tycho Parent</name>
<properties>
<tycho-version>0.14.1</tycho-version>
<tycho-version>0.15.0</tycho-version>
<jetty-version>7.6.0.v20120127</jetty-version>
<eclipse-site>http://download.eclipse.org/releases/indigo</eclipse-site>
</properties>

1
org.eclipse.jgit.storage.dht/src/org/eclipse/jgit/storage/dht/ChunkIndex.java

@ -204,7 +204,6 @@ public abstract class ChunkIndex {
return fmt;
}
@SuppressWarnings("unchecked")
private static void sortObjectList(List<? extends PackedObjectInfo> list) {
Collections.sort(list);
}

40
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CherryPickCommandTest.java

@ -44,6 +44,7 @@ package org.eclipse.jgit.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
@ -54,7 +55,10 @@ import org.eclipse.jgit.api.CherryPickResult.CherryPickStatus;
import org.eclipse.jgit.api.ResetCommand.ResetType;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.RepositoryState;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason;
@ -183,6 +187,42 @@ public class CherryPickCommandTest extends RepositoryTestCase {
.exists());
}
@Test
public void testCherryPickOverExecutableChangeOnNonExectuableFileSystem()
throws Exception {
Git git = new Git(db);
File file = writeTrashFile("test.txt", "a");
assertNotNull(git.add().addFilepattern("test.txt").call());
assertNotNull(git.commit().setMessage("commit1").call());
assertNotNull(git.checkout().setCreateBranch(true).setName("a").call());
writeTrashFile("test.txt", "b");
assertNotNull(git.add().addFilepattern("test.txt").call());
RevCommit commit2 = git.commit().setMessage("commit2").call();
assertNotNull(commit2);
assertNotNull(git.checkout().setName(Constants.MASTER).call());
DirCache cache = db.lockDirCache();
cache.getEntry("test.txt").setFileMode(FileMode.EXECUTABLE_FILE);
cache.write();
assertTrue(cache.commit());
cache.unlock();
assertNotNull(git.commit().setMessage("commit3").call());
db.getFS().setExecute(file, false);
git.getRepository()
.getConfig()
.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
ConfigConstants.CONFIG_KEY_FILEMODE, false);
CherryPickResult result = git.cherryPick().include(commit2).call();
assertNotNull(result);
assertEquals(CherryPickStatus.OK, result.getStatus());
}
private RevCommit prepareCherryPick(final Git git) throws Exception {
// create, add and commit file a
writeTrashFile("a", "a");

57
org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileRepositoryBuilderTest.java

@ -45,13 +45,16 @@ package org.eclipse.jgit.storage.file;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.util.FileUtils;
import org.junit.Test;
@ -108,4 +111,58 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
assertNotNull(e.getMessage());
}
}
@Test
public void absoluteGitDirRef() throws Exception {
FileRepository repo1 = createWorkRepository();
File dir = createTempDirectory("dir");
File dotGit = new File(dir, Constants.DOT_GIT);
new FileWriter(dotGit).append(
"gitdir: " + repo1.getDirectory().getAbsolutePath()).close();
FileRepositoryBuilder builder = new FileRepositoryBuilder();
builder.setWorkTree(dir);
builder.setMustExist(true);
FileRepository repo2 = builder.build();
assertEquals(repo1.getDirectory(), repo2.getDirectory());
assertEquals(dir, repo2.getWorkTree());
}
@Test
public void relativeGitDirRef() throws Exception {
FileRepository repo1 = createWorkRepository();
File dir = new File(repo1.getWorkTree(), "dir");
assertTrue(dir.mkdir());
File dotGit = new File(dir, Constants.DOT_GIT);
new FileWriter(dotGit).append("gitdir: ../" + Constants.DOT_GIT)
.close();
FileRepositoryBuilder builder = new FileRepositoryBuilder();
builder.setWorkTree(dir);
builder.setMustExist(true);
FileRepository repo2 = builder.build();
assertEquals(repo1.getDirectory(), repo2.getDirectory());
assertEquals(dir, repo2.getWorkTree());
}
@Test
public void scanWithGitDirRef() throws Exception {
FileRepository repo1 = createWorkRepository();
File dir = createTempDirectory("dir");
File dotGit = new File(dir, Constants.DOT_GIT);
new FileWriter(dotGit).append(
"gitdir: " + repo1.getDirectory().getAbsolutePath()).close();
FileRepositoryBuilder builder = new FileRepositoryBuilder();
builder.setWorkTree(dir);
builder.findGitDir(dir);
assertEquals(repo1.getDirectory(), builder.getGitDir());
builder.setMustExist(true);
FileRepository repo2 = builder.build();
assertEquals(repo1.getDirectory(), repo2.getDirectory());
assertEquals(dir, repo2.getWorkTree());
}
}

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

@ -102,8 +102,12 @@ public class ApplyCommand extends GitCommand<ApplyResult> {
* method twice on an instance.
*
* @return an {@link ApplyResult} object representing the command result
* @throws GitAPIException
* @throws PatchFormatException
* @throws PatchApplyException
*/
public ApplyResult call() throws GitAPIException {
public ApplyResult call() throws GitAPIException, PatchFormatException,
PatchApplyException {
checkCallable();
ApplyResult r = new ApplyResult();
try {

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

@ -47,10 +47,14 @@ import java.text.MessageFormat;
import java.util.LinkedList;
import java.util.List;
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.MultipleParentsNotAllowedException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.api.errors.UnmergedPathsException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.AnyObjectId;
@ -94,8 +98,16 @@ public class CherryPickCommand extends GitCommand<CherryPickResult> {
* invocation of the command. Don't call this method twice on an instance.
*
* @return the result of the cherry-pick
* @throws GitAPIException
* @throws WrongRepositoryStateException
* @throws ConcurrentRefUpdateException
* @throws UnmergedPathsException
* @throws NoMessageException
* @throws NoHeadException
*/
public CherryPickResult call() throws GitAPIException {
public CherryPickResult call() throws GitAPIException, NoMessageException,
UnmergedPathsException, ConcurrentRefUpdateException,
WrongRepositoryStateException, NoHeadException {
RevCommit newHead = null;
List<Ref> cherryPickedRefs = new LinkedList<Ref>();
checkCallable();

5
org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java

@ -51,6 +51,7 @@ import java.util.TreeSet;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.util.FileUtils;
@ -81,8 +82,10 @@ public class CleanCommand extends GitCommand<Set<String>> {
* call to {@link #call()})
*
* @return a set of strings representing each file cleaned.
* @throws GitAPIException
* @throws NoWorkTreeException
*/
public Set<String> call() throws GitAPIException {
public Set<String> call() throws NoWorkTreeException, GitAPIException {
Set<String> files = new TreeSet<String>();
try {
StatusCommand command = new StatusCommand(repo);

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

@ -113,8 +113,12 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
* Executes the {@code Clone} command.
*
* @return the newly created {@code Git} object with associated repository
* @throws InvalidRemoteException
* @throws org.eclipse.jgit.api.errors.TransportException
* @throws GitAPIException
*/
public Git call() throws GitAPIException {
public Git call() throws GitAPIException, InvalidRemoteException,
org.eclipse.jgit.api.errors.TransportException {
try {
URIish u = new URIish(uri);
Repository repository = init(u);
@ -124,10 +128,9 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
return new Git(repository);
} catch (IOException ioe) {
throw new JGitInternalException(ioe.getMessage(), ioe);
} catch (InvalidRemoteException e) {
throw new JGitInternalException(e.getMessage(), e);
} catch (URISyntaxException e) {
throw new JGitInternalException(e.getMessage(), e);
throw new InvalidRemoteException(MessageFormat.format(
JGitText.get().invalidRemote, remote));
}
}
@ -144,7 +147,9 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
}
private FetchResult fetch(Repository clonedRepo, URIish u)
throws URISyntaxException, IOException, GitAPIException {
throws URISyntaxException,
org.eclipse.jgit.api.errors.TransportException, IOException,
GitAPIException {
// create the remote config and save it
RemoteConfig config = new RemoteConfig(clonedRepo.getConfig(), remote);
config.addURI(u);

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

@ -135,8 +135,7 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
JGitText.get().invalidRemote, remote), e);
} catch (TransportException e) {
throw new org.eclipse.jgit.api.errors.TransportException(
JGitText.get().exceptionCaughtDuringExecutionOfFetchCommand,
e);
e.getMessage(), e);
} catch (URISyntaxException e) {
throw new InvalidRemoteException(MessageFormat.format(
JGitText.get().invalidRemote, remote));

5
org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java

@ -148,6 +148,7 @@ public class LsRemoteCommand extends
* for errors that occurs during transport
*/
public Collection<Ref> call() throws GitAPIException,
InvalidRemoteException,
org.eclipse.jgit.api.errors.TransportException {
checkCallable();
@ -186,8 +187,8 @@ public class LsRemoteCommand extends
JGitText.get().exceptionCaughtDuringExecutionOfLsRemoteCommand,
e);
} catch (TransportException e) {
throw new org.eclipse.jgit.api.errors.TransportException(
JGitText.get().exceptionCaughtDuringExecutionOfLsRemoteCommand,
throw new org.eclipse.jgit.api.errors.TransportException(
e.getMessage(),
e);
} finally {
if (fc != null)

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

@ -48,16 +48,12 @@ import java.text.MessageFormat;
import org.eclipse.jgit.api.RebaseCommand.Operation;
import org.eclipse.jgit.api.errors.CanceledException;
import org.eclipse.jgit.api.errors.CheckoutConflictException;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
import org.eclipse.jgit.api.errors.DetachedHeadException;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.InvalidConfigurationException;
import org.eclipse.jgit.api.errors.InvalidMergeHeadsException;
import org.eclipse.jgit.api.errors.InvalidRemoteException;
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.RefNotFoundException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.internal.JGitText;
@ -109,11 +105,21 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> {
* command. Don't call this method twice on an instance.
*
* @return the result of the pull
* @throws WrongRepositoryStateException
* @throws InvalidConfigurationException
* @throws DetachedHeadException
* @throws InvalidRemoteException
* @throws CanceledException
* @throws RefNotFoundException
* @throws NoHeadException
* @throws org.eclipse.jgit.api.errors.TransportException
* @throws GitAPIException
*/
public PullResult call() throws GitAPIException, WrongRepositoryStateException,
InvalidConfigurationException, DetachedHeadException,
InvalidRemoteException, CanceledException, RefNotFoundException,
NoHeadException {
public PullResult call() throws GitAPIException,
WrongRepositoryStateException, InvalidConfigurationException,
DetachedHeadException, InvalidRemoteException, CanceledException,
RefNotFoundException, NoHeadException,
org.eclipse.jgit.api.errors.TransportException {
checkCallable();
monitor.beginTask(JGitText.get().pullTaskName, 2);
@ -239,44 +245,19 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> {
PullResult result;
if (doRebase) {
RebaseCommand rebase = new RebaseCommand(repo);
try {
RebaseResult rebaseRes = rebase.setUpstream(commitToMerge)
.setProgressMonitor(monitor).setOperation(
Operation.BEGIN).call();
result = new PullResult(fetchRes, remote, rebaseRes);
} catch (NoHeadException e) {
throw new JGitInternalException(e.getMessage(), e);
} catch (RefNotFoundException e) {
throw new JGitInternalException(e.getMessage(), e);
} catch (JGitInternalException e) {
throw new JGitInternalException(e.getMessage(), e);
} catch (GitAPIException e) {
throw new JGitInternalException(e.getMessage(), e);
}
RebaseResult rebaseRes = rebase.setUpstream(commitToMerge)
.setProgressMonitor(monitor).setOperation(Operation.BEGIN)
.call();
result = new PullResult(fetchRes, remote, rebaseRes);
} else {
MergeCommand merge = new MergeCommand(repo);
String name = "branch \'"
+ Repository.shortenRefName(remoteBranchName) + "\' of "
+ remoteUri;
merge.include(name, commitToMerge);
MergeResult mergeRes;
try {
mergeRes = merge.call();
monitor.update(1);
result = new PullResult(fetchRes, remote, mergeRes);
} catch (NoHeadException e) {
throw new JGitInternalException(e.getMessage(), e);
} catch (ConcurrentRefUpdateException e) {
throw new JGitInternalException(e.getMessage(), e);
} catch (CheckoutConflictException e) {
throw new JGitInternalException(e.getMessage(), e);
} catch (InvalidMergeHeadsException e) {
throw new JGitInternalException(e.getMessage(), e);
} catch (WrongRepositoryStateException e) {
throw new JGitInternalException(e.getMessage(), e);
} catch (NoMessageException e) {
throw new JGitInternalException(e.getMessage(), e);
}
MergeResult mergeRes = merge.call();
monitor.update(1);
result = new PullResult(fetchRes, remote, mergeRes);
}
monitor.endTask();
return result;

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

@ -109,9 +109,13 @@ public class PushCommand extends
* @return an iteration over {@link PushResult} objects
* @throws InvalidRemoteException
* when called with an invalid remote uri
* @throws org.eclipse.jgit.api.errors.TransportException
* when an error occurs with the transport
* @throws GitAPIException
*/
public Iterable<PushResult> call() throws GitAPIException,
InvalidRemoteException {
InvalidRemoteException,
org.eclipse.jgit.api.errors.TransportException {
checkCallable();
ArrayList<PushResult> pushResults = new ArrayList<PushResult>(3);
@ -150,9 +154,8 @@ public class PushCommand extends
pushResults.add(result);
} catch (TransportException e) {
throw new JGitInternalException(
JGitText.get().exceptionCaughtDuringExecutionOfPushCommand,
e);
throw new org.eclipse.jgit.api.errors.TransportException(
e.getMessage(), e);
} finally {
transport.close();
}
@ -161,6 +164,9 @@ public class PushCommand extends
} catch (URISyntaxException e) {
throw new InvalidRemoteException(MessageFormat.format(
JGitText.get().invalidRemote, remote));
} catch (TransportException e) {
throw new org.eclipse.jgit.api.errors.TransportException(
e.getMessage(), e);
} catch (NotSupportedException e) {
throw new JGitInternalException(
JGitText.get().exceptionCaughtDuringExecutionOfPushCommand,

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

@ -189,9 +189,13 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
* this method twice on an instance.
*
* @return an object describing the result of this command
* @throws GitAPIException
* @throws WrongRepositoryStateException
* @throws NoHeadException
* @throws RefNotFoundException
*/
public RebaseResult call() throws GitAPIException, NoHeadException,
RefNotFoundException {
RefNotFoundException, WrongRepositoryStateException {
RevCommit newHead = null;
boolean lastStepWasForward = false;
checkCallable();

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

@ -85,7 +85,14 @@ public class ReflogCommand extends GitCommand<Collection<ReflogEntry>> {
return this;
}
public Collection<ReflogEntry> call() throws GitAPIException {
/**
* Run the reflog command
*
* @throws GitAPIException
* @throws InvalidRefNameException
*/
public Collection<ReflogEntry> call() throws GitAPIException,
InvalidRefNameException {
checkCallable();
try {

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

@ -47,6 +47,7 @@ import java.text.MessageFormat;
import java.util.Collection;
import java.util.LinkedList;
import org.eclipse.jgit.api.errors.CheckoutConflictException;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.dircache.DirCache;
@ -135,8 +136,9 @@ public class ResetCommand extends GitCommand<Ref> {
* twice on an instance.
*
* @return the Ref after reset
* @throws GitAPIException
*/
public Ref call() throws GitAPIException {
public Ref call() throws GitAPIException, CheckoutConflictException {
checkCallable();
Ref r;
@ -366,13 +368,19 @@ public class ResetCommand extends GitCommand<Ref> {
}
}
private void checkoutIndex(RevCommit commit) throws IOException {
private void checkoutIndex(RevCommit commit) throws IOException,
GitAPIException {
DirCache dc = repo.lockDirCache();
try {
DirCacheCheckout checkout = new DirCacheCheckout(repo, dc,
commit.getTree());
checkout.setFailOnConflict(false);
checkout.checkout();
try {
checkout.checkout();
} catch (org.eclipse.jgit.errors.CheckoutConflictException cce) {
throw new CheckoutConflictException(checkout.getConflicts(),
cce);
}
} finally {
dc.unlock();
}

13
org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java

@ -49,10 +49,14 @@ import java.util.List;
import java.util.Map;
import org.eclipse.jgit.api.MergeResult.MergeStatus;
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.MultipleParentsNotAllowedException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.api.errors.UnmergedPathsException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.AnyObjectId;
@ -105,8 +109,15 @@ public class RevertCommand extends GitCommand<RevCommit> {
* returned. If a failure occurred during revert <code>null</code>
* is returned. The list of successfully reverted {@link Ref}'s can
* be obtained by calling {@link #getRevertedRefs()}
* @throws GitAPIException
* @throws WrongRepositoryStateException
* @throws ConcurrentRefUpdateException
* @throws UnmergedPathsException
* @throws NoMessageException
*/
public RevCommit call() throws GitAPIException {
public RevCommit call() throws NoMessageException, UnmergedPathsException,
ConcurrentRefUpdateException, WrongRepositoryStateException,
GitAPIException {
RevCommit newHead = null;
checkCallable();

5
org.eclipse.jgit/src/org/eclipse/jgit/api/StashApplyCommand.java

@ -296,8 +296,11 @@ public class StashApplyCommand extends GitCommand<ObjectId> {
* Apply the changes in a stashed commit to the working directory and index
*
* @return id of stashed commit that was applied
* @throws GitAPIException
* @throws WrongRepositoryStateException
*/
public ObjectId call() throws GitAPIException {
public ObjectId call() throws GitAPIException,
WrongRepositoryStateException {
checkCallable();
if (repo.getRepositoryState() != RepositoryState.SAFE)

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

@ -211,6 +211,7 @@ public class StashCreateCommand extends GitCommand<RevCommit> {
* and reset to the current HEAD commit.
*
* @return stashed commit or null if no changes to stash
* @throws GitAPIException
*/
public RevCommit call() throws GitAPIException {
checkCallable();

1
org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java

@ -167,6 +167,7 @@ public class StashDropCommand extends GitCommand<ObjectId> {
* stash reference after the drop occurs
*
* @return commit id of stash reference or null if no more stashed changes
* @throws GitAPIException
*/
public ObjectId call() throws GitAPIException {
checkCallable();

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

@ -76,7 +76,8 @@ public class StashListCommand extends GitCommand<Collection<RevCommit>> {
super(repo);
}
public Collection<RevCommit> call() throws GitAPIException {
public Collection<RevCommit> call() throws GitAPIException,
InvalidRefNameException {
checkCallable();
try {

32
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java

@ -47,8 +47,16 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.jgit.api.errors.CheckoutConflictException;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.InvalidConfigurationException;
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.RefNotFoundException;
import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.dircache.DirCacheCheckout;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.ConfigConstants;
@ -109,7 +117,25 @@ public class SubmoduleUpdateCommand extends
return this;
}
public Collection<String> call() throws GitAPIException {
/**
* Execute the SubmoduleUpdateCommand command.
*
* @return a collection of updated submodule paths
* @throws ConcurrentRefUpdateException
* @throws CheckoutConflictException
* @throws InvalidMergeHeadsException
* @throws InvalidConfigurationException
* @throws NoHeadException
* @throws NoMessageException
* @throws RefNotFoundException
* @throws WrongRepositoryStateException
* @throws GitAPIException
*/
public Collection<String> call() throws InvalidConfigurationException,
NoHeadException, ConcurrentRefUpdateException,
CheckoutConflictException, InvalidMergeHeadsException,
WrongRepositoryStateException, NoMessageException, NoHeadException,
RefNotFoundException, GitAPIException {
checkCallable();
try {
@ -168,9 +194,7 @@ public class SubmoduleUpdateCommand extends
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);
} catch (ConfigInvalidException e) {
throw new JGitInternalException(e.getMessage(), e);
} catch (GitAPIException e) {
throw new JGitInternalException(e.getMessage(), e);
throw new InvalidConfigurationException(e.getMessage(), e);
}
}
}

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

@ -963,7 +963,7 @@ public class DiffFormatter {
if (entry.getMode(side).getObjectType() != Constants.OBJ_BLOB)
return EMPTY;
if (isBinary(entry.getPath(side)))
if (isBinary())
return BINARY;
AbbreviatedObjectId id = entry.getId(side);
@ -1004,7 +1004,7 @@ public class DiffFormatter {
}
}
private boolean isBinary(String path) {
private boolean isBinary() {
return false;
}

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

@ -1021,10 +1021,9 @@ public class DirCacheCheckout {
}
private static boolean isValidPathSegment(CanonicalTreeParser t) {
boolean isWindows = "Windows".equals(SystemReader.getInstance()
.getProperty("os.name"));
boolean isOSX = "Mac OS X".equals(SystemReader.getInstance()
.getProperty("os.name"));
String osName = SystemReader.getInstance().getProperty("os.name");
boolean isWindows = "Windows".equals(osName);
boolean isOSX = "Darwin".equals(osName) || "Mac OS X".equals(osName);
boolean ignCase = isOSX || isWindows;
int ptr = t.getNameOffset();

3
org.eclipse.jgit/src/org/eclipse/jgit/errors/RevisionSyntaxException.java

@ -45,13 +45,12 @@
package org.eclipse.jgit.errors;
import java.io.IOException;
/**
* This signals a revision or object reference was not
* properly formatted.
*/
public class RevisionSyntaxException extends IOException {
public class RevisionSyntaxException extends IllegalArgumentException {
private static final long serialVersionUID = 1L;
private final String revstr;

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

@ -100,6 +100,29 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
&& ref[7] == ' ';
}
private static File getSymRef(File workTree, File dotGit)
throws IOException {
byte[] content = IO.readFully(dotGit);
if (!isSymRef(content))
throw new IOException(MessageFormat.format(
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
int pathStart = 8;
int lineEnd = RawParseUtils.nextLF(content, pathStart);
if (content[lineEnd - 1] == '\n')
lineEnd--;
if (lineEnd == pathStart)
throw new IOException(MessageFormat.format(
JGitText.get().invalidGitdirRef, dotGit.getAbsolutePath()));
String gitdirPath = RawParseUtils.decode(content, pathStart, lineEnd);
File gitdirFile = new File(gitdirPath);
if (gitdirFile.isAbsolute())
return gitdirFile;
else
return new File(workTree, gitdirPath).getCanonicalFile();
}
private FS fs;
private File gitDir;
@ -491,7 +514,13 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
if (FileKey.isGitRepository(dir, tryFS)) {
setGitDir(dir);
break;
}
} else if (dir.isFile())
try {
setGitDir(getSymRef(current, dir));
break;
} catch (IOException ignored) {
// Continue searching if gitdir ref isn't found
}
current = current.getParentFile();
if (current != null && ceilingDirectories != null
@ -567,30 +596,8 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
File dotGit = new File(getWorkTree(), DOT_GIT);
if (!dotGit.isFile())
setGitDir(dotGit);
else {
byte[] content = IO.readFully(dotGit);
if (!isSymRef(content))
throw new IOException(MessageFormat.format(
JGitText.get().invalidGitdirRef,
dotGit.getAbsolutePath()));
int pathStart = 8;
int lineEnd = RawParseUtils.nextLF(content, pathStart);
if (content[lineEnd - 1] == '\n')
lineEnd--;
if (lineEnd == pathStart)
throw new IOException(MessageFormat.format(
JGitText.get().invalidGitdirRef,
dotGit.getAbsolutePath()));
String gitdirPath = RawParseUtils.decode(content, pathStart,
lineEnd);
File gitdirFile = new File(gitdirPath);
if (gitdirFile.isAbsolute())
setGitDir(gitdirFile);
else
setGitDir(new File(getWorkTree(), gitdirPath)
.getCanonicalFile());
}
else
setGitDir(getSymRef(getWorkTree(), dotGit));
}
}

1
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java

@ -230,5 +230,6 @@ public abstract class RefDatabase {
* Implementors should overwrite this method if they use any kind of caches.
*/
public void refresh() {
// nothing
}
}

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

@ -399,7 +399,7 @@ public class ResolveMerger extends ThreeWayMerger {
else {
// the preferred version THEIRS has a different mode
// than ours. Check it out!
if (isWorktreeDirty())
if (isWorktreeDirty(work))
return false;
DirCacheEntry e = add(tw.getRawPath(), theirs,
DirCacheEntry.STAGE_0);
@ -434,7 +434,7 @@ public class ResolveMerger extends ThreeWayMerger {
// THEIRS. THEIRS is chosen.
// Check worktree before checking out THEIRS
if (isWorktreeDirty())
if (isWorktreeDirty(work))
return false;
if (nonTree(modeT)) {
DirCacheEntry e = add(tw.getRawPath(), theirs,
@ -485,7 +485,7 @@ public class ResolveMerger extends ThreeWayMerger {
if (nonTree(modeO) && nonTree(modeT)) {
// Check worktree before modifying files
if (isWorktreeDirty())
if (isWorktreeDirty(work))
return false;
MergeResult<RawText> result = contentMerge(base, ours, theirs);
@ -507,7 +507,7 @@ public class ResolveMerger extends ThreeWayMerger {
// OURS was deleted checkout THEIRS
if (modeO == 0) {
// Check worktree before checking out THEIRS
if (isWorktreeDirty())
if (isWorktreeDirty(work))
return false;
if (nonTree(modeT)) {
if (e != null)
@ -563,7 +563,7 @@ public class ResolveMerger extends ThreeWayMerger {
return isDirty;
}
private boolean isWorktreeDirty() {
private boolean isWorktreeDirty(WorkingTreeIterator work) {
if (inCore)
return false;
@ -571,8 +571,13 @@ public class ResolveMerger extends ThreeWayMerger {
final int modeO = tw.getRawMode(T_OURS);
// Worktree entry has to match ours to be considered clean
final boolean isDirty = nonTree(modeF)
&& !(modeO == modeF && tw.idEqual(T_FILE, T_OURS));
final boolean isDirty;
if (nonTree(modeF))
isDirty = work.isModeDifferent(modeO)
|| !tw.idEqual(T_FILE, T_OURS);
else
isDirty = false;
if (isDirty)
failingPaths.put(tw.getPathString(),
MergeFailureReason.DIRTY_WORKTREE);

1
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsInserter.java

@ -231,7 +231,6 @@ public class DfsInserter extends ObjectInserter {
packOut.write(buf, 0, 12);
}
@SuppressWarnings("unchecked")
private void sortObjectsById() {
Collections.sort(objectList);
}

12
org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpAuthMethod.java

@ -277,12 +277,14 @@ abstract class HttpAuthMethod {
r.append("://");
r.append(u.getHost());
if (0 < u.getPort()) {
if (u.getPort() == 80 && "http".equals(u.getProtocol()))
/* nothing */;
else if (u.getPort() == 443 && "https".equals(u.getProtocol()))
/* nothing */;
else
if (u.getPort() == 80 && "http".equals(u.getProtocol())) {
/* nothing */
} else if (u.getPort() == 443
&& "https".equals(u.getProtocol())) {
/* nothing */
} else {
r.append(':').append(u.getPort());
}
}
r.append(u.getPath());
if (u.getQuery() != null)

11
org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java

@ -591,15 +591,14 @@ public class URIish implements Serializable {
* @return the URI, including its password field, if any.
*/
public String toPrivateString() {
return format(true, false, false);
return format(true, false);
}
public String toString() {
return format(false, false, false);
return format(false, false);
}
private String format(final boolean includePassword, boolean escape,
boolean escapeNonAscii) {
private String format(final boolean includePassword, boolean escapeNonAscii) {
final StringBuilder r = new StringBuilder();
if (getScheme() != null) {
r.append(getScheme());
@ -646,7 +645,7 @@ public class URIish implements Serializable {
* @return the URI as an ASCII string. Password is not included.
*/
public String toASCIIString() {
return format(false, true, true);
return format(false, true);
}
/**
@ -654,7 +653,7 @@ public class URIish implements Serializable {
* such that it will be valid for use over the network.
*/
public String toPrivateASCIIString() {
return format(true, true, true);
return format(true, true);
}
/**

46
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java

@ -695,6 +695,33 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
DIFFER_BY_TIMESTAMP
}
/**
* Is the file mode of the current entry different than the given raw mode?
*
* @param rawMode
* @return true if different, false otherwise
*/
public boolean isModeDifferent(final int rawMode) {
// Determine difference in mode-bits of file and index-entry. In the
// bitwise presentation of modeDiff we'll have a '1' when the two modes
// differ at this position.
int modeDiff = getEntryRawMode() ^ rawMode;
if (modeDiff == 0)
return false;
// Do not rely on filemode differences in case of symbolic links
if (FileMode.SYMLINK.equals(rawMode))
return false;
// Ignore the executable file bits if WorkingTreeOptions tell me to
// do so. Ignoring is done by setting the bits representing a
// EXECUTABLE_FILE to '0' in modeDiff
if (!state.options.isFileMode())
modeDiff &= ~FileMode.EXECUTABLE_FILE.getBits();
return modeDiff != 0;
}
/**
* Compare the metadata (mode, length, modification-timestamp) of the
* current entry and a {@link DirCacheEntry}
@ -714,23 +741,8 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
if (!entry.isSmudged() && entry.getLength() != (int) getEntryLength())
return MetadataDiff.DIFFER_BY_METADATA;
// Determine difference in mode-bits of file and index-entry. In the
// bitwise presentation of modeDiff we'll have a '1' when the two modes
// differ at this position.
int modeDiff = getEntryRawMode() ^ entry.getRawMode();
// Do not rely on filemode differences in case of symbolic links
if (modeDiff != 0 && !FileMode.SYMLINK.equals(entry.getRawMode())) {
// Ignore the executable file bits if WorkingTreeOptions tell me to
// do so. Ignoring is done by setting the bits representing a
// EXECUTABLE_FILE to '0' in modeDiff
if (!state.options.isFileMode())
modeDiff &= ~FileMode.EXECUTABLE_FILE.getBits();
if (modeDiff != 0)
// Report a modification if the modes still (after potentially
// ignoring EXECUTABLE_FILE bits) differ
return MetadataDiff.DIFFER_BY_METADATA;
}
if (isModeDifferent(entry.getRawMode()))
return MetadataDiff.DIFFER_BY_METADATA;
// Git under windows only stores seconds so we round the timestamp
// Java gives us if it looks like the timestamp in index is seconds

2
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java

@ -105,6 +105,6 @@ abstract class FS_POSIX extends FS {
return System.getProperty("os.name");
}
});
return "Mac OS X".equals(osDotName);
return "Mac OS X".equals(osDotName) || "Darwin".equals(osDotName);
}
}

19
pom.xml

@ -183,11 +183,6 @@
<id>jgit-repository</id>
<url>http://download.eclipse.org/jgit/maven</url>
</repository>
<repository>
<id>jetty</id>
<layout>p2</layout>
<url>http://download.eclipse.org/jetty/updates/jetty-bundles-7.x/${jetty-version}/</url>
</repository>
</repositories>
<build>
@ -377,6 +372,20 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<inherited>true</inherited>
<executions>
<execution>
<id>attach-sources</id>
<phase>process-classes</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Loading…
Cancel
Save