Skip to main content

Scenario: nested-splices, replaced in the upstream above

a's upstream replaces b with another repository, b2, at the same path b/. The monorepo has a change in b that it hasn't pushed yet, so its pull of a conflicts there, and it keeps its own b.

Up to the pull, b's history would come from a's upstream (spliced elsewhere). But a's upstream has another splice at b/ now, with another id: its history isn't b's. So b's history comes from the monorepo alone, as if a's upstream didn't splice anything in there. Before, the rebuild joined b2's history into b's, which a push of b would have published to b's upstream, and until b2's commits were fetched, status failed on a synced commit of b2's.

Outputโ€‹

setup.bash builds the state of the README: a with b spliced in at b/, cloned into the monorepo:

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

A change in b, not pushed yet:

$ echo "b local" >>vendor/a/b/file.txt && git commit -q -a -m "b local"

a's upstream replaces bโ€‹

b2 is another repository:

$ make_bare_repo "$UPSTREAM-b2.git" && seed_bare_repo "$UPSTREAM-b2.git" "b2 seed" >/dev/null 2>&1

In a clone of a's upstream, b is removed and b2 spliced in at b/:

$ git clone -q "$UPSTREAM" ../a-work && cd ../a-work && git rm -q -r b && git commit -q -m "remove b" && git splice clone https://git.example.com/b2.git b && git push -q origin HEAD:main && cd ../monorepo
=== b: fetching https://git.example.com/b2.git
ok b: cloned 4d884bd from main

b2's .splice has another id than b's:

$ git -C ../a-work config --file b/.splice splice.id; git config --file vendor/a/b/.splice splice.id
88a02361b312d5a4
548ac82ad47ea22d

The monorepo keeps its own bโ€‹

The pull of a conflicts in b:

$ git splice pull vendor/a
ok vendor/a fetched (main moved ddf42f3..e114b33)
ok vendor/a/b fetched
Auto-merging vendor/a/b/file.txt
CONFLICT (content): Merge conflict in vendor/a/b/file.txt
!! vendor/a: conflict -- resolve it, then 'git commit' (or 'git cherry-pick --abort' to give up)
!! vendor/a: pull failed
!! Failed: vendor/a
[1]

The monorepo keeps its own b, .splice included, and commits the pull:

$ git checkout HEAD -- vendor/a/b && git commit -q --no-edit

b has only its own history: b local, on top of b's synced commit.

$ git splice status vendor/a/b
On branch main

ahead 1 vendor/a/b
$ git splice log vendor/a/b
=== vendor/a/b (main)
< 701ab17 b local (Test <test@example.com>)