[PATCH v2] guess default branch from HEAD
Lars Hjemli
hjemli at gmail.com
Thu Apr 7 13:05:52 CEST 2011
On Thu, Apr 7, 2011 at 12:49, Julius Plenz <plenz at cis.fu-berlin.de> wrote:
> Hi, Lars!
>
> * Lars Hjemli <hjemli at gmail.com> [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
More information about the CGit
mailing list