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
$ cat vendor/a/.splice
[splice]
commit = bde416459fbcc09c9b585f3b65a94cab3f68bfcd
id = c7ecd5a4c78d8a27
default-upstream = origin
[upstream "origin"]
url = https://git.example.com/lib.git
[upstream "fork"]
url = https://git.example.com/company/lib.git
default-branch = trunk

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

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

up to date vendor/a -> origin/main
$ git splice status --upstream fork
On branch main

behind 1 vendor/a -> fork/trunk

c (vendor/a: add the company fork) named the fork on trunk. The original's main is still k (seed), where the monorepo cloned it in a (add vendor/a); the fork's trunk has f (fork patch) on top:

The monorepo's a and c, which is H and B; the lane vendor/a/ split in two: origin with k, which is T, R, U(H), U(B) and its main; fork with f on top of k, its 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]