summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki <kevin@github.com>2012-06-05 02:17:30 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2012-06-05 15:49:55 +0200
commit108e2bc6e43b1ddf4d7545edffc75dcc9e106cd7 (patch)
tree2c6855a461989c86464e8f389692a0ce6dc6eb7d
parent036e40ef42b6461f1547b6b8e1b3dd896c26f69b (diff)
downloadjgit-108e2bc6e43b1ddf4d7545edffc75dcc9e106cd7.tar.gz
jgit-108e2bc6e43b1ddf4d7545edffc75dcc9e106cd7.zip
Throw formal CheckoutConflictException on hard reset
This will allow calling classes to have access to the conflicts that occurred during the attempted checkout. Even though setFailOnConflict(false) is called on the DirCacheCheckout a CheckoutConflictException can still be thrown if cleanup fails. Change-Id: Iea7ad3176a1b0e8606a643de8945e276718eb3ce Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
index a6d425ea31..24984803ff 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
+++ b/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;
@@ -136,7 +137,7 @@ public class ResetCommand extends GitCommand<Ref> {
*
* @return the Ref after reset
*/
- public Ref call() throws GitAPIException {
+ public Ref call() throws GitAPIException, CheckoutConflictException {
checkCallable();
Ref r;
@@ -366,13 +367,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();
}