This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 242207 - Project corrupted after hard reset
Summary: Project corrupted after hard reset
Status: RESOLVED WONTFIX
Alias: None
Product: projects
Classification: Unclassified
Component: Ant Project (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P4 normal (vote)
Assignee: Tomas Stupka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-22 01:01 UTC by janrossler
Modified: 2016-07-07 08:37 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Complete log before/after bug occurs (115.25 KB, text/plain)
2014-02-23 01:04 UTC, janrossler
Details
Corrupted project.xml (633 bytes, application/xml)
2014-02-23 13:03 UTC, janrossler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description janrossler 2014-02-22 01:01:56 UTC
Git reset --hard corrupts the NB project if used on non-HEAD commit.

Steps to reproduce:
1) Open a project under Git revision
2) Right-click the project and select Git -> Revert/Recover -> Reset..
3) In the "Git Reset" window, select a previous commit (not HEAD)
4) Select option "Update Index and Working Tree (--hard)" and press the "Reset" button

Result: All source files disappear and the project is no longer usable within Netbeans. 

Expected Results: Project should remain usable.

Additional Information: I have checked the netbeans project folder and found out the project files are still there albeit renamed - both have the string "~ORIGINAL" appended. Manually renaming these files fixes the problem (project.properties, project.xml).
Comment 1 Ondrej Vrabec 2014-02-22 06:52:09 UTC
It doesn't happen to me. I followed the exact steps and nothing wrong happened. Start with attaching the IDE log after your project disappears [1].
Are source files also renamed? Or is it just a problem of project metadata files? Are they committed into the repository? What is the result of 'git status' after the reset?

[1] - http://wiki.netbeans.org/FaqLogMessagesFile
Comment 2 janrossler 2014-02-23 01:04:37 UTC
Created attachment 145500 [details]
Complete log before/after bug occurs

I have attached my complete IDE log, during which the corruption happened. The affected project is named "unis_core" and it is a local PHP project. I am currently unable to reproduce this on any other project, however, I have had the same issue happen once before.

As for your questions: The actual source files are not renamed and are reset correctly, only the two metadata files were renamed - project.properties, project.xml. The metadata files were not committed, but they now appear as untracked files (normally, they should be ignored). Other than that, git status shows no changes.
Comment 3 Ondrej Vrabec 2014-02-23 08:05:45 UTC
> The metadata files were not committed, but they now appear as untracked files (normally, they should be ignored).
How do you ignore them? Paste here the content of .gitignore file, thanks.
The same happens to me when:
1) a file is ignored
2) yet it is added to index (scheduled for commit by a previous git add)
3) now git reset --hard removes that file - *even with the commandline client*
So it is possible your project files were already scheduled for commit. Are you able to reproduce this without adding them to index?

BTW ide log says:
> CONFIG [null]: Parse error in file file:/C:/xampp/htdocs/unis_core/nbproject/project.xml line 10 column 2 (PUBLIC null)
> INFO: The markup in the document following the root element must be well-formed.
> org.xml.sax.SAXParseException; systemId: file:/C:/xampp/htdocs/unis_core/nbproject/project.xml; lineNumber: 10; columnNumber: 2; The markup in the document following the root element must be well-formed.
So it may be your project files are corrupted
Comment 4 janrossler 2014-02-23 13:03:07 UTC
Created attachment 145512 [details]
Corrupted project.xml

> How do you ignore them?
Sorry I was quite unclear, I don't have them ignored. I meant they normally appear as unchecked in the Netbeans commit window (because I always exclude them), but were checked after the reset.
In my .gitignore, I have ignored only the private folder "/nbproject/private/", which is not corrupted. The corrupted files were neither ignored by .gitignore nor scheduled for commit by git add.

> So it may be your project files are corrupted
I have attached my project.xml file, this is how it looks like after the reset. It seems like two different projects are mashed together in the file (unis, unis_core). This corruption happened during the same IDE session as the attached log. 

Shortly before the reset, I have applied a patch exported from project "unis" to the project "unis_core". This has probably caused the actual corruption, but it went unnoticed until I tried to use reset. The patch was generated from Netbeans with the option "Export Uncommitted Changes" and the project files are uncommitted in both projects..
Comment 5 Ondrej Vrabec 2014-02-23 18:11:15 UTC
The project.xml file seems to be kind corrupted. Another thing i wonder is why the exception comes from:
[catch] at org.netbeans.spi.project.support.ant.AntProjectHelper.loadXml(AntProjectHelper.java:311)
	at org.netbeans.spi.project.support.ant.AntProjectHelper.getConfigurationXml(AntProjectHelper.java:264)
...
when the project is a php one. Is it OK for php projects to trigger ant support? Passing to ant projects for evaluation. Git reset does not delete the files, they were already deleted/corrupted and project system just realized this too late.
But this looks like a user error, applying a patch modifying project metadata (when the patch actually comes from a different project) sounds like a suicidal game.
Comment 6 Martin Balin 2016-07-07 08:37:26 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss