Commit e6bd4954 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Replace "master" with the value of init.defaultBranch

Also replace options and variables named "master" with "main".
parent 13fb7cd6
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ shopt -s dotglob
[[ -v DEBUG ]] && set -x || true

SCRIPT=$(basename $0)
DEFAULT_BRANCH=$(git config init.defaultBranch || echo main)
USAGE="Usage: $SCRIPT [-h] {init|clone|convert|add|mv|rm} [OPTION [OPTION ...]]

  Create 'super working trees', which are a trees of working trees. This is
@@ -39,8 +40,8 @@ USAGE="Usage: $SCRIPT [-h] {init|clone|convert|add|mv|rm} [OPTION [OPTION ...]]
$SCRIPT init [WORKTREE-BASE] [-b BRANCH[:PATH]]
  Create a new super working tree at WORKTREE-BASE (default: current directory)

  -b --branch  Create an initial branch named BRANCH (default: 'master') checked
               out at PATH (default: BRANCH) relative to WORKTREE-BASE.
  -b --branch  Create an initial branch named BRANCH (default: $DEFAULT_BRANCH)
               checked out at PATH (default: BRANCH) relative to WORKTREE-BASE.

$SCRIPT clone URL [WORKTREE-BASE] [-b BRANCH[:PATH]]
  Clone a remote repository at URL in a super working tree at
@@ -50,11 +51,11 @@ $SCRIPT clone URL [WORKTREE-BASE] [-b BRANCH[:PATH]]
               BRANCH (default: origin/HEAD) at PATH (default: BRANCH) relative
               to WORKTREE-BASE.

$SCRIPT convert [REPOPATH] [-m MASTER]
$SCRIPT convert [REPOPATH] [-m MAIN]
  Convert a regular git working tree + repository at WORKTREE (default: PWD)
  into a super working tree.

  -m --master  Point the base HEAD symbolic ref to MASTER
  -m --main  Point the base HEAD symbolic ref to MAIN
             (default: current HEAD)

$SCRIPT add [--from SOURCE|--orphan] BRANCH[:PATH]
@@ -170,7 +171,7 @@ new_repo()
set_head()
(
	cd "$1"
	git symbolic-ref HEAD refs/heads/${2-master}
	git symbolic-ref HEAD refs/heads/$2
)

get_head()
@@ -249,7 +250,7 @@ readlink()

action_init()
{
	local REPOPATH BRANCH_SPEC=master:master
	local REPOPATH BRANCH_SPEC=$DEFAULT_BRANCH:$DEFAULT_BRANCH
	while [[ $# -gt 0 ]]; do
		case $1 in
			-b|--branch) BRANCH_SPEC=$2; shift ;;
@@ -306,10 +307,10 @@ action_clone()

action_convert()
{
	local REPOPATH=. MASTER
	local REPOPATH=. MAIN
	while [[ $# -gt 0 ]]; do
		case $1 in
			-m|--master) MASTER="$2"; shift ;;
			-m|--main|--master) MAIN="$2"; shift ;;
			*) case '' in
				"${REPOPATH-}") REPOPATH=$1 ;;
				*) arg_error "Unknown argument: $1" ;;
@@ -360,8 +361,8 @@ action_convert()

	git config core.bare true

	if [[ -v MASTER ]]; then
		git symbolic-ref HEAD refs/heads/$MASTER
	if [[ -v MAIN ]]; then
		git symbolic-ref HEAD refs/heads/$MAIN
	fi

	rm .backup.tar