setCallable(false);
return repo.getRef(Constants.HEAD);
}
// write the ref
final RefUpdate ru = repo.updateRef(Constants.HEAD);
ru.setNewObjectId(commitId);
String refName = Repository.shortenRefName(ref);
String message = refName + ": updating " + Constants.HEAD; //$NON-NLS-1$
ru.setRefLogMessage(message, false);
if (ru.forceUpdate() == RefUpdate.Result.LOCK_FAILURE)
throw new JGitInternalException(MessageFormat.format(
JGitText.get().cannotLock, ru.getName()));
ObjectId origHead = ru.getOldObjectId();
if (origHead != null)
repo.writeOrigHead(origHead);
switch (mode) {
case HARD:
checkoutIndex(commit);
break;
case MIXED:
resetIndex(commit);
break;
case SOFT: // do nothing, only the ref was changed
break;
case KEEP: // TODO
case MERGE: // TODO
throw new UnsupportedOperationException();
}
if (mode != ResetType.SOFT) {
if (merging)
resetMerge();
else if (cherryPicking)
resetCherryPick();
else if (repo.readSquashCommitMsg() != null)
repo.writeSquashCommitMsg(null /* delete */);
}
setCallable(false);
r = ru.getRef();
} catch (IOException e) {
throw new JGitInternalException(
JGitText.get().exceptionCaughtDuringExecutionOfResetCommand,
e);
}