rebase: factor out clean work tree check