cgit patch : make scan-path guess default branch

Lars Hjemli hjemli at gmail.com
Thu Mar 10 18:41:22 CET 2011


[Added cgit list to cc, sorry for the late reply]

On Tue, Mar 1, 2011 at 13:24, Matthieu CASTET
<matthieu.castet at parrot.com> wrote:
> this patch make scan-tree parse HEAD file to guess the default branch.
>
> It is not perfect, but it does what I wanted on my repository.

I've received a very similar patch today, and your patch has the same
problems. Please see
http://hjemli.net/pipermail/cgit/2011-March/000037.html

> diff --git a/scan-tree.c b/scan-tree.c
> index a0e09ce..125adec 100644
> --- a/scan-tree.c
> +++ b/scan-tree.c
> @@ -122,6 +122,16 @@ static void add_repo(const char *base, const char
> *path, repo_config_fn fn)
>        if (!stat(p, &st))
>                readfile(p, &repo->desc, &size);
>
> +       p = fmt("%s/HEAD", path);
> +       if (!stat(p, &st)) {
> +               int skip = strlen("ref: refs/heads/");
> +               readfile(p, &repo->defbranch, &size);
> +               if (size > skip) {
> +                       repo->defbranch[size-1] = '\0';
> +                       repo->defbranch += skip;
> +               }
> +       }
> +
>        if (!repo->readme) {
>                p = fmt("%s/README.html", path);
>                if (!stat(p, &st))
>
>




More information about the CGit mailing list