Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Cancelling a JGit operation
Cancelling a JGit operation [message #1779343] Fri, 05 January 2018 16:08 Go to next message
Dave Musicant is currently offline Dave MusicantFriend
Messages: 15
Registered: May 2016
Junior Member
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 18:52 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
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 19:36 Go to previous messageGo to next message
Dave Musicant is currently offline Dave MusicantFriend
Messages: 15
Registered: May 2016
Junior Member
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 20:26 Go to previous message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
yes
Previous Topic:Installation EGit
Next Topic:How to use EGIT to change a file to executable
Goto Forum:
  


Current Time: Thu Apr 25 13:27:41 GMT 2024

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

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

Back to the top