test: lab 30 checks that each tier has its own chezmoi state

The private init's --persistent-state (chezmoistate-private.boltdb) and its
unit assertion landed in 06b03c9. chezmoi keeps its state next to the config
file, so the tiers used to share chezmoistate.boltdb and each wrote its
config-template hash over the other's: after the private init every public
command warned "config file template has changed".

Lab 30 now asserts the private state file exists, private.toml names it, and
neither tier warns and both statuses are clean after both inits. The fake
private tier is resynced with the real template and cmp alias.
This commit is contained in:
bcherb2 committed 2026-11-18 03:03:24 -05:00
1 parent 0279d4a5d0
commit 28bcea9850
3 files changed
+43 -3

No files matched your search

@@ -24,6 +24,18 @@
# so the symptom was `git commit` not knowing who you are, days later, with
# nothing pointing back at the install that caused it. A loud failure would
# have been a smaller bug.
#
# The same goes for the PERSISTENT STATE. chezmoi keeps it next to the config
# file, so both tiers shared ~/.config/chezmoi/chezmoistate.boltdb: each wrote
# its own config-template hash and run_onchange hashes over the other's, and
# after the private init every public command warned "config file template has
# changed". Running the init it suggests only moved the warning to this tier.
# So this tier gets its own state file, beside private.toml. This key covers a
# bare `chezmoi -c private.toml`; `dotup` and `cmp` also pass the same path as
# --persistent-state, because `init` opens the state BEFORE it writes this key,
# so the first init (or a re-init from a config that predates it) would
# otherwise record its hash in the public tier's file.
persistentState = {{ joinPath (dir .chezmoi.configFile) "chezmoistate-private.boltdb" | quote }}
[data]
gitName = {{ promptStringOnce . "gitName" "git user.name" | quote }}