Skip to main content



      Home
Home » Eclipse Projects » EGit / JGit » Cancelling a JGit operation
Cancelling a JGit operation [message #1779343] Fri, 05 January 2018 11:08 Go to next message
Eclipse UserFriend
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?

Thanks for the info.
Re: Cancelling a JGit operation [message #1779411 is a reply to message #1779343] Sat, 06 January 2018 13:52 Go to previous messageGo to next message
Eclipse UserFriend
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
be cancelled.
Re: Cancelling a JGit operation [message #1779500 is a reply to message #1779411] Mon, 08 January 2018 14:36 Go to previous messageGo to next message
Eclipse UserFriend
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.

Have I got this right?
Re: Cancelling a JGit operation [message #1780549 is a reply to message #1779500] Tue, 23 January 2018 15:26 Go to previous message
Eclipse UserFriend
yes
Previous Topic:Installation EGit
Next Topic:How to use EGIT to change a file to executable
Goto Forum:
  


Current Time: Fri Jul 04 15:22:52 EDT 2025

Powered by FUDForum. Page generated in 0.27559 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top