"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Kurt Mosiejczuk <kurt@cranky.work>
Subject:
Defaulting primary branch name to "main"
To:
gameoftrees <gameoftrees@openbsd.org>
Date:
Tue, 29 Oct 2019 13:24:01 -0400

Download raw body.

Thread
OpenBSD cvs works on the "MAIN" branch by default. This diff moves got
to using "main" by default rather than "master". As a side benefit, it
also avoids using the potentially loaded term "master".

I'm having trouble with the regression test test_import_requires_new_branch.
I'm not seeing why it fails. I did verify it doesn't fail before my changes
though. Maybe someone can point out what I broke.

--Kurt

diff --git a/got/got.1 b/got/got.1
index 703e42f..d68cdb3 100644
--- a/got/got.1
+++ b/got/got.1
@@ -109,9 +109,9 @@ are as follows:
 Create the specified
 .Ar branch
 instead of creating the default branch
-.Dq master .
+.Dq main .
 Use of this option is required if the
-.Dq master
+.Dq main
 branch already exists.
 .It Fl m Ar message
 Use the specified log message when creating the new commit.
@@ -1380,10 +1380,10 @@ In a work tree or a git repository directory, list all branch references:
 In a work tree or a git repository directory, create a new branch called
 .Dq unified-buffer-cache
 which is forked off the
-.Dq master
+.Dq main
 branch:
 .Pp
-.Dl $ got branch unified-buffer-cache master
+.Dl $ got branch unified-buffer-cache main
 .Pp
 Switch an existing work tree to the branch
 .Dq unified-buffer-cache .
@@ -1427,20 +1427,20 @@ to be amended and perhaps committed again:
 .Dl $ # now back out the previous backout :-)
 .Dl $ got backout unified-buffer-cache
 .Pp
-Fetch new upstream commits into the local repository's master branch.
+Fetch new upstream commits into the local repository's main branch.
 This step currently requires
 .Xr git 1 :
 .Pp
 .Dl $ cd /var/git/src.git
-.Dl $ git fetch origin master:master
+.Dl $ git fetch origin main:main
 .Pp
 Rebase the
 .Dq unified-buffer-cache
 branch on top of the new head commit of the
-.Dq master
+.Dq main
 branch.
 .Pp
-.Dl $ got update -b master
+.Dl $ got update -b main
 .Dl $ got rebase unified-buffer-cache
 .Pp
 Create a patch from all changes on the unified-buffer-cache branch.
@@ -1448,14 +1448,14 @@ The patch can be mailed out for review and applied to
 .Ox Ns 's
 CVS tree:
 .Pp
-.Dl $ got diff master unified-buffer-cache > /tmp/ubc.diff
+.Dl $ got diff main unified-buffer-cache > /tmp/ubc.diff
 .Pp
 Edit the entire commit history of the
 .Dq unified-buffer-cache
 branch:
 .Pp
 .Dl $ got update -b unified-buffer-cache
-.Dl $ got update -c master
+.Dl $ got update -c main
 .Dl $ got histedit
 .Pp
 Additional steps are necessary if local changes need to be pushed back
@@ -1509,54 +1509,54 @@ repository with
 .Dl $ git fetch
 .Pp
 Before outgoing changes on the local
-.Dq master
+.Dq main
 branch can be pushed to the remote repository, the local
-.Dq master
+.Dq main
 branch must be rebased onto the
-.Dq origin/master
+.Dq origin/main
 branch:
 .Pp
-.Dl $ got update -b origin/master
-.Dl $ got rebase master
+.Dl $ got update -b origin/main
+.Dl $ got rebase main
 .Pp
 Changes on the local
-.Dq master
+.Dq main
 branch can then be pushed to the remote
 repository with
 .Cm git push :
 .Pp
 .Dl $ cd /var/git/repo
-.Dl $ git push origin master
+.Dl $ git push origin main
 .Pp
 In order to merge changes committed to the
 .Dq unified-buffer-cache
 branch back into the
-.Dq master
+.Dq main
 branch, the
 .Dq unified-buffer-cache
 branch must first be rebased onto the
-.Dq master
+.Dq main
 branch:
 .Pp
