Stagingview: JGIT index lock exception when adding and removing files in one step
eder-s opened this issue · comments
Version
at least since EGit 5
Operating System
Windows
Eclipse version
independent
Bug description
A Jgit index lock exception occurs if you add/remove unstaged files in one single step via the "add all files including not selected ones to the index". The bug only occurs if the git repository is not an Eclipse project.
Steps to reproduce:
- Create an empty git repository and do not add it as Eclispe project
- Add some files to the repository
- Go to the "staging view" and add all files from step 2 to the index, do not commit, you might need to click the "refresh" button to see the unstaged files
- Delete a file created in step 2
- Add more files to the repsoitory
- Go to the staging view again, you might need to click the "refresh" button to see the unstaged files from step 4&5
- The unstaged file list contains now some files which need to be added to the index and some files which need to be removed
- Click on the "++" button to add/remove all unstaged files to the index
- A Jgit index lock error exception is shown and the operation in 8 is not fully performed
Actual behavior
An jgit index lock error is displayed and not all files are staged. You have to stage the remaining unstaged files again.
Expected behavior
No jgit index lock exception occurs, all files are staged
Relevant log output
No response
Other information
The root cause is in "RuleUtil.java" as it can create job schedule rules for repositories which have a Eclipse project linked.
public static ISchedulingRule getRule(Repository repository) {
IProject[] projects = getProjects(repository);
if (projects.length == 0)
return null;
return new MultiRule(projects);
}
The return null
above leads to no scheduling rule being created which leads to the concurrent index access during staging.
I provided an potential fix at https://eclipse.gerrithub.io/c/eclipse-egit/egit/+/1173395