Unlock DirCache in case of occurring exception
A DirCache was not unlocked if an exception occurred in the DirCacheCheckout constructor. Bug: 365449 Change-Id: I231d902d52e3e5e9a7748eedaa63a2bb889ebb13 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
This commit is contained in:
parent
86db05602f
commit
0a84ad2d2a
|
@ -160,15 +160,21 @@ public Ref call() throws JGitInternalException, RefAlreadyExistsException,
|
||||||
.parseCommit(headId);
|
.parseCommit(headId);
|
||||||
RevCommit newCommit = revWalk.parseCommit(branch);
|
RevCommit newCommit = revWalk.parseCommit(branch);
|
||||||
RevTree headTree = headCommit == null ? null : headCommit.getTree();
|
RevTree headTree = headCommit == null ? null : headCommit.getTree();
|
||||||
DirCacheCheckout dco = new DirCacheCheckout(repo, headTree,
|
DirCacheCheckout dco;
|
||||||
repo.lockDirCache(), newCommit.getTree());
|
DirCache dc = repo.lockDirCache();
|
||||||
dco.setFailOnConflict(true);
|
|
||||||
try {
|
try {
|
||||||
dco.checkout();
|
dco = new DirCacheCheckout(repo, headTree, dc,
|
||||||
} catch (org.eclipse.jgit.errors.CheckoutConflictException e) {
|
newCommit.getTree());
|
||||||
status = new CheckoutResult(Status.CONFLICTS, dco
|
dco.setFailOnConflict(true);
|
||||||
.getConflicts());
|
try {
|
||||||
throw new CheckoutConflictException(dco.getConflicts(), e);
|
dco.checkout();
|
||||||
|
} catch (org.eclipse.jgit.errors.CheckoutConflictException e) {
|
||||||
|
status = new CheckoutResult(Status.CONFLICTS,
|
||||||
|
dco.getConflicts());
|
||||||
|
throw new CheckoutConflictException(dco.getConflicts(), e);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
dc.unlock();
|
||||||
}
|
}
|
||||||
Ref ref = repo.getRef(name);
|
Ref ref = repo.getRef(name);
|
||||||
if (ref != null && !ref.getName().startsWith(Constants.R_HEADS))
|
if (ref != null && !ref.getName().startsWith(Constants.R_HEADS))
|
||||||
|
|
Loading…
Reference in New Issue