Program: 91510
Project: 91510
Buggy source:
/** 
 * @param pm the monitor to be used for reporting progress and responding to cancellation. The monitor is never <code>null</code>
 * @throws InvocationTargetException
 * @throws InterruptedException
 */
public void run(final IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
  final IProgressMonitor monitor;
  if (pm == null)   monitor=new NullProgressMonitor();
 else   monitor=pm;
  EclipseGitProgressTransformer gitMonitor=new EclipseGitProgressTransformer(monitor);
  Repository repository=null;
  try {
    monitor.beginTask(NLS.bind(CoreText.CloneOperation_title,uri),5000);
    CloneCommand cloneRepository=Git.cloneRepository();
    cloneRepository.setCredentialsProvider(credentialsProvider);
    if (refName != null)     cloneRepository.setBranch(refName);
    cloneRepository.setDirectory(workdir);
    cloneRepository.setProgressMonitor(gitMonitor);
    cloneRepository.setRemote(remoteName);
    cloneRepository.setURI(uri.toString());
    cloneRepository.setTimeout(timeout);
    cloneRepository.setCloneAllBranches(allSelected);
    if (selectedBranches != null) {
      List<String> branches=new ArrayList<String>();
      for (      Ref branch : selectedBranches)       branches.add(branch.getName());
      cloneRepository.setBranchesToClone(branches);
    }
    Git git=cloneRepository.call();
    repository=git.getRepository();
    if (postCloneTasks != null)     for (    PostCloneTask task : postCloneTasks)     task.execute(git.getRepository(),monitor);
  }
 catch (  final Exception e) {
    try {
      if (repository != null)       repository.close();
      FileUtils.delete(workdir,FileUtils.RECURSIVE);
    }
 catch (    IOException ioe) {
      throw new InvocationTargetException(ioe);
    }
    if (monitor.isCanceled())     throw new InterruptedException();
 else     throw new InvocationTargetException(e);
  }
 finally {
    monitor.done();
    if (repository != null)     repository.close();
  }
}

Fixed version (ground truth):
/** 
 * @param pm the monitor to be used for reporting progress and responding to cancellation. The monitor is never <code>null</code>
 * @throws InvocationTargetException
 * @throws InterruptedException
 */
public void run(final IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
  final IProgressMonitor monitor;
  if (pm == null)   monitor=new NullProgressMonitor();
 else   monitor=pm;
  EclipseGitProgressTransformer gitMonitor=new EclipseGitProgressTransformer(monitor);
  Repository repository=null;
  try {
    monitor.beginTask(NLS.bind(CoreText.CloneOperation_title,uri),5000);
    CloneCommand cloneRepository=Git.cloneRepository();
    cloneRepository.setCredentialsProvider(credentialsProvider);
    if (refName != null)     cloneRepository.setBranch(refName);
    cloneRepository.setDirectory(workdir);
    cloneRepository.setProgressMonitor(gitMonitor);
    cloneRepository.setRemote(remoteName);
    cloneRepository.setURI(uri.toString());
    cloneRepository.setTimeout(timeout);
    cloneRepository.setCloneAllBranches(allSelected);
    if (selectedBranches != null) {
      List<String> branches=new ArrayList<String>();
      for (      Ref branch : selectedBranches)       branches.add(branch.getName());
      cloneRepository.setBranchesToClone(branches);
    }
    Git git=cloneRepository.call();
    repository=git.getRepository();
synchronized (this) {
      if (postCloneTasks != null)       for (      PostCloneTask task : postCloneTasks)       task.execute(git.getRepository(),monitor);
    }
  }
 catch (  final Exception e) {
    try {
      if (repository != null)       repository.close();
      FileUtils.delete(workdir,FileUtils.RECURSIVE);
    }
 catch (    IOException ioe) {
      throw new InvocationTargetException(ioe);
    }
    if (monitor.isCanceled())     throw new InterruptedException();
 else     throw new InvocationTargetException(e);
  }
 finally {
    monitor.done();
    if (repository != null)     repository.close();
  }
}