Fix detached head handling for non-committish sources, fixes #2732