Skip to main content

rename_worktree_metadata

Function rename_worktree_metadata 

Source
pub fn rename_worktree_metadata(
    repo: &Repository,
    old_name: &str,
    new_name: &str,
    worktree_path: &Path,
) -> Result<()>
Expand description

Rename a worktree’s admin (metadata) directory from old_name to new_name, and rewrite the gitdir / .git pointer pair so worktree_path and the admin directory stay linked.

This is the metadata-only tail of move_worktree’s three-step move, factored out so workon doctor --fix can repair a stale admin name (one that no longer matches encode_worktree_name of the worktree’s current path) without moving the worktree directory itself.