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

Bug 349664

Summary: Repository#getBranch() returns 'master' when the repo has no branches.
Product: [Technology] JGit Reporter: Szymon Brandys <Szymon.Brandys>
Component: JGitAssignee: Project Inbox <jgit.core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: pwebster, robin.rosenberg, tomasz.zarna
Version: 1.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 349663    

Description Szymon Brandys CLA 2011-06-17 05:29:04 EDT
Repository#getBranch() returns 'master' when the repo has no branches. I would expect to see 'null' or an exception.

Steps:
Try to clone git://github.com/bokowski/empty.git and check what the active branch is using #getBranch for it.
Comment 1 Robin Rosenberg CLA 2011-06-18 05:32:33 EDT
This is correct. The current branch IS master, but it has no commits and is therefore sometimes called and "unborn" branch. If you commit now, the commit will be created on the master branch.

If you want to see that the branch is unborn, just resolve it and you'll get a null.