Is there a way to kill/cancel a JGit call in progress? Suppose I'm building a GUI with a cancel button, where I want to be able to kill a slow JGit command that is in progress. The call() method itself is blocking. Is there an API for interrupting it?
You should be able to cancel commands which accept a ProgressMonitor, e.g. CloneCommand.
Find examples in EGit which uses Eclipse's ProgressMonitor which can be used in JGit by wrapping it with an
EclipseGitProgressTransformer. When ProgressMonitor.isCancelled() returns true the command should
Thanks for the response, Matthias. It looks to me like EclipseGitProgressTransformer, wrapped around a ProgressMonitor, can tell me when an operation (such as CloneCommand) has been cancelled. As you say, the isCancelled method will return true when the operation has been cancelled.
So I think I've now got it, based on your answer, but let's see if I've got this right: to cancel a git operation (where doing so is enabled) I should...
1. Create an IProgressMonitor
2. Wrap an EclipseGitProgressTransformer around the IProgressMonitor
3. Pass the EclipseGitProgressTransformer as a parameter to the git command setProgressMonitor method, e.g. CloneCommand.setProgressMonitor before the call
4. When I want to cancel, issue IProgressMonitor.setCanceled(true); the git command (e.g. CloneCommand) will then poll that and cancel accordingly.