Source:
<code>public RevCommit call() throws GitAPIException { checkCallable(); <START> RevWalk revWalk = null; <END> try { revWalk = new RevWalk(repo); Ref headRef = repo.getRef(Constants.HEAD); if (headRef == null) throw new NoHeadException( JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); RevCommit headCommit = revWalk.lookupCommit(headRef.getObjectId()); for (Ref src : commits) { ObjectId srcObjectId = src.getPeeledObjectId(); if (srcObjectId == null) srcObjectId = src.getObjectId(); RevCommit srcCommit = revWalk.parseCommit(srcObjectId); if (srcCommit.getParentCount() != 1) { throw new InvalidCherryPickCommit( JGitText.get().canOnlyCherryPickCommitsWithOneParent); } RevCommit srcParent = revWalk.parseCommit(srcCommit .getParent(0)); ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE .newMerger(repo); merger.setWorkingTreeIt(new FileTreeIterator(repo)); merger.setBase(srcParent.getTree()); if (merger.merge(headCommit, srcCommit)) { DirCacheCheckout dco = new DirCacheCheckout(repo, headCommit.getTree(), repo.lockDirCache(), merger.getResultTreeId()); dco.setFailOnConflict(true); dco.checkout(); RevCommit newHead = new Git(getRepository()).commit() .setMessage(srcCommit.getFullMessage()) .setAuthor(srcCommit.getAuthorIdent()).call(); return newHead; } else { return null; } } } catch (IOException e) { throw new JGitInternalException( MessageFormat.format( JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand, e), e); } finally { if (revWalk != null) revWalk.release(); } return null; }</code><technical_language>initialize null. RevWalk revWalk = new RevWalk(repo); try { } finally { revWalk.release(); }</technical_language>

Target:
public RevCommit call() throws GitAPIException { RevCommit newHead = null; checkCallable(); RevWalk revWalk = new RevWalk(repo); try { Ref headRef = repo.getRef(Constants.HEAD); if (headRef == null) throw new NoHeadException( JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); RevCommit headCommit = revWalk.lookupCommit(headRef.getObjectId()); for (Ref src : commits) { ObjectId srcObjectId = src.getPeeledObjectId(); if (srcObjectId == null) srcObjectId = src.getObjectId(); RevCommit srcCommit = revWalk.parseCommit(srcObjectId); if (srcCommit.getParentCount() != 1) { throw new InvalidCherryPickCommit( JGitText.get().canOnlyCherryPickCommitsWithOneParent); } RevCommit srcParent = revWalk.parseCommit(srcCommit .getParent(0)); ResolveMerger merger = (ResolveMerger) MergeStrategy.RESOLVE .newMerger(repo); merger.setWorkingTreeIterator(new FileTreeIterator(repo)); merger.setBase(srcParent.getTree()); if (merger.merge(headCommit, srcCommit)) { DirCacheCheckout dco = new DirCacheCheckout(repo, headCommit.getTree(), repo.lockDirCache(), merger.getResultTreeId()); dco.setFailOnConflict(true); dco.checkout(); newHead = new Git(getRepository()).commit() .setMessage(srcCommit.getFullMessage()) .setAuthor(srcCommit.getAuthorIdent()).call(); cherryPickedRefs.add(src); } else { return null; } } } catch (IOException e) { throw new JGitInternalException( MessageFormat.format( JGitText.get().exceptionCaughtDuringExecutionOfCherryPickCommand, e), e); } finally { revWalk.release(); } return newHead; }