Repository navigation
refactor(config): drop project-config preload at picker / branchless entry - #2582
Conversation
…entry `for_action_branchless` and the picker were calling `repo.project_config()?` purely as a side effect — to populate the cache and emit any deprecation warnings before downstream hook output. With user-config warnings already emitted by prewarm and project-config warnings deferring to the first real read inside `run_pre_switch_hooks` / `plan_switch`, the entry-point preload is just timing — not correctness — and reads as a load-bearing-but-discarded `?` that the next reader has to puzzle out. Drop both. Project config now loads on demand from the call sites that actually consume it; the surrounding comments name that explicitly. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The deletions look correct — both call sites had downstream consumers that load project config promptly: the picker calls run_pre_switch_hooks next (which routes to approve_hooks_filtered's load_project_config()), and all three for_action_branchless callers in hook_commands.rs and step_commands.rs either call repo.load_project_config()? directly or run approve_or_skip / approve_hooks_filtered on the very next line. So project-config deprecation warnings still emit before any hook output, as the PR body claims.
One small staleness: the rustdoc on Repository::project_config (added in #2573) at src/git/repository/config.rs:565-568 still says
Deprecation warnings emit on that first call, so handlers that produce ordered output (hooks, picker) typically warm this from the entry point rather than letting it interleave with their own stderr later.
After this PR there are no longer any callers that warm from the entry point — the picker and for_action_branchless were the two referenced. Worth dropping the "typically warm this from the entry point" sentence so the doc no longer points at a convention the codebase doesn't follow.
Happy to push a one-line commit dropping that sentence if you'd like.
The rustdoc on `project_config` added in #2573 documented a convention that this PR's parent commit removed. Without any callers warming from the entry point, the paragraph pointed readers at a pattern the codebase no longer uses. Co-Authored-By: Claude <[email protected]>
Follow-up to #2573. The
LoadedConfigs::loadinlining left two call sites with a barerepo.project_config()?;whose only effect was to warm the cache and emit any deprecation warnings before downstream hook output started. Reading the resulting code, the discarded?looks load-bearing without being so — the next reader has to trace the call chain to confirm nothing reads the value.Both call sites —
CommandEnv::for_action_branchlessand the picker post-switch path — have downstream consumers (run_pre_switch_hooks,plan_switch, the rest of the hook pipeline) that load project config themselves on first use. Project-config deprecation warnings still surface; they just emerge from the first real read instead of from a bare statement at the entry point. User-config warnings continue to come from prewarm, so the user-visible ordering of warnings vs. command output is unchanged in the common path.Drop both. The surrounding comments now name where project config is loaded, rather than implying the entry point pre-warms it.