diff options
| author | Lars Hjemli <hjemli@gmail.com> | 2012-03-18 21:00:18 +0000 | 
|---|---|---|
| committer | Lars Hjemli <hjemli@gmail.com> | 2012-03-18 21:00:18 +0000 | 
| commit | 181b6e789b79fc385e5ec75b2b83f01192d54051 (patch) | |
| tree | 8888b5eb9c6674b69bcb8f508f9d6f548fc1fed3 /cgit.c | |
| parent | Merge branch 'lh/module-links' (diff) | |
| parent | ui-repolist.c: fallback to "master" if no default branch is specified (diff) | |
| download | cgit-181b6e789b79fc385e5ec75b2b83f01192d54051.tar.gz cgit-181b6e789b79fc385e5ec75b2b83f01192d54051.tar.bz2 cgit-181b6e789b79fc385e5ec75b2b83f01192d54051.zip | |
Merge branch 'jp/defbranch'
Diffstat (limited to '')
| -rw-r--r-- | cgit.c | 15 | 
1 files changed, 14 insertions, 1 deletions
| @@ -421,6 +421,17 @@ char *find_default_branch(struct cgit_repo *repo)  	return ref;  } +static char *guess_defbranch(const char *repo_path) +{ +	const char *ref; +	unsigned char sha1[20]; + +	ref = resolve_ref("HEAD", sha1, 0, NULL); +	if (!ref || prefixcmp(ref, "refs/heads/")) +		return "master"; +	return xstrdup(ref + 11); +} +  static int prepare_repo_cmd(struct cgit_context *ctx)  {  	char *tmp; @@ -447,10 +458,12 @@ static int prepare_repo_cmd(struct cgit_context *ctx)  	}  	ctx->page.title = fmt("%s - %s", ctx->repo->name, ctx->repo->desc); +	if (!ctx->repo->defbranch) +		ctx->repo->defbranch = guess_defbranch(ctx->repo->path); +  	if (!ctx->qry.head) {  		ctx->qry.nohead = 1;  		ctx->qry.head = find_default_branch(ctx->repo); -		ctx->repo->defbranch = ctx->qry.head;  	}  	if (!ctx->qry.head) { | 
