井上司 originally reported that when writing tracking config fails, for example because .git/config.lock exists, git switch or checkout creating a new branch exits midway. The worktree and index are already updated, but HEAD still points to the old branch, so the user sees unrelated staged changes.
In the latest message, thanking Junio Hamano for merging ti/checkout-track-failure and D. Ben Knoble for questions, the reporter said they now want to work on an all-or-none switch. Today switch_branches() updates the worktree first, then creates the branch ref, writes tracking config and updates HEAD, so a failure after the first step leaves the worktree switched.
The reporter said they looked at two ways to fix this; the excerpt shows only the start of the first, which would put the branch ref step first. Patrick Steinhardt is copied on the message. No patch for the broader change has been posted.