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

Bug 339354

Summary: Decapitation error when pulling after cloning with CloneCommand
Product: [Technology] JGit Reporter: Tomasz Zarna <tomasz.zarna>
Component: JGitAssignee: Stefan Lay <stefan.lay>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: caniszczyk, stefan.lay
Version: unspecified   
Target Milestone: 0.12-M2   
Hardware: PC   
OS: Windows XP   
URL: http://egit.eclipse.org/r/2677
Whiteboard:
Bug Depends on:    
Bug Blocks: 339110, 339115, 339254    
Attachments:
Description Flags
failing test none

Description Tomasz Zarna CLA 2011-03-09 09:19:46 EST
master (0.12.x)

After creating a clone with CloneCommand I'm not able to pull. The exception I get says "HEAD is detached". 

I'm attaching a failing test. I will try to provide a fix, and when ready will submit both (test + fix) on gerrit.
Comment 1 Tomasz Zarna CLA 2011-03-09 09:21:41 EST
Created attachment 190756 [details]
failing test
Comment 2 Tomasz Zarna CLA 2011-03-09 09:49:28 EST
(In reply to comment #0)
> I will try to provide a fix, and when ready will submit both (test + fix) on gerrit.

http://egit.eclipse.org/r/2677
Comment 3 Tomasz Zarna CLA 2011-03-09 10:52:05 EST
I'm not able to do "git checkout master" on the clone neither (see bug 339254, comment 6). I'm really stuck, so bumping severity.
Comment 4 Chris Aniszczyk CLA 2011-03-09 11:28:14 EST
Thanks for investigating.
Comment 5 Stefan Lay CLA 2011-03-30 11:34:33 EDT
I suppose the reason is that the CloneCommand does not checkout a branch but the commit where HEAD points to at the remote repo. The reason is that 

final Ref head = result.getAdvertisedRef("HEAD")

does not return the name of the remotely checked out branch but only the commit ID.

In egit there is a heuristic to find the corresponding branch. However, there must be a better solution for this. I asked this question on the jgit mailing list: http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg01037.html
Comment 6 Tomasz Zarna CLA 2011-04-01 07:49:21 EDT
The current shape of the CloneCommand is going to be a show stopper for bug 339115 where I'm trying to push local changes. I found that out while writing junits for bug 339110.

Stefan, looking the the latest response from Shawn on the jgit mailing list, does it mean there is nothing we can do about it? What about the fix proposed on http://egit.eclipse.org/r/2677? Is it no good? It works for me, at least junits for bug 339110 are happy ;)
Comment 7 Stefan Lay CLA 2011-04-06 08:42:09 EDT
I proposed a change on Gerrit (http://egit.eclipse.org/r/#change,3008) which does the same as EGit does to checkout a branch after clone. This should also solve the problem of a subsequent pull.
Comment 8 Chris Aniszczyk CLA 2011-04-06 13:15:26 EDT
Fixed, thanks Stefan.