Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316104 - Problems occur if checkout deletes a .project file
Summary: Problems occur if checkout deletes a .project file
Status: REOPENED
Alias: None
Product: EGit
Classification: Technology
Component: Core (show other bugs)
Version: 0.9.0   Edit
Hardware: PC Windows Vista
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-08 04:55 EDT by Jens Baumgart CLA
Modified: 2013-03-30 19:43 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Baumgart CLA 2010-06-08 04:55:00 EDT
Problems occur if a workdir checkout (e.g. done by branch or reset) deletes .project files.

Precondition
============

Project p exist in branch b1.
.project file of project p is contained in the Git repository.
Project p does not exist in branch b2.
Active branch is b1.

Error
=====

Checkout branch b2. This removes the .project file of p.
Branch operation fails because refreshing p fails.
The workspace now contains a project with missing .project file.

Some time later the DelayedSnapshotJob (Workspace AUto-save) restores the .project file.

Switching back to branch b1 fails with a checkout conflict:
workdir checkout can not be done because there is an untracked .project file 
in the working directory.
Comment 1 Jens Baumgart CLA 2010-06-08 04:57:32 EDT
I think the issue could be solved in the following way: if workdir checkout deletes a .project file in the working directory the corresponding project is deleted. This guarantees a consistent workspace.
Comment 2 Jens Baumgart CLA 2010-06-08 11:13:14 EDT
Fix proposed: http://egit.eclipse.org/r/821
Comment 3 Matthias Sohn CLA 2010-06-16 05:10:13 EDT
merged as a2ade7f6fdaffc8bf698480d0fe4f341d1248787
Comment 4 Markus Duft CLA 2012-01-25 08:40:35 EST
i have not enough rights to do so, but i want to reopen this bug. it happens again with current EGit. in the "good case", when "track projects for each branch" is enabled, i "only" get such things (and projects disappear, although they should have stayed (closed) :)):

Error
Wed Jan 25 14:36:02 CET 2012
File not found: /fast/wamas5/workspaces/runtime-EclipseApplication/wamas5/com.wamas.wms.mobile.voice.shared/build.properties.

java.io.FileNotFoundException: /fast/wamas5/workspaces/runtime-EclipseApplication/wamas5/com.wamas.wms.mobile.voice.shared/build.properties (No such file or directory)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:137)
	at org.eclipse.core.internal.filesystem.local.LocalFile.openInputStream(LocalFile.java:362)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:797)
	at org.eclipse.core.internal.resources.File.getContents(File.java:289)
	at org.eclipse.pde.internal.core.build.WorkspaceBuildModel.load(WorkspaceBuildModel.java:67)
	at org.eclipse.pde.internal.core.build.BuildModel.getBuild(BuildModel.java:36)
	at org.eclipse.pde.internal.core.ClasspathUtilCore.getBuild(ClasspathUtilCore.java:195)
	at org.eclipse.pde.internal.core.PluginModelManager.updateAffectedEntries(PluginModelManager.java:342)
	at org.eclipse.pde.internal.core.PluginModelManager.modelsChanged(PluginModelManager.java:280)
	at org.eclipse.pde.internal.core.AbstractModelManager.fireModelProviderEvent(AbstractModelManager.java:35)
	at org.eclipse.pde.internal.core.WorkspaceModelManager.createAndFireEvent(WorkspaceModelManager.java:263)
	at org.eclipse.pde.internal.core.WorkspacePluginModelManager.createAndFireEvent(WorkspacePluginModelManager.java:471)
	at org.eclipse.pde.internal.core.WorkspaceModelManager.processModelChanges(WorkspaceModelManager.java:235)
	at org.eclipse.pde.internal.core.WorkspaceModelManager.processModelChanges(WorkspaceModelManager.java:197)
	at org.eclipse.pde.internal.core.WorkspacePluginModelManager.processModelChanges(WorkspacePluginModelManager.java:461)
	at org.eclipse.pde.internal.core.WorkspaceModelManager.resourceChanged(WorkspaceModelManager.java:118)
	at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:291)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:285)
	at org.eclipse.core.internal.events.NotificationManager.handleEvent(NotificationManager.java:249)
	at org.eclipse.core.internal.resources.Workspace.broadcastEvent(Workspace.java:390)
	at org.eclipse.core.internal.resources.Project.close(Project.java:199)
	at org.eclipse.egit.core.internal.util.ProjectUtil.closeMissingProject(ProjectUtil.java:173)
	at org.eclipse.egit.core.internal.util.ProjectUtil.refreshValidProjects(ProjectUtil.java:142)
	at org.eclipse.egit.core.op.BranchOperation$1.run(BranchOperation.java:122)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2326)
	at org.eclipse.egit.core.op.BranchOperation.execute(BranchOperation.java:132)
	at org.eclipse.egit.ui.internal.branch.BranchOperationUI$1.run(BranchOperationUI.java:199)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


in the more bad case i get this:

Warning
Wed Jan 25 08:21:03 CET 2012
The project description file (.project) for 'com.wamas.wms.mobile.voice.shared' was missing.  This file contains important information about the project.  A new project description file has been created, but some information about the project may have been lost.

and eclipse dumps the file back on disc, which is fatal of course, as it taints the repository. after this happens the only resolution is to close eclipse, manually clean the repo, and restart eclipse. otherwise, the periodic save job will always recreate those files, even though the projects are no longer in the workspace.

i don't have an exact reproduction guide, as i'm not reliably able to reproduce here. it seems to depend on the periodic save job somehow...? :S
Comment 5 Matthias Sohn CLA 2012-02-16 07:51:31 EST
reopened on Markus' request
Comment 6 Matthias Sohn CLA 2012-02-16 07:53:52 EST
Markus: which version are you using here ?
Comment 7 Markus Duft CLA 2012-02-16 11:13:27 EST
(In reply to comment #6)
> Markus: which version are you using here ?

happens with builds of most recent master, all nightly's and my self-built ones.

maybe a special situation: we have a 400MB git repo with >600 projects, and the re-indexing, updating, etc. takes many many seconds for one go over the repo. It seems like somehow the periodic workspace save job interferes with the refreshing, deleting, and whatever that egit does in this cases.

however: i checked the code, and actually i _think_ that at least egit does everything right, because the scheduling rule for the job says to lock the whole workspace. i could not find any reasonable code path that would cause the problem - still it must exist, as the problem is there ... :S
Comment 8 Markus Duft CLA 2012-03-12 10:40:27 EDT
actually, an easy way for me to reproduce this is to run the UI tests for EGit :)

last lines in the console output are these i just noticed:

!ENTRY org.eclipse.ui.ide 4 4 2012-03-12 15:36:47.668
!MESSAGE Problems saving workspace

!ENTRY org.eclipse.ui.ide 2 1 2012-03-12 15:36:47.669
!MESSAGE Problems occurred while trying to save the state of the workbench.
!SUBENTRY 1 org.eclipse.core.resources 2 234 2012-03-12 15:36:47.669
!MESSAGE The project description file (.project) for 'EmptyProject' was missing.  This file contains important information about the project.  A new project description file has been created, but some information about the project may have been lost.
Comment 9 Robin Rosenberg CLA 2013-03-30 19:43:50 EDT
Perhaps the only way is to hook into the resources API and delete resources,
including projects that way.