Bug 395351 - Deleting repo from Git Repositories deletes .git directory, even when the 'also delete content' checkbox isn't ticked
Summary: Deleting repo from Git Repositories deletes .git directory, even when the 'al...
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 1.3   Edit
Hardware: PC Windows 7
: P3 major with 1 vote (vote)
Target Milestone: 3.0.2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted, usability
Depends on:
Blocks:
 
Reported: 2012-11-29 02:28 EST by Michael Scheper CLA
Modified: 2013-08-26 02:19 EDT (History)
5 users (show)

See Also:


Attachments
proposed explicit delete dialog (33.36 KB, image/png)
2013-08-08 12:13 EDT, Robin Stocker CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Scheper CLA 2012-11-29 02:28:10 EST
1. Select a repo under Git Repositories in EGit

2. Press the Delete key. A dialogue box appears to confirm whether the user wants to remove the repo.

3. Leave 'Also delete repository content in working directory...' UNTICKED.

4. Click OK.

Expected behaviour: For the repo to be removed from Eclipse, but nothing to actually be deleted.

Actual behaviour: The .git directory is deleted, along with two days' worth of my work in unpushed branches. (I wasn't able to push because of another bug; I was trying to remove the repo from Eclipse and reimport it, to see if that would fix the problem I was having. Now I have a much bigger problem.)

Notes: Yes, the dialogue box does include the name of the .git directory in the title. However, elsewhere in Eclipse, e.g. the Project Explorer, when an item is deleted with the 'also delete from disk' checkbox unticked, nothing is actually deleted when it is removed from Eclipse. The fact that it displays the name of the .git directory, and not just the repo, is an easily overlooked detail. Also, since the .git directory normally is *in* the working directory, it's fair for users to assume it would be included in the 'working directory content' they're electing to preserve.

Suggested fix: If the intent of this operation really is for the .git directory to be deleted, there should be a second checkbox for this purpose. When it's ticked, the .git directory should actually be deleted, but when it's not, the repo should simply removed from Eclipse. This would make the latter operation possible, and clarify what will happen—a checkbox is less easily overlooked.

Additional suggestion: I'm not normally an advocate for 'are you sure' dialogues, but one would be appropriate in this case, because the operation is unusual and potentially catastrophic. It should be worded to ensure users know there's no way to recover unpushed changes on other branches if the .git directory is deleted. I may know this, but it's clear from various forums that a lot of Git users don't.
Comment 1 Tom Deering CLA 2013-07-22 14:18:07 EDT
Also affects EGit 3.0 on Eclipse Kepler, Linux.

It is a MAJOR annoyance to have EGit clobbering the .git directory whenever a repository is removed from the view... upvoted.
Comment 2 Robin Stocker CLA 2013-08-08 09:30:02 EDT
See also bug 393332 comment 15. The problem summed up:

In the context menu, there is both a "Remove Repository from View" and a "Delete Repository...". The former just removes from view, the latter deletes the .git in any case.

When pressing the Delete key, the dialog of "Delete Repository..." is shown. As opposed to other Eclipse behavior, just removing it from the view is not possible with the Delete key.

Proposed solution:

When pressing the Delete key, bring up a dialog with Cancel and two buttons, "Remove Repository from View" and "Delete Repository...".

In addition to that, the labels in the "Delete Repository" dialog could be made more clear. Instead of in the description, there could also be an explicit checkbox "Delete repository data in foo/bar/.git". When it's not selected (default), the dialog can not be confirmed.

Thoughts on this?
Comment 3 Matthias Sohn CLA 2013-08-08 09:51:53 EDT
your proposal sounds good to me
Comment 4 Robin Stocker CLA 2013-08-08 10:47:42 EDT
(In reply to comment #2)
> When pressing the Delete key, bring up a dialog with Cancel and two buttons,
> "Remove Repository from View" and "Delete Repository...".

Please review: https://git.eclipse.org/r/15252
Comment 5 Tom Deering CLA 2013-08-08 10:48:44 EDT
I can't think of a good reason why someone would expect "delete repository" to remove only the hidden .git folder and preserve the data. To me, this command suggests that the entire directory, data and all, should be deleted. Thoughts?

In any case, there seem to be three distinct operations (assuming someone disagrees with me on the above):

1) Remove repo from view
2) Delete .git folder from repo
3) Delete entire repo directory

The trouble we're reporting here is that attempting to accomplish #1 may accidentally result in #2. As long as the proposed solution remedies this, sounds good to me.
Comment 6 Robin Stocker CLA 2013-08-08 12:13:55 EDT
Created attachment 234203 [details]
proposed explicit delete dialog

Second change for making the "Delete Repository..." dialog more explicit (see screenshot):

https://git.eclipse.org/r/15255
Comment 7 Robin Stocker CLA 2013-08-08 12:16:19 EDT
(In reply to comment #5)
> I can't think of a good reason why someone would expect "delete repository"
> to remove only the hidden .git folder and preserve the data. To me, this
> command suggests that the entire directory, data and all, should be deleted.
> Thoughts?

Well, maybe you found out that you didn't need version control for the project or it was created at the wrong location.

See proposed change which should make it more clear what the dialog does.

> In any case, there seem to be three distinct operations (assuming someone
> disagrees with me on the above):
> 
> 1) Remove repo from view
> 2) Delete .git folder from repo
> 3) Delete entire repo directory
> 
> The trouble we're reporting here is that attempting to accomplish #1 may
> accidentally result in #2. As long as the proposed solution remedies this,
> sounds good to me.

Yes, this should be fixed by asking whether to do 1 or 2/3 when just pressing the Delete key, see first change.
Comment 8 Tom Deering CLA 2013-08-08 12:25:09 EDT
LGTM
Comment 9 Matthias Sohn CLA 2013-08-10 19:40:14 EDT
(In reply to comment #4)
> (In reply to comment #2)
> > When pressing the Delete key, bring up a dialog with Cancel and two buttons,
> > "Remove Repository from View" and "Delete Repository...".
> 
> Please review: https://git.eclipse.org/r/15252

merged as 354fa7a5af0dd8d759c7e6516b0e8cf0a73dd513
Comment 10 Matthias Sohn CLA 2013-08-12 17:57:56 EDT
(In reply to comment #6)
> Second change for making the "Delete Repository..." dialog more explicit
> (see screenshot):
> 
> https://git.eclipse.org/r/15255

merged as 52218b828cf03abf6df0fc1d99e34cb20a51d2f6
Comment 11 Robin Stocker CLA 2013-08-13 04:30:15 EDT
Thanks Matthias (and sorry for being kind of a pain on the review).
Comment 12 Matthias Sohn CLA 2013-08-26 02:19:39 EDT
cherry-picked for 3.0.2