aboutsummaryrefslogtreecommitdiff
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
-rw-r--r--cgit.c15
-rw-r--r--cgitrc.5.txt3
-rw-r--r--shared.c1
-rw-r--r--ui-repolist.c3
4 files changed, 4 insertions, 18 deletions
diff --git a/cgit.c b/cgit.c
index 6a75f27..7e3d349 100644
--- a/cgit.c
+++ b/cgit.c
@@ -421,17 +421,6 @@ 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;
@@ -458,12 +447,10 @@ 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) {
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index fab0e0a..b4ad2ac 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -377,8 +377,7 @@ repo.commit-filter::
repo.defbranch::
The name of the default branch for this repository. If no such branch
exists in the repository, the first branch name (when sorted) is used
- as default instead. Default value: branch pointed to by HEAD, or
- "master" if there is no suitable HEAD.
+ as default instead. Default value: "master".
repo.desc::
The value to show as repository description. Default value: none.
diff --git a/shared.c b/shared.c
index 0a0e22e..cb52380 100644
--- a/shared.c
+++ b/shared.c
@@ -55,6 +55,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret->desc = "[no description]";
ret->owner = NULL;
ret->section = ctx.cfg.section;
+ ret->defbranch = "master";
ret->snapshots = ctx.cfg.snapshots;
ret->enable_commit_graph = ctx.cfg.enable_commit_graph;
ret->enable_log_filecount = ctx.cfg.enable_log_filecount;
diff --git a/ui-repolist.c b/ui-repolist.c
index d946f32..a09a689 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -45,8 +45,7 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime)
return 1;
}
- path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch ?
- repo->defbranch : "master");
+ path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch);
if (stat(path, &s) == 0) {
*mtime = s.st_mtime;
r->mtime = *mtime;