[PATCH 1/5] guess default branch from HEAD
plenz at cis.fu-berlin.de
Wed Mar 16 11:53:06 CET 2011
* Lars Hjemli <hjemli at gmail.com> [2011-03-10 18:24]:
> On Thu, Mar 10, 2011 at 17:03, Julius Plenz <plenz at cis.fu-berlin.de> wrote:
> > This is a saner alternative than hardcoding the default branch to be
> > "master". The add_repo() function will now check for a symbolic ref in
> > repo_path/HEAD. If there is a suitable one, overwrite repo->defbranch
> > with it.
> I agree with the motivation, but...
> > + fd = open(fmt("%s/HEAD", repo->path), O_RDONLY);
> ...since git supports fs links, you'll need to lstat() and then
> either readlink() or read_in_full(). And if you readlink(), you'll
> obviously need to parse the result differently.
I just tried this out:
$ cd /repositories/...
$ mv HEAD head
$ ln -s head HEAD
The patch handles that just fine (it wouldn't if I were to add the
O_NOFOLLOW flag); however, git complains:
$ git rev-list -1 HEAD
fatal: Not a git repository (or any parent up to mount parent )
With hardlinks, neither git complains, nor the patch fails.
More information about the CGit