Functions

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].

The main functional function.

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.

Pushes as new branch to origin. Other remote names are currently not supported. If there is a need, please let us know.

Returns Ok(true) if stashing was successful. Ok(false) if stashing was not needed.

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.