Scenario: nested-default-branch
A nested splice's .splice without default-branch means the same
branch in the monorepo as in the upstream it came from.
- Monorepo: empty, default branch
main. - a's upstream (
$UPSTREAM): default branchmaster. It uses git splice itself: b is spliced in atb/. - b's upstream (
$UPSTREAM-b.git): default branchmastertoo, sob/.splicedoesn't name a default branch.
A .splice without default-branch means: the upstream's default
branch has the same name as the default branch of what the splice lives
in. In a's upstream, that's the repository, with master. In the
monorepo, it's a, which stands in for a's upstream there, and whose
default branch is master too. So b syncs with master in both places,
as it would in a separate clone of a's upstream. Before, a .splice
without default-branch followed the monorepo's default branch, main,
which b's upstream doesn't have
(#71).
clone and init inside a splice follow the same rule: they record
default-branch only if the new upstream's default branch differs from
the one of the splice above. So the file means the same in both
directions.
Outputโ
setup.bash builds this state:
$ build_scenario scenario_nested_default_branch https://git.example.com/b.git
In a plain clone of a's upstreamโ
As a separate folder with a clone of a's upstream would have it, b syncs
with master:
$ git clone -q "$UPSTREAM" ../a-clone && git -C ../a-clone splice fetch && git -C ../a-clone splice status
ok b fetched
On branch master
up to date b
In the monorepoโ
clone records a's default branch, since it differs from the
monorepo's:
$ git splice clone "$UPSTREAM" vendor/a && git splice fetch
=== vendor/a: fetching $UPSTREAM
ok vendor/a: cloned ddf42f3 from master
ok vendor/a fetched
ok vendor/a/b fetched
$ git config --file vendor/a/.splice upstream.origin.default-branch
master
b's .splice came along unchanged, without one:
$ git config --file vendor/a/b/.splice upstream.origin.default-branch
[1]
So on the monorepo's main, both sync with master:
$ git splice status
On branch main
up to date vendor/a -> master
up to date vendor/a/b -> master
A change to b, pushed from main, goes to master in b's upstream,
which has no other branch:
$ echo "b local" >>vendor/a/b/file.txt && git commit -q -a -m "b local" && git splice push vendor/a/b
ok vendor/a/b: pushed 701ab17 to master
$ git -C "$UPSTREAM-b.git" for-each-ref --format='%(refname:short)' refs/heads
master