make rebase more robust such that itnever leaves a working copy in a bad
state