On Thu, Apr 7, 2011 at 12:49, Julius Plenz <[email protected]> wrote:
> Hi, Lars!
>
> * Lars Hjemli <[email protected]> [2011-04-07 11:46]:
>> This seems like a workable solution, but with two issues:
>> * The feature only works for repos added by scan-path
>> * I prefer to declare variables at the start of the function
>
> I did some simple refactoring. See attached patch.
>
> There is a function guess_defbranch now, which in any case returns a
> char* (which is "master" in fallthrough cases). So you can use it in
> any place you like.

Great, thanks. I actually think it only needs to be invoked once, in
prepare_repo_cmd():

@@ -421,6 +421,7 @@ static int prepare_repo_cmd(struct cgit_context *ctx)
        }
        ctx->page.title = fmt("%s - %s", ctx->repo->name, ctx->repo->desc);

+       ctx->repo->defbranch = guess_defbranch(ctx->repo->path);
        if (!ctx->qry.head) {
                ctx->qry.nohead = 1;
                ctx->qry.head = find_default_branch(ctx->repo);

-- 
larsh

_______________________________________________
cgit mailing list
[email protected]
http://hjemli.net/mailman/listinfo/cgit

Reply via email to