Catch early trying rebasing to unknown ref, and add testcase.