Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331890 - Branch is lost after commit
Summary: Branch is lost after commit
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: Core (show other bugs)
Version: 0.10.0   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Jens Baumgart CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-06 07:38 EST by Jens Baumgart CLA
Modified: 2010-12-06 18:56 EST (History)
1 user (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-12-06 07:38:09 EST
I tried to commit my last change. The commit failed and my local branch is gone with all my changes.
The error in the log:
!ENTRY org.eclipse.egit.ui 4 0 2010-12-03 16:42:49.023
!MESSAGE Committing failed
!STACK 1
org.eclipse.team.core.TeamException: Failed to update HEAD to commit AnyObjectId[6e24cb7ec8a73746e515f49be833eb18911eb165].
        at org.eclipse.egit.core.op.CommitOperation.doCommits(CommitOperation.java:344)
        at org.eclipse.egit.core.op.CommitOperation.access$8(CommitOperation.java:281)
        at org.eclipse.egit.core.op.CommitOperation$1.run(CommitOperation.java:178)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1782)
        at org.eclipse.egit.core.op.CommitOperation.execute(CommitOperation.java:192)
        at org.eclipse.egit.ui.internal.actions.CommitActionHandler$1.run(CommitActionHandler.java:187)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
!SUBENTRY 1 org.eclipse.team.core 4 0 2010-12-03 16:42:49.023
!MESSAGE Failed to update HEAD to commit AnyObjectId[6e24cb7ec8a73746e515f49be833eb18911eb165].
 
What I have done:
        
1.	EGit version 0.9.3
2.	I had local branch different then the master.
3.	I changed some files
4.	Team->Commit -> Amend previous commit.
5.	When I tried to commit the error appeared.
6.	Now the local branch is gone – I don’t have active branch at the moment:
7.	At the moment in the log I see NPE – it seems because I don’t have local active branch now and all my files has icon “+”.
Comment 1 Jens Baumgart CLA 2010-12-06 07:47:05 EST
CommitOperation fails in line 343:

if (ru.forceUpdate() == RefUpdate.Result.LOCK_FAILURE) 

We could reproduce the scenario by simulating the following in LockFile.commit

1. Deleting the original file succeeds.
2. Renaming the temporary file fails.

Workaround
==========

1. The commit is not lost. You can create a new branch pointing to it using the command line:

Exit Eclipse
git checkout -b tmpbranch 6e24cb7ec8a73746e515f49be833eb18911eb165
The id of the commit is taken from the error log.

2. Check your .git directory \.git\refs\heads
Is there a file <branchname>.lock and the corresponding file <branchname> is missing? 
If yes: delete branchname.lock.
Comment 2 Jens Baumgart CLA 2010-12-06 07:54:21 EST
Fix proposed: http://egit.eclipse.org/r/2049
Comment 3 Shawn Pearce CLA 2010-12-06 18:56:03 EST
Fix committed to JGit as cbf5ff6ac7762e2b7170edae9d1563ae3869544a