Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337556 - Adding (and later deleting) a git repo directly in the eclipse workspace is a very bad idea
Summary: Adding (and later deleting) a git repo directly in the eclipse workspace is a...
Status: CLOSED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 0.11   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Stefan Lay CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-18 06:35 EST by Kay Huber CLA
Modified: 2013-09-27 13:11 EDT (History)
3 users (show)

See Also:


Attachments
dialog presented when deleting a repository (18.07 KB, image/png)
2011-02-18 08:21 EST, Kay Huber CLA
no flags Details
dialog presented after confirming delection of "working directory" (21.50 KB, image/png)
2011-02-18 08:22 EST, Kay Huber CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kay Huber CLA 2011-02-18 06:35:17 EST
Currently it is well possible to add a .git repository directly in the current eclipse workspace. Even "worse", this is the default behaviour, if I have a project created in the workspace, add it to git and thus create a local repository.

Doing so is actually a very bad idea. At the latest when the repository is deleted, but possibly also when changing branches (I didn't test that...) git will actually try to remove everything in the workspace - including the .metadata directory.

I suggest a warning if a git repository is created in the current workspace (if it is being created in other workspaces than the current, "help texts" in the creation wizard may help...). Also I'd suggest a different default behaviour when creating a local git repo "on the fly" when sharing a project for the first time.
Comment 1 Stefan Lay CLA 2011-02-18 08:04:45 EST
Adding a git repo directly in the eclipse workspace is the default behavior only when you have selected more than one project in the workspace, because then EGit determines the parent directory of the projects.

I'm not sure if we need to present a warning:

- Changing the branches is no problem, at least if you have not added the .metadata directory to the repository.
- When the repository is deleted from EGit, the default is not to remove the parent folder but only to delete the projects
Comment 2 Kay Huber CLA 2011-02-18 08:20:45 EST
You're right about the first part: .git is only added directly to the workspace folder if I have multiple projects selected and share them. Nevertheless, as a starter I'm not warned nor aware of the implications of this -> I just tried again and "deleted" the git repository right after adding two projects to it. When deleting, the dialog asks whether I want to "also delete working directory" (see screenshot "egit_deleting_workspace") - when clicked this tries to remove all files, not just the projects from git (see screenshot "egit_deleting_workspace_2").
Comment 3 Kay Huber CLA 2011-02-18 08:21:40 EST
Created attachment 189269 [details]
dialog presented when deleting a repository
Comment 4 Kay Huber CLA 2011-02-18 08:22:38 EST
Created attachment 189270 [details]
dialog presented after confirming delection of "working directory"
Comment 5 Stefan Lay CLA 2011-02-18 08:43:35 EST
Maybe we should check during repo deletion if the repo is in the eclipse workspace and in that case present a warning in the "also delete working directory" dialog, or even do not present this dialog.
Comment 6 Kay Huber CLA 2011-02-18 09:05:20 EST
I agree: If the working directory of a repository is located in the current eclipse workspace then present a warning in the "also delete working directory" dialog. The dialog itself is very useful (at least for testing it is very helpful to easily get rid of a repo and all that was managed by it), I'd miss it if you drop it ;-)

As an alternative: Wouldn't it be possible to just delete, what was under control of that git repository at the time of deletion? I guess that's actually what I would expect. Losing my .metadata folder is only one bad thing: If I had other projects in that folder which I probably consciously didn't add to git would get removed with the current implementation as well... If you only remove what was tracked already, you could also skip the warning in the dialog.
Comment 7 Stefan Lay CLA 2011-03-29 08:26:00 EDT
I like the alternative idea. However, what do you expect with respect to content below a project that is not tracked, for example a bin folder? I would think that this should also be deleted.
Comment 8 Stefan Lay CLA 2011-03-30 04:56:57 EDT
Fix proposed at http://egit.eclipse.org/r/#change,2972
Comment 9 Kay Huber CLA 2011-03-30 05:57:33 EDT
In response to comment #7: I agree, I would expect that all content of a tracked project is dropped. If there is untracked "non-derived" content (not the bin folder), issuing a warning would be a good idea (probably one, that can be "don't ask me again" ticked...).
Comment 10 Robin Rosenberg CLA 2013-03-30 19:50:09 EDT
Did Stefan Lays' patch solve the issue? It was merged over a year ago.

Updated link: https://git.eclipse.org/r/#/c/4071/
Comment 11 Robin Rosenberg CLA 2013-03-30 19:50:46 EDT
Did Stefan Lays' patch solve the issue? It was merged over a year ago.

Updated link: https://git.eclipse.org/r/#/c/2972
Comment 12 Robin Stocker CLA 2013-09-27 13:11:51 EDT
This looks fixed. If not, please open a new bug report.