[PATCH] guess default branch from HEAD

larsh at hjemli.net larsh at hjemli.net
Mon Jun 13 12:16:22 CEST 2011


On Fri, Jun 10, 2011 at 06:42:51AM +0000, chris wrote:
> Julius Plenz <plenz at ...> writes:
> > 
> > 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. Note that you'll need to strip the newline from the file (->
> > len-17).
> > 
> > If HEAD is a symbolic link pointing directly to a branch below
> > refs/heads/, do a readlink() instead to find the ref name.
> > 
> > Signed-off-by: Julius Plenz <plenz at ...>
> 
> I've successfully applied this patch against the current stable branch (commit: 
> 2a8f5531) and deployed the resulting binary without trouble.  The functionality 
> appears to work as advertised.  So, along with setting the default 'readme'
> value as:
> 
> readme=HEAD:README.md
> 
> each project is able to have a sensible default presentation based off of the 
> project's default branch.  Very useful as we use gitolite to manage our 
> repositories, this saves us further manual configuration outside of gitolite.
> 

Thanks for testing.

> I hope this patch can be integrated into the official release.

The last issue with this patch is that it invokes guess_defbranch() once
per repository during scan-path processing, but never for repositories
added manually to cgitrc. I think it shouldn't be invoked at all
during scan-path but instead just once when a repo page has been
selected, i.e. in prepare_repo_cmd(). I can add a fixup patch on top
of the patch from Julius if there's no objections to this plan.

--
larsh




More information about the CGit mailing list