git fetch fails silently if remote repo is not checked out on any branch

Bug #1335638 reported by Andrey Gelman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
git (Ubuntu)
New
Undecided
Unassigned

Bug Description

Reproduction steps:
1) Create a git repository that has no branches at all (detached HEAD and no branches).
2) Let this repository serve as a remote to another repository.
   Now, 'git fetch <name>' fails silently.

Notes:
1) If it cannot succeed, let it fail loudly at least, if possible providing a useful hint.
2) A repository with no branches at all is not that rare thing as one might think - e.g. clone AOSP (Android Open Source Project) - every one of its git repos is checked out at some point with no branches at all.
3) I have built git version 2 - the bug is still there.

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: git 1:1.9.1-1
ProcVersionSignature: Ubuntu 3.13.0-29.53-generic 3.13.11.2
Uname: Linux 3.13.0-29-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 2.14.1-0ubuntu3.2
Architecture: amd64
CurrentDesktop: Unity
Date: Sun Jun 29 18:25:16 2014
InstallationDate: Installed on 2011-10-23 (980 days ago)
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111011)
SourcePackage: git
UpgradeStatus: Upgraded to trusty on 2014-05-25 (35 days ago)

Revision history for this message
Andrey Gelman (andrey-gelman) wrote :
Revision history for this message
Anders Kaseorg (andersk) wrote :

I believe Git is working as designed. You asked it to fetch the empty set of branches, so that’s what it did.

It is slightly confusing that, in the normal non-detached case, ‘git clone’ creates the refs/remotes/origin/HEAD symref pointing to the remote’s default branch; however, even in this case, ‘git fetch’ does not update it.

If you think the design is wrong, you may want to bring this up with the upstream developers.

But I don’t believe that the AOSP repositories have no branches. They look completely normal to me.

$ git clone https://android.googlesource.com/platform/packages/apps/Email
$ cd Email
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/donut-release
  remotes/origin/donut-release2
  remotes/origin/eclair-passion-release
  […]
  remotes/origin/master
  remotes/origin/tools_r20
  remotes/origin/tools_r21
  remotes/origin/tools_r22
  remotes/origin/tools_r22.2

I think the answer is that you should not create repositories with no branches.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.