Source:
public Ref call() throws IOException { checkCallable(); Ref r; RevCommit commit; try { boolean merging = false; if (repo.getRepositoryState().equals(RepositoryState.MERGING) || repo.getRepositoryState().equals( RepositoryState.MERGING_RESOLVED)) merging = true; final boolean cherryPicking = repo.getRepositoryState().equals( RepositoryState.CHERRY_PICKING) || repo.getRepositoryState().equals( RepositoryState.CHERRY_PICKING_RESOLVED); final ObjectId commitId; try { commitId = repo.resolve(ref); } catch (IOException e) { throw new JGitInternalException( MessageFormat.format(JGitText.get().cannotRead, ref), e); } RevWalk rw = new RevWalk(repo); try { commit = rw.parseCommit(commitId); } catch (IOException e) { throw new JGitInternalException( MessageFormat.format( JGitText.get().cannotReadCommit, commitId.toString()), e); } finally { rw.release(); } final RefUpdate ru = repo.updateRef(Constants.HEAD); ru.setNewObjectId(commitId); String refName = Repository.shortenRefName(ref); String message = "reset --" + mode.toString().toLowerCase() + " " + refName; ru.setRefLogMessage(message, false); if (ru.forceUpdate() == RefUpdate.Result.LOCK_FAILURE) throw new JGitInternalException(MessageFormat.format( JGitText.get().cannotLock, ru.getName())); switch (mode) { case HARD: checkoutIndex(commit); break; case MIXED: resetIndex(commit); break; case SOFT: break; case KEEP: case MERGE: throw new UnsupportedOperationException(); } if (mode != ResetType.SOFT) { if (merging) resetMerge(); else if (cherryPicking) resetCherryPick(); } setCallable(false); r = ru.getRef(); } catch (IOException e) { throw new JGitInternalException( JGitText.get().exceptionCaughtDuringExecutionOfResetCommand, e); } return r; }

Target:
public Ref call() throws IOException { checkCallable(); Ref r; RevCommit commit; try { RepositoryState state = repo.getRepositoryState(); final boolean merging = state.equals(RepositoryState.MERGING) || state.equals(RepositoryState.MERGING_RESOLVED); final boolean cherryPicking = state .equals(RepositoryState.CHERRY_PICKING) || state.equals(RepositoryState.CHERRY_PICKING_RESOLVED); final ObjectId commitId; try { commitId = repo.resolve(ref); } catch (IOException e) { throw new JGitInternalException( MessageFormat.format(JGitText.get().cannotRead, ref), e); } RevWalk rw = new RevWalk(repo); try { commit = rw.parseCommit(commitId); } catch (IOException e) { throw new JGitInternalException( MessageFormat.format( JGitText.get().cannotReadCommit, commitId.toString()), e); } finally { rw.release(); } final RefUpdate ru = repo.updateRef(Constants.HEAD); ru.setNewObjectId(commitId); String refName = Repository.shortenRefName(ref); String message = "reset --" + mode.toString().toLowerCase() + " " + refName; ru.setRefLogMessage(message, false); if (ru.forceUpdate() == RefUpdate.Result.LOCK_FAILURE) throw new JGitInternalException(MessageFormat.format( JGitText.get().cannotLock, ru.getName())); switch (mode) { case HARD: checkoutIndex(commit); break; case MIXED: resetIndex(commit); break; case SOFT: break; case KEEP: case MERGE: throw new UnsupportedOperationException(); } if (mode != ResetType.SOFT) { if (merging) resetMerge(); else if (cherryPicking) resetCherryPick(); } setCallable(false); r = ru.getRef(); } catch (IOException e) { throw new JGitInternalException( JGitText.get().exceptionCaughtDuringExecutionOfResetCommand, e); } return r; }