Browse Source

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>
tags/v2.0.0.201206130900-r
Kevin Sawicki 12 years ago
parent
commit
108e2bc6e4
1 changed files with 10 additions and 3 deletions
  1. 10
    3
      org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java

+ 10
- 3
org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java View File

import java.util.Collection; import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;


import org.eclipse.jgit.api.errors.CheckoutConflictException;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCache;
* *
* @return the Ref after reset * @return the Ref after reset
*/ */
public Ref call() throws GitAPIException {
public Ref call() throws GitAPIException, CheckoutConflictException {
checkCallable(); checkCallable();


Ref r; Ref r;
} }
} }


private void checkoutIndex(RevCommit commit) throws IOException {
private void checkoutIndex(RevCommit commit) throws IOException,
GitAPIException {
DirCache dc = repo.lockDirCache(); DirCache dc = repo.lockDirCache();
try { try {
DirCacheCheckout checkout = new DirCacheCheckout(repo, dc, DirCacheCheckout checkout = new DirCacheCheckout(repo, dc,
commit.getTree()); commit.getTree());
checkout.setFailOnConflict(false); checkout.setFailOnConflict(false);
checkout.checkout();
try {
checkout.checkout();
} catch (org.eclipse.jgit.errors.CheckoutConflictException cce) {
throw new CheckoutConflictException(checkout.getConflicts(),
cce);
}
} finally { } finally {
dc.unlock(); dc.unlock();
} }

Loading…
Cancel
Save