Skip to main content



      Home
Home » Eclipse Projects » EGit / JGit » Does JGIT allow for running commands in parallel?
Does JGIT allow for running commands in parallel? [message #1848839] Mon, 20 December 2021 11:28 Go to next message
Eclipse UserFriend
When trying to run two jgit commands in parallel, I'm getting lock exceptions. Essentially I'm trying to add everything currently in my working directory into my index. (deleted + modified + added files)

This is how I do this at the moment


launch {
    // setUpdate allows us to remove deleted files, but disallows adding new files. So we have to do this twice...
    this@stageAll
        .add()
        .addFilepattern(".")
        .setUpdate(true)
        .call()
        .also { logger.info("Staging all files") }
        .unit()
}
launch {
    this@stageAll
        .add()
        .addFilepattern(".")
        .call()
        .also { logger.info("Staging all files") }
        .unit()
}


Is there a way to have jgit run these together in a single operation?
Re: Does JGIT allow for running commands in parallel? [message #1849002 is a reply to message #1848839] Tue, 28 December 2021 19:40 Go to previous messageGo to next message
Eclipse UserFriend
what is
- launch { }
- this@stageAll
?
Re: Does JGIT allow for running commands in parallel? [message #1853125 is a reply to message #1849002] Sun, 19 June 2022 11:29 Go to previous messageGo to next message
Eclipse UserFriend
This is kotlin code

@ is a label

launch will run something in a coroutine context

Sorry, I tried a few times to find my own post, but didn't know how to find my own post.
Re: Does JGIT allow for running commands in parallel? [message #1853157 is a reply to message #1853125] Tue, 21 June 2022 02:03 Go to previous message
Eclipse UserFriend
Staging requires locking the git index (aka DirCache) that's why you can't run AddCommand concurrently on the same repository.
See https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/refs/heads/master/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java#122
Previous Topic:jgit.sh on wsl
Next Topic:How to get User info from personal access token
Goto Forum:
  


Current Time: Sat May 17 20:17:14 EDT 2025

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

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

Back to the top