Expand description
The one-time move of greengate 3.x’s local state to greengate 4.0’s names (plan “greengate 4.0 renames its data names”, a hard rename: 4.0 reads and writes only the new names, so what 3.x left on this machine is moved once instead of being read twice forever).
Per repository, the first 4.0 command moves, under a flock on
$GIT_COMMON_DIR/greengate-migrate.lock:
- every
amont-*file and theamont/folder in the common dir and in each linked worktree’s private git dir ($GIT_COMMON_DIR/worktrees/*), a ledger’s header line rewritten to itsgreengate-…spelling first; - the repository’s local
amont.*config keys togreengate.*, each value copied (--get-all, then--add), then the old key removed.
then writes $GIT_COMMON_DIR/greengate-migrated, which every later
command only stats. The machine’s global amont.* keys move the same
way, once, under a lock in greengate’s config folder.
Every step is idempotent and ordered so an interrupted migration resumes: a header is rewritten before its file is renamed, and a key is removed only after all its values were copied. A migration that cannot finish leaves what it has not reached under the old names and refuses the command, naming what to fix.
One store is never moved: amont-held holds unstaged changes a 3.x
check parked, and 3.x records no owner, so a live 3.x may still be about
to put them back. The command is refused until greengate restore (which
reads the old store, old_held_store) has put them back.
The old spellings live in names::old and here; the names test exempts
both files.
Modules§
- tracked
greengate migrate --tracked: the names a repository COMMITS, renamed in its work tree and staged, for the repository to commit (the fleet sweep lands one such commit per repository).
Structs§
- Moved
- What the first-run migration did, for
greengate migrateto say. - Repo
- The git dirs of one repository: the common dir, then each linked worktree’s private one.
Enums§
- Direction
- Which way a migration goes.
- Migrate
Error - Why a migration stopped. Its
Displayis the line a refused command prints; the variants are what a caller or a test tells apart. - Scope
- Where config keys are moved.
Functions§
- config_
dir - greengate’s folder of machine state:
$XDG_CONFIG_HOME/greengate, else~/.config/greengate. - ensure
- Before any command but
--help,--version,restore,uninstall,migrate,doctorand a--dry-run: migrate the repository the process stands in, once, then the machine’s global keys, once. - ensure_
repo - The repository half of
ensure: the onecwdstands in, once, unless a reverse asked 4.0 to leave it alone. - forget_
global - Forget that the global keys were moved or reversed, so the next
ensurereads the global config again:greengate migrate --global. - leftovers
- What
greengate doctorreports: the 3.x names still visible from here, one line each, with the command that moves them (and, since 4.4, the signing key’s rename when only theamont-attestkey exists).Errwhen git could not answer: a failure never reads as “nothing left”. - migrate_
repo - Migrate
repoindirection, under its lock. Forward writes the done-marker and clears a reverse; reverse removes the done-marker and leaves the reversed one, so a 4.0 hook does not move it forward again. - move_
keys - Move the
amont.*keys ofscopetogreengate.*(or back); how many keys moved. Each value the old key holds is added to the new one unless already there (a migration interrupted between two--adds resumes without losing one), and the old key goes only once every value is present. A new key that holds a value of its own was set by the person: the new name wins, and the old values are dropped.amont.agent.*is greenbelay’s, never moved. Acluster.namespaceofamont-gatesis dropped on the way forward: 4.0’s default namespace isgreengate-gates. - move_
state - Move every name of [
MOVES] indir, indirection; how many moved. - old_
held_ store - The held store greengate 3.x left in this worktree, for
greengate restore:$GIT_DIR/amont-held, when it exists. - reverse_
global - Move the machine’s global keys back:
greengate migrate --reverse --global. - system_
git - git, with
GIT_DIRset todirwhen one is given, asGitFnsays.