Archiving a worktree on a detached HEAD removed its folder, and nothing
pointed at the commits that only HEAD held. Undo or Restore came back on
the record's branch or a branch cut from the base, without those commits,
and git's cleanup later deleted them.
Before archive removes the folder of a worktree on a detached HEAD, it now
records HEAD as refs/paseo/archived/<workspaceId>. The ref keeps the commit
alive while the workspace stays archived. Undo and Restore read it before
the record's branch, which can still name the branch HEAD left, create a
new restored/<id> branch at that commit, and then delete the ref. A
worktree on a branch archives and restores as before. If the commit cannot
be recorded, the folder stays in place.
ragokan found the lost detached commits in #9850.
Closes#9856
Co-authored-by: Okan YILDIRIM <63511519+ragokan@users.noreply.github.com>