Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326693

Summary: Problem with CloneOperation and refs/tags/
Product: [Technology] EGit Reporter: Igor Fedorenko <igor>
Component: CoreAssignee: Stefan Lay <stefan.lay>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: matthias.sohn, stefan.lay
Version: 0.9.0   
Target Milestone: 0.10.0   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Igor Fedorenko CLA 2010-09-30 13:16:26 EDT
Even though CloneOperation manages to clone remote repo and checkout working tree when branch=refs/tags/sometag, the cloned repo is left is somewhat inconsistent state and running "git branch -a" fails with "fatal: HEAD not found below refs/heads!" message. Doing "git checkout sometag" puts the local repository back into good state as far as I can tell.
Comment 1 Stefan Lay CLA 2010-12-01 09:04:36 EST
I could reproduce that. Bit I already get an exception in the clone wizard:

java.lang.StringIndexOutOfBoundsException: String index out of range: -7
at java.lang.String.substring(String.java:1937)
at java.lang.String.substring(String.java:1904)
at org.eclipse.egit.ui.internal.clone.SourceBranchPage$1.getText(SourceBranchPage.java:128)
at org.eclipse.jface.viewers.WrappedViewerLabelProvider.getText(WrappedViewerLabelProvider.java:108)
at org.eclipse.jface.viewers.WrappedViewerLabelProvider.update(WrappedViewerLabelProvider.java:164)
at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn.java:145)
When I continue I have the same behavior as secribed by Igor. My cloned repo has no HEAD and no branches.
Comment 2 Igor Fedorenko CLA 2010-12-01 11:03:29 EST
To clarify, I was using CloneOperation directly, without using egit GUI.
Comment 3 Stefan Lay CLA 2010-12-01 12:13:10 EST
I can reproduce the error. The EGit operatoin writes ref: refs/tags/TagForDemo into the HEAD file. This seems not to work. "git checkout sometag" replaces this by the commit id and everything works.
Comment 4 Stefan Lay CLA 2010-12-02 09:53:53 EST
In the proposal http://egit.eclipse.org/r/#change,2003 we changed the API of CloneOperation. 

The former String parameter "branch" which contained the ref name of the branch to check out is replaced by a parameter of type Ref. This Ref must exist in the cloned repo. An example code how to get such a ref is e.g. in org.eclipse.egit.ui.view.repositories.GitRepositoriesViewBranchHandlingTest.beforeClass(). This should work for tags now.
Comment 5 Matthias Sohn CLA 2010-12-14 08:28:31 EST
merged as 35b7b6520355106dd62f2f241e71843a56b62503
will be shipped with 0.10