Source:
public void execute(IProgressMonitor m) throws CoreException { IProgressMonitor monitor; if (m == null) monitor = new NullProgressMonitor(); else monitor = m; IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor pm) throws CoreException { preExecute(pm); IProject[] missing = getMissingProjects(target, ProjectUtil .getValidOpenProjects(repository)); pm.beginTask(NLS.bind( CoreText.BranchOperation_performingBranch, target), missing.length > 0 ? 3 : 2); if (missing.length > 0) { SubProgressMonitor closeMonitor = new SubProgressMonitor( pm, 1); closeMonitor.beginTask("", missing.length); for (IProject project : missing) { closeMonitor.subTask(MessageFormat.format( CoreText.BranchOperation_closingMissingProject, project.getName())); project.close(closeMonitor); } closeMonitor.done(); } CheckoutCommand co = new Git(repository).checkout(); co.setName(target); try { co.call(); } catch (CheckoutConflictException e) { return; } catch (JGitInternalException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } catch (GitAPIException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } finally { BranchOperation.this.result = co.getResult(); } if (result.getStatus() == Status.NONDELETED) retryDelete(result.getUndeletedList()); pm.worked(1); List<String> pathsToHandle = new ArrayList<String>(); pathsToHandle.addAll(co.getResult().getModifiedList()); pathsToHandle.addAll(co.getResult().getRemovedList()); IProject[] refreshProjects = ProjectUtil .getProjectsContaining(repository, pathsToHandle); ProjectUtil.refreshValidProjects(refreshProjects, delete, new SubProgressMonitor(pm, 1)); pm.worked(1); postExecute(pm); pm.done(); } }; ResourcesPlugin.getWorkspace().run(action, monitor); }

Target:
public void execute(IProgressMonitor m) throws CoreException { IProgressMonitor monitor; if (m == null) monitor = new NullProgressMonitor(); else monitor = m; IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor pm) throws CoreException { preExecute(pm); IProject[] missing = getMissingProjects(target, ProjectUtil .getValidOpenProjects(repository)); pm.beginTask(NLS.bind( CoreText.BranchOperation_performingBranch, target), missing.length > 0 ? 3 : 2); if (missing.length > 0) { SubProgressMonitor closeMonitor = new SubProgressMonitor( pm, 1); closeMonitor.beginTask("", missing.length); for (IProject project : missing) { closeMonitor.subTask(MessageFormat.format( CoreText.BranchOperation_closingMissingProject, project.getName())); project.close(closeMonitor); } closeMonitor.done(); } CheckoutCommand co = new Git(repository).checkout(); co.setName(target); try { co.call(); } catch (CheckoutConflictException e) { return; } catch (JGitInternalException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } catch (GitAPIException e) { throw new CoreException(Activator.error(e.getMessage(), e)); } finally { BranchOperation.this.result = co.getResult(); } if (result.getStatus() == Status.NONDELETED) retryDelete(result.getUndeletedList()); pm.worked(1); List<String> pathsToHandle = new ArrayList<String>(); pathsToHandle.addAll(co.getResult().getModifiedList()); pathsToHandle.addAll(co.getResult().getRemovedList()); pathsToHandle.addAll(co.getResult().getConflictList()); IProject[] refreshProjects = ProjectUtil .getProjectsContaining(repository, pathsToHandle); ProjectUtil.refreshValidProjects(refreshProjects, delete, new SubProgressMonitor(pm, 1)); pm.worked(1); postExecute(pm); pm.done(); } }; ResourcesPlugin.getWorkspace().run(action, monitor); }