Skip to main content

A fork with its own default branch

The company fork names its default branch trunk, the original main (#122). Each upstream in .splice can record its own default-branch, so on the monorepo's main, each syncs with its own default branch.

setup.bash builds the state of several-upstreams: vendor/a/ from the original, and its company fork.

Outputโ€‹

$ build_scenario scenario_several_upstreams https://git.example.com/lib.git

The fork renames its default branch:

$ git -C "$UPSTREAM-fork.git" branch -m main trunk

Each upstream's default branchโ€‹

The fork is added with its default branch, and the original stays the default upstream:

$ git config --file vendor/a/.splice upstream.fork.url https://git.example.com/company/lib.git && git config --file vendor/a/.splice upstream.fork.default-branch trunk && git config --file vendor/a/.splice splice.default-upstream origin && git commit -q -m "vendor/a: add the company fork" -- vendor/a/.splice
$ git config --file vendor/a/.splice --list
splice.commit=[0-9a-f]{40} (regex)
splice.id=[0-9a-f]{16} (regex)
splice.default-upstream=origin
upstream.origin.url=https://git.example.com/lib.git
upstream.fork.url=https://git.example.com/company/lib.git
upstream.fork.default-branch=trunk

On main, the original syncs with its main, the fork with trunk:

$ git splice fetch >/dev/null && git splice status && git splice status --upstream fork
On branch main

up to date vendor/a -> origin/main
On branch main

behind 1 vendor/a -> fork/trunk

The earlier formatโ€‹

A default-branch in [splice] named one branch for every upstream. It's refused, rather than read for the default upstream only:

$ git config --file vendor/a/.splice splice.default-branch master && git commit -q -m "the earlier format" -- vendor/a/.splice && git splice status
!! vendor/a/.splice has default-branch in [splice], from an earlier version -- it belongs to an upstream now: upstream.<name>.default-branch
[1]