[PATCH] use main as default branch instead of master

Derek Stevens nilix at nilfm.cc
Sun Jan 9 01:45:45 UTC 2022


Signed-off-by: Derek Stevens <nilix at nilfm.cc>
---
 cgit.c        | 2 +-
 cgitrc.5.txt  | 2 +-
 ui-repolist.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cgit.c b/cgit.c
index 08d81a1..5b0a016 100644
--- a/cgit.c
+++ b/cgit.c
@@ -489,7 +489,7 @@ static char *guess_defbranch(void)
 
 	ref = resolve_ref_unsafe("HEAD", 0, &oid, NULL);
 	if (!ref || !skip_prefix(ref, "refs/heads/", &refname))
-		return "master";
+		return "main";
 	return xstrdup(refname);
 }
 
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 33a6a8c..9639156 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -479,7 +479,7 @@ 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.
+	"main" if there is no suitable HEAD.
 
 repo.desc::
 	The value to show as repository description. Default value: none.
diff --git a/ui-repolist.c b/ui-repolist.c
index 529a203..c162290 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -53,7 +53,7 @@ static int get_repo_modtime(const struct cgit_repo *repo, time_t *mtime)
 
 	strbuf_reset(&path);
 	strbuf_addf(&path, "%s/refs/heads/%s", repo->path,
-		    repo->defbranch ? repo->defbranch : "master");
+		    repo->defbranch ? repo->defbranch : "main");
 	if (stat(path.buf, &s) == 0) {
 		*mtime = s.st_mtime;
 		r->mtime = *mtime;
-- 
2.34.1



More information about the CGit mailing list