Skip to main content

The same name above and below

Both splices name an upstream fork, each its company's fork of its own upstream. Names are unique only within one .splice, so --upstream fork means a's fork for vendor/a/ and b's fork for vendor/a/b/ (#107).

setup.bash builds the state of outer-fork.

Outputโ€‹

$ build_scenario scenario_outer_fork https://git.example.com/b.git

Each .splice gets its own fork, and keeps its upstream as the default:

$ git config --file vendor/a/.splice upstream.fork.url https://git.example.com/company/a.git && git config --file vendor/a/.splice splice.default-upstream origin
$ git config --file vendor/a/b/.splice upstream.fork.url https://git.example.com/company/b.git && git config --file vendor/a/b/.splice splice.default-upstream origin
$ git commit -q -m "add the company forks" -- vendor/a/.splice vendor/a/b/.splice
$ git splice fetch
ok vendor/a fetched from origin
ok vendor/a fetched from fork
ok vendor/a/b fetched from origin
ok vendor/a/b fetched from fork
$ git splice status --upstream fork
On branch main

ahead 1, behind 1 vendor/a -> fork/main
behind 1 vendor/a/b -> fork/main

Pulling each from its forkโ€‹

Top-down, as every pull: a's fork's patch to b/ first, then b's fork's patch. Since vendor/a/b/ is selected too, its fork is b's fork, and it pulls from that one. It's fetched from both of its upstreams, as when it isn't selected: a's fork may move its synced commit to one only b's origin has.

$ git splice pull --upstream fork --all
ok vendor/a fetched from fork
ok vendor/a/b fetched from origin
ok vendor/a/b fetched from fork
ok vendor/a: pulled 1b1cea6
ok vendor/a/b: pulled d5d5b62
$ git splice status --upstream fork
On branch main

ahead 3 vendor/a -> fork/main
ahead 2 vendor/a/b -> fork/main
$ git splice status
On branch main

ahead 4 vendor/a -> origin/main
ahead 3 vendor/a/b -> origin/main

The default travels with the .spliceโ€‹

The push of vendor/a/ publishes I's .splice with the rest of its folder. Its default-upstream goes along, so in a's upstream, b/ pulls and pushes by default where it does in the monorepo:

$ git splice push vendor/a
ok vendor/a: pushed e824c9c to origin/main
$ git -C "$UPSTREAM" show main:b/.splice | tr '\t' ' '
[splice]
commit = d5d5b62373ad5b94d1393019ab51f2ad34bb43c2
id = 548ac82ad47ea22d
default-upstream = origin
[upstream "origin"]
url = https://git.example.com/b.git
[upstream "fork"]
url = https://git.example.com/company/b.git