-.Dl $ got update -b master
+.Dl $ got update -b main
 .Dl $ got rebase unified-buffer-cache
 .Pp
 Changes on the
 .Dq unified-buffer-cache
 branch can now be made visible on the
-.Dq master
+.Dq main
 branch with
 .Cm got integrate .
 Because the rebase operation switched the work tree to the
 .Dq unified-buffer-cache
 branch, the work tree must be switched back to the
-.Dq master
+.Dq main
 branch before the
 .Dq unified-buffer-cache
 branch can be integrated into
-.Dq master :
+.Dq main :
 .Pp
-.Dl $ got update -b master
+.Dl $ got update -b main
 .Dl $ got integrate unified-buffer-cache
 .Pp
 .Sh SEE ALSO
diff --git a/got/got.c b/got/got.c
index a6420b5..9d1c786 100644
--- a/got/got.c
+++ b/got/got.c
@@ -574,7 +574,7 @@ cmd_import(int argc, char *argv[])
 	const struct got_error *error = NULL;
 	char *path_dir = NULL, *repo_path = NULL, *logmsg = NULL;
 	char *gitconfig_path = NULL, *editor = NULL, *author = NULL;
-	const char *branch_name = "master";
+	const char *branch_name = "main";
 	char *refname = NULL, *id_str = NULL, *logmsg_path = NULL;
 	struct got_repository *repo = NULL;
 	struct got_reference *branch_ref = NULL, *head_ref = NULL;
diff --git a/lib/repository.c b/lib/repository.c
index 22355c1..23d2de6 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -1015,7 +1015,7 @@ got_repo_init(const char *repo_path)
 	};
 	const char *description_str = "Unnamed repository; "
 	    "edit this file 'description' to name the repository.";
-	const char *headref_str = "ref: refs/heads/master";
+	const char *headref_str = "ref: refs/heads/main";
 	const char *gitconfig_str = "[core]\n"
 	    "\trepositoryformatversion = 0\n"
 	    "\tfilemode = true\n"
diff --git a/regress/cmdline/import.sh b/regress/cmdline/import.sh
index a7b1c1d..a86064c 100755
--- a/regress/cmdline/import.sh
+++ b/regress/cmdline/import.sh
@@ -38,7 +38,7 @@ function test_import_basic {
 	echo "A  $testroot/tree/epsilon/zeta" >> $testroot/stdout.expected
 	echo "A  $testroot/tree/alpha" >> $testroot/stdout.expected
 	echo "A  $testroot/tree/beta" >> $testroot/stdout.expected
-	echo "Created branch refs/heads/master with commit $head_commit" \
+	echo "Created branch refs/heads/main with commit $head_commit" \
 		>> $testroot/stdout.expected
 
 	cmp -s $testroot/stdout.expected $testroot/stdout
@@ -60,7 +60,7 @@ function test_import_basic {
 
 	echo "-----------------------------------------------" \
 		> $testroot/stdout.expected
-	echo "commit $head_commit (master)" >> $testroot/stdout.expected
+	echo "commit $head_commit (main)" >> $testroot/stdout.expected
 	echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
 	echo " " >> $testroot/stdout.expected
 	echo " init" >> $testroot/stdout.expected
@@ -187,7 +187,7 @@ function test_import_ignores {
 
 	local head_commit=`git_show_head $testroot/repo`
 	echo "A  $testroot/tree/beta" >> $testroot/stdout.expected
-	echo "Created branch refs/heads/master with commit $head_commit" \
+	echo "Created branch refs/heads/main with commit $head_commit" \
 		>> $testroot/stdout.expected
 
 	cmp -s $testroot/stdout.expected $testroot/stdout
@@ -217,7 +217,7 @@ function test_import_empty_dir {
 
 	local head_commit=`git_show_head $testroot/repo`
 	echo "A  $testroot/tree/notempty/alpha" >> $testroot/stdout.expected
-	echo "Created branch refs/heads/master with commit $head_commit" \
+	echo "Created branch refs/heads/main with commit $head_commit" \
 		>> $testroot/stdout.expected
 
 	cmp -s $testroot/stdout.expected $testroot/stdout