Checks that repo is in “RepositoryState::Clean” state. This means there is
no rebase, cherry-pick, merge, etc is in progress. Confusingly, this is different
from no uncommitted or staged changes being present in the repo. For this,
see [fn.assure_workspace_is_clean].
Resolve the default branch name on the ‘origin’ remote.
First tries looking for where origin/HEAD is pointing to. If that fails
tries a hardcoded list of possible branches.
Wraps the three steps below into one, such that any error can be caught and
the git stash can be popped before exiting.
In many ways this is a poor-person’s try-finally (or context manager in Python).
Using Drop led to multiple borrowing errors. Any improvements along those lines
are more than welcome.